-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix: skip implied bounds if unconstrained lifetime exists #110272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,16 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> { | |
) -> Vec<OutlivesBound<'tcx>> { | ||
let ty = self.resolve_vars_if_possible(ty); | ||
let ty = OpportunisticRegionResolver::new(self).fold_ty(ty); | ||
assert!(!ty.needs_infer()); | ||
|
||
// We must avoid processing constrained lifetime variables in implied | ||
// bounds. See #110161 for context. | ||
if ty.needs_infer() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would keep the assertion around for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess type vars has the same problem. For a test case, we can probably replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fwiw (and I'm completely inexperienced), I think we are good here, there aren't unconstrained type variables in the same way? |
||
self.tcx.sess.delay_span_bug( | ||
self.tcx.source_span_untracked(body_id), | ||
Ezrashaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"skipped implied_outlives_bounds due to unconstrained lifetimes", | ||
); | ||
return vec![]; | ||
} | ||
|
||
let span = self.tcx.def_span(body_id); | ||
let result = param_env | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// ICE regression relating to unconstrained lifetimes in implied | ||
// bounds. See #110161. | ||
|
||
// compile-flags: --crate-type=lib | ||
|
||
trait Trait { | ||
type Ty; | ||
} | ||
|
||
// erroneous `Ty` impl | ||
impl Trait for () { | ||
//~^ ERROR not all trait items implemented, missing: `Ty` [E0046] | ||
} | ||
|
||
// `'lt` is not constrained by the erroneous `Ty` | ||
impl<'lt, T> Trait for Box<T> | ||
where | ||
T: Trait<Ty = &'lt ()>, | ||
{ | ||
type Ty = &'lt (); | ||
} | ||
|
||
// unconstrained lifetime appears in implied bounds | ||
fn test(_: <Box<()> as Trait>::Ty) {} | ||
Ezrashaw marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0046]: not all trait items implemented, missing: `Ty` | ||
--> $DIR/issue-110161.rs:11:1 | ||
| | ||
LL | type Ty; | ||
| ------- `Ty` from trait | ||
... | ||
LL | impl Trait for () { | ||
| ^^^^^^^^^^^^^^^^^ missing `Ty` in implementation | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
Uh oh!
There was an error while loading. Please reload this page.