Merge from rustc
This commit is contained in:
commit
e9433426a1
295 changed files with 15161 additions and 12950 deletions
|
|
@ -1,29 +1,22 @@
|
|||
use super::INLINE_ALWAYS;
|
||||
use super::utils::is_word;
|
||||
use clippy_utils::diagnostics::span_lint;
|
||||
use rustc_attr_data_structures::{find_attr, AttributeKind, InlineAttr};
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{Span, sym};
|
||||
use rustc_span::Span;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribute]) {
|
||||
if span.from_expansion() {
|
||||
return;
|
||||
}
|
||||
|
||||
for attr in attrs {
|
||||
if let Some(values) = attr.meta_item_list() {
|
||||
if values.len() != 1 || !attr.has_name(sym::inline) {
|
||||
continue;
|
||||
}
|
||||
if is_word(&values[0], sym::always) {
|
||||
span_lint(
|
||||
cx,
|
||||
INLINE_ALWAYS,
|
||||
attr.span(),
|
||||
format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"),
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(span) = find_attr!(attrs, AttributeKind::Inline(InlineAttr::Always, span) => *span) {
|
||||
span_lint(
|
||||
cx,
|
||||
INLINE_ALWAYS,
|
||||
span,
|
||||
format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::sugg::DiagExt;
|
||||
use rustc_attr_data_structures::{find_attr, AttributeKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{TraitFn, TraitItem, TraitItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::sym;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
|
|
@ -32,15 +32,19 @@ declare_lint_pass!(InlineFnWithoutBody => [INLINE_FN_WITHOUT_BODY]);
|
|||
impl<'tcx> LateLintPass<'tcx> for InlineFnWithoutBody {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
|
||||
if let TraitItemKind::Fn(_, TraitFn::Required(_)) = item.kind
|
||||
&& let Some(attr) = cx.tcx.hir_attrs(item.hir_id()).iter().find(|a| a.has_name(sym::inline))
|
||||
&& let Some(attr_span) = find_attr!(cx
|
||||
.tcx
|
||||
.hir_attrs(item.hir_id()),
|
||||
AttributeKind::Inline(_, span) => *span
|
||||
)
|
||||
{
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
INLINE_FN_WITHOUT_BODY,
|
||||
attr.span(),
|
||||
attr_span,
|
||||
format!("use of `#[inline]` on trait method `{}` which has no body", item.ident),
|
||||
|diag| {
|
||||
diag.suggest_remove_item(cx, attr.span(), "remove", Applicability::MachineApplicable);
|
||||
diag.suggest_remove_item(cx, attr_span, "remove", Applicability::MachineApplicable);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
use clippy_utils::diagnostics::span_lint;
|
||||
use rustc_attr_data_structures::{find_attr, AttributeKind};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::Attribute;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::ty::AssocItemContainer;
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::{Span, sym};
|
||||
use rustc_span::Span;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
|
|
@ -64,8 +65,7 @@ declare_clippy_lint! {
|
|||
}
|
||||
|
||||
fn check_missing_inline_attrs(cx: &LateContext<'_>, attrs: &[Attribute], sp: Span, desc: &'static str) {
|
||||
let has_inline = attrs.iter().any(|a| a.has_name(sym::inline));
|
||||
if !has_inline {
|
||||
if !find_attr!(attrs, AttributeKind::Inline(..)) {
|
||||
span_lint(
|
||||
cx,
|
||||
MISSING_INLINE_IN_PUBLIC_ITEMS,
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
|
|||
use clippy_utils::source::snippet;
|
||||
use clippy_utils::ty::{for_each_top_level_late_bound_region, is_copy};
|
||||
use clippy_utils::{is_self, is_self_ty};
|
||||
use rustc_attr_data_structures::{find_attr, AttributeKind, InlineAttr};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_ast::attr;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
|
|
@ -270,11 +270,13 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
|
|||
return;
|
||||
}
|
||||
let attrs = cx.tcx.hir_attrs(hir_id);
|
||||
if find_attr!(attrs, AttributeKind::Inline(InlineAttr::Always, _)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for a in attrs {
|
||||
if let Some(meta_items) = a.meta_item_list()
|
||||
&& (a.has_name(sym::proc_macro_derive)
|
||||
|| (a.has_name(sym::inline) && attr::list_contains_name(&meta_items, sym::always)))
|
||||
{
|
||||
// FIXME(jdonszelmann): make part of the find_attr above
|
||||
if a.has_name(sym::proc_macro_derive) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
//@no-rustfix: overlapping suggestions
|
||||
#![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::useless_vec, unused)]
|
||||
#![warn(clippy::single_range_in_vec_init)]
|
||||
#![feature(generic_arg_infer)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate proc_macros;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: an array of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:26:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:25:5
|
||||
|
|
||||
LL | [0..200];
|
||||
| ^^^^^^^^
|
||||
|
|
@ -18,7 +18,7 @@ LL + [0; 200];
|
|||
|
|
||||
|
||||
error: a `Vec` of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:28:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:27:5
|
||||
|
|
||||
LL | vec![0..200];
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -35,7 +35,7 @@ LL + vec![0; 200];
|
|||
|
|
||||
|
||||
error: an array of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:30:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:29:5
|
||||
|
|
||||
LL | [0u8..200];
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -52,7 +52,7 @@ LL + [0u8; 200];
|
|||
|
|
||||
|
||||
error: an array of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:32:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:31:5
|
||||
|
|
||||
LL | [0usize..200];
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -69,7 +69,7 @@ LL + [0usize; 200];
|
|||
|
|
||||
|
||||
error: an array of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:34:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:33:5
|
||||
|
|
||||
LL | [0..200usize];
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -86,7 +86,7 @@ LL + [0; 200usize];
|
|||
|
|
||||
|
||||
error: a `Vec` of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:36:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:35:5
|
||||
|
|
||||
LL | vec![0u8..200];
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
@ -103,7 +103,7 @@ LL + vec![0u8; 200];
|
|||
|
|
||||
|
||||
error: a `Vec` of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:38:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:37:5
|
||||
|
|
||||
LL | vec![0usize..200];
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -120,7 +120,7 @@ LL + vec![0usize; 200];
|
|||
|
|
||||
|
||||
error: a `Vec` of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:40:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:39:5
|
||||
|
|
||||
LL | vec![0..200usize];
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -137,7 +137,7 @@ LL + vec![0; 200usize];
|
|||
|
|
||||
|
||||
error: an array of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:43:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:42:5
|
||||
|
|
||||
LL | [0..200isize];
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -149,7 +149,7 @@ LL + (0..200isize).collect::<std::vec::Vec<isize>>();
|
|||
|
|
||||
|
||||
error: a `Vec` of `Range` that is only one element
|
||||
--> tests/ui/single_range_in_vec_init.rs:45:5
|
||||
--> tests/ui/single_range_in_vec_init.rs:44:5
|
||||
|
|
||||
LL | vec![0..200isize];
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -2368,9 +2368,16 @@ impl<'test> TestCx<'test> {
|
|||
// Real paths into the libstd/libcore
|
||||
let rust_src_dir = &self.config.sysroot_base.join("lib/rustlib/src/rust");
|
||||
rust_src_dir.try_exists().expect(&*format!("{} should exists", rust_src_dir));
|
||||
let rust_src_dir = rust_src_dir.read_link_utf8().unwrap_or(rust_src_dir.to_path_buf());
|
||||
let rust_src_dir =
|
||||
rust_src_dir.read_link_utf8().unwrap_or_else(|_| rust_src_dir.to_path_buf());
|
||||
normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL");
|
||||
|
||||
// Real paths into the compiler
|
||||
let rustc_src_dir = &self.config.sysroot_base.join("lib/rustlib/rustc-src/rust");
|
||||
rustc_src_dir.try_exists().expect(&*format!("{} should exists", rustc_src_dir));
|
||||
let rustc_src_dir = rustc_src_dir.read_link_utf8().unwrap_or(rustc_src_dir.to_path_buf());
|
||||
normalize_path(&rustc_src_dir.join("compiler"), "$COMPILER_DIR_REAL");
|
||||
|
||||
// eg.
|
||||
// /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui/<test_dir>/$name.$revision.$mode/
|
||||
normalize_path(&self.output_base_dir(), "$TEST_BUILD_DIR");
|
||||
|
|
|
|||
|
|
@ -357,9 +357,9 @@ impl<'test> TestCx<'test> {
|
|||
// Add this line to the current subview.
|
||||
subviews
|
||||
.last_mut()
|
||||
.ok_or(format!(
|
||||
"unexpected subview line outside of a subview on line {line_num}"
|
||||
))?
|
||||
.ok_or_else(|| {
|
||||
format!("unexpected subview line outside of a subview on line {line_num}")
|
||||
})?
|
||||
.push(line);
|
||||
} else {
|
||||
// This line is not part of a subview, so sort and print any
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ impl TestCx<'_> {
|
|||
// For `run-make` V2, we need to perform 2 steps to build and run a `run-make` V2 recipe
|
||||
// (`rmake.rs`) to run the actual tests. The support library is already built as a tool rust
|
||||
// library and is available under
|
||||
// `build/$HOST/stage0-bootstrap-tools/$TARGET/release/librun_make_support.rlib`.
|
||||
// `build/$HOST/bootstrap-tools/$TARGET/release/librun_make_support.rlib`.
|
||||
//
|
||||
// 1. We need to build the recipe `rmake.rs` as a binary and link in the `run_make_support`
|
||||
// library.
|
||||
|
|
@ -63,7 +63,7 @@ impl TestCx<'_> {
|
|||
//
|
||||
// ```
|
||||
// build/<target_triple>/
|
||||
// ├── stage0-bootstrap-tools/
|
||||
// ├── bootstrap-tools/
|
||||
// │ ├── <host_triple>/release/librun_make_support.rlib // <- support rlib itself
|
||||
// │ ├── <host_triple>/release/deps/ // <- deps
|
||||
// │ └── release/deps/ // <- deps of deps
|
||||
|
|
@ -72,7 +72,7 @@ impl TestCx<'_> {
|
|||
// FIXME(jieyouxu): there almost certainly is a better way to do this (specifically how the
|
||||
// support lib and its deps are organized), but this seems to work for now.
|
||||
|
||||
let tools_bin = host_build_root.join("stage0-bootstrap-tools");
|
||||
let tools_bin = host_build_root.join("bootstrap-tools");
|
||||
let support_host_path = tools_bin.join(&self.config.host).join("release");
|
||||
let support_lib_path = support_host_path.join("librun_make_support.rlib");
|
||||
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@ impl<'tcx> MiriMachine<'tcx> {
|
|||
|
||||
/// Sets up the "extern statics" for this machine.
|
||||
pub fn init_extern_statics(ecx: &mut MiriInterpCx<'tcx>) -> InterpResult<'tcx> {
|
||||
// "__rust_no_alloc_shim_is_unstable"
|
||||
let val = ImmTy::from_int(0, ecx.machine.layouts.u8); // always 0, value does not matter
|
||||
Self::alloc_extern_static(ecx, "__rust_no_alloc_shim_is_unstable", val)?;
|
||||
|
||||
// "__rust_alloc_error_handler_should_panic"
|
||||
let val = ecx.tcx.sess.opts.unstable_opts.oom.should_panic();
|
||||
let val = ImmTy::from_int(val, ecx.machine.layouts.u8);
|
||||
|
|
|
|||
|
|
@ -611,6 +611,10 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
this.write_pointer(new_ptr, dest)
|
||||
});
|
||||
}
|
||||
name if name == this.mangle_internal_symbol("__rust_no_alloc_shim_is_unstable_v2") => {
|
||||
// This is a no-op shim that only exists to prevent making the allocator shims instantly stable.
|
||||
let [] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?;
|
||||
}
|
||||
|
||||
// C memory handling functions
|
||||
"memcmp" => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
//@compile-flags: -Zmiri-track-alloc-id=20 -Zmiri-track-alloc-accesses -Cpanic=abort
|
||||
//@normalize-stderr-test: "id 20" -> "id $$ALLOC"
|
||||
//@compile-flags: -Zmiri-track-alloc-id=19 -Zmiri-track-alloc-accesses -Cpanic=abort
|
||||
//@normalize-stderr-test: "id 19" -> "id $$ALLOC"
|
||||
//@only-target: linux # alloc IDs differ between OSes (due to extern static allocations)
|
||||
|
||||
extern "Rust" {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ use toml::Value;
|
|||
|
||||
pub fn check(path: &Path, bad: &mut bool) {
|
||||
let triagebot_path = path.join("triagebot.toml");
|
||||
|
||||
// This check is mostly to catch broken path filters *within* `triagebot.toml`, and not enforce
|
||||
// the existence of `triagebot.toml` itself (which is more obvious), as distribution tarballs
|
||||
// will not include non-essential bits like `triagebot.toml`.
|
||||
if !triagebot_path.exists() {
|
||||
tidy_error!(bad, "triagebot.toml file not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue