-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add const generics support for pattern types #123689
Add const generics support for pattern types #123689
Conversation
HIR ty lowering was modified cc @fmease |
3bd2744
to
f7b9e47
Compare
res: Res::Def(DefKind::ConstParam, def_id), .. | ||
}, | ||
)) => { | ||
let ty = tcx.type_of(def_id).instantiate_identity(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let ty = tcx.type_of(def_id).instantiate_identity(); | |
let ty = tcx.type_of(def_id).no_bound_vars().expect("const parameter types cannot be generic"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would factor out the logic common between this code path here and lower_const_param
🤔, not blocking though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slowly wondering if we should just use entirely new hir nodes so we can just use AnonConst like other type system consts
f7b9e47
to
30c546a
Compare
@bors r+ rollup |
…llaumeGomez Rollup of 7 pull requests Successful merges: - rust-lang#118391 (Add `REDUNDANT_LIFETIMES` lint to detect lifetimes which are semantically redundant) - rust-lang#123534 (Windows: set main thread name without re-encoding) - rust-lang#123659 (Add support to intrinsics fallback body) - rust-lang#123689 (Add const generics support for pattern types) - rust-lang#123701 (Only assert for child/parent projection compatibility AFTER checking that theyre coming from the same place) - rust-lang#123702 (Further cleanup cfgs in the UI test suite) - rust-lang#123706 (rustdoc: reduce per-page HTML overhead) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#123689 - spastorino:pattern_types_const_generics, r=oli-obk Add const generics support for pattern types r? `@oli-obk`
…, r=compiler-errors Call lower_const_param instead of duplicating the code Follow up of rust-lang#123689 r? `@oli-obk` I had this commit in my old branch that I had forgotten about, `@fmease` pointed about this in rust-lang#123689 I've left the branches that are not `Range` as do nothing as that's what we are currently doing but maybe we want to err or something.
Rollup merge of rust-lang#123738 - spastorino:reuse-lower-const-param, r=compiler-errors Call lower_const_param instead of duplicating the code Follow up of rust-lang#123689 r? `@oli-obk` I had this commit in my old branch that I had forgotten about, `@fmease` pointed about this in rust-lang#123689 I've left the branches that are not `Range` as do nothing as that's what we are currently doing but maybe we want to err or something.
&hir::Path { | ||
res: Res::Def(DefKind::ConstParam, def_id), .. | ||
}, | ||
)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we're missing a call to prohibit_generic_args
here. Right now, we permit:
pattern_type!(u32 is START::<(), i32, 2>..=END::<_>)
where START
and END
are u32
s like in the UI test.
While we could add this check, this just reinforces oli's point: #123689 (comment), Zulip discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this while reviewing an unrelated PR.
r? @oli-obk