-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Forbid elided lifetimes within const generic parameter types #68143
Forbid elided lifetimes within const generic parameter types #68143
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -0,0 +1,19 @@ | |||
#![feature(const_generics)] |
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.
Could you give a brief comment at the top explaining why the behavior is how it is? (Contrast and compare with e.g. fn foo<T: Ord<&u8>>() {}
.)
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.
I have added that comment. Though I'm not sure what the behaviour should be in the long term, it was the easiest fix(for the ICE) to just disallow elided lifetimes.
I think the only lifetime const generic arguments can have is 'static
, so maybe we should do ''static
lifetime elision'(https://doc.rust-lang.org/reference/lifetime-elision.html#static-lifetime-elision), like what happens for const/static items.
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.
It's better to make this an error for now.
Then we'll be able to introduce a 'static
default more explicitly than in some bugfix PR, when const generics are stable and we have more experience with them.
(The 'static
default for const
items actually went through an RFC.)
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r+ |
📌 Commit 82b90bd has been approved by |
…ifetime, r=petrochenkov Forbid elided lifetimes within const generic parameter types Disallows `fn foo<const T: &u32>()`, the lifetime must be explicitly given, i.e. `fn foo<const T: &'static u32>()`. Fixes rust-lang#67883
…ifetime, r=petrochenkov Forbid elided lifetimes within const generic parameter types Disallows `fn foo<const T: &u32>()`, the lifetime must be explicitly given, i.e. `fn foo<const T: &'static u32>()`. Fixes rust-lang#67883
Rollup of 10 pull requests Successful merges: - #67854 (Use `report_in_external_macro` for internal lints) - #67989 (rustdoc: Don't allow `#![feature(...)]` on stable or beta) - #68036 (libterm: parse extended terminfo format) - #68127 (Clarify the relationship between `extended` and `tools` in `config.toml`) - #68143 (Forbid elided lifetimes within const generic parameter types) - #68150 (Document behavior of set_nonblocking on UnixListener) - #68166 (rustdoc: HTML escape arrows on help popup) - #68176 (Clean up err codes) - #68179 (Remove unneeded scope) - #68188 (Tweak assertion note in format check) Failed merges: r? @ghost
Disallows
fn foo<const T: &u32>()
, the lifetime must be explicitly given, i.e.fn foo<const T: &'static u32>()
.Fixes #67883