diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 81161490d0e85..419b76eaf367c 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -160,6 +160,8 @@ pub fn check_crate(tcx: TyCtxt<'_>) { if tcx.features().rustc_attrs { tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx)); + tcx.sess.time("variance_testing", || variance::test::test_variance(tcx)); + collect::test_opaque_hidden_types(tcx); } tcx.sess.time("coherence_checking", || { @@ -175,14 +177,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) { let _ = tcx.ensure().crate_inherent_impls_overlap_check(()); }); - if tcx.features().rustc_attrs { - tcx.sess.time("variance_testing", || variance::test::test_variance(tcx)); - } - - if tcx.features().rustc_attrs { - collect::test_opaque_hidden_types(tcx); - } - // Make sure we evaluate all static and (non-associated) const items, even if unused. // If any of these fail to evaluate, we do not want this crate to pass compilation. tcx.hir().par_body_owners(|item_def_id| { diff --git a/tests/ui/type-alias-impl-trait/variance.stderr b/tests/ui/type-alias-impl-trait/variance.stderr index 1aaf36223b7f5..3daacacdb4a3a 100644 --- a/tests/ui/type-alias-impl-trait/variance.stderr +++ b/tests/ui/type-alias-impl-trait/variance.stderr @@ -1,3 +1,69 @@ +error: [*, o] + --> $DIR/variance.rs:8:29 + | +LL | type NotCapturedEarly<'a> = impl Sized; + | ^^^^^^^^^^ + +error: [*, o] + --> $DIR/variance.rs:11:26 + | +LL | type CapturedEarly<'a> = impl Sized + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, o, o] + --> $DIR/variance.rs:14:56 + | +LL | type NotCapturedLate<'a> = dyn for<'b> Iterator; + | ^^^^^^^^^^ + +error: [*, o, o] + --> $DIR/variance.rs:18:49 + | +LL | type Captured<'a> = dyn for<'b> Iterator>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, *, o, o, o] + --> $DIR/variance.rs:22:27 + | +LL | type Bar<'a, 'b: 'b, T> = impl Sized; + | ^^^^^^^^^^ + +error: [*, *, o, o] + --> $DIR/variance.rs:34:32 + | +LL | type ImplicitCapture<'a> = impl Sized; + | ^^^^^^^^^^ + +error: [*, *, o, o] + --> $DIR/variance.rs:37:42 + | +LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, *, o, o] + --> $DIR/variance.rs:40:39 + | +LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, *, o, o] + --> $DIR/variance.rs:45:32 + | +LL | type ImplicitCapture<'a> = impl Sized; + | ^^^^^^^^^^ + +error: [*, *, o, o] + --> $DIR/variance.rs:48:42 + | +LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, *, o, o] + --> $DIR/variance.rs:51:39 + | +LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type --> $DIR/variance.rs:14:56 | @@ -110,72 +176,6 @@ LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; | = note: `ExplicitCaptureFromGat` must be used in combination with a concrete type within the same impl -error: [*, o] - --> $DIR/variance.rs:8:29 - | -LL | type NotCapturedEarly<'a> = impl Sized; - | ^^^^^^^^^^ - -error: [*, o] - --> $DIR/variance.rs:11:26 - | -LL | type CapturedEarly<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, o, o] - --> $DIR/variance.rs:14:56 - | -LL | type NotCapturedLate<'a> = dyn for<'b> Iterator; - | ^^^^^^^^^^ - -error: [*, o, o] - --> $DIR/variance.rs:18:49 - | -LL | type Captured<'a> = dyn for<'b> Iterator>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, *, o, o, o] - --> $DIR/variance.rs:22:27 - | -LL | type Bar<'a, 'b: 'b, T> = impl Sized; - | ^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:34:32 - | -LL | type ImplicitCapture<'a> = impl Sized; - | ^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:37:42 - | -LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:40:39 - | -LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:45:32 - | -LL | type ImplicitCapture<'a> = impl Sized; - | ^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:48:42 - | -LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, *, o, o] - --> $DIR/variance.rs:51:39 - | -LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 24 previous errors For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/variance/variance-associated-consts.stderr b/tests/ui/variance/variance-associated-consts.stderr index f41574ca3a37b..b910f668db521 100644 --- a/tests/ui/variance/variance-associated-consts.stderr +++ b/tests/ui/variance/variance-associated-consts.stderr @@ -1,3 +1,9 @@ +error: [o] + --> $DIR/variance-associated-consts.rs:13:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^^ + error: unconstrained generic constant --> $DIR/variance-associated-consts.rs:14:12 | @@ -6,11 +12,5 @@ LL | field: [u8; ::Const] | = help: try adding a `where` bound using this expression: `where [(); ::Const]:` -error: [o] - --> $DIR/variance-associated-consts.rs:13:1 - | -LL | struct Foo { - | ^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 2 previous errors diff --git a/tests/ui/variance/variance-regions-direct.stderr b/tests/ui/variance/variance-regions-direct.stderr index edfc888f65667..5ac538982aa85 100644 --- a/tests/ui/variance/variance-regions-direct.stderr +++ b/tests/ui/variance/variance-regions-direct.stderr @@ -1,11 +1,3 @@ -error[E0392]: lifetime parameter `'a` is never used - --> $DIR/variance-regions-direct.rs:52:14 - | -LL | struct Test7<'a> { - | ^^ unused lifetime parameter - | - = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` - error: [+, +, +] --> $DIR/variance-regions-direct.rs:9:1 | @@ -48,6 +40,14 @@ error: [-, +, o] LL | enum Test8<'a, 'b, 'c:'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0392]: lifetime parameter `'a` is never used + --> $DIR/variance-regions-direct.rs:52:14 + | +LL | struct Test7<'a> { + | ^^ unused lifetime parameter + | + = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` + error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0392`. diff --git a/tests/ui/variance/variance-regions-indirect.stderr b/tests/ui/variance/variance-regions-indirect.stderr index 901ec0c6a762b..b6b943026ebe6 100644 --- a/tests/ui/variance/variance-regions-indirect.stderr +++ b/tests/ui/variance/variance-regions-indirect.stderr @@ -1,3 +1,33 @@ +error: [-, +, o, *] + --> $DIR/variance-regions-indirect.rs:8:1 + | +LL | enum Base<'a, 'b, 'c:'b, 'd> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, o, +, -] + --> $DIR/variance-regions-indirect.rs:16:1 + | +LL | struct Derived1<'w, 'x:'y, 'y, 'z> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [o, o, *] + --> $DIR/variance-regions-indirect.rs:22:1 + | +LL | struct Derived2<'a, 'b:'a, 'c> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [o, +, *] + --> $DIR/variance-regions-indirect.rs:28:1 + | +LL | struct Derived3<'a:'b, 'b, 'c> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [-, +, o] + --> $DIR/variance-regions-indirect.rs:34:1 + | +LL | struct Derived4<'a, 'b, 'c:'b> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0392]: lifetime parameter `'d` is never used --> $DIR/variance-regions-indirect.rs:8:26 | @@ -30,36 +60,6 @@ LL | struct Derived3<'a:'b, 'b, 'c> { | = help: consider removing `'c`, referring to it in a field, or using a marker such as `PhantomData` -error: [-, +, o, *] - --> $DIR/variance-regions-indirect.rs:8:1 - | -LL | enum Base<'a, 'b, 'c:'b, 'd> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, o, +, -] - --> $DIR/variance-regions-indirect.rs:16:1 - | -LL | struct Derived1<'w, 'x:'y, 'y, 'z> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [o, o, *] - --> $DIR/variance-regions-indirect.rs:22:1 - | -LL | struct Derived2<'a, 'b:'a, 'c> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [o, +, *] - --> $DIR/variance-regions-indirect.rs:28:1 - | -LL | struct Derived3<'a:'b, 'b, 'c> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [-, +, o] - --> $DIR/variance-regions-indirect.rs:34:1 - | -LL | struct Derived4<'a, 'b, 'c:'b> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0392`. diff --git a/tests/ui/variance/variance-trait-bounds.stderr b/tests/ui/variance/variance-trait-bounds.stderr index 95ed18c1ad2bf..9d106fb11f6a8 100644 --- a/tests/ui/variance/variance-trait-bounds.stderr +++ b/tests/ui/variance/variance-trait-bounds.stderr @@ -1,3 +1,27 @@ +error: [+, +] + --> $DIR/variance-trait-bounds.rs:16:1 + | +LL | struct TestStruct> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, +] + --> $DIR/variance-trait-bounds.rs:21:1 + | +LL | enum TestEnum> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, +] + --> $DIR/variance-trait-bounds.rs:27:1 + | +LL | struct TestContraStruct> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [*, +] + --> $DIR/variance-trait-bounds.rs:33:1 + | +LL | struct TestBox+Setter> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0392]: type parameter `U` is never used --> $DIR/variance-trait-bounds.rs:21:15 | @@ -25,30 +49,6 @@ LL | struct TestBox+Setter> { = help: consider removing `U`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `U` to be a const parameter, use `const U: /* Type */` instead -error: [+, +] - --> $DIR/variance-trait-bounds.rs:16:1 - | -LL | struct TestStruct> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, +] - --> $DIR/variance-trait-bounds.rs:21:1 - | -LL | enum TestEnum> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, +] - --> $DIR/variance-trait-bounds.rs:27:1 - | -LL | struct TestContraStruct> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [*, +] - --> $DIR/variance-trait-bounds.rs:33:1 - | -LL | struct TestBox+Setter> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0392`.