-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add #[rustc_legacy_const_generics] #82447
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d87eec1
Add #[rustc_legacy_const_generics]
Amanieu e604d01
Move tests to subdirectory
Amanieu 69cde44
TODO -> FIXME
Amanieu 00eca69
Properly reject non-const arguments
Amanieu 2451f12
Address review comments
Amanieu cccd779
Fix tests
Amanieu 22184a0
Add a cache for rustc_legacy_const_generics
Amanieu 00afbe7
Improve checking for attribute
Amanieu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#![feature(rustc_attrs)] | ||
|
||
#[rustc_legacy_const_generics(1)] | ||
pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] { | ||
[x, Y, z] | ||
} | ||
Amanieu marked this conversation as resolved.
Show resolved
Hide resolved
|
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#![feature(rustc_attrs)] | ||
|
||
#[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] must have one index for | ||
fn foo1() {} | ||
|
||
#[rustc_legacy_const_generics(1)] //~ ERROR index exceeds number of arguments | ||
fn foo2<const X: usize>() {} | ||
|
||
#[rustc_legacy_const_generics(2)] //~ ERROR index exceeds number of arguments | ||
fn foo3<const X: usize>(_: u8) {} | ||
|
||
#[rustc_legacy_const_generics(a)] //~ ERROR arguments should be non-negative integers | ||
fn foo4<const X: usize>() {} | ||
|
||
#[rustc_legacy_const_generics(1, a, 2, b)] //~ ERROR arguments should be non-negative integers | ||
fn foo5<const X: usize, const Y: usize, const Z: usize, const W: usize>() {} | ||
|
||
#[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function | ||
struct S; | ||
|
||
#[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes | ||
fn foo6<const X: usize>() {} | ||
|
||
extern { | ||
#[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function | ||
fn foo7<const X: usize>(); //~ ERROR foreign items may not have const parameters | ||
} | ||
|
||
#[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have | ||
fn foo8<X>() {} | ||
|
||
#[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute | ||
fn bar1() {} | ||
|
||
#[rustc_legacy_const_generics = 1] //~ ERROR malformed `rustc_legacy_const_generics` attribute | ||
fn bar2() {} | ||
|
||
fn main() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.