Skip to content

Commit

Permalink
Rollup merge of #97927 - cjgillot:issue-97836, r=petrochenkov
Browse files Browse the repository at this point in the history
Do not introduce bindings for types and consts in HRTB.

Fixes #97836

r? `@petrochenkov`
  • Loading branch information
JohnTitor committed Jun 10, 2022
2 parents 3e5ddb7 + 4d871a2 commit c2355a6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
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));
rib.bindings.insert(ident, res);
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/higher-rank-trait-bounds/hrtb-wrong-kind.rs
Original file line number Diff line number Diff line change
@@ -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() {}
14 changes: 14 additions & 0 deletions src/test/ui/higher-rank-trait-bounds/hrtb-wrong-kind.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c2355a6

Please sign in to comment.