Rollup merge of #97927 - cjgillot:issue-97836, r=petrochenkov

Do not introduce bindings for types and consts in HRTB.

Fixes https://github.com/rust-lang/rust/issues/97836

r? `@petrochenkov`
This commit is contained in:
Yuki Okushi 2022-06-10 17:22:32 +09:00 committed by GitHub
commit c2355a615d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View file

@ -1981,7 +1981,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
continue; continue;
} }
}; };
let res = Res::Def(def_kind, def_id.to_def_id());
let res = match kind {
ItemRibKind(..) | AssocItemRibKind => Res::Def(def_kind, def_id.to_def_id()),
NormalRibKind => Res::Err,
_ => bug!("Unexpected rib kind {:?}", kind),
};
self.r.record_partial_res(param.id, PartialRes::new(res)); self.r.record_partial_res(param.id, PartialRes::new(res));
rib.bindings.insert(ident, res); rib.bindings.insert(ident, res);
} }

View file

@ -0,0 +1,7 @@
fn a() where for<T> T: Copy {}
//~^ ERROR only lifetime parameters can be used in this context
fn b() where for<const C: usize> [(); C]: Copy {}
//~^ ERROR only lifetime parameters can be used in this context
fn main() {}

View file

@ -0,0 +1,14 @@
error: only lifetime parameters can be used in this context
--> $DIR/hrtb-wrong-kind.rs:1:18
|
LL | fn a() where for<T> T: Copy {}
| ^
error: only lifetime parameters can be used in this context
--> $DIR/hrtb-wrong-kind.rs:4:24
|
LL | fn b() where for<const C: usize> [(); C]: Copy {}
| ^
error: aborting due to 2 previous errors