mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
implement review suggestions
This commit is contained in:
parent
ecf2a9b75e
commit
b506d966a3
@ -56,11 +56,12 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
|
|||||||
let ty = self.resolve_vars_if_possible(ty);
|
let ty = self.resolve_vars_if_possible(ty);
|
||||||
let ty = OpportunisticRegionResolver::new(self).fold_ty(ty);
|
let ty = OpportunisticRegionResolver::new(self).fold_ty(ty);
|
||||||
|
|
||||||
// We must avoid processing constrained lifetime variables in implied
|
// We must avoid processing unconstrained lifetime variables in implied
|
||||||
// bounds. See #110161 for context.
|
// bounds. See #110161 for context.
|
||||||
|
assert!(!ty.has_non_region_infer());
|
||||||
if ty.needs_infer() {
|
if ty.needs_infer() {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.delay_span_bug(
|
||||||
self.tcx.source_span_untracked(body_id),
|
self.tcx.def_span(body_id),
|
||||||
"skipped implied_outlives_bounds due to unconstrained lifetimes",
|
"skipped implied_outlives_bounds due to unconstrained lifetimes",
|
||||||
);
|
);
|
||||||
return vec![];
|
return vec![];
|
||||||
|
@ -3,22 +3,24 @@
|
|||||||
|
|
||||||
// compile-flags: --crate-type=lib
|
// compile-flags: --crate-type=lib
|
||||||
|
|
||||||
trait Trait {
|
trait LtTrait {
|
||||||
type Ty;
|
type Ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// erroneous `Ty` impl
|
// erroneous `Ty` impl
|
||||||
impl Trait for () {
|
impl LtTrait for () {
|
||||||
//~^ ERROR not all trait items implemented, missing: `Ty` [E0046]
|
//~^ ERROR not all trait items implemented, missing: `Ty` [E0046]
|
||||||
}
|
}
|
||||||
|
|
||||||
// `'lt` is not constrained by the erroneous `Ty`
|
// `'lt` is not constrained by the erroneous `Ty`
|
||||||
impl<'lt, T> Trait for Box<T>
|
impl<'lt, T> LtTrait for Box<T>
|
||||||
where
|
where
|
||||||
T: Trait<Ty = &'lt ()>,
|
T: LtTrait<Ty = &'lt ()>,
|
||||||
{
|
{
|
||||||
type Ty = &'lt ();
|
type Ty = &'lt ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// unconstrained lifetime appears in implied bounds
|
// unconstrained lifetime appears in implied bounds
|
||||||
fn test(_: <Box<()> as Trait>::Ty) {}
|
fn test(_: <Box<()> as LtTrait>::Ty) {}
|
||||||
|
|
||||||
|
fn test2<'x>(_: &'x <Box<()> as LtTrait>::Ty) {}
|
||||||
|
@ -4,8 +4,8 @@ error[E0046]: not all trait items implemented, missing: `Ty`
|
|||||||
LL | type Ty;
|
LL | type Ty;
|
||||||
| ------- `Ty` from trait
|
| ------- `Ty` from trait
|
||||||
...
|
...
|
||||||
LL | impl Trait for () {
|
LL | impl LtTrait for () {
|
||||||
| ^^^^^^^^^^^^^^^^^ missing `Ty` in implementation
|
| ^^^^^^^^^^^^^^^^^^^ missing `Ty` in implementation
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user