Skip to content

Commit 3ae5fed

Browse files
committedApr 6, 2021
Fix a couple resolve bugs from binder refactor
1 parent 5c897d4 commit 3ae5fed

5 files changed

+56
-1
lines changed
 

Diff for: ‎compiler/rustc_resolve/src/late/lifetimes.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -2659,6 +2659,13 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
26592659
Some(next) => next,
26602660
None => break None,
26612661
};
2662+
// See issue #83753. If someone writes an associated type on a non-trait, just treat it as
2663+
// there being no supertrait HRTBs.
2664+
match tcx.def_kind(def_id) {
2665+
DefKind::Trait | DefKind::TraitAlias | DefKind::Impl => {}
2666+
_ => break None,
2667+
}
2668+
26622669
if trait_defines_associated_type_named(def_id) {
26632670
break Some(bound_vars.into_iter().collect());
26642671
}
@@ -2703,7 +2710,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
27032710
| Scope::Supertrait { ref s, .. } => {
27042711
scope = *s;
27052712
}
2706-
Scope::Root => bug!("In fn_like_elision without appropriate scope above"),
2713+
Scope::Root => {
2714+
// See issue #83907. Just bail out from looking inside.
2715+
self.tcx.sess.delay_span_bug(
2716+
rustc_span::DUMMY_SP,
2717+
"In fn_like_elision without appropriate scope above",
2718+
);
2719+
return;
2720+
}
27072721
}
27082722
};
27092723
// While not strictly necessary, we gather anon lifetimes *before* actually
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// check-fail
2+
3+
struct Foo {}
4+
impl Foo {
5+
fn bar(foo: Foo<Target = usize>) {}
6+
//~^ associated type bindings are not allowed here
7+
}
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0229]: associated type bindings are not allowed here
2+
--> $DIR/issue-83753-invalid-associated-type-supertrait-hrtb.rs:5:21
3+
|
4+
LL | fn bar(foo: Foo<Target = usize>) {}
5+
| ^^^^^^^^^^^^^^ associated type not allowed here
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0229`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// check-fail
2+
3+
static STATIC_VAR_FIVE: &One();
4+
//~^ cannot find type
5+
//~| free static item without body
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: free static item without body
2+
--> $DIR/issue-83907-invalid-fn-like-path.rs:3:1
3+
|
4+
LL | static STATIC_VAR_FIVE: &One();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
6+
| |
7+
| help: provide a definition for the static: `= <expr>;`
8+
9+
error[E0412]: cannot find type `One` in this scope
10+
--> $DIR/issue-83907-invalid-fn-like-path.rs:3:26
11+
|
12+
LL | static STATIC_VAR_FIVE: &One();
13+
| ^^^ not found in this scope
14+
15+
error: aborting due to 2 previous errors
16+
17+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)
Please sign in to comment.