diff --git a/Cargo.lock b/Cargo.lock index 2cc2e094e9f9c..46de7c331258c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5615,6 +5615,7 @@ dependencies = [ "semver", "serde", "similar", + "tempfile", "termcolor", "toml 0.7.8", "walkdir", diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 532539f893aed..f31ad4f591b1e 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -34,10 +34,6 @@ pub(crate) fn expand_test_case( check_builtin_macro_attribute(ecx, meta_item, sym::test_case); warn_on_duplicate_attribute(ecx, &anno_item, sym::test_case); - if !ecx.ecfg.should_test { - return vec![]; - } - let sp = ecx.with_def_site_ctxt(attr_sp); let (mut item, is_stmt) = match anno_item { Annotatable::Item(item) => (item, false), @@ -54,6 +50,10 @@ pub(crate) fn expand_test_case( } }; + if !ecx.ecfg.should_test { + return vec![]; + } + // `#[test_case]` is valid on functions, consts, and statics. Only modify // the item in those cases. match &mut item.kind { @@ -113,22 +113,17 @@ pub(crate) fn expand_test_or_bench( item: Annotatable, is_bench: bool, ) -> Vec { - // If we're not in test configuration, remove the annotated item - if !cx.ecfg.should_test { - return vec![]; - } - let (item, is_stmt) = match item { Annotatable::Item(i) => (i, false), Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true), other => { - not_testable_error(cx, attr_sp, None); + not_testable_error(cx, is_bench, attr_sp, None); return vec![other]; } }; let ast::ItemKind::Fn(fn_) = &item.kind else { - not_testable_error(cx, attr_sp, Some(&item)); + not_testable_error(cx, is_bench, attr_sp, Some(&item)); return if is_stmt { vec![Annotatable::Stmt(Box::new(cx.stmt_item(item.span, item)))] } else { @@ -136,6 +131,11 @@ pub(crate) fn expand_test_or_bench( }; }; + // If we're not in test configuration, remove the annotated item + if !cx.ecfg.should_test { + return vec![]; + } + if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) { cx.dcx().emit_err(errors::NakedFunctionTestingAttribute { testing_span: attr_sp, @@ -405,9 +405,10 @@ pub(crate) fn expand_test_or_bench( } } -fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) { +fn not_testable_error(cx: &ExtCtxt<'_>, is_bench: bool, attr_sp: Span, item: Option<&ast::Item>) { let dcx = cx.dcx(); - let msg = "the `#[test]` attribute may only be used on a non-associated function"; + let name = if is_bench { "bench" } else { "test" }; + let msg = format!("the `#[{name}]` attribute may only be used on a free function"); let level = match item.map(|i| &i.kind) { // These were a warning before #92959 and need to continue being that to avoid breaking // stable user code (#94508). @@ -426,12 +427,16 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) ), ); } - err.with_span_label(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions") - .with_span_suggestion(attr_sp, + err.span_label(attr_sp, format!("the `#[{name}]` macro causes a function to be run as a test and has no effect on non-functions")); + + if !is_bench { + err.with_span_suggestion(attr_sp, "replace with conditional compilation to make the item only exist when tests are being run", "#[cfg(test)]", - Applicability::MaybeIncorrect) - .emit(); + Applicability::MaybeIncorrect).emit(); + } else { + err.emit(); + } } fn get_location_info(cx: &ExtCtxt<'_>, fn_: &ast::Fn) -> (Symbol, usize, usize, usize, usize) { diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 5a49d0f07a490..6dff79374f20f 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -86,8 +86,7 @@ impl MetadataLoader for DefaultMetadataLoader { format!("failed to parse aix dylib '{}': {}", path.display(), e) })?; - // FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266 - match Itertools::exactly_one(archive.members()) { + match archive.members().exactly_one() { Ok(lib) => { let lib = lib.map_err(|e| { format!("failed to parse aix dylib '{}': {}", path.display(), e) diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 0e4a98f0941ac..d23369caffa42 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -11,7 +11,9 @@ use rustc_middle::ty::layout::{ self, FnAbiError, FnAbiOf, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout, }; -use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypingEnv, Variance}; +use rustc_middle::ty::{ + self, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingEnv, Variance, +}; use rustc_middle::{mir, span_bug}; use rustc_span::Span; use rustc_target::callconv::FnAbi; @@ -84,10 +86,31 @@ impl<'tcx, M: Machine<'tcx>> LayoutOfHelpers<'tcx> for InterpCx<'tcx, M> { #[inline] fn handle_layout_err( &self, - err: LayoutError<'tcx>, + mut err: LayoutError<'tcx>, _: Span, _: Ty<'tcx>, ) -> InterpErrorKind<'tcx> { + // FIXME(#149283): This is really hacky and is only used to hide type + // system bugs. We use it as a temporary fix for #149081. + // + // While it's expected that we sometimes get ambiguity errors when + // entering another generic environment while the current environment + // itself is still generic, we should never fail to entirely prove + // something. + match err { + LayoutError::NormalizationFailure(ty, _) => { + if ty.has_non_region_param() { + err = LayoutError::TooGeneric(ty); + } + } + + LayoutError::Unknown(_) + | LayoutError::SizeOverflow(_) + | LayoutError::InvalidSimd { .. } + | LayoutError::TooGeneric(_) + | LayoutError::ReferencesError(_) + | LayoutError::Cycle(_) => {} + } err_inval!(Layout(err)) } } @@ -112,7 +135,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { /// and allows wrapping the actual [LayoutOf::layout_of] with a tracing span. /// See [LayoutOf::layout_of] for the original documentation. #[inline(always)] - pub fn layout_of(&self, ty: Ty<'tcx>) -> >::LayoutOfResult { + pub fn layout_of(&self, ty: Ty<'tcx>) -> Result, InterpErrorKind<'tcx>> { let _trace = enter_trace_span!(M, layouting::layout_of, ty = ?ty.kind()); LayoutOf::layout_of(self, ty) } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 8f297677ff852..77e86fdce38d1 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1793,6 +1793,55 @@ impl<'hir> Pat<'hir> { }); is_never_pattern } + + /// Whether this pattern constitutes a read of value of the scrutinee that + /// it is matching against. This is used to determine whether we should + /// perform `NeverToAny` coercions. + /// + /// See [`expr_guaranteed_to_constitute_read_for_never`][m] for the nuances of + /// what happens when this returns true. + /// + /// [m]: ../../rustc_middle/ty/struct.TyCtxt.html#method.expr_guaranteed_to_constitute_read_for_never + pub fn is_guaranteed_to_constitute_read_for_never(&self) -> bool { + match self.kind { + // Does not constitute a read. + PatKind::Wild => false, + + // The guard cannot affect if we make a read or not (it runs after the inner pattern + // has matched), therefore it's irrelevant. + PatKind::Guard(pat, _) => pat.is_guaranteed_to_constitute_read_for_never(), + + // This is unnecessarily restrictive when the pattern that doesn't + // constitute a read is unreachable. + // + // For example `match *never_ptr { value => {}, _ => {} }` or + // `match *never_ptr { _ if false => {}, value => {} }`. + // + // It is however fine to be restrictive here; only returning `true` + // can lead to unsoundness. + PatKind::Or(subpats) => { + subpats.iter().all(|pat| pat.is_guaranteed_to_constitute_read_for_never()) + } + + // Does constitute a read, since it is equivalent to a discriminant read. + PatKind::Never => true, + + // All of these constitute a read, or match on something that isn't `!`, + // which would require a `NeverToAny` coercion. + PatKind::Missing + | PatKind::Binding(_, _, _, _) + | PatKind::Struct(_, _, _) + | PatKind::TupleStruct(_, _, _) + | PatKind::Tuple(_, _) + | PatKind::Box(_) + | PatKind::Ref(_, _, _) + | PatKind::Deref(_) + | PatKind::Expr(_) + | PatKind::Range(_, _, _) + | PatKind::Slice(_, _, _) + | PatKind::Err(_) => true, + } + } } /// A single field in a struct pattern. diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 009caad51eacb..4abbace05e7c0 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1078,7 +1078,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self, cause, allow_two_phase, - self.expr_guaranteed_to_constitute_read_for_never(expr), + self.tcx.expr_guaranteed_to_constitute_read_for_never(expr), ); let ok = self.commit_if_ok(|_| coerce.coerce(source, target))?; diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 658f9857e5e10..4520dd515885e 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -102,7 +102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // While we don't allow *arbitrary* coercions here, we *do* allow // coercions from ! to `expected`. if self.try_structurally_resolve_type(expr.span, ty).is_never() - && self.expr_guaranteed_to_constitute_read_for_never(expr) + && self.tcx.expr_guaranteed_to_constitute_read_for_never(expr) { if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { let reported = self.dcx().span_delayed_bug( @@ -320,7 +320,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // diverging would be unsound since we may never actually read the `!`. // e.g. `let _ = *never_ptr;` with `never_ptr: *const !`. if self.try_structurally_resolve_type(expr.span, ty).is_never() - && self.expr_guaranteed_to_constitute_read_for_never(expr) + && self.tcx.expr_guaranteed_to_constitute_read_for_never(expr) { self.diverges.set(self.diverges.get() | Diverges::always(expr.span)); } @@ -339,199 +339,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty } - /// Whether this expression constitutes a read of value of the type that - /// it evaluates to. - /// - /// This is used to determine if we should consider the block to diverge - /// if the expression evaluates to `!`, and if we should insert a `NeverToAny` - /// coercion for values of type `!`. - /// - /// This function generally returns `false` if the expression is a place - /// expression and the *parent* expression is the scrutinee of a match or - /// the pointee of an `&` addr-of expression, since both of those parent - /// expressions take a *place* and not a value. - pub(super) fn expr_guaranteed_to_constitute_read_for_never( - &self, - expr: &'tcx hir::Expr<'tcx>, - ) -> bool { - // We only care about place exprs. Anything else returns an immediate - // which would constitute a read. We don't care about distinguishing - // "syntactic" place exprs since if the base of a field projection is - // not a place then it would've been UB to read from it anyways since - // that constitutes a read. - if !expr.is_syntactic_place_expr() { - return true; - } - - let parent_node = self.tcx.parent_hir_node(expr.hir_id); - match parent_node { - hir::Node::Expr(parent_expr) => { - match parent_expr.kind { - // Addr-of, field projections, and LHS of assignment don't constitute reads. - // Assignment does call `drop_in_place`, though, but its safety - // requirements are not the same. - ExprKind::AddrOf(..) | hir::ExprKind::Field(..) => false, - - // Place-preserving expressions only constitute reads if their - // parent expression constitutes a read. - ExprKind::Type(..) | ExprKind::UnsafeBinderCast(..) => { - self.expr_guaranteed_to_constitute_read_for_never(expr) - } - - ExprKind::Assign(lhs, _, _) => { - // Only the LHS does not constitute a read - expr.hir_id != lhs.hir_id - } - - // See note on `PatKind::Or` below for why this is `all`. - ExprKind::Match(scrutinee, arms, _) => { - assert_eq!(scrutinee.hir_id, expr.hir_id); - arms.iter() - .all(|arm| self.pat_guaranteed_to_constitute_read_for_never(arm.pat)) - } - ExprKind::Let(hir::LetExpr { init, pat, .. }) => { - assert_eq!(init.hir_id, expr.hir_id); - self.pat_guaranteed_to_constitute_read_for_never(*pat) - } - - // Any expression child of these expressions constitute reads. - ExprKind::Array(_) - | ExprKind::Call(_, _) - | ExprKind::Use(_, _) - | ExprKind::MethodCall(_, _, _, _) - | ExprKind::Tup(_) - | ExprKind::Binary(_, _, _) - | ExprKind::Unary(_, _) - | ExprKind::Cast(_, _) - | ExprKind::DropTemps(_) - | ExprKind::If(_, _, _) - | ExprKind::Closure(_) - | ExprKind::Block(_, _) - | ExprKind::AssignOp(_, _, _) - | ExprKind::Index(_, _, _) - | ExprKind::Break(_, _) - | ExprKind::Ret(_) - | ExprKind::Become(_) - | ExprKind::InlineAsm(_) - | ExprKind::Struct(_, _, _) - | ExprKind::Repeat(_, _) - | ExprKind::Yield(_, _) => true, - - // These expressions have no (direct) sub-exprs. - ExprKind::ConstBlock(_) - | ExprKind::Loop(_, _, _, _) - | ExprKind::Lit(_) - | ExprKind::Path(_) - | ExprKind::Continue(_) - | ExprKind::OffsetOf(_, _) - | ExprKind::Err(_) => unreachable!("no sub-expr expected for {:?}", expr.kind), - } - } - - // If we have a subpattern that performs a read, we want to consider this - // to diverge for compatibility to support something like `let x: () = *never_ptr;`. - hir::Node::LetStmt(hir::LetStmt { init: Some(target), pat, .. }) => { - assert_eq!(target.hir_id, expr.hir_id); - self.pat_guaranteed_to_constitute_read_for_never(*pat) - } - - // These nodes (if they have a sub-expr) do constitute a read. - hir::Node::Block(_) - | hir::Node::Arm(_) - | hir::Node::ExprField(_) - | hir::Node::AnonConst(_) - | hir::Node::ConstBlock(_) - | hir::Node::ConstArg(_) - | hir::Node::Stmt(_) - | hir::Node::Item(hir::Item { - kind: hir::ItemKind::Const(..) | hir::ItemKind::Static(..), - .. - }) - | hir::Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Const(..), .. - }) - | hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. }) => true, - - hir::Node::TyPat(_) | hir::Node::Pat(_) => { - self.dcx().span_delayed_bug(expr.span, "place expr not allowed in pattern"); - true - } - - // These nodes do not have direct sub-exprs. - hir::Node::Param(_) - | hir::Node::Item(_) - | hir::Node::ForeignItem(_) - | hir::Node::TraitItem(_) - | hir::Node::ImplItem(_) - | hir::Node::Variant(_) - | hir::Node::Field(_) - | hir::Node::PathSegment(_) - | hir::Node::Ty(_) - | hir::Node::AssocItemConstraint(_) - | hir::Node::TraitRef(_) - | hir::Node::PatField(_) - | hir::Node::PatExpr(_) - | hir::Node::LetStmt(_) - | hir::Node::Synthetic - | hir::Node::Err(_) - | hir::Node::Ctor(_) - | hir::Node::Lifetime(_) - | hir::Node::GenericParam(_) - | hir::Node::Crate(_) - | hir::Node::Infer(_) - | hir::Node::WherePredicate(_) - | hir::Node::PreciseCapturingNonLifetimeArg(_) - | hir::Node::OpaqueTy(_) => { - unreachable!("no sub-expr expected for {parent_node:?}") - } - } - } - - /// Whether this pattern constitutes a read of value of the scrutinee that - /// it is matching against. This is used to determine whether we should - /// perform `NeverToAny` coercions. - /// - /// See above for the nuances of what happens when this returns true. - pub(super) fn pat_guaranteed_to_constitute_read_for_never(&self, pat: &hir::Pat<'_>) -> bool { - match pat.kind { - // Does not constitute a read. - hir::PatKind::Wild => false, - - // Might not constitute a read, since the condition might be false. - hir::PatKind::Guard(_, _) => true, - - // This is unnecessarily restrictive when the pattern that doesn't - // constitute a read is unreachable. - // - // For example `match *never_ptr { value => {}, _ => {} }` or - // `match *never_ptr { _ if false => {}, value => {} }`. - // - // It is however fine to be restrictive here; only returning `true` - // can lead to unsoundness. - hir::PatKind::Or(subpats) => { - subpats.iter().all(|pat| self.pat_guaranteed_to_constitute_read_for_never(pat)) - } - - // Does constitute a read, since it is equivalent to a discriminant read. - hir::PatKind::Never => true, - - // All of these constitute a read, or match on something that isn't `!`, - // which would require a `NeverToAny` coercion. - hir::PatKind::Missing - | hir::PatKind::Binding(_, _, _, _) - | hir::PatKind::Struct(_, _, _) - | hir::PatKind::TupleStruct(_, _, _) - | hir::PatKind::Tuple(_, _) - | hir::PatKind::Box(_) - | hir::PatKind::Ref(_, _, _) - | hir::PatKind::Deref(_) - | hir::PatKind::Expr(_) - | hir::PatKind::Range(_, _, _) - | hir::PatKind::Slice(_, _, _) - | hir::PatKind::Err(_) => true, - } - } - #[instrument(skip(self, expr), level = "debug")] fn check_expr_kind( &self, diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 42150dd6a1907..0ab5a792e040b 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -217,6 +217,146 @@ impl<'tcx> TyCtxt<'tcx> { } None } + + /// Whether this expression constitutes a read of value of the type that + /// it evaluates to. + /// + /// This is used to determine if we should consider the block to diverge + /// if the expression evaluates to `!`, and if we should insert a `NeverToAny` + /// coercion for values of type `!`. + /// + /// This function generally returns `false` if the expression is a place + /// expression and the *parent* expression is the scrutinee of a match or + /// the pointee of an `&` addr-of expression, since both of those parent + /// expressions take a *place* and not a value. + pub fn expr_guaranteed_to_constitute_read_for_never(self, expr: &Expr<'_>) -> bool { + // We only care about place exprs. Anything else returns an immediate + // which would constitute a read. We don't care about distinguishing + // "syntactic" place exprs since if the base of a field projection is + // not a place then it would've been UB to read from it anyways since + // that constitutes a read. + if !expr.is_syntactic_place_expr() { + return true; + } + + let parent_node = self.parent_hir_node(expr.hir_id); + match parent_node { + Node::Expr(parent_expr) => { + match parent_expr.kind { + // Addr-of, field projections, and LHS of assignment don't constitute reads. + // Assignment does call `drop_in_place`, though, but its safety + // requirements are not the same. + ExprKind::AddrOf(..) | ExprKind::Field(..) => false, + + // Place-preserving expressions only constitute reads if their + // parent expression constitutes a read. + ExprKind::Type(..) | ExprKind::UnsafeBinderCast(..) => { + self.expr_guaranteed_to_constitute_read_for_never(parent_expr) + } + + ExprKind::Assign(lhs, _, _) => { + // Only the LHS does not constitute a read + expr.hir_id != lhs.hir_id + } + + // See note on `PatKind::Or` in `Pat::is_guaranteed_to_constitute_read_for_never` + // for why this is `all`. + ExprKind::Match(scrutinee, arms, _) => { + assert_eq!(scrutinee.hir_id, expr.hir_id); + arms.iter().all(|arm| arm.pat.is_guaranteed_to_constitute_read_for_never()) + } + ExprKind::Let(LetExpr { init, pat, .. }) => { + assert_eq!(init.hir_id, expr.hir_id); + pat.is_guaranteed_to_constitute_read_for_never() + } + + // Any expression child of these expressions constitute reads. + ExprKind::Array(_) + | ExprKind::Call(_, _) + | ExprKind::Use(_, _) + | ExprKind::MethodCall(_, _, _, _) + | ExprKind::Tup(_) + | ExprKind::Binary(_, _, _) + | ExprKind::Unary(_, _) + | ExprKind::Cast(_, _) + | ExprKind::DropTemps(_) + | ExprKind::If(_, _, _) + | ExprKind::Closure(_) + | ExprKind::Block(_, _) + | ExprKind::AssignOp(_, _, _) + | ExprKind::Index(_, _, _) + | ExprKind::Break(_, _) + | ExprKind::Ret(_) + | ExprKind::Become(_) + | ExprKind::InlineAsm(_) + | ExprKind::Struct(_, _, _) + | ExprKind::Repeat(_, _) + | ExprKind::Yield(_, _) => true, + + // These expressions have no (direct) sub-exprs. + ExprKind::ConstBlock(_) + | ExprKind::Loop(_, _, _, _) + | ExprKind::Lit(_) + | ExprKind::Path(_) + | ExprKind::Continue(_) + | ExprKind::OffsetOf(_, _) + | ExprKind::Err(_) => unreachable!("no sub-expr expected for {:?}", expr.kind), + } + } + + // If we have a subpattern that performs a read, we want to consider this + // to diverge for compatibility to support something like `let x: () = *never_ptr;`. + Node::LetStmt(LetStmt { init: Some(target), pat, .. }) => { + assert_eq!(target.hir_id, expr.hir_id); + pat.is_guaranteed_to_constitute_read_for_never() + } + + // These nodes (if they have a sub-expr) do constitute a read. + Node::Block(_) + | Node::Arm(_) + | Node::ExprField(_) + | Node::AnonConst(_) + | Node::ConstBlock(_) + | Node::ConstArg(_) + | Node::Stmt(_) + | Node::Item(Item { kind: ItemKind::Const(..) | ItemKind::Static(..), .. }) + | Node::TraitItem(TraitItem { kind: TraitItemKind::Const(..), .. }) + | Node::ImplItem(ImplItem { kind: ImplItemKind::Const(..), .. }) => true, + + Node::TyPat(_) | Node::Pat(_) => { + self.dcx().span_delayed_bug(expr.span, "place expr not allowed in pattern"); + true + } + + // These nodes do not have direct sub-exprs. + Node::Param(_) + | Node::Item(_) + | Node::ForeignItem(_) + | Node::TraitItem(_) + | Node::ImplItem(_) + | Node::Variant(_) + | Node::Field(_) + | Node::PathSegment(_) + | Node::Ty(_) + | Node::AssocItemConstraint(_) + | Node::TraitRef(_) + | Node::PatField(_) + | Node::PatExpr(_) + | Node::LetStmt(_) + | Node::Synthetic + | Node::Err(_) + | Node::Ctor(_) + | Node::Lifetime(_) + | Node::GenericParam(_) + | Node::Crate(_) + | Node::Infer(_) + | Node::WherePredicate(_) + | Node::PreciseCapturingNonLifetimeArg(_) + | Node::OpaqueTy(_) => { + unreachable!("no sub-expr expected for {parent_node:?}") + } + } + } } /// Hashes computed by [`TyCtxt::hash_owner_nodes`] if necessary. diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index c1e3019612676..8065db1e05dd7 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -4,11 +4,11 @@ #![allow(rustc::usage_of_ty_tykind)] #![allow(rustc::usage_of_type_ir_inherent)] #![allow(rustc::usage_of_type_ir_traits)] +#![cfg_attr(feature = "nightly", allow(internal_features))] #![cfg_attr( feature = "nightly", feature(associated_type_defaults, never_type, rustc_attrs, negative_impls) )] -#![cfg_attr(feature = "nightly", allow(internal_features))] // tidy-alphabetical-end extern crate self as rustc_type_ir; diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index f898382086512..29230b1665380 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -4034,62 +4034,6 @@ pub trait Iterator { { unreachable!("Always specialized"); } - - /// Checks if the iterator contains *exactly* one element. - /// If so, returns this one element. - /// - /// See also [`collect_array`](Iterator::collect_array) for lengths other than `1`. - /// - /// # Examples - /// - /// ``` - /// #![feature(exact_length_collection)] - /// - /// assert_eq!([1].into_iter().exactly_one(), Some(1)); - /// assert_eq!([].into_iter().exactly_one(), None::<()>); - /// - /// // There is exactly one even integer in the array: - /// assert_eq!([1, 2, 3].into_iter().filter(|x| x % 2 == 0).exactly_one(), Some(2)); - /// // But there are two odds, which is too many: - /// assert_eq!([1, 2, 3].into_iter().filter(|x| x % 2 == 1).exactly_one(), None); - /// ``` - #[inline] - #[unstable(feature = "exact_length_collection", issue = "149266")] - fn exactly_one(self) -> Option - where - Self: Sized, - { - self.collect_array::<1>().map(|[i]| i) - } - - /// Checks if an iterator has *exactly* `N` elements. - /// If so, returns those `N` elements in an array. - /// - /// See also [`exactly_one`](Iterator::exactly_one) when expecting a single element. - /// - /// # Examples - /// - /// ``` - /// #![feature(exact_length_collection)] - /// - /// assert_eq!([1, 2, 3, 4].into_iter().collect_array(), Some([1, 2, 3, 4])); - /// assert_eq!([1, 2].into_iter().chain([3, 4]).collect_array(), Some([1, 2, 3, 4])); - /// - /// // Iterator contains too few elements: - /// assert_eq!([1, 2].into_iter().collect_array::<4>(), None); - /// // Iterator contains too many elements: - /// assert_eq!([1, 2, 3, 4, 5].into_iter().collect_array::<4>(), None); - /// // Taking 4 makes it work again: - /// assert_eq!([1, 2, 3, 4, 5].into_iter().take(4).collect_array(), Some([1, 2, 3, 4])); - /// ``` - #[inline] - #[unstable(feature = "exact_length_collection", issue = "149266")] - fn collect_array(mut self) -> Option<[Self::Item; N]> - where - Self: Sized, - { - self.next_chunk().ok().filter(|_| self.next().is_none()) - } } trait SpecIterEq: Iterator { diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 21e82d43a800c..0167be4d514c0 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -950,19 +950,19 @@ impl Error { where E: error::Error + Send + Sync + 'static, { - match self.repr.into_data() { - ErrorData::Custom(b) if b.error.is::() => { - let res = (*b).error.downcast::(); - - // downcast is a really trivial and is marked as inline, so - // it's likely be inlined here. - // - // And the compiler should be able to eliminate the branch - // that produces `Err` here since b.error.is::() - // returns true. - Ok(*res.unwrap()) + if let ErrorData::Custom(c) = self.repr.data() + && c.error.is::() + { + if let ErrorData::Custom(b) = self.repr.into_data() + && let Ok(err) = b.error.downcast::() + { + Ok(*err) + } else { + // Safety: We have just checked that the condition is true + unsafe { crate::hint::unreachable_unchecked() } } - repr_data => Err(Self { repr: Repr::new(repr_data) }), + } else { + Err(self) } } diff --git a/library/std/src/io/error/repr_bitpacked.rs b/library/std/src/io/error/repr_bitpacked.rs index 716da37168d01..7353816a8171b 100644 --- a/library/std/src/io/error/repr_bitpacked.rs +++ b/library/std/src/io/error/repr_bitpacked.rs @@ -133,15 +133,6 @@ unsafe impl Send for Repr {} unsafe impl Sync for Repr {} impl Repr { - pub(super) fn new(dat: ErrorData>) -> Self { - match dat { - ErrorData::Os(code) => Self::new_os(code), - ErrorData::Simple(kind) => Self::new_simple(kind), - ErrorData::SimpleMessage(simple_message) => Self::new_simple_message(simple_message), - ErrorData::Custom(b) => Self::new_custom(b), - } - } - pub(super) fn new_custom(b: Box) -> Self { let p = Box::into_raw(b).cast::(); // Should only be possible if an allocator handed out a pointer with diff --git a/library/std/src/io/error/repr_unpacked.rs b/library/std/src/io/error/repr_unpacked.rs index dc8a95577c959..b3e7b5f024ea0 100644 --- a/library/std/src/io/error/repr_unpacked.rs +++ b/library/std/src/io/error/repr_unpacked.rs @@ -10,9 +10,6 @@ pub(super) struct Repr(Inner); impl Repr { #[inline] - pub(super) fn new(dat: ErrorData>) -> Self { - Self(dat) - } pub(super) fn new_custom(b: Box) -> Self { Self(Inner::Custom(b)) } diff --git a/library/std/src/sys/thread/motor.rs b/library/std/src/sys/thread/motor.rs index 0457d8818f326..4c6d3ccb84ec9 100644 --- a/library/std/src/sys/thread/motor.rs +++ b/library/std/src/sys/thread/motor.rs @@ -2,6 +2,7 @@ use crate::ffi::CStr; use crate::io; use crate::num::NonZeroUsize; use crate::sys::map_motor_error; +use crate::thread::ThreadInit; use crate::time::Duration; pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 256; @@ -14,21 +15,21 @@ unsafe impl Send for Thread {} unsafe impl Sync for Thread {} impl Thread { - pub unsafe fn new( - stack: usize, - _name: Option<&str>, - p: Box, - ) -> io::Result { + pub unsafe fn new(stack: usize, init: Box) -> io::Result { extern "C" fn __moto_rt_thread_fn(thread_arg: u64) { unsafe { - Box::from_raw( - core::ptr::with_exposed_provenance::>(thread_arg as usize) - .cast_mut(), - )(); + let init = Box::from_raw(core::ptr::with_exposed_provenance_mut::( + thread_arg as usize, + )); + let rust_start = init.init(); + if let Some(name) = crate::thread::current().name() { + let _ = moto_rt::thread::set_name(name); + } + rust_start(); } } - let thread_arg = Box::into_raw(Box::new(p)).expose_provenance() as u64; + let thread_arg = Box::into_raw(init).expose_provenance() as u64; let sys_thread = moto_rt::thread::spawn(__moto_rt_thread_fn, stack, thread_arg) .map_err(map_motor_error)?; Ok(Self { sys_thread }) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 2b9562f26574a..eee13ff2b0dc0 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1126,8 +1126,7 @@ pub(crate) fn print_impl( } if impl_.kind.is_fake_variadic() && let Some(generics) = ty.generics() - // FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266 - && let Ok(inner_type) = Itertools::exactly_one(generics) + && let Ok(inner_type) = generics.exactly_one() { let last = ty.last(); if f.alternate() { @@ -1207,8 +1206,7 @@ impl clean::Impl { } } else if let clean::Type::Path { path } = type_ && let Some(generics) = path.generics() - // FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266 - && let Ok(ty) = Itertools::exactly_one(generics) + && let Ok(ty) = generics.exactly_one() && self.kind.is_fake_variadic() { print_anchor(path.def_id(), path.last(), cx).fmt(f)?; diff --git a/src/tools/clippy/clippy_lints/src/manual_non_exhaustive.rs b/src/tools/clippy/clippy_lints/src/manual_non_exhaustive.rs index 08e7c7593cb27..0d783fde33131 100644 --- a/src/tools/clippy/clippy_lints/src/manual_non_exhaustive.rs +++ b/src/tools/clippy/clippy_lints/src/manual_non_exhaustive.rs @@ -92,8 +92,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive { (matches!(v.data, VariantData::Unit(_, _)) && is_doc_hidden(cx.tcx.hir_attrs(v.hir_id))) .then_some((v.def_id, v.span)) }); - // FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266 - if let Ok((id, span)) = Itertools::exactly_one(iter) + if let Ok((id, span)) = iter.exactly_one() && !find_attr!(cx.tcx.hir_attrs(item.hir_id()), AttributeKind::NonExhaustive(..)) { self.potential_enums.push((item.owner_id.def_id, id, item.span, span)); @@ -105,8 +104,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive { .iter() .filter(|field| !cx.effective_visibilities.is_exported(field.def_id)); if fields.len() > 1 - // FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266 - && let Ok(field) = Itertools::exactly_one(private_fields) + && let Ok(field) = private_fields.exactly_one() && let TyKind::Tup([]) = field.ty.kind { span_lint_and_then( diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index c1f27de7ed4a5..47b59543c59cc 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -18,6 +18,7 @@ rustc-hash = "2.0.0" fluent-syntax = "0.12" similar = "2.5.0" toml = "0.7.8" +tempfile = "3.15.0" [features] build-metrics = ["dep:serde"] diff --git a/src/tools/tidy/src/alphabetical.rs b/src/tools/tidy/src/alphabetical.rs index 3845e2269e9b2..4ef1775d4bed9 100644 --- a/src/tools/tidy/src/alphabetical.rs +++ b/src/tools/tidy/src/alphabetical.rs @@ -9,19 +9,33 @@ //! // tidy-alphabetical-end //! ``` //! -//! The following lines are ignored: -//! - Empty lines -//! - Lines that are indented with more or less spaces than the first line -//! - Lines starting with `//`, `#` (except those starting with `#!`), `)`, `]`, `}` if the comment -//! has the same indentation as the first line -//! - Lines starting with a closing delimiter (`)`, `[`, `}`) are ignored. +//! Empty lines and lines starting (ignoring spaces) with `//` or `#` (except those starting with +//! `#!`) are considered comments are are sorted together with the next line (but do not affect +//! sorting). //! -//! If a line ends with an opening delimiter, we effectively join the following line to it before -//! checking it. E.g. `foo(\nbar)` is treated like `foo(bar)`. +//! If the following lines have higher indentation we effectively join them with the current line +//! before comparing it. If the next line with the same indentation starts (ignoring spaces) with +//! a closing delimiter (`)`, `[`, `}`) it is joined as well. +//! +//! E.g. +//! +//! ```rust,ignore ilustrative example for sorting mentioning non-existent functions +//! foo(a, +//! b); +//! bar( +//! a, +//! b +//! ); +//! // are treated for sorting purposes as +//! foo(a, b); +//! bar(a, b); +//! ``` use std::cmp::Ordering; -use std::fmt::Display; +use std::fs; +use std::io::{Seek, Write}; use std::iter::Peekable; +use std::ops::{Range, RangeBounds}; use std::path::Path; use crate::diagnostics::{CheckId, RunningCheck, TidyCtx}; @@ -38,94 +52,206 @@ fn is_close_bracket(c: char) -> bool { matches!(c, ')' | ']' | '}') } +fn is_empty_or_comment(line: &&str) -> bool { + let trimmed_line = line.trim_start_matches(' ').trim_end_matches('\n'); + + trimmed_line.is_empty() + || trimmed_line.starts_with("//") + || (trimmed_line.starts_with('#') && !trimmed_line.starts_with("#!")) +} + const START_MARKER: &str = "tidy-alphabetical-start"; const END_MARKER: &str = "tidy-alphabetical-end"; -fn check_section<'a>( - file: impl Display, - lines: impl Iterator, - check: &mut RunningCheck, -) { - let mut prev_line = String::new(); - let mut first_indent = None; - let mut in_split_line = None; - - for (idx, line) in lines { - if line.is_empty() { - continue; - } +/// Given contents of a section that is enclosed between [`START_MARKER`] and [`END_MARKER`], sorts +/// them according to the rules described at the top of the module. +fn sort_section(section: &str) -> String { + /// A sortable item + struct Item { + /// Full contents including comments and whitespace + full: String, + /// Trimmed contents for sorting + trimmed: String, + } - if line.contains(START_MARKER) { - check.error(format!( - "{file}:{} found `{START_MARKER}` expecting `{END_MARKER}`", - idx + 1 - )); - return; - } + let mut items = Vec::new(); + let mut lines = section.split_inclusive('\n').peekable(); + + let end_comments = loop { + let mut full = String::new(); + let mut trimmed = String::new(); - if line.contains(END_MARKER) { - return; + while let Some(comment) = lines.next_if(is_empty_or_comment) { + full.push_str(comment); } - let indent = first_indent.unwrap_or_else(|| { - let indent = indentation(line); - first_indent = Some(indent); - indent - }); - - let line = if let Some(prev_split_line) = in_split_line { - // Join the split lines. - in_split_line = None; - format!("{prev_split_line}{}", line.trim_start()) - } else { - line.to_string() + let Some(line) = lines.next() else { + // remember comments at the end of a block + break full; }; - if indentation(&line) != indent { - continue; - } + let mut push = |line| { + full.push_str(line); + trimmed.push_str(line.trim_start_matches(' ').trim_end_matches('\n')) + }; - let trimmed_line = line.trim_start_matches(' '); + push(line); - if trimmed_line.starts_with("//") - || (trimmed_line.starts_with('#') && !trimmed_line.starts_with("#!")) - || trimmed_line.starts_with(is_close_bracket) + let indent = indentation(line); + let mut multiline = false; + + // If the item is split between multiple lines... + while let Some(more_indented) = + lines.next_if(|&line: &&_| indent < indentation(line) || line == "\n") { - continue; + multiline = true; + push(more_indented); } - if line.trim_end().ends_with('(') { - in_split_line = Some(line); - continue; + if multiline + && let Some(indented) = + // Only append next indented line if it looks like a closing bracket. + // Otherwise we incorrectly merge code like this (can be seen in + // compiler/rustc_session/src/options.rs): + // + // force_unwind_tables: Option = (None, parse_opt_bool, [TRACKED], + // "force use of unwind tables"), + // incremental: Option = (None, parse_opt_string, [UNTRACKED], + // "enable incremental compilation"), + lines.next_if(|l| { + indentation(l) == indent + && l.trim_start_matches(' ').starts_with(is_close_bracket) + }) + { + push(indented); } - let prev_line_trimmed_lowercase = prev_line.trim_start_matches(' '); + items.push(Item { full, trimmed }); + }; - if version_sort(trimmed_line, prev_line_trimmed_lowercase).is_lt() { - check.error(format!("{file}:{}: line not in alphabetical order", idx + 1)); - } + items.sort_by(|a, b| version_sort(&a.trimmed, &b.trimmed)); + items.into_iter().map(|l| l.full).chain([end_comments]).collect() +} - prev_line = line; - } +fn check_lines<'a>(path: &Path, content: &'a str, tidy_ctx: &TidyCtx, check: &mut RunningCheck) { + let mut offset = 0; + + loop { + let rest = &content[offset..]; + let start = rest.find(START_MARKER); + let end = rest.find(END_MARKER); + + match (start, end) { + // error handling + + // end before start + (Some(start), Some(end)) if end < start => { + check.error(format!( + "{path}:{line_number} found `{END_MARKER}` expecting `{START_MARKER}`", + path = path.display(), + line_number = content[..offset + end].lines().count(), + )); + break; + } - check.error(format!("{file}: reached end of file expecting `{END_MARKER}`")); -} + // end without a start + (None, Some(end)) => { + check.error(format!( + "{path}:{line_number} found `{END_MARKER}` expecting `{START_MARKER}`", + path = path.display(), + line_number = content[..offset + end].lines().count(), + )); + break; + } -fn check_lines<'a>( - file: &impl Display, - mut lines: impl Iterator, - check: &mut RunningCheck, -) { - while let Some((idx, line)) = lines.next() { - if line.contains(END_MARKER) { - check.error(format!( - "{file}:{} found `{END_MARKER}` expecting `{START_MARKER}`", - idx + 1 - )); - } + // start without an end + (Some(start), None) => { + check.error(format!( + "{path}:{line_number} `{START_MARKER}` without a matching `{END_MARKER}`", + path = path.display(), + line_number = content[..offset + start].lines().count(), + )); + break; + } + + // a second start in between start/end pair + (Some(start), Some(end)) + if rest[start + START_MARKER.len()..end].contains(START_MARKER) => + { + check.error(format!( + "{path}:{line_number} found `{START_MARKER}` expecting `{END_MARKER}`", + path = path.display(), + line_number = content[..offset + + sub_find(rest, start + START_MARKER.len()..end, START_MARKER) + .unwrap() + .start] + .lines() + .count() + )); + break; + } - if line.contains(START_MARKER) { - check_section(file, &mut lines, check); + // happy happy path :3 + (Some(start), Some(end)) => { + assert!(start <= end); + + // "...␤// tidy-alphabetical-start␤...␤// tidy-alphabetical-end␤..." + // start_nl_end --^ ^-- end_nl_start ^-- end_nl_end + + // Position after the newline after start marker + let start_nl_end = sub_find(rest, start + START_MARKER.len().., "\n").unwrap().end; + + // Position before the new line before the end marker + let end_nl_start = rest[..end].rfind('\n').unwrap(); + + // Position after the newline after end marker + let end_nl_end = sub_find(rest, end + END_MARKER.len().., "\n") + .map(|r| r.end) + .unwrap_or(content.len() - offset); + + let section = &rest[start_nl_end..=end_nl_start]; + let sorted = sort_section(section); + + // oh nyooo :( + if sorted != section { + if !tidy_ctx.is_bless_enabled() { + let base_line_number = content[..offset + start_nl_end].lines().count(); + let line_offset = sorted + .lines() + .zip(section.lines()) + .enumerate() + .find(|(_, (a, b))| a != b) + .unwrap() + .0; + let line_number = base_line_number + line_offset; + + check.error(format!( + "{path}:{line_number}: line not in alphabetical order (tip: use --bless to sort this list)", + path = path.display(), + )); + } else { + // Use atomic rename as to not corrupt the file upon crashes/ctrl+c + let mut tempfile = + tempfile::Builder::new().tempfile_in(path.parent().unwrap()).unwrap(); + + fs::copy(path, tempfile.path()).unwrap(); + + tempfile + .as_file_mut() + .seek(std::io::SeekFrom::Start((offset + start_nl_end) as u64)) + .unwrap(); + tempfile.as_file_mut().write_all(sorted.as_bytes()).unwrap(); + + tempfile.persist(path).unwrap(); + } + } + + // Start the next search after the end section + offset += end_nl_end; + } + + // No more alphabetical lists, yay :3 + (None, None) => break, } } } @@ -133,13 +259,14 @@ fn check_lines<'a>( pub fn check(path: &Path, tidy_ctx: TidyCtx) { let mut check = tidy_ctx.start_check(CheckId::new("alphabetical").path(path)); - let skip = - |path: &_, _is_dir| filter_dirs(path) || path.ends_with("tidy/src/alphabetical/tests.rs"); + let skip = |path: &_, _is_dir| { + filter_dirs(path) + || path.ends_with("tidy/src/alphabetical.rs") + || path.ends_with("tidy/src/alphabetical/tests.rs") + }; - walk(path, skip, &mut |entry, contents| { - let file = &entry.path().display(); - let lines = contents.lines().enumerate(); - check_lines(file, lines, &mut check) + walk(path, skip, &mut |entry, content| { + check_lines(entry.path(), content, &tidy_ctx, &mut check) }); } @@ -195,3 +322,17 @@ fn version_sort(a: &str, b: &str) -> Ordering { it1.next().cmp(&it2.next()) } + +/// Finds `pat` in `s[range]` and returns a range such that `s[ret] == pat`. +fn sub_find(s: &str, range: impl RangeBounds, pat: &str) -> Option> { + s[(range.start_bound().cloned(), range.end_bound().cloned())] + .find(pat) + .map(|pos| { + pos + match range.start_bound().cloned() { + std::ops::Bound::Included(x) => x, + std::ops::Bound::Excluded(x) => x + 1, + std::ops::Bound::Unbounded => 0, + } + }) + .map(|pos| pos..pos + pat.len()) +} diff --git a/src/tools/tidy/src/alphabetical/tests.rs b/src/tools/tidy/src/alphabetical/tests.rs index 3e0dd798ab9df..e5cab33101260 100644 --- a/src/tools/tidy/src/alphabetical/tests.rs +++ b/src/tools/tidy/src/alphabetical/tests.rs @@ -7,7 +7,7 @@ use crate::diagnostics::{TidyCtx, TidyFlags}; fn test(lines: &str, name: &str, expected_msg: &str, expected_bad: bool) { let tidy_ctx = TidyCtx::new(Path::new("/"), false, TidyFlags::default()); let mut check = tidy_ctx.start_check("alphabetical-test"); - check_lines(&name, lines.lines().enumerate(), &mut check); + check_lines(Path::new(name), lines, &tidy_ctx, &mut check); assert_eq!(expected_bad, check.is_bad()); let errors = check.get_errors(); @@ -29,6 +29,23 @@ fn bad(lines: &str, expected_msg: &str) { test(lines, "bad", expected_msg, true); } +#[track_caller] +fn bless_test(before: &str, after: &str) { + let tempfile = tempfile::Builder::new().tempfile().unwrap(); + std::fs::write(tempfile.path(), before).unwrap(); + + let tidy_ctx = TidyCtx::new(Path::new("/"), false, TidyFlags::new(&["--bless".to_owned()])); + + let mut check = tidy_ctx.start_check("alphabetical-test"); + check_lines(tempfile.path(), before, &tidy_ctx, &mut check); + + assert!(!check.is_bad()); + let new = std::fs::read_to_string(tempfile.path()).unwrap(); + assert_eq!(new, after); + + good(&new); +} + #[test] fn test_no_markers() { let lines = "\ @@ -95,7 +112,7 @@ fn test_rust_bad() { def // tidy-alphabetical-end "; - bad(lines, "bad:4: line not in alphabetical order"); + bad(lines, "bad:2: line not in alphabetical order (tip: use --bless to sort this list)"); } #[test] @@ -107,7 +124,7 @@ fn test_toml_bad() { def # tidy-alphabetical-end "; - bad(lines, "bad:4: line not in alphabetical order"); + bad(lines, "bad:2: line not in alphabetical order (tip: use --bless to sort this list)"); } #[test] @@ -121,7 +138,7 @@ fn test_features_bad() { #![feature(def)] tidy-alphabetical-end "; - bad(lines, "bad:4: line not in alphabetical order"); + bad(lines, "bad:2: line not in alphabetical order (tip: use --bless to sort this list)"); } #[test] @@ -134,7 +151,7 @@ fn test_indent_bad() { def $ tidy-alphabetical-end "; - bad(lines, "bad:4: line not in alphabetical order"); + bad(lines, "bad:2: line not in alphabetical order (tip: use --bless to sort this list)"); } #[test] @@ -150,7 +167,7 @@ fn test_split_bad() { ) && tidy-alphabetical-end "; - bad(lines, "bad:7: line not in alphabetical order"); + bad(lines, "bad:3: line not in alphabetical order (tip: use --bless to sort this list)"); } #[test] @@ -160,7 +177,7 @@ fn test_double_start() { abc tidy-alphabetical-start "; - bad(lines, "bad:3 found `tidy-alphabetical-start` expecting `tidy-alphabetical-end`"); + bad(lines, "bad:0 `tidy-alphabetical-start` without a matching `tidy-alphabetical-end`"); } #[test] @@ -179,7 +196,7 @@ fn test_missing_end() { tidy-alphabetical-start abc "; - bad(lines, "bad: reached end of file expecting `tidy-alphabetical-end`"); + bad(lines, "bad:0 `tidy-alphabetical-start` without a matching `tidy-alphabetical-end`"); } #[test] @@ -319,7 +336,7 @@ fn test_numeric_bad() { item2 # tidy-alphabetical-end "; - bad(lines, "bad:4: line not in alphabetical order"); + bad(lines, "bad:2: line not in alphabetical order (tip: use --bless to sort this list)"); let lines = "\ # tidy-alphabetical-start @@ -327,7 +344,7 @@ fn test_numeric_bad() { zve64d # tidy-alphabetical-end "; - bad(lines, "bad:3: line not in alphabetical order"); + bad(lines, "bad:1: line not in alphabetical order (tip: use --bless to sort this list)"); let lines = "\ # tidy-alphabetical-start @@ -335,5 +352,154 @@ fn test_numeric_bad() { 00 # tidy-alphabetical-end "; - bad(lines, "bad:3: line not in alphabetical order"); + bad(lines, "bad:1: line not in alphabetical order (tip: use --bless to sort this list)"); +} + +#[test] +fn multiline() { + let lines = "\ + tidy-alphabetical-start + (b, + a); + ( + b, + a + ); + tidy-alphabetical-end + "; + good(lines); + + let lines = "\ + tidy-alphabetical-start + ( + b, + a + ); + (b, + a); + tidy-alphabetical-end + "; + good(lines); + + let lines = "\ + tidy-alphabetical-start + (c, + a); + ( + b, + a + ); + tidy-alphabetical-end + "; + bad(lines, "bad:1: line not in alphabetical order (tip: use --bless to sort this list)"); + + let lines = "\ + tidy-alphabetical-start + ( + c, + a + ); + (b, + a); + tidy-alphabetical-end + "; + bad(lines, "bad:1: line not in alphabetical order (tip: use --bless to sort this list)"); + + let lines = "\ + force_unwind_tables: Option = (None, parse_opt_bool, [TRACKED], + 'force use of unwind tables'), + incremental: Option = (None, parse_opt_string, [UNTRACKED], + 'enable incremental compilation'), + "; + good(lines); +} + +#[test] +fn bless_smoke() { + let before = "\ + tidy-alphabetical-start + 08 + 1 + 11 + 03 + tidy-alphabetical-end + "; + let after = "\ + tidy-alphabetical-start + 1 + 03 + 08 + 11 + tidy-alphabetical-end + "; + + bless_test(before, after); +} + +#[test] +fn bless_multiline() { + let before = "\ + tidy-alphabetical-start + 08 { + z} + 08 { + x + } + 1 + 08 {y} + 02 + 11 ( + 0 + ) + 03 + addition + notaddition + tidy-alphabetical-end + "; + let after = "\ + tidy-alphabetical-start + 1 + 02 + 03 + addition + 08 { + x + } + 08 {y} + 08 { + z} + 11 ( + 0 + ) + notaddition + tidy-alphabetical-end + "; + + bless_test(before, after); +} + +#[test] +fn bless_funny_numbers() { + // Because `2` is indented it gets merged into one entry with `1` and gets + // interpreted by version sort as `12`, which is greater than `3`. + // + // This is neither a wanted nor an unwanted behavior, this test just checks + // that it hasn't changed. + + let before = "\ + tidy-alphabetical-start + 1 + 2 + 3 + tidy-alphabetical-end + "; + let after = "\ + tidy-alphabetical-start + 3 + 1 + 2 + tidy-alphabetical-end + "; + + bless_test(before, after); } diff --git a/src/tools/tidy/src/diagnostics.rs b/src/tools/tidy/src/diagnostics.rs index 159500751aa5a..88816b5abefff 100644 --- a/src/tools/tidy/src/diagnostics.rs +++ b/src/tools/tidy/src/diagnostics.rs @@ -6,10 +6,10 @@ use std::sync::{Arc, Mutex}; use termcolor::Color; +/// CLI flags used by tidy. #[derive(Clone, Default)] -///CLI flags used by tidy. pub struct TidyFlags { - ///Applies style and formatting changes during a tidy run. + /// Applies style and formatting changes during a tidy run. bless: bool, } diff --git a/tests/crashes/114920.rs b/tests/crashes/114920.rs deleted file mode 100644 index 9aa7598e10fc3..0000000000000 --- a/tests/crashes/114920.rs +++ /dev/null @@ -1,2 +0,0 @@ -//@ known-bug: #114920 -#![core::prelude::v1::test] diff --git a/tests/ui/asm/aarch64/ttbr0_el2.rs b/tests/ui/asm/aarch64/ttbr0_el2.rs new file mode 100644 index 0000000000000..a283d75c8fffd --- /dev/null +++ b/tests/ui/asm/aarch64/ttbr0_el2.rs @@ -0,0 +1,11 @@ +//! Regression test for #97724, recognising ttbr0_el2 as a valid armv8 system register +//@ only-aarch64 +//@ build-pass +use std::arch::asm; + +static PT: [u64; 512] = [0; 512]; +fn main() { + unsafe { + asm!("msr ttbr0_el2, {pt}", pt = in(reg) &PT as *const _ ); + } +} diff --git a/tests/ui/const-generics/type-dependent/issue-71805.rs b/tests/ui/const-generics/type-dependent/issue-71805.rs index de04a809da60f..27c101df107c8 100644 --- a/tests/ui/const-generics/type-dependent/issue-71805.rs +++ b/tests/ui/const-generics/type-dependent/issue-71805.rs @@ -4,7 +4,7 @@ use std::mem::MaybeUninit; trait CollectSlice<'a>: Iterator { fn inner_array(&mut self) -> [Self::Item; N]; - fn custom_collect_array(&mut self) -> [Self::Item; N] { + fn collect_array(&mut self) -> [Self::Item; N] { let result = self.inner_array(); assert!(self.next().is_none()); result @@ -34,5 +34,5 @@ where fn main() { let mut foos = [0u64; 9].iter().cloned(); - let _bar: [u64; 9] = foos.custom_collect_array::<9_usize>(); + let _bar: [u64; 9] = foos.collect_array::<9_usize>(); } diff --git a/tests/ui/feature-gates/gating-of-test-attrs.rs b/tests/ui/feature-gates/gating-of-test-attrs.rs new file mode 100644 index 0000000000000..3b07e2ad03c9f --- /dev/null +++ b/tests/ui/feature-gates/gating-of-test-attrs.rs @@ -0,0 +1,48 @@ +#![feature(test)] + +// test is a built-in macro, not a built-in attribute, but it kind of acts like both. +// check its target checking anyway here +#[test] +//~^ ERROR the `#[test]` attribute may only be used on a free function +mod test { + mod inner { #![test] } + //~^ ERROR inner macro attributes are unstable + //~| ERROR the `#[test]` attribute may only be used on a free function + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a free function + struct S; + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a free function + type T = S; + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a free function + impl S { } +} + +// At time of unit test authorship, if compiling without `--test` then +// non-crate-level #[bench] attributes seem to be ignored. + +#[bench] +//~^ ERROR the `#[bench]` attribute may only be used on a free function +mod bench { + mod inner { #![bench] } + //~^ ERROR inner macro attributes are unstable + //~| ERROR the `#[bench]` attribute may only be used on a free function + + #[bench] + //~^ ERROR the `#[bench]` attribute may only be used on a free function + struct S; + + #[bench] + //~^ ERROR the `#[bench]` attribute may only be used on a free function + type T = S; + + #[bench] + //~^ ERROR the `#[bench]` attribute may only be used on a free function + impl S { } +} + +fn main() {} diff --git a/tests/ui/feature-gates/gating-of-test-attrs.stderr b/tests/ui/feature-gates/gating-of-test-attrs.stderr new file mode 100644 index 0000000000000..0f47ab85dc18e --- /dev/null +++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr @@ -0,0 +1,151 @@ +error: the `#[test]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:5:1 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | / mod test { +LL | | mod inner { #![test] } +... | +LL | | impl S { } +LL | | } + | |_- expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error[E0658]: inner macro attributes are unstable + --> $DIR/gating-of-test-attrs.rs:8:20 + | +LL | mod inner { #![test] } + | ^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[test]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:8:17 + | +LL | mod inner { #![test] } + | ------------^^^^^^^^-- + | | | + | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - mod inner { #![test] } +LL + mod inner { #[cfg(test)] } + | + +error: the `#[test]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:12:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | struct S; + | --------- expected a non-associated function, found a struct + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:16:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | type T = S; + | ----------- expected a non-associated function, found a type alias + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:20:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | impl S { } + | ---------- expected a non-associated function, found an implementation + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[bench]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:28:1 + | +LL | #[bench] + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | / mod bench { +LL | | mod inner { #![bench] } +... | +LL | | impl S { } +LL | | } + | |_- expected a non-associated function, found a module + +error[E0658]: inner macro attributes are unstable + --> $DIR/gating-of-test-attrs.rs:31:20 + | +LL | mod inner { #![bench] } + | ^^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[bench]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:31:17 + | +LL | mod inner { #![bench] } + | ------------^^^^^^^^^-- + | | | + | | the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions + | expected a non-associated function, found a module + +error: the `#[bench]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:35:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | struct S; + | --------- expected a non-associated function, found a struct + +error: the `#[bench]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:39:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | type T = S; + | ----------- expected a non-associated function, found a type alias + +error: the `#[bench]` attribute may only be used on a free function + --> $DIR/gating-of-test-attrs.rs:43:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | impl S { } + | ---------- expected a non-associated function, found an implementation + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index 8d67bf37279df..4b5420a2ff8b4 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -33,7 +33,6 @@ //@ check-pass -#![feature(test)] #![warn(unused_attributes, unknown_lints)] //~^ NOTE the lint level is defined here //~| NOTE the lint level is defined here @@ -250,38 +249,6 @@ mod macro_export { //~| HELP remove the attribute } -// At time of unit test authorship, if compiling without `--test` then -// non-crate-level #[test] attributes seem to be ignored. - -#[test] -mod test { mod inner { #![test] } - - fn f() { } - - struct S; - - type T = S; - - impl S { } -} - -// At time of unit test authorship, if compiling without `--test` then -// non-crate-level #[bench] attributes seem to be ignored. - -#[bench] -mod bench { - mod inner { #![bench] } - - #[bench] - struct S; - - #[bench] - type T = S; - - #[bench] - impl S { } -} - #[path = "3800"] mod path { mod inner { #![path="3800"] } diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index f7e8d9c7c4001..676372ad85e05 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -1,5 +1,5 @@ warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:529:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:496:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ @@ -7,193 +7,193 @@ LL | mod inner { #![macro_escape] } = help: try an outer attribute: `#[macro_use]` warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:526:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:493:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:43:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:42:9 | LL | #![warn(x5400)] | ^^^^^ | note: the lint level is defined here - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:37:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:36:28 | LL | #![warn(unused_attributes, unknown_lints)] | ^^^^^^^^^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:44:10 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:43:10 | LL | #![allow(x5300)] | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:45:11 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:44:11 | LL | #![forbid(x5200)] | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:46:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:45:9 | LL | #![deny(x5100)] | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:111:8 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:110:8 | LL | #[warn(x5400)] | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:114:25 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:113:25 | LL | mod inner { #![warn(x5400)] } | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:117:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:116:12 | LL | #[warn(x5400)] fn f() { } | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:120:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:119:12 | LL | #[warn(x5400)] struct S; | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:123:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:122:12 | LL | #[warn(x5400)] type T = S; | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:126:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:125:12 | LL | #[warn(x5400)] impl S { } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:130:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:129:9 | LL | #[allow(x5300)] | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:133:26 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:132:26 | LL | mod inner { #![allow(x5300)] } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:136:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:135:13 | LL | #[allow(x5300)] fn f() { } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:139:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:138:13 | LL | #[allow(x5300)] struct S; | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:142:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:141:13 | LL | #[allow(x5300)] type T = S; | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:145:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:144:13 | LL | #[allow(x5300)] impl S { } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:149:10 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:148:10 | LL | #[forbid(x5200)] | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:152:27 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:151:27 | LL | mod inner { #![forbid(x5200)] } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:155:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:154:14 | LL | #[forbid(x5200)] fn f() { } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:158:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:157:14 | LL | #[forbid(x5200)] struct S; | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:161:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:160:14 | LL | #[forbid(x5200)] type T = S; | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:164:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:163:14 | LL | #[forbid(x5200)] impl S { } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:168:8 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:167:8 | LL | #[deny(x5100)] | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:171:25 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:170:25 | LL | mod inner { #![deny(x5100)] } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:174:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:173:12 | LL | #[deny(x5100)] fn f() { } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:177:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:176:12 | LL | #[deny(x5100)] struct S; | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:180:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:179:12 | LL | #[deny(x5100)] type T = S; | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:183:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:182:12 | LL | #[deny(x5100)] impl S { } | ^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:501:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:468:1 | LL | #[reexport_test_harness_main = "2900"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:37:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:36:9 | LL | #![warn(unused_attributes, unknown_lints)] | ^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | #![reexport_test_harness_main = "2900"] | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:739:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:1 | LL | #[link(name = "x")] | ^^^^^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ LL | | } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:865:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:832:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +230,7 @@ LL | #![crate_type = "0800"] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:889:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ LL | #![feature(x0600)] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:914:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:881:1 | LL | #[no_main] | ^^^^^^^^^^ @@ -252,7 +252,7 @@ LL | #![no_main] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:938:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:905:1 | LL | #[no_builtins] | ^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | #![no_builtins] | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:71:1 | LL | #![link(name = "x")] | ^^^^^^^^^^^^^^^^^^^^ not an `extern` block @@ -271,7 +271,7 @@ LL | #![link(name = "x")] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:100:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:99:12 | LL | #![feature(rust1)] | ^^^^^ @@ -279,13 +279,13 @@ LL | #![feature(rust1)] = note: `#[warn(stable_features)]` on by default warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:505:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:472:17 | LL | mod inner { #![reexport_test_harness_main="2900"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:508:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:475:5 | LL | #[reexport_test_harness_main = "2900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -296,7 +296,7 @@ LL | #![reexport_test_harness_main = "2900"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:512:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:479:5 | LL | #[reexport_test_harness_main = "2900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +307,7 @@ LL | #![reexport_test_harness_main = "2900"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:516:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:483:5 | LL | #[reexport_test_harness_main = "2900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +318,7 @@ LL | #![reexport_test_harness_main = "2900"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:520:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:5 | LL | #[reexport_test_harness_main = "2900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,7 @@ LL | #![reexport_test_harness_main = "2900"] impl S { } | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:17 | LL | mod inner { #![link(name = "x")] } | ------------^^^^^^^^^^^^^^^^^^^^-- not an `extern` block @@ -337,7 +337,7 @@ LL | mod inner { #![link(name = "x")] } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:717:5 | LL | #[link(name = "x")] fn f() { } | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block @@ -345,7 +345,7 @@ LL | #[link(name = "x")] fn f() { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:755:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:722:5 | LL | #[link(name = "x")] struct S; | ^^^^^^^^^^^^^^^^^^^ --------- not an `extern` block @@ -353,7 +353,7 @@ LL | #[link(name = "x")] struct S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:760:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:727:5 | LL | #[link(name = "x")] type T = S; | ^^^^^^^^^^^^^^^^^^^ ----------- not an `extern` block @@ -361,7 +361,7 @@ LL | #[link(name = "x")] type T = S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:732:5 | LL | #[link(name = "x")] impl S { } | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block @@ -369,7 +369,7 @@ LL | #[link(name = "x")] impl S { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:5 | LL | #[link(name = "x")] extern "Rust" {} | ^^^^^^^^^^^^^^^^^^^ @@ -377,13 +377,13 @@ LL | #[link(name = "x")] extern "Rust" {} = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:869:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:836:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:872:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:839:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -394,7 +394,7 @@ LL | #![crate_type = "0800"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:876:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:843:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ LL | #![crate_type = "0800"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:880:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:847:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -416,7 +416,7 @@ LL | #![crate_type = "0800"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:884:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:851:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -427,13 +427,13 @@ LL | #![crate_type = "0800"] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:893:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:896:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:863:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ @@ -444,7 +444,7 @@ LL | #![feature(x0600)] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:900:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:867:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ LL | #![feature(x0600)] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:904:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:871:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ @@ -466,7 +466,7 @@ LL | #![feature(x0600)] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:908:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:875:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ @@ -477,13 +477,13 @@ LL | #![feature(x0600)] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:918:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:885:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:921:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:888:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ @@ -494,7 +494,7 @@ LL | #![no_main] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:925:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:892:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ @@ -505,7 +505,7 @@ LL | #![no_main] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:929:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:896:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ @@ -516,7 +516,7 @@ LL | #![no_main] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:933:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:900:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ @@ -527,13 +527,13 @@ LL | #![no_main] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:942:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:909:17 | LL | mod inner { #![no_builtins] } | ^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:912:5 | LL | #[no_builtins] fn f() { } | ^^^^^^^^^^^^^^ @@ -544,7 +544,7 @@ LL | #![no_builtins] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:916:5 | LL | #[no_builtins] struct S; | ^^^^^^^^^^^^^^ @@ -555,7 +555,7 @@ LL | #![no_builtins] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:953:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:920:5 | LL | #[no_builtins] type T = S; | ^^^^^^^^^^^^^^ @@ -566,7 +566,7 @@ LL | #![no_builtins] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:957:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:924:5 | LL | #[no_builtins] impl S { } | ^^^^^^^^^^^^^^ @@ -577,7 +577,7 @@ LL | #![no_builtins] impl S { } | + warning: `#[macro_use]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:191:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:190:5 | LL | #[macro_use] fn f() { } | ^^^^^^^^^^^^ @@ -586,7 +586,7 @@ LL | #[macro_use] fn f() { } = help: `#[macro_use]` can be applied to crates, extern crates, and modules warning: `#[macro_use]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:197:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:196:5 | LL | #[macro_use] struct S; | ^^^^^^^^^^^^ @@ -595,7 +595,7 @@ LL | #[macro_use] struct S; = help: `#[macro_use]` can be applied to crates, extern crates, and modules warning: `#[macro_use]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:203:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:202:5 | LL | #[macro_use] type T = S; | ^^^^^^^^^^^^ @@ -604,7 +604,7 @@ LL | #[macro_use] type T = S; = help: `#[macro_use]` can be applied to crates, extern crates, and modules warning: `#[macro_use]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:209:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:208:5 | LL | #[macro_use] impl S { } | ^^^^^^^^^^^^ @@ -613,7 +613,7 @@ LL | #[macro_use] impl S { } = help: `#[macro_use]` can be applied to crates, extern crates, and modules warning: `#[macro_export]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:216:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:215:1 | LL | #[macro_export] | ^^^^^^^^^^^^^^^ @@ -622,7 +622,7 @@ LL | #[macro_export] = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:222:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:221:17 | LL | mod inner { #![macro_export] } | ^^^^^^^^^^^^^^^^ @@ -631,7 +631,7 @@ LL | mod inner { #![macro_export] } = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:228:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:227:5 | LL | #[macro_export] fn f() { } | ^^^^^^^^^^^^^^^ @@ -640,7 +640,7 @@ LL | #[macro_export] fn f() { } = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:234:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:233:5 | LL | #[macro_export] struct S; | ^^^^^^^^^^^^^^^ @@ -649,7 +649,7 @@ LL | #[macro_export] struct S; = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:240:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:239:5 | LL | #[macro_export] type T = S; | ^^^^^^^^^^^^^^^ @@ -658,7 +658,7 @@ LL | #[macro_export] type T = S; = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:246:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:245:5 | LL | #[macro_export] impl S { } | ^^^^^^^^^^^^^^^ @@ -667,7 +667,7 @@ LL | #[macro_export] impl S { } = help: `#[macro_export]` can only be applied to macro defs warning: `#[path]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:289:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:256:5 | LL | #[path = "3800"] fn f() { } | ^^^^^^^^^^^^^^^^ @@ -676,7 +676,7 @@ LL | #[path = "3800"] fn f() { } = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:295:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:262:5 | LL | #[path = "3800"] struct S; | ^^^^^^^^^^^^^^^^ @@ -685,7 +685,7 @@ LL | #[path = "3800"] struct S; = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:301:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:268:5 | LL | #[path = "3800"] type T = S; | ^^^^^^^^^^^^^^^^ @@ -694,7 +694,7 @@ LL | #[path = "3800"] type T = S; = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:307:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:274:5 | LL | #[path = "3800"] impl S { } | ^^^^^^^^^^^^^^^^ @@ -703,7 +703,7 @@ LL | #[path = "3800"] impl S { } = help: `#[path]` can only be applied to modules warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:314:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:281:1 | LL | #[automatically_derived] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -712,7 +712,7 @@ LL | #[automatically_derived] = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:320:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:287:17 | LL | mod inner { #![automatically_derived] } | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -721,7 +721,7 @@ LL | mod inner { #![automatically_derived] } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:326:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:293:5 | LL | #[automatically_derived] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -730,7 +730,7 @@ LL | #[automatically_derived] fn f() { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:332:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:299:5 | LL | #[automatically_derived] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -739,7 +739,7 @@ LL | #[automatically_derived] struct S; = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:338:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:305:5 | LL | #[automatically_derived] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -748,7 +748,7 @@ LL | #[automatically_derived] type T = S; = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on traits - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:344:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:311:5 | LL | #[automatically_derived] trait W { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -757,7 +757,7 @@ LL | #[automatically_derived] trait W { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:350:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:317:5 | LL | #[automatically_derived] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -766,7 +766,7 @@ LL | #[automatically_derived] impl S { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[no_mangle]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:359:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:326:1 | LL | #[no_mangle] | ^^^^^^^^^^^^ @@ -775,7 +775,7 @@ LL | #[no_mangle] = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:365:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:332:17 | LL | mod inner { #![no_mangle] } | ^^^^^^^^^^^^^ @@ -784,7 +784,7 @@ LL | mod inner { #![no_mangle] } = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:373:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:340:5 | LL | #[no_mangle] struct S; | ^^^^^^^^^^^^ @@ -793,7 +793,7 @@ LL | #[no_mangle] struct S; = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:379:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:346:5 | LL | #[no_mangle] type T = S; | ^^^^^^^^^^^^ @@ -802,7 +802,7 @@ LL | #[no_mangle] type T = S; = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:385:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:352:5 | LL | #[no_mangle] impl S { } | ^^^^^^^^^^^^ @@ -811,7 +811,7 @@ LL | #[no_mangle] impl S { } = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on required trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:392:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:359:9 | LL | #[no_mangle] fn foo(); | ^^^^^^^^^^^^ @@ -820,7 +820,7 @@ LL | #[no_mangle] fn foo(); = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks warning: `#[no_mangle]` attribute cannot be used on provided trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:365:9 | LL | #[no_mangle] fn bar() {} | ^^^^^^^^^^^^ @@ -829,7 +829,7 @@ LL | #[no_mangle] fn bar() {} = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks warning: `#[should_panic]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:406:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:373:1 | LL | #[should_panic] | ^^^^^^^^^^^^^^^ @@ -838,7 +838,7 @@ LL | #[should_panic] = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:412:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:379:17 | LL | mod inner { #![should_panic] } | ^^^^^^^^^^^^^^^^ @@ -847,7 +847,7 @@ LL | mod inner { #![should_panic] } = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:420:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:387:5 | LL | #[should_panic] struct S; | ^^^^^^^^^^^^^^^ @@ -856,7 +856,7 @@ LL | #[should_panic] struct S; = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:426:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:393:5 | LL | #[should_panic] type T = S; | ^^^^^^^^^^^^^^^ @@ -865,7 +865,7 @@ LL | #[should_panic] type T = S; = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:432:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:399:5 | LL | #[should_panic] impl S { } | ^^^^^^^^^^^^^^^ @@ -874,7 +874,7 @@ LL | #[should_panic] impl S { } = help: `#[should_panic]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:439:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:406:1 | LL | #[ignore] | ^^^^^^^^^ @@ -883,7 +883,7 @@ LL | #[ignore] = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:445:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:412:17 | LL | mod inner { #![ignore] } | ^^^^^^^^^^ @@ -892,7 +892,7 @@ LL | mod inner { #![ignore] } = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:453:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:420:5 | LL | #[ignore] struct S; | ^^^^^^^^^ @@ -901,7 +901,7 @@ LL | #[ignore] struct S; = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:459:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:426:5 | LL | #[ignore] type T = S; | ^^^^^^^^^ @@ -910,7 +910,7 @@ LL | #[ignore] type T = S; = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:465:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:432:5 | LL | #[ignore] impl S { } | ^^^^^^^^^ @@ -919,7 +919,7 @@ LL | #[ignore] impl S { } = help: `#[ignore]` can only be applied to functions warning: `#[no_implicit_prelude]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:443:5 | LL | #[no_implicit_prelude] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -928,7 +928,7 @@ LL | #[no_implicit_prelude] fn f() { } = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:482:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:449:5 | LL | #[no_implicit_prelude] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -937,7 +937,7 @@ LL | #[no_implicit_prelude] struct S; = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:455:5 | LL | #[no_implicit_prelude] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -946,7 +946,7 @@ LL | #[no_implicit_prelude] type T = S; = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:461:5 | LL | #[no_implicit_prelude] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -955,7 +955,7 @@ LL | #[no_implicit_prelude] impl S { } = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[macro_escape]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:500:5 | LL | #[macro_escape] fn f() { } | ^^^^^^^^^^^^^^^ @@ -964,7 +964,7 @@ LL | #[macro_escape] fn f() { } = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:539:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:506:5 | LL | #[macro_escape] struct S; | ^^^^^^^^^^^^^^^ @@ -973,7 +973,7 @@ LL | #[macro_escape] struct S; = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:512:5 | LL | #[macro_escape] type T = S; | ^^^^^^^^^^^^^^^ @@ -982,7 +982,7 @@ LL | #[macro_escape] type T = S; = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:551:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:518:5 | LL | #[macro_escape] impl S { } | ^^^^^^^^^^^^^^^ @@ -991,13 +991,13 @@ LL | #[macro_escape] impl S { } = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:558:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:525:1 | LL | #[no_std] | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:560:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:527:1 | LL | / mod no_std { LL | | @@ -1007,61 +1007,61 @@ LL | | } | |_^ warning: the `#![no_std]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:562:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:529:17 | LL | mod inner { #![no_std] } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:565:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:532:5 | LL | #[no_std] fn f() { } | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:565:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:532:15 | LL | #[no_std] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:569:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:5 | LL | #[no_std] struct S; | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:569:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:15 | LL | #[no_std] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:540:5 | LL | #[no_std] type T = S; | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:540:15 | LL | #[no_std] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:577:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:544:5 | LL | #[no_std] impl S { } | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:577:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:544:15 | LL | #[no_std] impl S { } | ^^^^^^^^^^ warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:599:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:566:1 | LL | #[cold] | ^^^^^^^ @@ -1070,7 +1070,7 @@ LL | #[cold] = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:606:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:17 | LL | mod inner { #![cold] } | ^^^^^^^^ @@ -1079,7 +1079,7 @@ LL | mod inner { #![cold] } = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:581:5 | LL | #[cold] struct S; | ^^^^^^^ @@ -1088,7 +1088,7 @@ LL | #[cold] struct S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:587:5 | LL | #[cold] type T = S; | ^^^^^^^ @@ -1097,7 +1097,7 @@ LL | #[cold] type T = S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:593:5 | LL | #[cold] impl S { } | ^^^^^^^ @@ -1106,7 +1106,7 @@ LL | #[cold] impl S { } = help: `#[cold]` can only be applied to functions warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:633:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:600:1 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1115,7 +1115,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on foreign modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:639:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:606:5 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1124,7 +1124,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:613:17 | LL | mod inner { #![link_name="1900"] } | ^^^^^^^^^^^^^^^^^^^^ @@ -1133,7 +1133,7 @@ LL | mod inner { #![link_name="1900"] } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:619:5 | LL | #[link_name = "1900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1142,7 +1142,7 @@ LL | #[link_name = "1900"] fn f() { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:658:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:625:5 | LL | #[link_name = "1900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1151,7 +1151,7 @@ LL | #[link_name = "1900"] struct S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:631:5 | LL | #[link_name = "1900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1160,7 +1160,7 @@ LL | #[link_name = "1900"] type T = S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:670:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:637:5 | LL | #[link_name = "1900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1169,7 +1169,7 @@ LL | #[link_name = "1900"] impl S { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:1 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1178,7 +1178,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:683:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:650:17 | LL | mod inner { #![link_section="1800"] } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -1187,7 +1187,7 @@ LL | mod inner { #![link_section="1800"] } = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:658:5 | LL | #[link_section = "1800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1196,7 +1196,7 @@ LL | #[link_section = "1800"] struct S; = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5 | LL | #[link_section = "1800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1205,7 +1205,7 @@ LL | #[link_section = "1800"] type T = S; = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:670:5 | LL | #[link_section = "1800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1214,7 +1214,7 @@ LL | #[link_section = "1800"] impl S { } = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on traits - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:709:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:676:5 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1223,7 +1223,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:757:1 | LL | #[must_use] | ^^^^^^^^^^^ @@ -1232,7 +1232,7 @@ LL | #[must_use] = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:795:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:17 | LL | mod inner { #![must_use] } | ^^^^^^^^^^^^ @@ -1241,7 +1241,7 @@ LL | mod inner { #![must_use] } = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:5 | LL | #[must_use] type T = S; | ^^^^^^^^^^^ @@ -1250,7 +1250,7 @@ LL | #[must_use] type T = S; = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:776:5 | LL | #[must_use] impl S { } | ^^^^^^^^^^^ @@ -1259,13 +1259,13 @@ LL | #[must_use] impl S { } = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:782:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:784:1 | LL | / mod windows_subsystem { LL | | @@ -1275,67 +1275,67 @@ LL | | } | |_^ warning: the `#![windows_subsystem]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:819:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:786:17 | LL | mod inner { #![windows_subsystem="windows"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:5 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:38 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:793:5 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:793:38 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:797:5 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:797:38 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:5 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:38 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:841:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:808:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:843:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:810:1 | LL | / mod crate_name { LL | | @@ -1345,67 +1345,67 @@ LL | | } | |_^ warning: the `#![crate_name]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:845:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:812:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:28 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:819:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:819:28 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:823:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:823:28 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:827:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:827:28 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:962:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:929:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:964:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:931:1 | LL | / mod recursion_limit { LL | | @@ -1415,67 +1415,67 @@ LL | | } | |_^ warning: the `#![recursion_limit]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:966:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:933:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:936:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:936:31 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:940:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:940:31 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:977:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:944:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:977:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:944:31 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:981:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:948:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:981:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:948:31 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:986:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:953:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:988:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:955:1 | LL | / mod type_length_limit { LL | | @@ -1485,61 +1485,61 @@ LL | | } | |_^ warning: the `#![type_length_limit]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:990:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:957:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:993:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:960:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:993:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:960:33 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:997:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:964:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:997:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:964:33 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1001:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:968:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1001:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:968:33 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1005:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:972:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1005:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:972:33 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^ warning: `#[should_panic]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:50:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:49:1 | LL | #![should_panic] | ^^^^^^^^^^^^^^^^ @@ -1548,7 +1548,7 @@ LL | #![should_panic] = help: `#[should_panic]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:54:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:53:1 | LL | #![ignore] | ^^^^^^^^^^ @@ -1557,7 +1557,7 @@ LL | #![ignore] = help: `#[ignore]` can only be applied to functions warning: `#[proc_macro_derive]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:63:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 | LL | #![proc_macro_derive(Test)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1566,7 +1566,7 @@ LL | #![proc_macro_derive(Test)] = help: `#[proc_macro_derive]` can only be applied to functions warning: `#[cold]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:68:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:67:1 | LL | #![cold] | ^^^^^^^^ @@ -1575,7 +1575,7 @@ LL | #![cold] = help: `#[cold]` can only be applied to functions warning: `#[link_name]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:74:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:73:1 | LL | #![link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -1584,7 +1584,7 @@ LL | #![link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_section]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:79:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:78:1 | LL | #![link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1593,7 +1593,7 @@ LL | #![link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[must_use]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:84:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:83:1 | LL | #![must_use] | ^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-3477.rs b/tests/ui/issues/issue-3477.rs deleted file mode 100644 index eb94294d5a877..0000000000000 --- a/tests/ui/issues/issue-3477.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - let _p: char = 100; - //~^ ERROR mismatched types - //~| NOTE expected `char`, found `u8` - //~| NOTE expected due to this -} diff --git a/tests/ui/issues/issue-3477.stderr b/tests/ui/issues/issue-3477.stderr deleted file mode 100644 index 2a4d6d2449ed4..0000000000000 --- a/tests/ui/issues/issue-3477.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-3477.rs:2:20 - | -LL | let _p: char = 100; - | ---- ^^^ expected `char`, found `u8` - | | - | expected due to this - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-4935.rs b/tests/ui/issues/issue-4935.rs deleted file mode 100644 index ef8a3eb32abbe..0000000000000 --- a/tests/ui/issues/issue-4935.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Regression test for issue #4935 - -fn foo(a: usize) {} -//~^ NOTE defined here -fn main() { foo(5, 6) } -//~^ ERROR function takes 1 argument but 2 arguments were supplied -//~| NOTE unexpected argument #2 of type `{integer}` diff --git a/tests/ui/issues/issue-4935.stderr b/tests/ui/issues/issue-4935.stderr deleted file mode 100644 index 918f74256c034..0000000000000 --- a/tests/ui/issues/issue-4935.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0061]: this function takes 1 argument but 2 arguments were supplied - --> $DIR/issue-4935.rs:5:13 - | -LL | fn main() { foo(5, 6) } - | ^^^ - unexpected argument #2 of type `{integer}` - | -note: function defined here - --> $DIR/issue-4935.rs:3:4 - | -LL | fn foo(a: usize) {} - | ^^^ -help: remove the extra argument - | -LL - fn main() { foo(5, 6) } -LL + fn main() { foo(5) } - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/issues/issue-5062.rs b/tests/ui/issues/issue-5062.rs deleted file mode 100644 index 2db0a8e25b462..0000000000000 --- a/tests/ui/issues/issue-5062.rs +++ /dev/null @@ -1,2 +0,0 @@ -fn main() { format!("{:?}", None); } - //~^ ERROR type annotations needed [E0282] diff --git a/tests/ui/issues/issue-5062.stderr b/tests/ui/issues/issue-5062.stderr deleted file mode 100644 index 0839ece79aaff..0000000000000 --- a/tests/ui/issues/issue-5062.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/issue-5062.rs:1:29 - | -LL | fn main() { format!("{:?}", None); } - | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` - | -help: consider specifying the generic argument - | -LL | fn main() { format!("{:?}", None::); } - | +++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/macros/attr-empty-expr.rs b/tests/ui/macros/attr-empty-expr.rs deleted file mode 100644 index d4d1a3ee71e67..0000000000000 --- a/tests/ui/macros/attr-empty-expr.rs +++ /dev/null @@ -1,11 +0,0 @@ -// AST-based macro attributes expanding to an empty expression produce an error and not ICE. - -#![feature(custom_test_frameworks)] -#![feature(stmt_expr_attributes)] -#![feature(test)] - -fn main() { - let _ = #[test] 0; //~ ERROR removing an expression is not supported in this position - let _ = #[bench] 1; //~ ERROR removing an expression is not supported in this position - let _ = #[test_case] 2; //~ ERROR removing an expression is not supported in this position -} diff --git a/tests/ui/macros/attr-empty-expr.stderr b/tests/ui/macros/attr-empty-expr.stderr deleted file mode 100644 index 53721053bcc08..0000000000000 --- a/tests/ui/macros/attr-empty-expr.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:8:13 - | -LL | let _ = #[test] 0; - | ^^^^^^^ - -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:9:13 - | -LL | let _ = #[bench] 1; - | ^^^^^^^^ - -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:10:13 - | -LL | let _ = #[test_case] 2; - | ^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/macros/issue-111749.rs b/tests/ui/macros/issue-111749.rs index 6c45e4e8cd719..e92b9e4ccff82 100644 --- a/tests/ui/macros/issue-111749.rs +++ b/tests/ui/macros/issue-111749.rs @@ -5,8 +5,8 @@ macro_rules! cbor_map { } fn main() { - cbor_map! { #[test(test)] 4}; - //~^ ERROR removing an expression is not supported in this position + cbor_map! { #[test(test)] 4i32}; + //~^ ERROR the `#[test]` attribute may only be used on a free function //~| ERROR attribute must be of the form `#[test]` //~| WARNING this was previously accepted by the compiler but is being phased out } diff --git a/tests/ui/macros/issue-111749.stderr b/tests/ui/macros/issue-111749.stderr index ae953e042e094..ead01f87eaec0 100644 --- a/tests/ui/macros/issue-111749.stderr +++ b/tests/ui/macros/issue-111749.stderr @@ -1,13 +1,19 @@ -error: removing an expression is not supported in this position +error: the `#[test]` attribute may only be used on a free function --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; - | ^^^^^^^^^^^^^ +LL | cbor_map! { #[test(test)] 4i32}; + | ^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - cbor_map! { #[test(test)] 4i32}; +LL + cbor_map! { #[cfg(test)] 4i32}; + | error: attribute must be of the form `#[test]` --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; +LL | cbor_map! { #[test(test)] 4i32}; | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -20,7 +26,7 @@ Future incompatibility report: Future breakage diagnostic: error: attribute must be of the form `#[test]` --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; +LL | cbor_map! { #[test(test)] 4i32}; | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs new file mode 100644 index 0000000000000..88d6ec40af840 --- /dev/null +++ b/tests/ui/macros/test-on-crate-root.rs @@ -0,0 +1,10 @@ +// Regression test for rust-lang/rust#114920 +// +// Applying `#![test]` to the crate root used to ICE, +// when referring to the attribute with full path specifically. +#![core::prelude::v1::test] +//~^ ERROR inner macro attributes are unstable +//~| ERROR the `#[test]` attribute may only be used on a free function + + +fn main() {} diff --git a/tests/ui/macros/test-on-crate-root.stderr b/tests/ui/macros/test-on-crate-root.stderr new file mode 100644 index 0000000000000..750c510ecbca1 --- /dev/null +++ b/tests/ui/macros/test-on-crate-root.stderr @@ -0,0 +1,25 @@ +error[E0658]: inner macro attributes are unstable + --> $DIR/test-on-crate-root.rs:5:4 + | +LL | #![core::prelude::v1::test] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[test]` attribute may only be used on a free function + --> $DIR/test-on-crate-root.rs:5:1 + | +LL | #![core::prelude::v1::test] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #![core::prelude::v1::test] +LL + #[cfg(test)] + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/mir/mir-inlining/ice-issue-77564.rs b/tests/ui/mir/mir-inlining/ice-issue-77564.rs index 256ff295184d7..fce6d1d174f66 100644 --- a/tests/ui/mir/mir-inlining/ice-issue-77564.rs +++ b/tests/ui/mir/mir-inlining/ice-issue-77564.rs @@ -29,11 +29,10 @@ where fn main() { assert_eq!( - CollectArray::collect_array( - &mut [[1, 2], [3, 4]] + [[1, 2], [3, 4]] .iter() - .map(|row| CollectArray::collect_array(&mut row.iter())) - ), + .map(|row| row.iter().collect_array()) + .collect_array(), [[&1, &2], [&3, &4]] ); } diff --git a/tests/ui/mismatched_types/assignment-mismatch-various-types.rs b/tests/ui/mismatched_types/assignment-mismatch-various-types.rs new file mode 100644 index 0000000000000..903bfd9756f01 --- /dev/null +++ b/tests/ui/mismatched_types/assignment-mismatch-various-types.rs @@ -0,0 +1,9 @@ +//! regression test for + +fn main() { + let x: u32 = (); + //~^ ERROR mismatched types + + let _p: char = 100; + //~^ ERROR mismatched types +} diff --git a/tests/ui/mismatched_types/assignment-mismatch-various-types.stderr b/tests/ui/mismatched_types/assignment-mismatch-various-types.stderr new file mode 100644 index 0000000000000..14356fe16d3d8 --- /dev/null +++ b/tests/ui/mismatched_types/assignment-mismatch-various-types.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/assignment-mismatch-various-types.rs:4:18 + | +LL | let x: u32 = (); + | --- ^^ expected `u32`, found `()` + | | + | expected due to this + +error[E0308]: mismatched types + --> $DIR/assignment-mismatch-various-types.rs:7:20 + | +LL | let _p: char = 100; + | ---- ^^^ expected `char`, found `u8` + | | + | expected due to this + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/mismatched_types/main.rs b/tests/ui/mismatched_types/main.rs deleted file mode 100644 index e2d09dc219922..0000000000000 --- a/tests/ui/mismatched_types/main.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let x: u32 = ( //~ ERROR mismatched types - ); -} diff --git a/tests/ui/mismatched_types/main.stderr b/tests/ui/mismatched_types/main.stderr deleted file mode 100644 index 38146cef3475a..0000000000000 --- a/tests/ui/mismatched_types/main.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/main.rs:2:18 - | -LL | let x: u32 = ( - | ____________---___^ - | | | - | | expected due to this -LL | | ); - | |_____^ expected `u32`, found `()` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/unreachable-code/boolean-negation-in-unreachable-code-7344.rs b/tests/ui/reachable/boolean-negation-in-unreachable-code-7344.rs similarity index 100% rename from tests/ui/unreachable-code/boolean-negation-in-unreachable-code-7344.rs rename to tests/ui/reachable/boolean-negation-in-unreachable-code-7344.rs diff --git a/tests/ui/reachable/guard_read_for_never.rs b/tests/ui/reachable/guard_read_for_never.rs new file mode 100644 index 0000000000000..7061da635301c --- /dev/null +++ b/tests/ui/reachable/guard_read_for_never.rs @@ -0,0 +1,16 @@ +// Regression test for +// +//@ check-pass +#![feature(guard_patterns, never_type)] +#![expect(incomplete_features, unused_parens)] +#![deny(unreachable_code)] + +fn main() { + unsafe { + let x = std::ptr::null::(); + + // This should not constitute a read for never, therefore no code here is unreachable + let (_ if false): ! = *x; + (); + } +} diff --git a/tests/ui/reachable/nested_type_ascription.rs b/tests/ui/reachable/nested_type_ascription.rs new file mode 100644 index 0000000000000..1712ee00b17c8 --- /dev/null +++ b/tests/ui/reachable/nested_type_ascription.rs @@ -0,0 +1,19 @@ +// Regression test for . +// +// This checks that a nested type ascription doesn't cause a crash when the +// compiler checks if it constitutes a read of the never type. +// +//@ check-pass + +#![feature(never_type)] +#![feature(type_ascription)] +#![deny(unreachable_code)] + +fn main() { + unsafe { + let _ = type_ascribe!(type_ascribe!(*std::ptr::null(), !), _); + + // this is *not* unreachable, because previous line does not actually read the never type + (); + } +} diff --git a/tests/ui/reachable/type_ascribe_never_field.rs b/tests/ui/reachable/type_ascribe_never_field.rs new file mode 100644 index 0000000000000..2788d30414e69 --- /dev/null +++ b/tests/ui/reachable/type_ascribe_never_field.rs @@ -0,0 +1,17 @@ +// Regression test for +// +// Checks that type ascription of a field place with type never is correctly +// checked for if it constitutes a read of type never. (it doesn't) +// +//@ check-pass + +#![feature(never_type)] +#![feature(type_ascription)] +#![deny(unreachable_code)] + +fn main() { + let x: (!,); + let _ = type_ascribe!(x.0, _); + + (); // reachable +} diff --git a/tests/ui/unreachable-code/unreachable-bool-read-7246.rs b/tests/ui/reachable/unreachable-bool-read-7246.rs similarity index 100% rename from tests/ui/unreachable-code/unreachable-bool-read-7246.rs rename to tests/ui/reachable/unreachable-bool-read-7246.rs diff --git a/tests/ui/unreachable-code/unreachable-bool-read-7246.stderr b/tests/ui/reachable/unreachable-bool-read-7246.stderr similarity index 100% rename from tests/ui/unreachable-code/unreachable-bool-read-7246.stderr rename to tests/ui/reachable/unreachable-bool-read-7246.stderr diff --git a/tests/ui/issues/issue-3109.rs b/tests/ui/str/debug-print-basic-tuple.rs similarity index 51% rename from tests/ui/issues/issue-3109.rs rename to tests/ui/str/debug-print-basic-tuple.rs index 89beaa2222732..7e2b86f56293d 100644 --- a/tests/ui/issues/issue-3109.rs +++ b/tests/ui/str/debug-print-basic-tuple.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass pub fn main() { println!("{:?}", ("hi there!", "you")); diff --git a/tests/ui/test-attrs/issue-109816.rs b/tests/ui/test-attrs/issue-109816.rs index 3cabf451c6635..c7caae67fefa6 100644 --- a/tests/ui/test-attrs/issue-109816.rs +++ b/tests/ui/test-attrs/issue-109816.rs @@ -2,6 +2,6 @@ fn align_offset_weird_strides() { #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function struct A5(u32, u8); } diff --git a/tests/ui/test-attrs/issue-109816.stderr b/tests/ui/test-attrs/issue-109816.stderr index 433421fff1b57..270f4e0a66683 100644 --- a/tests/ui/test-attrs/issue-109816.stderr +++ b/tests/ui/test-attrs/issue-109816.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/issue-109816.rs:4:5 | LL | #[test] diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.rs b/tests/ui/test-attrs/test-attr-non-associated-functions.rs index 1a4dfda090970..4bf337d0f1b3c 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.rs +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.rs @@ -4,12 +4,12 @@ struct A {} impl A { #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function fn new() -> A { A {} } #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function fn recovery_witness() -> A { A {} } diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr index 0ede0cbb97f33..13914971b558a 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-attr-non-associated-functions.rs:6:5 | LL | #[test] @@ -10,7 +10,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-attr-non-associated-functions.rs:11:5 | LL | #[test] diff --git a/tests/ui/test-attrs/test-on-not-fn.rs b/tests/ui/test-attrs/test-on-not-fn.rs index deba26f24ca71..16e9cd8d5b8d7 100644 --- a/tests/ui/test-attrs/test-on-not-fn.rs +++ b/tests/ui/test-attrs/test-on-not-fn.rs @@ -1,9 +1,9 @@ //@ compile-flags: --test -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod test {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod loooooooooooooong_teeeeeeeeeest { /* this is a comment @@ -17,37 +17,37 @@ mod loooooooooooooong_teeeeeeeeeest { */ } -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function extern "C" {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function trait Foo {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function impl Foo for i32 {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function const FOO: i32 = -1_i32; -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function static BAR: u64 = 10_000_u64; -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function enum MyUnit { Unit, } -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function struct NewI32(i32); -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function union Spooky { x: i32, y: u32, } #[repr(C, align(64))] -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function #[derive(Copy, Clone, Debug)] struct MoreAttrs { a: i32, @@ -58,7 +58,7 @@ macro_rules! foo { () => {}; } -#[test] //~ WARN: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ WARN: the `#[test]` attribute may only be used on a free function foo!(); // make sure it doesn't erroneously trigger on a real test diff --git a/tests/ui/test-attrs/test-on-not-fn.stderr b/tests/ui/test-attrs/test-on-not-fn.stderr index a282db012540a..db8bed100a635 100644 --- a/tests/ui/test-attrs/test-on-not-fn.stderr +++ b/tests/ui/test-attrs/test-on-not-fn.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:3:1 | LL | #[test] @@ -12,7 +12,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:6:1 | LL | #[test] @@ -32,7 +32,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:20:1 | LL | #[test] @@ -46,7 +46,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:23:1 | LL | #[test] @@ -60,7 +60,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:26:1 | LL | #[test] @@ -74,7 +74,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:29:1 | LL | #[test] @@ -88,7 +88,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:32:1 | LL | #[test] @@ -102,7 +102,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:35:1 | LL | #[test] @@ -118,7 +118,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:40:1 | LL | #[test] @@ -132,7 +132,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:43:1 | LL | #[test] @@ -149,7 +149,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:50:1 | LL | #[test] @@ -167,7 +167,7 @@ LL - #[test] LL + #[cfg(test)] | -warning: the `#[test]` attribute may only be used on a non-associated function +warning: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:61:1 | LL | #[test] diff --git a/tests/ui/issues/issue-51874.rs b/tests/ui/type-inference/ambiguous-num-type-method-call.rs similarity index 57% rename from tests/ui/issues/issue-51874.rs rename to tests/ui/type-inference/ambiguous-num-type-method-call.rs index d9d7e36b50e9b..ee3c95ba0843b 100644 --- a/tests/ui/issues/issue-51874.rs +++ b/tests/ui/type-inference/ambiguous-num-type-method-call.rs @@ -1,3 +1,5 @@ +//! regression test for + fn main() { let a = (1.0).pow(1.0); //~ ERROR can't call method `pow` on ambiguous numeric type } diff --git a/tests/ui/issues/issue-51874.stderr b/tests/ui/type-inference/ambiguous-num-type-method-call.stderr similarity index 88% rename from tests/ui/issues/issue-51874.stderr rename to tests/ui/type-inference/ambiguous-num-type-method-call.stderr index 5c9331b4e1e1a..3a808c06aef1c 100644 --- a/tests/ui/issues/issue-51874.stderr +++ b/tests/ui/type-inference/ambiguous-num-type-method-call.stderr @@ -1,5 +1,5 @@ error[E0689]: can't call method `pow` on ambiguous numeric type `{float}` - --> $DIR/issue-51874.rs:2:19 + --> $DIR/ambiguous-num-type-method-call.rs:4:19 | LL | let a = (1.0).pow(1.0); | ^^^ diff --git a/tests/ui/type-inference/type-inference-unconstrained-none.rs b/tests/ui/type-inference/type-inference-unconstrained-none.rs index 38a506763c761..5b24e866b5216 100644 --- a/tests/ui/type-inference/type-inference-unconstrained-none.rs +++ b/tests/ui/type-inference/type-inference-unconstrained-none.rs @@ -1,5 +1,9 @@ //! Regression test for . +fn foo() { + format!("{:?}", None); //~ ERROR type annotations needed [E0282] +} + fn main() { None; //~ ERROR type annotations needed [E0282] } diff --git a/tests/ui/type-inference/type-inference-unconstrained-none.stderr b/tests/ui/type-inference/type-inference-unconstrained-none.stderr index 80572b845e84f..54260c03b76a1 100644 --- a/tests/ui/type-inference/type-inference-unconstrained-none.stderr +++ b/tests/ui/type-inference/type-inference-unconstrained-none.stderr @@ -1,5 +1,16 @@ error[E0282]: type annotations needed - --> $DIR/type-inference-unconstrained-none.rs:4:5 + --> $DIR/type-inference-unconstrained-none.rs:4:21 + | +LL | format!("{:?}", None); + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` + | +help: consider specifying the generic argument + | +LL | format!("{:?}", None::); + | +++++ + +error[E0282]: type annotations needed + --> $DIR/type-inference-unconstrained-none.rs:8:5 | LL | None; | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` @@ -9,6 +20,6 @@ help: consider specifying the generic argument LL | None::; | +++++ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/where-clauses/projection-bound-unsatisfied-item-bounds-mit-opt-ice.rs b/tests/ui/where-clauses/projection-bound-unsatisfied-item-bounds-mit-opt-ice.rs new file mode 100644 index 0000000000000..80eec709eecbc --- /dev/null +++ b/tests/ui/where-clauses/projection-bound-unsatisfied-item-bounds-mit-opt-ice.rs @@ -0,0 +1,25 @@ +//@ compile-flags: -Copt-level=3 --crate-type=rlib +//@ build-pass + +// A regression test for #149081. The environment of `size` and `align` +// currently means that the item bound of`T::Assoc` doesn't hold. This can +// result in normalization failures and ICE during MIR optimizations. +// +// This will no longer be an issue once #149283 is implemented. + +pub fn align, U>() -> usize { + std::mem::align_of::>() +} + +pub fn size, U>() -> usize { + std::mem::size_of::>() +} + +pub struct Wrapper { + assoc2: ::Assoc, + value: T, +} + +pub trait WithAssoc { + type Assoc: WithAssoc; +}