-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deny providing explicit effect params
- Loading branch information
Showing
5 changed files
with
126 additions
and
5 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
27 changes: 27 additions & 0 deletions
27
tests/ui/rfcs/rfc-2632-const-trait-impl/effects/no_explicit_const_params.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,27 @@ | ||
#![feature(const_trait_impl, effects)] | ||
|
||
const fn foo() {} | ||
|
||
#[const_trait] | ||
trait Bar { | ||
fn bar(); | ||
} | ||
|
||
impl Bar for () { | ||
fn bar() {} | ||
} | ||
|
||
fn main() { | ||
foo::<true>(); | ||
//~^ ERROR: function takes 0 generic arguments but 1 generic argument was supplied | ||
<() as Bar<true>>::bar(); | ||
//~^ ERROR: trait takes 0 generic arguments but 1 generic argument was supplied | ||
} | ||
|
||
const FOO: () = { | ||
foo::<false>(); | ||
//~^ ERROR: function takes 0 generic arguments but 1 generic argument was supplied | ||
<() as Bar<false>>::bar(); | ||
//~^ ERROR: trait takes 0 generic arguments but 1 generic argument was supplied | ||
//~| ERROR: mismatched types | ||
}; |
69 changes: 69 additions & 0 deletions
69
tests/ui/rfcs/rfc-2632-const-trait-impl/effects/no_explicit_const_params.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,69 @@ | ||
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/no_explicit_const_params.rs:22:5 | ||
| | ||
LL | foo::<false>(); | ||
| ^^^--------- help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: function defined here, with 0 generic parameters | ||
--> $DIR/no_explicit_const_params.rs:3:10 | ||
| | ||
LL | const fn foo() {} | ||
| ^^^ | ||
|
||
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/no_explicit_const_params.rs:24:12 | ||
| | ||
LL | <() as Bar<false>>::bar(); | ||
| ^^^------- help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: trait defined here, with 0 generic parameters | ||
--> $DIR/no_explicit_const_params.rs:6:7 | ||
| | ||
LL | trait Bar { | ||
| ^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/no_explicit_const_params.rs:24:5 | ||
| | ||
LL | <() as Bar<false>>::bar(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `false`, found `true` | ||
| | ||
= note: expected constant `false` | ||
found constant `true` | ||
|
||
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/no_explicit_const_params.rs:15:5 | ||
| | ||
LL | foo::<true>(); | ||
| ^^^-------- help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: function defined here, with 0 generic parameters | ||
--> $DIR/no_explicit_const_params.rs:3:10 | ||
| | ||
LL | const fn foo() {} | ||
| ^^^ | ||
|
||
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/no_explicit_const_params.rs:17:12 | ||
| | ||
LL | <() as Bar<true>>::bar(); | ||
| ^^^------ help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: trait defined here, with 0 generic parameters | ||
--> $DIR/no_explicit_const_params.rs:6:7 | ||
| | ||
LL | trait Bar { | ||
| ^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
Some errors have detailed explanations: E0107, E0308. | ||
For more information about an error, try `rustc --explain E0107`. |