From 6bb6b11d9d54ad95a61d8157bf6090ef8a67f8b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Mon, 2 Mar 2026 18:06:31 +0100 Subject: [PATCH] Rename `#[rustc_variance]` to `#[rustc_dump_variances]` --- .../src/attributes/rustc_dump.rs | 18 ++++++++ .../src/attributes/test_attrs.rs | 18 -------- compiler/rustc_attr_parsing/src/context.rs | 2 +- .../src/error_codes/E0208.md | 45 ------------------- compiler/rustc_feature/src/builtin_attrs.rs | 2 +- .../rustc_hir/src/attrs/data_structures.rs | 6 +-- .../rustc_hir/src/attrs/encode_cross_crate.rs | 2 +- compiler/rustc_hir_analysis/src/errors.rs | 8 ---- .../rustc_hir_analysis/src/variance/dump.rs | 14 ++---- compiler/rustc_middle/src/queries.rs | 4 +- compiler/rustc_passes/src/check_attr.rs | 2 +- compiler/rustc_span/src/symbol.rs | 2 +- .../rustc-dev-guide/src/compiler-debugging.md | 2 +- tests/ui/error-codes/E0208.rs | 8 ---- tests/ui/error-codes/E0208.stderr | 8 ---- .../feature-gate-rustc-attrs-1.rs | 6 +-- .../feature-gate-rustc-attrs-1.stderr | 8 ++-- .../ui/variance/variance-associated-consts.rs | 2 +- .../ui/variance/variance-associated-types.rs | 4 +- tests/ui/variance/variance-object-types.rs | 2 +- tests/ui/variance/variance-regions-direct.rs | 14 +++--- .../ui/variance/variance-regions-indirect.rs | 10 ++--- tests/ui/variance/variance-trait-bounds.rs | 8 ++-- .../variance/variance-trait-object-bound.rs | 2 +- tests/ui/variance/variance-types-bounds.rs | 10 ++--- tests/ui/variance/variance-types.rs | 12 ++--- 26 files changed, 72 insertions(+), 147 deletions(-) delete mode 100644 tests/ui/error-codes/E0208.rs delete mode 100644 tests/ui/error-codes/E0208.stderr diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs index 0160a4b10ec0..dea66f3a74b9 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs @@ -76,6 +76,24 @@ impl NoArgsAttributeParser for RustcDumpPredicatesParser { const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpPredicates; } +pub(crate) struct RustcDumpVariancesParser; + +impl NoArgsAttributeParser for RustcDumpVariancesParser { + const PATH: &[Symbol] = &[sym::rustc_dump_variances]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Enum), + 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)), + Allow(Target::Struct), + Allow(Target::Union), + ]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpVariances; +} + pub(crate) struct RustcDumpVtableParser; impl NoArgsAttributeParser for RustcDumpVtableParser { diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index ed1bb50da498..b01666688f5e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -93,24 +93,6 @@ fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option NoArgsAttributeParser for RustcVarianceParser { - const PATH: &[Symbol] = &[sym::rustc_variance]; - const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; - const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ - Allow(Target::Enum), - 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)), - Allow(Target::Struct), - Allow(Target::Union), - ]); - const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcVariance; -} - pub(crate) struct RustcVarianceOfOpaquesParser; impl NoArgsAttributeParser for RustcVarianceOfOpaquesParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 0f057f77d610..915337b09d1d 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -285,6 +285,7 @@ mod late { Single>, Single>, Single>, + Single>, Single>, Single>, Single>, @@ -324,7 +325,6 @@ mod late { Single>, Single>, Single>, - Single>, Single>, Single>, // tidy-alphabetical-end diff --git a/compiler/rustc_error_codes/src/error_codes/E0208.md b/compiler/rustc_error_codes/src/error_codes/E0208.md index 2b811b4b8500..f7bbeb293cae 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0208.md +++ b/compiler/rustc_error_codes/src/error_codes/E0208.md @@ -1,47 +1,2 @@ #### This error code is internal to the compiler and will not be emitted with normal Rust code. #### Note: this error code is no longer emitted by the compiler. - -This error code shows the variance of a type's generic parameters. - -Erroneous code example: - -```compile_fail -// NOTE: this feature is perma-unstable and should *only* be used for -// testing purposes. -#![allow(internal_features)] -#![feature(rustc_attrs)] - -#[rustc_variance] -struct Foo<'a, T> { // error: deliberate error to display type's variance - t: &'a mut T, -} -``` - -which produces the following error: - -```text -error: [-, o] - --> :4:1 - | -4 | struct Foo<'a, T> { - | ^^^^^^^^^^^^^^^^^ -``` - -*Note that while `#[rustc_variance]` still exists and is used within the* -*compiler, it no longer is marked as `E0208` and instead has no error code.* - -This error is deliberately triggered with the `#[rustc_variance]` attribute -(`#![feature(rustc_attrs)]` must be enabled) and helps to show you the variance -of the type's generic parameters. You can read more about variance and -subtyping in [this section of the Rustonomicon]. For a more in depth look at -variance (including a more complete list of common variances) see -[this section of the Reference]. For information on how variance is implemented -in the compiler, see [this section of `rustc-dev-guide`]. - -This error can be easily fixed by removing the `#[rustc_variance]` attribute, -the compiler's suggestion to comment it out can be applied automatically with -`rustfix`. - -[this section of the Rustonomicon]: https://doc.rust-lang.org/nomicon/subtyping.html -[this section of the Reference]: https://doc.rust-lang.org/reference/subtyping.html#variance -[this section of `rustc-dev-guide`]: https://rustc-dev-guide.rust-lang.org/variance.html diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 526c7e912dca..faf29dd467e1 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -1439,7 +1439,7 @@ pub struct BuiltinAttribute { WarnFollowing, EncodeCrossCrate::Yes ), rustc_attr!( - TEST, rustc_variance, Normal, template!(Word), + TEST, rustc_dump_variances, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No ), rustc_attr!( diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 23e76207810f..d4fc0be8595e 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -1378,6 +1378,9 @@ pub enum AttributeKind { /// Represents `#[rustc_dump_user_args]` RustcDumpUserArgs, + /// Represents `#[rustc_dump_variances]` + RustcDumpVariances, + /// Represents `#[rustc_dump_vtable]` RustcDumpVtable(Span), @@ -1574,9 +1577,6 @@ pub enum AttributeKind { /// Represents `#[rustc_unsafe_specialization_marker]`. RustcUnsafeSpecializationMarker(Span), - /// Represents `#[rustc_variance]` - RustcVariance, - /// Represents `#[rustc_variance_of_opaques]` RustcVarianceOfOpaques, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index e61d102ef1f3..c36282439a1c 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -128,6 +128,7 @@ pub fn encode_cross_crate(&self) -> EncodeCrossCrate { RustcDumpItemBounds => No, RustcDumpPredicates => No, RustcDumpUserArgs => No, + RustcDumpVariances => No, RustcDumpVtable(..) => No, RustcDynIncompatibleTrait(..) => No, RustcEffectiveVisibility => Yes, @@ -185,7 +186,6 @@ pub fn encode_cross_crate(&self) -> EncodeCrossCrate { RustcThenThisWouldNeed(..) => No, RustcTrivialFieldReads => Yes, RustcUnsafeSpecializationMarker(..) => No, - RustcVariance => No, RustcVarianceOfOpaques => No, Sanitize { .. } => No, ShouldPanic { .. } => No, diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 5cda2ac660fb..1c999f1ffc93 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -735,14 +735,6 @@ pub(crate) enum CannotCaptureLateBound { }, } -#[derive(Diagnostic)] -#[diag("{$variances}")] -pub(crate) struct VariancesOf { - #[primary_span] - pub span: Span, - pub variances: String, -} - #[derive(Diagnostic)] #[diag("{$ty}")] pub(crate) struct TypeOf<'tcx> { diff --git a/compiler/rustc_hir_analysis/src/variance/dump.rs b/compiler/rustc_hir_analysis/src/variance/dump.rs index 84d25bbbe9b9..1c1216061973 100644 --- a/compiler/rustc_hir_analysis/src/variance/dump.rs +++ b/compiler/rustc_hir_analysis/src/variance/dump.rs @@ -28,15 +28,12 @@ pub(crate) fn variances(tcx: TyCtxt<'_>) { if find_attr!(tcx, crate, RustcVarianceOfOpaques) { for id in crate_items.opaques() { - tcx.dcx().emit_err(crate::errors::VariancesOf { - span: tcx.def_span(id), - variances: format_variances(tcx, id), - }); + tcx.dcx().span_err(tcx.def_span(id), format_variances(tcx, id)); } } for id in crate_items.owners() { - if !find_attr!(tcx, id, RustcVariance) { + if !find_attr!(tcx, id, RustcDumpVariances) { continue; } @@ -46,16 +43,13 @@ pub(crate) fn variances(tcx: TyCtxt<'_>) { kind => { let message = format!( "attr parsing didn't report an error for `#[{}]` on {kind:?}", - rustc_span::sym::rustc_variance, + rustc_span::sym::rustc_dump_variances, ); tcx.dcx().span_delayed_bug(tcx.def_span(id), message); continue; } } - tcx.dcx().emit_err(crate::errors::VariancesOf { - span: tcx.def_span(id), - variances: format_variances(tcx, id.def_id), - }); + tcx.dcx().span_err(tcx.def_span(id), format_variances(tcx, id.def_id)); } } diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index 5025510da1bd..42c4ff5e7afe 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -1046,8 +1046,8 @@ /// The list of variances corresponds to the list of (early-bound) generic /// parameters of the item (including its parents). /// - /// **Tip**: You can use `#[rustc_variance]` on an item to basically print the - /// result of this query for use in UI tests or for debugging purposes. + /// **Tip**: You can use `#[rustc_dump_variances]` on an item to basically print + /// the result of this query for use in UI tests or for debugging purposes. query variances_of(def_id: DefId) -> &'tcx [ty::Variance] { desc { "computing the variances of `{}`", tcx.def_path_str(def_id) } cache_on_disk_if { def_id.is_local() } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 46373adf4461..8a729a8f4b6a 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -323,6 +323,7 @@ fn check_attributes( | AttributeKind::RustcDumpItemBounds | AttributeKind::RustcDumpPredicates | AttributeKind::RustcDumpUserArgs + | AttributeKind::RustcDumpVariances | AttributeKind::RustcDumpVtable(..) | AttributeKind::RustcDynIncompatibleTrait(..) | AttributeKind::RustcEffectiveVisibility @@ -376,7 +377,6 @@ fn check_attributes( | AttributeKind::RustcThenThisWouldNeed(..) | AttributeKind::RustcTrivialFieldReads | AttributeKind::RustcUnsafeSpecializationMarker(..) - | AttributeKind::RustcVariance | AttributeKind::RustcVarianceOfOpaques | AttributeKind::ShouldPanic { .. } | AttributeKind::TestRunner(..) diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index df5ffe9ba740..ccbacea4c13e 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1725,6 +1725,7 @@ rustc_dump_item_bounds, rustc_dump_predicates, rustc_dump_user_args, + rustc_dump_variances, rustc_dump_vtable, rustc_dyn_incompatible_trait, rustc_effective_visibility, @@ -1793,7 +1794,6 @@ rustc_then_this_would_need, rustc_trivial_field_reads, rustc_unsafe_specialization_marker, - rustc_variance, rustc_variance_of_opaques, rustdoc, rustdoc_internals, diff --git a/src/doc/rustc-dev-guide/src/compiler-debugging.md b/src/doc/rustc-dev-guide/src/compiler-debugging.md index 8bddb985556a..d4eb004a0eef 100644 --- a/src/doc/rustc-dev-guide/src/compiler-debugging.md +++ b/src/doc/rustc-dev-guide/src/compiler-debugging.md @@ -278,13 +278,13 @@ Here are some notable ones: | `rustc_dump_inferred_outlives` | Dumps implied bounds of an item. More precisely, the [`inferred_outlives_of`] an item. | | `rustc_dump_item_bounds` | Dumps the [`item_bounds`] of an item. | | `rustc_dump_predicates` | Dumps the [`predicates_of`] an item. | +| `rustc_dump_variances` | Dumps the [variances] of an item. | | `rustc_dump_vtable` | Dumps the vtable layout of an impl, or a type alias of a dyn type. | | `rustc_hidden_type_of_opaques` | Dumps the [hidden type of each opaque types][opaq] in the crate. | | `rustc_layout` | [See this section](#debugging-type-layouts). | | `rustc_object_lifetime_default` | Dumps the [object lifetime defaults] of an item. | | `rustc_regions` | Dumps NLL closure region requirements. | | `rustc_symbol_name` | Dumps the mangled & demangled [`symbol_name`] of an item. | -| `rustc_variances` | Dumps the [variances] of an item. | Right below you can find elaborate explainers on a selected few. diff --git a/tests/ui/error-codes/E0208.rs b/tests/ui/error-codes/E0208.rs deleted file mode 100644 index 2713ba6ed6cb..000000000000 --- a/tests/ui/error-codes/E0208.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_variance] -struct Foo<'a, T> { //~ ERROR ['a: +, T: o] - t: &'a mut T, -} - -fn main() {} diff --git a/tests/ui/error-codes/E0208.stderr b/tests/ui/error-codes/E0208.stderr deleted file mode 100644 index a39e93afab3e..000000000000 --- a/tests/ui/error-codes/E0208.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: ['a: +, T: o] - --> $DIR/E0208.rs:4:1 - | -LL | struct Foo<'a, T> { - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/feature-gates/feature-gate-rustc-attrs-1.rs b/tests/ui/feature-gates/feature-gate-rustc-attrs-1.rs index beddfd87a5e7..f9b097fdd215 100644 --- a/tests/ui/feature-gates/feature-gate-rustc-attrs-1.rs +++ b/tests/ui/feature-gates/feature-gate-rustc-attrs-1.rs @@ -7,10 +7,10 @@ //~| NOTE the compiler does not even check whether the type indeed is being non-null-optimized; it is your responsibility to ensure that the attribute is only used on types that are optimized struct Foo {} -#[rustc_variance] +#[rustc_dump_variances] //~^ ERROR use of an internal attribute [E0658] -//~| NOTE the `#[rustc_variance]` attribute is an internal implementation detail that will never be stable -//~| NOTE the `#[rustc_variance]` attribute is used for rustc unit tests +//~| NOTE the `#[rustc_dump_variances]` attribute is an internal implementation detail that will never be stable +//~| NOTE the `#[rustc_dump_variances]` attribute is used for rustc unit tests enum E {} fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr b/tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr index 6588229b7d56..81d8a750b897 100644 --- a/tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr +++ b/tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr @@ -12,12 +12,12 @@ LL | #[rustc_nonnull_optimization_guaranteed] error[E0658]: use of an internal attribute --> $DIR/feature-gate-rustc-attrs-1.rs:10:1 | -LL | #[rustc_variance] - | ^^^^^^^^^^^^^^^^^ +LL | #[rustc_dump_variances] + | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable - = note: the `#[rustc_variance]` attribute is an internal implementation detail that will never be stable - = note: the `#[rustc_variance]` attribute is used for rustc unit tests + = note: the `#[rustc_dump_variances]` attribute is an internal implementation detail that will never be stable + = note: the `#[rustc_dump_variances]` attribute is used for rustc unit tests error: aborting due to 2 previous errors diff --git a/tests/ui/variance/variance-associated-consts.rs b/tests/ui/variance/variance-associated-consts.rs index 97edb7e266ad..e53533ae30d7 100644 --- a/tests/ui/variance/variance-associated-consts.rs +++ b/tests/ui/variance/variance-associated-consts.rs @@ -9,7 +9,7 @@ trait Trait { const Const: usize; } -#[rustc_variance] +#[rustc_dump_variances] struct Foo { //~ ERROR [T: o] field: [u8; ::Const] //~^ ERROR: unconstrained generic constant diff --git a/tests/ui/variance/variance-associated-types.rs b/tests/ui/variance/variance-associated-types.rs index 07ff41062e88..00e5338880a1 100644 --- a/tests/ui/variance/variance-associated-types.rs +++ b/tests/ui/variance/variance-associated-types.rs @@ -9,12 +9,12 @@ trait Trait<'a> { fn method(&'a self) { } } -#[rustc_variance] +#[rustc_dump_variances] struct Foo<'a, T : Trait<'a>> { //~ ERROR ['a: +, T: +] field: (T, &'a ()) } -#[rustc_variance] +#[rustc_dump_variances] struct Bar<'a, T : Trait<'a>> { //~ ERROR ['a: o, T: o] field: >::Type } diff --git a/tests/ui/variance/variance-object-types.rs b/tests/ui/variance/variance-object-types.rs index fd03dec98249..10e1e3ebd09a 100644 --- a/tests/ui/variance/variance-object-types.rs +++ b/tests/ui/variance/variance-object-types.rs @@ -3,7 +3,7 @@ // For better or worse, associated types are invariant, and hence we // get an invariant result for `'a`. -#[rustc_variance] +#[rustc_dump_variances] struct Foo<'a> { //~ ERROR ['a: o] x: Box &'a i32 + 'static> } diff --git a/tests/ui/variance/variance-regions-direct.rs b/tests/ui/variance/variance-regions-direct.rs index 2bcacec33ea5..1211db355baf 100644 --- a/tests/ui/variance/variance-regions-direct.rs +++ b/tests/ui/variance/variance-regions-direct.rs @@ -5,7 +5,7 @@ // Regions that just appear in normal spots are contravariant: -#[rustc_variance] +#[rustc_dump_variances] struct Test2<'a, 'b, 'c> { //~ ERROR ['a: +, 'b: +, 'c: +] x: &'a isize, y: &'b [isize], @@ -14,7 +14,7 @@ struct Test2<'a, 'b, 'c> { //~ ERROR ['a: +, 'b: +, 'c: +] // Those same annotations in function arguments become covariant: -#[rustc_variance] +#[rustc_dump_variances] struct Test3<'a, 'b, 'c> { //~ ERROR ['a: -, 'b: -, 'c: -] x: extern "Rust" fn(&'a isize), y: extern "Rust" fn(&'b [isize]), @@ -23,7 +23,7 @@ struct Test3<'a, 'b, 'c> { //~ ERROR ['a: -, 'b: -, 'c: -] // Mutability induces invariance: -#[rustc_variance] +#[rustc_dump_variances] struct Test4<'a, 'b:'a> { //~ ERROR ['a: +, 'b: o] x: &'a mut &'b isize, } @@ -31,7 +31,7 @@ struct Test4<'a, 'b:'a> { //~ ERROR ['a: +, 'b: o] // Mutability induces invariance, even when in a // contravariant context: -#[rustc_variance] +#[rustc_dump_variances] struct Test5<'a, 'b:'a> { //~ ERROR ['a: -, 'b: o] x: extern "Rust" fn(&'a mut &'b isize), } @@ -41,14 +41,14 @@ struct Test5<'a, 'b:'a> { //~ ERROR ['a: -, 'b: o] // an argument list (which is contravariant), that // argument list occurs in an invariant context. -#[rustc_variance] +#[rustc_dump_variances] struct Test6<'a, 'b:'a> { //~ ERROR ['a: +, 'b: o] x: &'a mut extern "Rust" fn(&'b isize), } // No uses at all is bivariant: -#[rustc_variance] +#[rustc_dump_variances] struct Test7<'a> { //~ ERROR ['a: *] //~^ ERROR: `'a` is never used x: isize @@ -56,7 +56,7 @@ struct Test7<'a> { //~ ERROR ['a: *] // Try enums too. -#[rustc_variance] +#[rustc_dump_variances] enum Test8<'a, 'b, 'c:'b> { //~ ERROR ['a: -, 'b: +, 'c: o] Test8A(extern "Rust" fn(&'a isize)), Test8B(&'b [isize]), diff --git a/tests/ui/variance/variance-regions-indirect.rs b/tests/ui/variance/variance-regions-indirect.rs index aaa4d3f87799..0c5348ae0e40 100644 --- a/tests/ui/variance/variance-regions-indirect.rs +++ b/tests/ui/variance/variance-regions-indirect.rs @@ -4,7 +4,7 @@ #![feature(rustc_attrs)] -#[rustc_variance] +#[rustc_dump_variances] enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR ['a: -, 'b: +, 'c: o, 'd: *] //~^ ERROR: `'d` is never used Test8A(extern "Rust" fn(&'a isize)), @@ -12,25 +12,25 @@ enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR ['a: -, 'b: +, 'c: o, 'd: *] Test8C(&'b mut &'c str), } -#[rustc_variance] +#[rustc_dump_variances] struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR ['w: *, 'x: o, 'y: +, 'z: -] //~^ ERROR: `'w` is never used f: Base<'z, 'y, 'x, 'w> } -#[rustc_variance] // Combine - and + to yield o +#[rustc_dump_variances] // Combine - and + to yield o struct Derived2<'a, 'b:'a, 'c> { //~ ERROR ['a: o, 'b: o, 'c: *] //~^ ERROR: `'c` is never used f: Base<'a, 'a, 'b, 'c> } -#[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here) +#[rustc_dump_variances] // Combine + and o to yield o (just pay attention to 'a here) struct Derived3<'a:'b, 'b, 'c> { //~ ERROR ['a: o, 'b: +, 'c: *] //~^ ERROR: `'c` is never used f: Base<'a, 'b, 'a, 'c> } -#[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here) +#[rustc_dump_variances] // Combine + and * to yield + (just pay attention to 'a here) struct Derived4<'a, 'b, 'c:'b> { //~ ERROR ['a: -, 'b: +, 'c: o] f: Base<'a, 'b, 'c, 'a> } diff --git a/tests/ui/variance/variance-trait-bounds.rs b/tests/ui/variance/variance-trait-bounds.rs index f86fa2bbef7a..43f19378ee54 100644 --- a/tests/ui/variance/variance-trait-bounds.rs +++ b/tests/ui/variance/variance-trait-bounds.rs @@ -12,24 +12,24 @@ trait Setter { fn get(&self, _: T); } -#[rustc_variance] +#[rustc_dump_variances] struct TestStruct> { //~ ERROR [U: +, T: +] t: T, u: U } -#[rustc_variance] +#[rustc_dump_variances] enum TestEnum> { //~ ERROR [U: *, T: +] //~^ ERROR: `U` is never used Foo(T) } -#[rustc_variance] +#[rustc_dump_variances] struct TestContraStruct> { //~ ERROR [U: *, T: +] //~^ ERROR: `U` is never used t: T } -#[rustc_variance] +#[rustc_dump_variances] struct TestBox+Setter> { //~ ERROR [U: *, T: +] //~^ ERROR: `U` is never used t: T diff --git a/tests/ui/variance/variance-trait-object-bound.rs b/tests/ui/variance/variance-trait-object-bound.rs index ca80c6b6dce2..03dbdfb0bd37 100644 --- a/tests/ui/variance/variance-trait-object-bound.rs +++ b/tests/ui/variance/variance-trait-object-bound.rs @@ -10,7 +10,7 @@ trait T { fn foo(&self); } -#[rustc_variance] +#[rustc_dump_variances] struct TOption<'a> { //~ ERROR ['a: +] v: Option>, } diff --git a/tests/ui/variance/variance-types-bounds.rs b/tests/ui/variance/variance-types-bounds.rs index f4738a2dae1a..b0c382560098 100644 --- a/tests/ui/variance/variance-types-bounds.rs +++ b/tests/ui/variance/variance-types-bounds.rs @@ -3,24 +3,24 @@ #![feature(rustc_attrs)] -#[rustc_variance] +#[rustc_dump_variances] struct TestImm { //~ ERROR [A: +, B: +] x: A, y: B, } -#[rustc_variance] +#[rustc_dump_variances] struct TestMut { //~ ERROR [A: +, B: o] x: A, y: &'static mut B, } -#[rustc_variance] +#[rustc_dump_variances] struct TestIndirect { //~ ERROR [A: +, B: o] m: TestMut } -#[rustc_variance] +#[rustc_dump_variances] struct TestIndirect2 { //~ ERROR [A: o, B: o] n: TestMut, m: TestMut @@ -34,7 +34,7 @@ trait Setter { fn set(&mut self, a: A); } -#[rustc_variance] +#[rustc_dump_variances] struct TestObject { //~ ERROR [A: o, R: o] n: Box+Send>, m: Box+Send>, diff --git a/tests/ui/variance/variance-types.rs b/tests/ui/variance/variance-types.rs index aa336d1b424c..3b3ac929a263 100644 --- a/tests/ui/variance/variance-types.rs +++ b/tests/ui/variance/variance-types.rs @@ -6,32 +6,32 @@ // Check that a type parameter which is only used in a trait bound is // not considered bivariant. -#[rustc_variance] +#[rustc_dump_variances] struct InvariantMut<'a,A:'a,B:'a> { //~ ERROR ['a: +, A: o, B: o] t: &'a mut (A,B) } -#[rustc_variance] +#[rustc_dump_variances] struct InvariantCell { //~ ERROR [A: o] t: Cell } -#[rustc_variance] +#[rustc_dump_variances] struct InvariantIndirect { //~ ERROR [A: o] t: InvariantCell } -#[rustc_variance] +#[rustc_dump_variances] struct Covariant { //~ ERROR [A: +] t: A, u: fn() -> A } -#[rustc_variance] +#[rustc_dump_variances] struct Contravariant { //~ ERROR [A: -] t: fn(A) } -#[rustc_variance] +#[rustc_dump_variances] enum Enum { //~ ERROR [A: +, B: -, C: o] Foo(Covariant), Bar(Contravariant),