Skip to content
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

Merged
merged 11 commits into from
Nov 12, 2020
Merged

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Nov 10, 2020

should implement most of #78433, especially all parts of the hackmd which I did not explicitly mention in that issue.

r? @varkor

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 10, 2020
@lcnr lcnr force-pushed the const-generics-tests branch 2 times, most recently from 7bfa78e to cc3bea2 Compare November 10, 2020 08:51
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
Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link

@Zaryob Zaryob left a 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.

@lcnr lcnr marked this pull request as ready for review November 10, 2020 10:59
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
Copy link
Contributor Author

@lcnr lcnr Nov 10, 2020

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.

Copy link
Member

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.

@jyn514 jyn514 added A-const-generics Area: const generics (parameters and arguments) A-testsuite Area: The testsuite used to check the correctness of rustc T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 10, 2020
// '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' \
Copy link
Member

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

Comment on lines +76 to +79
// 'pub fn concrete() -> [u8; 22]'
pub fn concrete() -> [u8; 3 + std::mem::size_of::<u64>() << 1] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is great!

loop {}
}

/// Document all the functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@varkor
Copy link
Member

varkor commented Nov 11, 2020

Thanks, these look great.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 11, 2020

📌 Commit a9eacf3 has been approved by varkor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2020
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 12, 2020
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`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2020
…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
@bors bors merged commit 0cd118d into rust-lang:master Nov 12, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants