From 042464f75ae1272260b24896b3266a5c1ba62c6b Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Mon, 29 Jun 2020 22:15:11 +0100 Subject: [PATCH] Fix tests and bootstrap --- .../rustc_trait_selection/src/opaque_types.rs | 3 +- .../rustc_trait_selection/src/traits/wf.rs | 21 +++++++--- .../rustc_typeck/src/check/compare_method.rs | 1 + compiler/rustc_typeck/src/collect.rs | 16 +++++++- src/test/incremental/issue-54242.rs | 2 +- ...mplify_arm.id_try.SimplifyArmIdentity.diff | 14 +++---- ...implify_arm.id_try.SimplifyBranchSame.diff | 14 +++---- ...y.try_identity.DestinationPropagation.diff | 2 +- ..._try.try_identity.SimplifyArmIdentity.diff | 2 +- ....try_identity.SimplifyBranchSame.after.mir | 2 +- .../param-env-normalize-cycle.rs | 39 +++++++++++++++++++ .../feature-gate-associated_type_bounds.rs | 1 + ...feature-gate-associated_type_bounds.stderr | 34 ++++++++-------- src/test/ui/for/for-c-in-str.rs | 18 +++++---- src/test/ui/for/for-c-in-str.stderr | 2 +- .../auxiliary/foo_defn.rs | 8 ++++ .../cross-crate-bounds.rs | 32 +++++++++++++++ .../cross-crate-bounds.stderr | 14 +++++++ .../ui/traits/check-trait-object-bounds-3.rs | 1 - .../traits/check-trait-object-bounds-3.stderr | 19 +++++---- 20 files changed, 182 insertions(+), 63 deletions(-) create mode 100644 src/test/ui/associated-types/param-env-normalize-cycle.rs create mode 100644 src/test/ui/generic-associated-types/auxiliary/foo_defn.rs create mode 100644 src/test/ui/generic-associated-types/cross-crate-bounds.rs create mode 100644 src/test/ui/generic-associated-types/cross-crate-bounds.stderr diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 0621d9bf09e..610c6fd7e35 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -1170,8 +1170,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> { // This also instantiates nested instances of `impl Trait`. let predicate = self.instantiate_opaque_types_in_map(&predicate); - let cause = - traits::ObligationCause::new(span, self.body_id, traits::MiscObligation); + let cause = traits::ObligationCause::new(span, self.body_id, traits::MiscObligation); // Require that the predicate holds for the concrete type. debug!("instantiate_opaque_types: predicate={:?}", predicate); diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 165e45aa94a..9fd635c64a0 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -241,18 +241,27 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { traits::ObligationCause::new(self.span, self.body_id, code) } - fn normalize(&mut self) -> Vec> { + fn normalize(mut self) -> Vec> { let cause = self.cause(traits::MiscObligation); let infcx = &mut self.infcx; let param_env = self.param_env; let mut obligations = Vec::with_capacity(self.out.len()); - for pred in &self.out { - assert!(!pred.has_escaping_bound_vars()); + for mut obligation in self.out { + assert!(!obligation.has_escaping_bound_vars()); let mut selcx = traits::SelectionContext::new(infcx); let i = obligations.len(); - let value = - traits::normalize_to(&mut selcx, param_env, cause.clone(), pred, &mut obligations); - obligations.insert(i, value); + // Don't normalize the whole obligation, the param env is either + // already normalized, or we're currently normalizing the + // param_env. Either way we should only normalize the predicate. + let normalized_predicate = traits::normalize_to( + &mut selcx, + param_env, + cause.clone(), + &obligation.predicate, + &mut obligations, + ); + obligation.predicate = normalized_predicate; + obligations.insert(i, obligation); } obligations } diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index b059b03bc05..ee21167ff97 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -1256,6 +1256,7 @@ pub fn check_type_bounds<'tcx>( ); debug!("compare_projection_bounds: normalized predicate = {:?}", normalized_predicate); + inh.register_predicates(obligations); inh.register_predicate(obligation); } diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 737bc3a753d..ac4abd6a511 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -1787,10 +1787,22 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat }) => { if impl_trait_fn.is_some() { // return-position impl trait - // TODO: Investigate why we have this special case? + // + // We don't inherit predicates from the parent here: + // If we have, say `fn f<'a, T: 'a>() -> impl Sized {}` + // then the return type is `f::<'static, T>::{{opaque}}`. + // + // If we inherited the predicates of `f` then we would + // require that `T: 'static` to show that the return + // type is well-formed. + // + // The only way to have something with this opaque type + // is from the return type of the containing function, + // which will ensure that the function's predicates + // hold. return ty::GenericPredicates { parent: None, predicates: &[] }; } else { - // type alias impl trait + // type-alias impl trait generics } } diff --git a/src/test/incremental/issue-54242.rs b/src/test/incremental/issue-54242.rs index 25dc7cdf129..a95cf776c2e 100644 --- a/src/test/incremental/issue-54242.rs +++ b/src/test/incremental/issue-54242.rs @@ -1,6 +1,6 @@ // revisions: rpass cfail -trait Tr { +trait Tr where Self::Arr: Sized { type Arr; const C: usize = 0; diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff index 33245b65e8c..6ec2b98bf5b 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff @@ -1,6 +1,6 @@ - // MIR for `id_try` before SimplifyArmIdentity + // MIR for `id_try` after SimplifyArmIdentity - + fn id_try(_1: std::result::Result) -> std::result::Result { debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:23:11: 23:12 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:23:34: 23:49 @@ -42,7 +42,7 @@ scope 6 { debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL } - + bb0: { StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:24:9: 24:10 StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 @@ -53,7 +53,7 @@ _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 } - + bb1: { - StorageLive(_10); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 - _10 = ((_3 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 @@ -69,11 +69,11 @@ StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 } - + bb2: { unreachable; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 } - + bb3: { - StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 - _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 @@ -94,9 +94,9 @@ StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 } - + bb4: { return; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 } } - + diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff index eb2521c8ba0..172fb04a3cc 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff @@ -1,6 +1,6 @@ - // MIR for `id_try` before SimplifyBranchSame + // MIR for `id_try` after SimplifyBranchSame - + fn id_try(_1: std::result::Result) -> std::result::Result { debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:23:11: 23:12 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:23:34: 23:49 @@ -37,7 +37,7 @@ scope 6 { debug self => _4; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL } - + bb0: { StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:24:9: 24:10 StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 @@ -49,7 +49,7 @@ - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 + goto -> bb1; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15 } - + bb1: { _0 = move _3; // scope 1 at $DIR/simplify-arm.rs:25:5: 25:10 StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16 @@ -57,20 +57,20 @@ - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 + goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 } - + bb2: { - unreachable; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15 - } -- +- - bb3: { - _0 = move _3; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 - } -- +- - bb4: { return; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2 } } - + diff --git a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff index 2af387a73b7..12a6617cc5a 100644 --- a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff +++ b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff @@ -25,7 +25,7 @@ } scope 8 { debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:14: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff index 6fa14f1e0d8..534836eff7b 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff @@ -29,7 +29,7 @@ scope 8 { - debug v => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:14: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir index ceb5bfb19a1..d2e37bf4e12 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir @@ -24,7 +24,7 @@ fn try_identity(_1: std::result::Result) -> std::result::Result ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:14: 8:15 + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } } diff --git a/src/test/ui/associated-types/param-env-normalize-cycle.rs b/src/test/ui/associated-types/param-env-normalize-cycle.rs new file mode 100644 index 00000000000..12db595ed25 --- /dev/null +++ b/src/test/ui/associated-types/param-env-normalize-cycle.rs @@ -0,0 +1,39 @@ +// Minimized case from typenum that didn't compile because: +// - We tried to normalize the ParamEnv of the second impl +// - This requires trying to normalize `GrEq>>` +// - This requires proving `Square>: Sized` so that the first impl +// applies +// - This requires Providing `Square>` is well-formed, so that we +// can use the `Sized` bound on `Mul::Output` +// - This requires proving `Square: Mul` +// - But first we tried normalizing the whole obligation, including the +// ParamEnv, which leads to a cycle error. + +// check-pass + +trait PrivateSquareRoot {} + +pub trait Mul { + type Output; +} + +pub trait IsGreaterOrEqual { + type Output; +} + +pub type Square = ::Output; +pub type GrEq = >::Output; + +impl IsGreaterOrEqual for A { + type Output = (); +} + +impl PrivateSquareRoot for U +where + U: Mul, + Square: Mul, + GrEq>>: Sized, +{ +} + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs index c5c8c5c1eca..7dac2b26cce 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -1,3 +1,4 @@ +// ignore-tidy-linelength // compile-flags: -Zsave-analysis // This is also a regression test for #69415 and the above flag is needed. diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr index db78e287d65..03011bd1e32 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -1,5 +1,5 @@ error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:15:22 + --> $DIR/feature-gate-associated_type_bounds.rs:16:22 | LL | type A: Iterator; | ^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | type A: Iterator; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:19:22 + --> $DIR/feature-gate-associated_type_bounds.rs:20:22 | LL | type B: Iterator; | ^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | type B: Iterator; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:23:20 + --> $DIR/feature-gate-associated_type_bounds.rs:24:20 | LL | struct _St1> { | ^^^^^^^^ @@ -26,7 +26,7 @@ LL | struct _St1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:30:18 + --> $DIR/feature-gate-associated_type_bounds.rs:31:18 | LL | enum _En1> { | ^^^^^^^^ @@ -35,7 +35,7 @@ LL | enum _En1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:37:19 + --> $DIR/feature-gate-associated_type_bounds.rs:38:19 | LL | union _Un1> { | ^^^^^^^^ @@ -44,7 +44,7 @@ LL | union _Un1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:44:37 + --> $DIR/feature-gate-associated_type_bounds.rs:45:37 | LL | type _TaWhere1 where T: Iterator = T; | ^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | type _TaWhere1 where T: Iterator = T; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:47:22 + --> $DIR/feature-gate-associated_type_bounds.rs:48:22 | LL | fn _apit(_: impl Tr1) {} | ^^^^^^^^^ @@ -62,7 +62,7 @@ LL | fn _apit(_: impl Tr1) {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:49:26 + --> $DIR/feature-gate-associated_type_bounds.rs:50:26 | LL | fn _apit_dyn(_: &dyn Tr1) {} | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | fn _apit_dyn(_: &dyn Tr1) {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:52:24 + --> $DIR/feature-gate-associated_type_bounds.rs:53:24 | LL | fn _rpit() -> impl Tr1 { S1 } | ^^^^^^^^^ @@ -80,7 +80,7 @@ LL | fn _rpit() -> impl Tr1 { S1 } = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:55:31 + --> $DIR/feature-gate-associated_type_bounds.rs:56:31 | LL | fn _rpit_dyn() -> Box> { Box::new(S1) } | ^^^^^^^^^ @@ -89,7 +89,7 @@ LL | fn _rpit_dyn() -> Box> { Box::new(S1) } = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:58:23 + --> $DIR/feature-gate-associated_type_bounds.rs:59:23 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^ @@ -98,7 +98,7 @@ LL | const _cdef: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:64:24 + --> $DIR/feature-gate-associated_type_bounds.rs:65:24 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^ @@ -107,7 +107,7 @@ LL | static _sdef: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:71:21 + --> $DIR/feature-gate-associated_type_bounds.rs:72:21 | LL | let _: impl Tr1 = S1; | ^^^^^^^^^ @@ -116,7 +116,7 @@ LL | let _: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:58:14 + --> $DIR/feature-gate-associated_type_bounds.rs:59:14 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -124,7 +124,7 @@ LL | const _cdef: impl Tr1 = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:64:15 + --> $DIR/feature-gate-associated_type_bounds.rs:65:15 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -132,7 +132,7 @@ LL | static _sdef: impl Tr1 = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:71:12 + --> $DIR/feature-gate-associated_type_bounds.rs:72:12 | LL | let _: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -140,7 +140,7 @@ LL | let _: impl Tr1 = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0277]: the trait bound `<::A as std::iter::Iterator>::Item: std::marker::Copy` is not satisfied - --> $DIR/feature-gate-associated_type_bounds.rs:15:28 + --> $DIR/feature-gate-associated_type_bounds.rs:16:28 | LL | type A: Iterator; | ^^^^ the trait `std::marker::Copy` is not implemented for `<::A as std::iter::Iterator>::Item` diff --git a/src/test/ui/for/for-c-in-str.rs b/src/test/ui/for/for-c-in-str.rs index df66127c604..8aca8c388d4 100644 --- a/src/test/ui/for/for-c-in-str.rs +++ b/src/test/ui/for/for-c-in-str.rs @@ -1,14 +1,16 @@ -// E0277 should point exclusively at line 14, not the entire for loop span +// E0277 should point exclusively at line 6, not the entire for loop span + +// ignore-tidy-linelength fn main() { for c in "asdf" { - //~^ ERROR `&str` is not an iterator - //~| NOTE `&str` is not an iterator - //~| HELP the trait `Iterator` is not implemented for `&str` - //~| NOTE required by `into_iter` - //~| NOTE in this expansion of desugaring of `for` loop - //~| NOTE in this expansion of desugaring of `for` loop - //~| NOTE in this expansion of desugaring of `for` loop + //~^ ERROR `&str` is not an iterator + //~| NOTE `&str` is not an iterator + //~| HELP the trait `Iterator` is not implemented for `&str` + //~| NOTE required by `into_iter` + //~| NOTE in this expansion of desugaring of `for` loop + //~| NOTE in this expansion of desugaring of `for` loop + //~| NOTE in this expansion of desugaring of `for` loop println!(); } } diff --git a/src/test/ui/for/for-c-in-str.stderr b/src/test/ui/for/for-c-in-str.stderr index b0f959ba027..f991e08e518 100644 --- a/src/test/ui/for/for-c-in-str.stderr +++ b/src/test/ui/for/for-c-in-str.stderr @@ -1,5 +1,5 @@ error[E0277]: `&str` is not an iterator - --> $DIR/for-c-in-str.rs:4:14 + --> $DIR/for-c-in-str.rs:6:14 | LL | for c in "asdf" { | ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` diff --git a/src/test/ui/generic-associated-types/auxiliary/foo_defn.rs b/src/test/ui/generic-associated-types/auxiliary/foo_defn.rs new file mode 100644 index 00000000000..0e8e14852d9 --- /dev/null +++ b/src/test/ui/generic-associated-types/auxiliary/foo_defn.rs @@ -0,0 +1,8 @@ +#![feature(generic_associated_types)] + +use std::{future::Future, pin::Pin}; + +pub trait Foo { + type Bar: AsRef<()>; + fn foo(&self) -> Pin + '_>>; +} diff --git a/src/test/ui/generic-associated-types/cross-crate-bounds.rs b/src/test/ui/generic-associated-types/cross-crate-bounds.rs new file mode 100644 index 00000000000..4e2bab38c88 --- /dev/null +++ b/src/test/ui/generic-associated-types/cross-crate-bounds.rs @@ -0,0 +1,32 @@ +// regression test for #73816 +// We handled bounds differently when `feature(generic_associated_types)` was enabled + +// edition:2018 +// aux-build:foo_defn.rs + +extern crate foo_defn; + +use foo_defn::Foo; +use std::{future::Future, pin::Pin}; + +pub struct FooImpl; + +impl Foo for FooImpl { + type Bar = (); + //~^ ERROR the trait bound `(): std::convert::AsRef<()>` is not satisfied + fn foo(&self) -> Pin + '_>> { + panic!() + } +} + +async fn foo() { + bar(&FooImpl).await; +} + +async fn bar(foo: &F) { + foo.foo().await.as_ref(); +} + +fn main() { + // futures::executor::block_on(foo()); +} diff --git a/src/test/ui/generic-associated-types/cross-crate-bounds.stderr b/src/test/ui/generic-associated-types/cross-crate-bounds.stderr new file mode 100644 index 00000000000..5fd2750868f --- /dev/null +++ b/src/test/ui/generic-associated-types/cross-crate-bounds.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `(): std::convert::AsRef<()>` is not satisfied + --> $DIR/cross-crate-bounds.rs:15:5 + | +LL | type Bar = (); + | ^^^^^^^^^^^^^^ the trait `std::convert::AsRef<()>` is not implemented for `()` + | + ::: $DIR/auxiliary/foo_defn.rs:6:15 + | +LL | type Bar: AsRef<()>; + | --------- required by this bound in `foo_defn::Foo::Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/traits/check-trait-object-bounds-3.rs b/src/test/ui/traits/check-trait-object-bounds-3.rs index d05aa14f2cf..ba04fd93acc 100644 --- a/src/test/ui/traits/check-trait-object-bounds-3.rs +++ b/src/test/ui/traits/check-trait-object-bounds-3.rs @@ -18,4 +18,3 @@ pub fn main() { println!("{}", z) } - diff --git a/src/test/ui/traits/check-trait-object-bounds-3.stderr b/src/test/ui/traits/check-trait-object-bounds-3.stderr index e2a4341454a..ade552c4bab 100644 --- a/src/test/ui/traits/check-trait-object-bounds-3.stderr +++ b/src/test/ui/traits/check-trait-object-bounds-3.stderr @@ -1,12 +1,15 @@ -error[E0277]: the trait bound `str: std::clone::Clone` is not satisfied - --> $DIR/check-trait-object-bounds-3.rs:12:5 +error[E0597]: `s` does not live long enough + --> $DIR/check-trait-object-bounds-3.rs:15:34 | -LL | fn f() { - | - required by this bound in `f` -... -LL | f::>(); - | ^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `str` +LL | z = f::>(&s); + | ---------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `s` is borrowed for `'static` +LL | +LL | } + | - `s` dropped here while still borrowed error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0597`.