-
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
extend const generics test suite #78916
Conversation
7bfa78e
to
cc3bea2
Compare
let _: foo!({{ N }}); //[min]~ ERROR generic parameters may not | ||
let _: bar!(N); | ||
let _: bar!({ N }); //[min]~ ERROR generic parameters may not | ||
let _: baz!(N); //~ ERROR expressions must be enclosed in braces |
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.
that one's surprising, Foo<N>
should be allowed but apparently doesn't work inside of macros
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 would be nice to fix this.
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.
do you or @petrochenkov have an idea on where this might go wrong?
That's not really something I am familiar with
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 believe the issue is here:
if !self.expr_is_valid_const_arg(&expr) { |
expr_is_valid_const_arg
returns false for an identifier like N
, because we usually simply parse identifiers as type arguments instead, and then resolve them to const arguments later. (The comment at the top of handle_unambiguous_unbraced_const_arg
is misleading and should probably be changed: it doesn't just handle an error code, it is also for parsing valid const arguments that are not surrounded in braces.) I think if you add the identifier case to expr_is_valid_const_arg
, this might work as expected. I'm not quite sure off the top of my head why this is the only place we're hitting this issue, though, or why there's not an ambiguity issue with type arguments.
We can do this as a follow up, though.
cc3bea2
to
a8310e2
Compare
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 has been the right approach to the issue #78433. I will follow.
2f44b25
to
f1e456f
Compare
let _: Foo<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime | ||
let _: Foo<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime | ||
let _: Foo<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime | ||
let _ = Foo::<{ foo::<T>() }>; //~ ERROR generic parameters may not |
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.
looks like this causes both the github and the vs code code highligher to break, what would be a good way to notify the relevant people here?
I personally don't think that this is 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.
GitHub and Atom use https://github.com/zargony/atom-language-rust. VS Code's Rust syntax is here It would be good to also check how it looks in CodeMirror.
f1e456f
to
4ff95f7
Compare
// 'pub trait Trait<const N: usize>' | ||
// @has - '//*[@id="impl-Trait%3C1_usize%3E-for-u8"]//code' 'impl Trait<1_usize> for u8' | ||
// @has - '//*[@id="impl-Trait%3C2_usize%3E-for-u8"]//code' 'impl Trait<2_usize> for u8' | ||
// @has - '//*[@id="impl-Trait%3CN%3E-for-%5Bu8%3B%20N%5D"]//code' \ |
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.
😢 rustdoc really needs a better naming scheme for impls
// 'pub fn concrete() -> [u8; 22]' | ||
pub fn concrete() -> [u8; 3 + std::mem::size_of::<u64>() << 1] { |
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.
Wow, this is great!
76c103a
to
0e25fbd
Compare
loop {} | ||
} | ||
|
||
/// Document all the functions |
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.
0e25fbd
to
a9eacf3
Compare
Thanks, these look great. @bors r+ rollup |
📌 Commit a9eacf3 has been approved by |
extend const generics test suite should implement most of rust-lang#78433, especially all parts of [the hackmd](https://hackmd.io/WnFmN4MjRCqAjGmYfYcu2A?view) which I did not explicitly mention in that issue. r? `@varkor`
…laumeGomez Rollup of 5 pull requests Successful merges: - rust-lang#78916 (extend const generics test suite) - rust-lang#78921 (Improve the page title switch handling between search and doc) - rust-lang#78933 (Don't print thread ids and names in `tracing` logs) - rust-lang#78960 (Test default values for const parameters.) - rust-lang#78971 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
should implement most of #78433, especially all parts of the hackmd which I did not explicitly mention in that issue.
r? @varkor