Skip to content

Commit c2355a6

Browse files
authored
Rollup merge of #97927 - cjgillot:issue-97836, r=petrochenkov
Do not introduce bindings for types and consts in HRTB. Fixes #97836 r? `@petrochenkov`
2 parents 3e5ddb7 + 4d871a2 commit c2355a6

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

compiler/rustc_resolve/src/late.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
19811981
continue;
19821982
}
19831983
};
1984-
let res = Res::Def(def_kind, def_id.to_def_id());
1984+
1985+
let res = match kind {
1986+
ItemRibKind(..) | AssocItemRibKind => Res::Def(def_kind, def_id.to_def_id()),
1987+
NormalRibKind => Res::Err,
1988+
_ => bug!("Unexpected rib kind {:?}", kind),
1989+
};
19851990
self.r.record_partial_res(param.id, PartialRes::new(res));
19861991
rib.bindings.insert(ident, res);
19871992
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn a() where for<T> T: Copy {}
2+
//~^ ERROR only lifetime parameters can be used in this context
3+
4+
fn b() where for<const C: usize> [(); C]: Copy {}
5+
//~^ ERROR only lifetime parameters can be used in this context
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: only lifetime parameters can be used in this context
2+
--> $DIR/hrtb-wrong-kind.rs:1:18
3+
|
4+
LL | fn a() where for<T> T: Copy {}
5+
| ^
6+
7+
error: only lifetime parameters can be used in this context
8+
--> $DIR/hrtb-wrong-kind.rs:4:24
9+
|
10+
LL | fn b() where for<const C: usize> [(); C]: Copy {}
11+
| ^
12+
13+
error: aborting due to 2 previous errors
14+

0 commit comments

Comments
 (0)