Skip to content
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

Fix a couple resolve bugs from binder refactor #83944

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion compiler/rustc_resolve/src/late/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,13 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
Some(next) => next,
None => break None,
};
// See issue #83753. If someone writes an associated type on a non-trait, just treat it as
// there being no supertrait HRTBs.
match tcx.def_kind(def_id) {
DefKind::Trait | DefKind::TraitAlias | DefKind::Impl => {}
_ => break None,
}

if trait_defines_associated_type_named(def_id) {
break Some(bound_vars.into_iter().collect());
}
Expand Down Expand Up @@ -2703,7 +2710,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
| Scope::Supertrait { ref s, .. } => {
scope = *s;
}
Scope::Root => bug!("In fn_like_elision without appropriate scope above"),
Scope::Root => {
// See issue #83907. Just bail out from looking inside.
self.tcx.sess.delay_span_bug(
rustc_span::DUMMY_SP,
"In fn_like_elision without appropriate scope above",
);
return;
}
}
};
// While not strictly necessary, we gather anon lifetimes *before* actually
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// check-fail

struct Foo {}
impl Foo {
fn bar(foo: Foo<Target = usize>) {}
//~^ associated type bindings are not allowed here
}
fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-83753-invalid-associated-type-supertrait-hrtb.rs:5:21
|
LL | fn bar(foo: Foo<Target = usize>) {}
| ^^^^^^^^^^^^^^ associated type not allowed here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0229`.
7 changes: 7 additions & 0 deletions src/test/ui/lifetimes/issue-83907-invalid-fn-like-path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// check-fail

static STATIC_VAR_FIVE: &One();
//~^ cannot find type
//~| free static item without body

fn main() {}
17 changes: 17 additions & 0 deletions src/test/ui/lifetimes/issue-83907-invalid-fn-like-path.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error: free static item without body
--> $DIR/issue-83907-invalid-fn-like-path.rs:3:1
|
LL | static STATIC_VAR_FIVE: &One();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the static: `= <expr>;`

error[E0412]: cannot find type `One` in this scope
--> $DIR/issue-83907-invalid-fn-like-path.rs:3:26
|
LL | static STATIC_VAR_FIVE: &One();
| ^^^ not found in this scope

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.