-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pattern types: Prohibit generic args on const params
- Loading branch information
Showing
6 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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
10 changes: 10 additions & 0 deletions
10
tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs
This file contains 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,10 @@ | ||
#![feature(pattern_types, core_pattern_type)] | ||
#![allow(internal_features)] | ||
|
||
type Pat<const START: u32, const END: u32> = | ||
std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); | ||
//~^ ERROR type and const arguments are not allowed on const parameter `START` | ||
//~| ERROR type arguments are not allowed on const parameter `END` | ||
//~| ERROR associated type bindings are not allowed here | ||
|
||
fn main() {} |
38 changes: 38 additions & 0 deletions
38
tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr
This file contains 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 @@ | ||
error[E0109]: type and const arguments are not allowed on const parameter `START` | ||
--> $DIR/bad_const_generics_args_on_const_param.rs:5:44 | ||
| | ||
LL | std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); | ||
| ----- ^^ ^^^ ^ type and const arguments not allowed | ||
| | | ||
| not allowed on const parameter `START` | ||
| | ||
note: const parameter `START` defined here | ||
--> $DIR/bad_const_generics_args_on_const_param.rs:4:16 | ||
| | ||
LL | type Pat<const START: u32, const END: u32> = | ||
| ^^^^^ | ||
|
||
error[E0109]: type arguments are not allowed on const parameter `END` | ||
--> $DIR/bad_const_generics_args_on_const_param.rs:5:64 | ||
| | ||
LL | std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); | ||
| --- ^ type argument not allowed | ||
| | | ||
| not allowed on const parameter `END` | ||
| | ||
note: const parameter `END` defined here | ||
--> $DIR/bad_const_generics_args_on_const_param.rs:4:34 | ||
| | ||
LL | type Pat<const START: u32, const END: u32> = | ||
| ^^^ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/bad_const_generics_args_on_const_param.rs:5:67 | ||
| | ||
LL | std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); | ||
| ^^^^^^^^^^ associated type not allowed here | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0109, E0229. | ||
For more information about an error, try `rustc --explain E0109`. |
This file contains 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