diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 620878fb87a7e..7910443787b4f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -27,6 +27,21 @@ impl NoArgsAttributeParser for RustcNeverReturnsNullPointerParser { ]); const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNeverReturnsNullPointer; } +pub(crate) struct RustcNoImplicitAutorefsParser; + +impl NoArgsAttributeParser for RustcNoImplicitAutorefsParser { + const PATH: &[Symbol] = &[sym::rustc_no_implicit_autorefs]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Fn), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: false })), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); + + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitAutorefs; +} pub(crate) struct RustcLayoutScalarValidRangeStartParser; @@ -102,6 +117,30 @@ impl SingleAttributeParser for RustcLegacyConstGenericsParser { } } +pub(crate) struct RustcLintOptTyParser; + +impl NoArgsAttributeParser for RustcLintOptTyParser { + const PATH: &[Symbol] = &[sym::rustc_lint_opt_ty]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintOptTy; +} + +pub(crate) struct RustcLintQueryInstabilityParser; + +impl NoArgsAttributeParser for RustcLintQueryInstabilityParser { + const PATH: &[Symbol] = &[sym::rustc_lint_query_instability]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Fn), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: false })), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintQueryInstability; +} + pub(crate) struct RustcObjectLifetimeDefaultParser; impl SingleAttributeParser for RustcObjectLifetimeDefaultParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 54c9785a42f6c..b4854c430cae0 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -61,7 +61,8 @@ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, - RustcLegacyConstGenericsParser, RustcMainParser, RustcNeverReturnsNullPointerParser, + RustcLegacyConstGenericsParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser, + RustcMainParser, RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; @@ -255,8 +256,11 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, + Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index a34826403df37..5e650fbb9bd0b 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -931,12 +931,21 @@ pub enum AttributeKind { /// Represents `#[rustc_legacy_const_generics]` RustcLegacyConstGenerics { fn_indexes: ThinVec<(usize, Span)>, attr_span: Span }, + /// Represents `#[rustc_lint_opt_ty]` + RustcLintOptTy, + + /// Represents `#[rustc_lint_query_instability]` + RustcLintQueryInstability, + /// Represents `#[rustc_main]`. RustcMain, /// Represents `#[rustc_never_returns_null_ptr]` RustcNeverReturnsNullPointer, + /// Represents `#[rustc_no_implicit_autorefs]` + RustcNoImplicitAutorefs, + /// Represents `#[rustc_object_lifetime_default]`. RustcObjectLifetimeDefault, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index e631d6a2ab872..f99069e416bd2 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -94,8 +94,11 @@ impl AttributeKind { RustcLayoutScalarValidRangeEnd(..) => Yes, RustcLayoutScalarValidRangeStart(..) => Yes, RustcLegacyConstGenerics { .. } => Yes, + RustcLintOptTy => Yes, + RustcLintQueryInstability => Yes, RustcMain => No, RustcNeverReturnsNullPointer => Yes, + RustcNoImplicitAutorefs => Yes, RustcObjectLifetimeDefault => No, RustcPassIndirectlyInNonRusticAbis(..) => No, RustcScalableVector { .. } => Yes, diff --git a/compiler/rustc_lint/src/autorefs.rs b/compiler/rustc_lint/src/autorefs.rs index 5490a3aac9b7a..ed7ac0e33244b 100644 --- a/compiler/rustc_lint/src/autorefs.rs +++ b/compiler/rustc_lint/src/autorefs.rs @@ -1,8 +1,8 @@ use rustc_ast::{BorrowKind, UnOp}; -use rustc_hir::{Expr, ExprKind, Mutability}; +use rustc_hir::attrs::AttributeKind; +use rustc_hir::{Expr, ExprKind, Mutability, find_attr}; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, OverloadedDeref}; use rustc_session::{declare_lint, declare_lint_pass}; -use rustc_span::sym; use crate::lints::{ ImplicitUnsafeAutorefsDiag, ImplicitUnsafeAutorefsMethodNote, ImplicitUnsafeAutorefsOrigin, @@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitAutorefs { ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id), _ => None, } - && method_did.map(|did| cx.tcx.has_attr(did, sym::rustc_no_implicit_autorefs)).unwrap_or(true) + && method_did.map(|did| find_attr!(cx.tcx.get_all_attrs(did), AttributeKind::RustcNoImplicitAutorefs)).unwrap_or(true) { cx.emit_span_lint( DANGEROUS_IMPLICIT_AUTOREFS, diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index c00ba4959c940..c32fed3674fcc 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -1,9 +1,10 @@ //! Some lints that are only useful in the compiler or crates that use compiler internals, such as //! Clippy. +use rustc_hir::attrs::AttributeKind; use rustc_hir::def::Res; use rustc_hir::def_id::DefId; -use rustc_hir::{Expr, ExprKind, HirId}; +use rustc_hir::{Expr, ExprKind, HirId, find_attr}; use rustc_middle::ty::{self, GenericArgsRef, PredicatePolarity, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::hygiene::{ExpnKind, MacroKind}; @@ -90,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for QueryStability { ty::Instance::try_resolve(cx.tcx, cx.typing_env(), callee_def_id, generic_args) { let def_id = instance.def_id(); - if cx.tcx.has_attr(def_id, sym::rustc_lint_query_instability) { + if find_attr!(cx.tcx.get_all_attrs(def_id), AttributeKind::RustcLintQueryInstability) { cx.emit_span_lint( POTENTIAL_QUERY_INSTABILITY, span, @@ -150,7 +151,10 @@ fn has_unstable_into_iter_predicate<'tcx>( }; // Does the input type's `IntoIterator` implementation have the // `rustc_lint_query_instability` attribute on its `into_iter` method? - if cx.tcx.has_attr(instance.def_id(), sym::rustc_lint_query_instability) { + if find_attr!( + cx.tcx.get_all_attrs(instance.def_id()), + AttributeKind::RustcLintQueryInstability + ) { return true; } } @@ -658,7 +662,7 @@ impl LateLintPass<'_> for BadOptAccess { let Some(adt_def) = cx.typeck_results().expr_ty(base).ty_adt_def() else { return }; // Skip types without `#[rustc_lint_opt_ty]` - only so that the rest of the lint can be // avoided. - if !cx.tcx.has_attr(adt_def.did(), sym::rustc_lint_opt_ty) { + if !find_attr!(cx.tcx.get_all_attrs(adt_def.did()), AttributeKind::RustcLintOptTy) { return; } diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index dfa7826ece7d3..5a9b759575172 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -477,10 +477,6 @@ passes_rustc_lint_opt_deny_field_access = `#[rustc_lint_opt_deny_field_access]` should be applied to a field .label = not a field -passes_rustc_lint_opt_ty = - `#[rustc_lint_opt_ty]` should be applied to a struct - .label = not a struct - passes_rustc_pub_transparent = attribute should be applied to `#[repr(transparent)]` types .label = not a `#[repr(transparent)]` type diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d1f96721fc65d..d03da2e06cf13 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -255,8 +255,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::MacroUse { .. } | AttributeKind::MacroEscape( .. ) | AttributeKind::NoLink + | AttributeKind::RustcNoImplicitAutorefs | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) + | AttributeKind::RustcLintOptTy + | AttributeKind::RustcLintQueryInstability | AttributeKind::RustcNeverReturnsNullPointer | AttributeKind::RustcScalableVector { .. } | AttributeKind::RustcSimdMonomorphizeLaneLimit(..) @@ -305,19 +308,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_diagnostic_on_const(attr.span(), hir_id, target, item) } [sym::thread_local, ..] => self.check_thread_local(attr, span, target), - [sym::rustc_no_implicit_autorefs, ..] => { - self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) - } - [sym::rustc_lint_query_instability, ..] => { - self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) - } [sym::rustc_lint_untracked_query_information, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } [sym::rustc_lint_diagnostics, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } - [sym::rustc_lint_opt_ty, ..] => self.check_rustc_lint_opt_ty(attr, span, target), [sym::rustc_lint_opt_deny_field_access, ..] => { self.check_rustc_lint_opt_deny_field_access(attr, span, target) } @@ -1255,16 +1251,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - /// Checks that the `#[rustc_lint_opt_ty]` attribute is only applied to a struct. - fn check_rustc_lint_opt_ty(&self, attr: &Attribute, span: Span, target: Target) { - match target { - Target::Struct => {} - _ => { - self.dcx().emit_err(errors::RustcLintOptTy { attr_span: attr.span(), span }); - } - } - } - /// Checks that the `#[rustc_lint_opt_deny_field_access]` attribute is only applied to a field. fn check_rustc_lint_opt_deny_field_access(&self, attr: &Attribute, span: Span, target: Target) { match target { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 6b3c2bd1a7b29..f2b7d3740cb64 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -412,15 +412,6 @@ pub(crate) struct UnusedMultiple { pub name: Symbol, } -#[derive(Diagnostic)] -#[diag(passes_rustc_lint_opt_ty)] -pub(crate) struct RustcLintOptTy { - #[primary_span] - pub attr_span: Span, - #[label] - pub span: Span, -} - #[derive(Diagnostic)] #[diag(passes_rustc_lint_opt_deny_field_access)] pub(crate) struct RustcLintOptDenyFieldAccess { diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index f714a87c18687..60758551cc048 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -2253,7 +2253,7 @@ impl + ?Sized, A: Allocator> AsyncFn for Box #[unstable(feature = "coerce_unsized", issue = "18598")] impl, U: ?Sized, A: Allocator> CoerceUnsized> for Box {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Box {} // It is quite crucial that we only allow the `Global` allocator here. diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index a3ebbbbaae05f..8a72748668ccb 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -2417,14 +2417,14 @@ impl Deref for Rc { } } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Rc {} //#[unstable(feature = "unique_rc_arc", issue = "112566")] -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for UniqueRc {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Weak {} #[unstable(feature = "deref_pure_trait", issue = "87121")] diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 6a49017a82767..4180fe91cb558 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -2423,10 +2423,10 @@ impl Deref for Arc { } } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Arc {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Weak {} #[unstable(feature = "deref_pure_trait", issue = "87121")] @@ -4852,7 +4852,7 @@ impl Deref for UniqueArc { } // #[unstable(feature = "unique_rc_arc", issue = "112566")] -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for UniqueArc {} #[unstable(feature = "unique_rc_arc", issue = "112566")] diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index c8340c328be12..9a3f7166f1fcb 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -2696,20 +2696,20 @@ fn assert_coerce_unsized( let _: RefCell<&dyn Send> = d; } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for UnsafeCell {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for SyncUnsafeCell {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Cell {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for RefCell {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl<'b, T: ?Sized> PinCoerceUnsized for Ref<'b, T> {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl<'b, T: ?Sized> PinCoerceUnsized for RefMut<'b, T> {} diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 81c2dabf0d1d8..74ecb5ee4946f 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1825,7 +1825,7 @@ where { } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] /// Trait that indicates that this is a pointer or a wrapper for one, where /// unsizing can be performed on the pointee when it is pinned. /// diff --git a/library/core/src/ptr/unique.rs b/library/core/src/ptr/unique.rs index 1bbe3ea242f6c..3160c9de4b7e9 100644 --- a/library/core/src/ptr/unique.rs +++ b/library/core/src/ptr/unique.rs @@ -176,7 +176,7 @@ impl CoerceUnsized> for Unique wh #[unstable(feature = "ptr_internals", issue = "none")] impl DispatchFromDyn> for Unique where T: Unsize {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Unique {} #[unstable(feature = "ptr_internals", issue = "none")] diff --git a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs index fb410c2851604..aaf380d1bef47 100644 --- a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs +++ b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs @@ -773,7 +773,7 @@ where #[unstable(feature = "sgx_platform", issue = "56975")] impl, U> CoerceUnsized> for UserRef {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for UserRef {} #[unstable(feature = "sgx_platform", issue = "56975")] diff --git a/tests/ui/README.md b/tests/ui/README.md index ca9f89f002ee4..da9be2e209acc 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -709,12 +709,6 @@ Tests on type inference. Tests for diagnostics on infinitely recursive types without indirection. -## `tests/ui/inherent-impls-overlap-check/` - -Checks that repeating the same function names across separate `impl` blocks triggers an informative error, but not if the `impl` are for different types, such as `Bar` and `Bar`. - -NOTE: This should maybe be a subdirectory within another related to duplicate definitions, such as `tests/ui/duplicate/`. - ## `tests/ui/inline-const/` These tests revolve around the inline `const` block that forces the compiler to const-eval its content. diff --git a/tests/ui/issues/issue-34074.rs b/tests/ui/anon-params/anon-params-trait-method-multiple.rs similarity index 68% rename from tests/ui/issues/issue-34074.rs rename to tests/ui/anon-params/anon-params-trait-method-multiple.rs index d642c74d412a4..ba06aa5115ba0 100644 --- a/tests/ui/issues/issue-34074.rs +++ b/tests/ui/anon-params/anon-params-trait-method-multiple.rs @@ -1,3 +1,4 @@ +//! regression test for //@ edition: 2015 //@ check-pass // Make sure several unnamed function parameters don't conflict with each other @@ -7,5 +8,4 @@ trait Tr { fn f(u8, u8) {} } -fn main() { -} +fn main() {} diff --git a/tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs b/tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs new file mode 100644 index 0000000000000..fb7a8ee103e13 --- /dev/null +++ b/tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs @@ -0,0 +1,10 @@ +//! regression test for +//@ run-pass + +use std::sync::Arc; + +fn main() { + let x = 5; + let command = Arc::new(Box::new(|| x * 2)); + assert_eq!(command(), 10); +} diff --git a/tests/ui/consts/const-closure-fn-trait-object.rs b/tests/ui/consts/const-closure-fn-trait-object.rs new file mode 100644 index 0000000000000..e47a118dd3f45 --- /dev/null +++ b/tests/ui/consts/const-closure-fn-trait-object.rs @@ -0,0 +1,5 @@ +//! regression test for +//@ run-pass +fn main() { + const _C: &'static dyn Fn() = &|| {}; +} diff --git a/tests/ui/inherent-impls-overlap-check/auxiliary/repeat.rs b/tests/ui/duplicate/inherent-impls-overlap-check/auxiliary/repeat.rs similarity index 100% rename from tests/ui/inherent-impls-overlap-check/auxiliary/repeat.rs rename to tests/ui/duplicate/inherent-impls-overlap-check/auxiliary/repeat.rs diff --git a/tests/ui/issues/issue-19097.rs b/tests/ui/duplicate/inherent-impls-overlap-check/disjoint-ref-mut-method.rs similarity index 69% rename from tests/ui/issues/issue-19097.rs rename to tests/ui/duplicate/inherent-impls-overlap-check/disjoint-ref-mut-method.rs index a329ba6f073e2..d4594b2e2c951 100644 --- a/tests/ui/issues/issue-19097.rs +++ b/tests/ui/duplicate/inherent-impls-overlap-check/disjoint-ref-mut-method.rs @@ -1,6 +1,6 @@ +//! regression test for //@ check-pass #![allow(dead_code)] -// regression test for #19097 struct Foo(T); diff --git a/tests/ui/inherent-impls-overlap-check/no-overlap.rs b/tests/ui/duplicate/inherent-impls-overlap-check/no-overlap.rs similarity index 100% rename from tests/ui/inherent-impls-overlap-check/no-overlap.rs rename to tests/ui/duplicate/inherent-impls-overlap-check/no-overlap.rs diff --git a/tests/ui/inherent-impls-overlap-check/overlap.rs b/tests/ui/duplicate/inherent-impls-overlap-check/overlap.rs similarity index 100% rename from tests/ui/inherent-impls-overlap-check/overlap.rs rename to tests/ui/duplicate/inherent-impls-overlap-check/overlap.rs diff --git a/tests/ui/inherent-impls-overlap-check/overlap.stderr b/tests/ui/duplicate/inherent-impls-overlap-check/overlap.stderr similarity index 100% rename from tests/ui/inherent-impls-overlap-check/overlap.stderr rename to tests/ui/duplicate/inherent-impls-overlap-check/overlap.stderr diff --git a/tests/ui/issues/issue-24161.rs b/tests/ui/extern/extern-fn-pointer-clone-copy.rs similarity index 54% rename from tests/ui/issues/issue-24161.rs rename to tests/ui/extern/extern-fn-pointer-clone-copy.rs index 974add4386165..a67e0d1d703ac 100644 --- a/tests/ui/issues/issue-24161.rs +++ b/tests/ui/extern/extern-fn-pointer-clone-copy.rs @@ -1,11 +1,12 @@ +//! regression test for //@ check-pass #![allow(dead_code)] -#[derive(Copy,Clone)] +#[derive(Copy, Clone)] struct Functions { a: fn(u32) -> u32, b: extern "C" fn(u32) -> u32, c: unsafe fn(u32) -> u32, - d: unsafe extern "C" fn(u32) -> u32 + d: unsafe extern "C" fn(u32) -> u32, } pub fn main() {} diff --git a/tests/ui/issues/issue-23036.rs b/tests/ui/hashmap/hashmap-path-key.rs similarity index 71% rename from tests/ui/issues/issue-23036.rs rename to tests/ui/hashmap/hashmap-path-key.rs index 5186fccd042b2..0551ba7ea8ee9 100644 --- a/tests/ui/issues/issue-23036.rs +++ b/tests/ui/hashmap/hashmap-path-key.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass use std::collections::HashMap; diff --git a/tests/ui/inference/inference-thread-loop-closure.rs b/tests/ui/inference/inference-thread-loop-closure.rs new file mode 100644 index 0000000000000..78b1b145367e8 --- /dev/null +++ b/tests/ui/inference/inference-thread-loop-closure.rs @@ -0,0 +1,16 @@ +//! regression test for +//@ check-pass +#![allow(unused_must_use)] +use std::thread; + +fn _foo() { + thread::spawn(move || { + // no need for -> () + loop { + println!("hello"); + } + }) + .join(); +} + +fn main() {} diff --git a/tests/ui/internal-lints/query_stability_incorrect.rs b/tests/ui/internal-lints/query_stability_incorrect.rs index a428611caaa47..cefd898677113 100644 --- a/tests/ui/internal-lints/query_stability_incorrect.rs +++ b/tests/ui/internal-lints/query_stability_incorrect.rs @@ -3,7 +3,7 @@ #![feature(rustc_attrs)] #[rustc_lint_query_instability] -//~^ ERROR attribute should be applied to a function +//~^ ERROR `#[rustc_lint_query_instability]` attribute cannot be used on structs struct Foo; impl Foo { diff --git a/tests/ui/internal-lints/query_stability_incorrect.stderr b/tests/ui/internal-lints/query_stability_incorrect.stderr index 3f78b39edd96a..8149ac3b95184 100644 --- a/tests/ui/internal-lints/query_stability_incorrect.stderr +++ b/tests/ui/internal-lints/query_stability_incorrect.stderr @@ -1,17 +1,20 @@ -error: malformed `rustc_lint_query_instability` attribute input - --> $DIR/query_stability_incorrect.rs:10:5 - | -LL | #[rustc_lint_query_instability(a)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_query_instability]` - -error: attribute should be applied to a function definition +error: `#[rustc_lint_query_instability]` attribute cannot be used on structs --> $DIR/query_stability_incorrect.rs:5:1 | LL | #[rustc_lint_query_instability] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct Foo; - | ----------- not a function definition + | + = help: `#[rustc_lint_query_instability]` can only be applied to functions + +error[E0565]: malformed `rustc_lint_query_instability` attribute input + --> $DIR/query_stability_incorrect.rs:10:5 + | +LL | #[rustc_lint_query_instability(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[rustc_lint_query_instability]` error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0565`. diff --git a/tests/ui/issues/issue-20454.rs b/tests/ui/issues/issue-20454.rs deleted file mode 100644 index e56f2ffa371a3..0000000000000 --- a/tests/ui/issues/issue-20454.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ check-pass -#![allow(unused_must_use)] -use std::thread; - -fn _foo() { - thread::spawn(move || { // no need for -> () - loop { - println!("hello"); - } - }).join(); -} - -fn main() {} diff --git a/tests/ui/issues/issue-21306.rs b/tests/ui/issues/issue-21306.rs deleted file mode 100644 index bf42e70a5bc04..0000000000000 --- a/tests/ui/issues/issue-21306.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass - -use std::sync::Arc; - -fn main() { - let x = 5; - let command = Arc::new(Box::new(|| { x*2 })); - assert_eq!(command(), 10); -} diff --git a/tests/ui/issues/issue-21891.rs b/tests/ui/issues/issue-21891.rs deleted file mode 100644 index 0da6071cdac4b..0000000000000 --- a/tests/ui/issues/issue-21891.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ build-pass -#![allow(dead_code)] -#![allow(non_upper_case_globals)] - - -static foo: [usize; 3] = [1, 2, 3]; - -static slice_1: &'static [usize] = &foo; -static slice_2: &'static [usize] = &foo; - -fn main() {} diff --git a/tests/ui/issues/issue-27268.rs b/tests/ui/issues/issue-27268.rs deleted file mode 100644 index e8704d215e888..0000000000000 --- a/tests/ui/issues/issue-27268.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ run-pass -fn main() { - const _C: &'static dyn Fn() = &||{}; -} diff --git a/tests/ui/issues/issue-50471.rs b/tests/ui/issues/issue-50471.rs deleted file mode 100644 index 1d8bad20377c7..0000000000000 --- a/tests/ui/issues/issue-50471.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ check-pass - -fn main() { - assert!({false}); - - assert!(r"\u{41}" == "A"); - - assert!(r"\u{".is_empty()); -} diff --git a/tests/ui/issues/issue-29540.rs b/tests/ui/limits/limit-huge-struct-derive-debug.rs similarity index 99% rename from tests/ui/issues/issue-29540.rs rename to tests/ui/limits/limit-huge-struct-derive-debug.rs index 6bfeae8559dc9..eb793aadd8c65 100644 --- a/tests/ui/issues/issue-29540.rs +++ b/tests/ui/limits/limit-huge-struct-derive-debug.rs @@ -1,3 +1,4 @@ +//! regression test for //@ build-pass #[derive(Debug)] pub struct Config { diff --git a/tests/ui/issues/issue-26646.rs b/tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs similarity index 60% rename from tests/ui/issues/issue-26646.rs rename to tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs index b1789b1a91fc2..a9da3e4175bdf 100644 --- a/tests/ui/issues/issue-26646.rs +++ b/tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs @@ -1,3 +1,4 @@ +//! regression test for //@ check-pass #![deny(unused_attributes)] @@ -9,4 +10,4 @@ pub struct Foo; #[repr(C)] pub struct Bar; -fn main() { } +fn main() {} diff --git a/tests/ui/issues/issue-37686.rs b/tests/ui/match/match-usize-min-max-pattern.rs similarity index 59% rename from tests/ui/issues/issue-37686.rs rename to tests/ui/match/match-usize-min-max-pattern.rs index 5a72f2fc74c2d..6a801406895d3 100644 --- a/tests/ui/issues/issue-37686.rs +++ b/tests/ui/match/match-usize-min-max-pattern.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass fn main() { match (0, 0) { diff --git a/tests/ui/issues/issue-38987.rs b/tests/ui/numbers-arithmetic/i128-min-literal-parses.rs similarity index 54% rename from tests/ui/issues/issue-38987.rs rename to tests/ui/numbers-arithmetic/i128-min-literal-parses.rs index 713fd5027918f..623a8a92ae62b 100644 --- a/tests/ui/issues/issue-38987.rs +++ b/tests/ui/numbers-arithmetic/i128-min-literal-parses.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass fn main() { let _ = -0x8000_0000_0000_0000_0000_0000_0000_0000i128; diff --git a/tests/ui/issues/issue-18352.rs b/tests/ui/pattern/const-pattern-str-match-lifetime.rs similarity index 65% rename from tests/ui/issues/issue-18352.rs rename to tests/ui/pattern/const-pattern-str-match-lifetime.rs index 8b6aa82ea8c0c..8814d55c63b6f 100644 --- a/tests/ui/issues/issue-18352.rs +++ b/tests/ui/pattern/const-pattern-str-match-lifetime.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass const X: &'static str = "12345"; @@ -5,7 +6,7 @@ const X: &'static str = "12345"; fn test(s: String) -> bool { match &*s { X => true, - _ => false + _ => false, } } diff --git a/tests/ui/static/static-array-shared-slice-references.rs b/tests/ui/static/static-array-shared-slice-references.rs new file mode 100644 index 0000000000000..a2ef169e2a290 --- /dev/null +++ b/tests/ui/static/static-array-shared-slice-references.rs @@ -0,0 +1,10 @@ +//! regression test for +//@ build-pass +#![allow(dead_code)] + +static FOO: [usize; 3] = [1, 2, 3]; + +static SLICE_1: &'static [usize] = &FOO; +static SLICE_2: &'static [usize] = &FOO; + +fn main() {} diff --git a/tests/ui/str/raw-string-literal-unescaped-unicode.rs b/tests/ui/str/raw-string-literal-unescaped-unicode.rs new file mode 100644 index 0000000000000..c0dc0743a28f7 --- /dev/null +++ b/tests/ui/str/raw-string-literal-unescaped-unicode.rs @@ -0,0 +1,10 @@ +//! regression test for +//@ check-pass + +fn main() { + assert!({ false }); + + assert!(r"\u{41}" == "A"); + + assert!(r"\u{".is_empty()); +}