Skip to content

Commit b506d96

Browse files
committed
implement review suggestions
1 parent ecf2a9b commit b506d96

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

compiler/rustc_trait_selection/src/traits/outlives_bounds.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
5656
let ty = self.resolve_vars_if_possible(ty);
5757
let ty = OpportunisticRegionResolver::new(self).fold_ty(ty);
5858

59-
// We must avoid processing constrained lifetime variables in implied
59+
// We must avoid processing unconstrained lifetime variables in implied
6060
// bounds. See #110161 for context.
61+
assert!(!ty.has_non_region_infer());
6162
if ty.needs_infer() {
6263
self.tcx.sess.delay_span_bug(
63-
self.tcx.source_span_untracked(body_id),
64+
self.tcx.def_span(body_id),
6465
"skipped implied_outlives_bounds due to unconstrained lifetimes",
6566
);
6667
return vec![];

tests/ui/implied-bounds/issue-110161.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33

44
// compile-flags: --crate-type=lib
55

6-
trait Trait {
6+
trait LtTrait {
77
type Ty;
88
}
99

1010
// erroneous `Ty` impl
11-
impl Trait for () {
11+
impl LtTrait for () {
1212
//~^ ERROR not all trait items implemented, missing: `Ty` [E0046]
1313
}
1414

1515
// `'lt` is not constrained by the erroneous `Ty`
16-
impl<'lt, T> Trait for Box<T>
16+
impl<'lt, T> LtTrait for Box<T>
1717
where
18-
T: Trait<Ty = &'lt ()>,
18+
T: LtTrait<Ty = &'lt ()>,
1919
{
2020
type Ty = &'lt ();
2121
}
2222

2323
// unconstrained lifetime appears in implied bounds
24-
fn test(_: <Box<()> as Trait>::Ty) {}
24+
fn test(_: <Box<()> as LtTrait>::Ty) {}
25+
26+
fn test2<'x>(_: &'x <Box<()> as LtTrait>::Ty) {}

tests/ui/implied-bounds/issue-110161.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0046]: not all trait items implemented, missing: `Ty`
44
LL | type Ty;
55
| ------- `Ty` from trait
66
...
7-
LL | impl Trait for () {
8-
| ^^^^^^^^^^^^^^^^^ missing `Ty` in implementation
7+
LL | impl LtTrait for () {
8+
| ^^^^^^^^^^^^^^^^^^^ missing `Ty` in implementation
99

1010
error: aborting due to previous error
1111

0 commit comments

Comments
 (0)