forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#117171 - fee1-dead-contrib:deny-explicit-effe…
…ct-params, r=oli-obk Deny providing explicit effect params r? `@oli-obk` cc rust-lang#110395
- Loading branch information
Showing
8 changed files
with
215 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
12 changes: 12 additions & 0 deletions
12
tests/ui/rfcs/rfc-2632-const-trait-impl/effects/auxiliary/cross-crate.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,12 @@ | ||
#![feature(const_trait_impl, effects)] | ||
|
||
pub const fn foo() {} | ||
|
||
#[const_trait] | ||
pub trait Bar { | ||
fn bar(); | ||
} | ||
|
||
impl Bar for () { | ||
fn bar() {} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/ui/rfcs/rfc-2632-const-trait-impl/effects/no-explicit-const-params-cross-crate.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,18 @@ | ||
// aux-build: cross-crate.rs | ||
extern crate cross_crate; | ||
|
||
use cross_crate::{Bar, foo}; | ||
|
||
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 | ||
}; |
59 changes: 59 additions & 0 deletions
59
tests/ui/rfcs/rfc-2632-const-trait-impl/effects/no-explicit-const-params-cross-crate.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,59 @@ | ||
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/no-explicit-const-params-cross-crate.rs:14:5 | ||
| | ||
LL | foo::<false>(); | ||
| ^^^--------- help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: function defined here, with 0 generic parameters | ||
--> $DIR/auxiliary/cross-crate.rs:3:14 | ||
| | ||
LL | pub const fn foo() {} | ||
| ^^^ | ||
|
||
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/no-explicit-const-params-cross-crate.rs:16:12 | ||
| | ||
LL | <() as Bar<false>>::bar(); | ||
| ^^^------- help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: trait defined here, with 0 generic parameters | ||
--> $DIR/auxiliary/cross-crate.rs:6:11 | ||
| | ||
LL | pub trait Bar { | ||
| ^^^ | ||
|
||
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/no-explicit-const-params-cross-crate.rs:7:5 | ||
| | ||
LL | foo::<true>(); | ||
| ^^^-------- help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: function defined here, with 0 generic parameters | ||
--> $DIR/auxiliary/cross-crate.rs:3:14 | ||
| | ||
LL | pub const fn foo() {} | ||
| ^^^ | ||
|
||
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/no-explicit-const-params-cross-crate.rs:9:12 | ||
| | ||
LL | <() as Bar<true>>::bar(); | ||
| ^^^------ help: remove these generics | ||
| | | ||
| expected 0 generic arguments | ||
| | ||
note: trait defined here, with 0 generic parameters | ||
--> $DIR/auxiliary/cross-crate.rs:6:11 | ||
| | ||
LL | pub trait Bar { | ||
| ^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0107`. |
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`. |