-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #64360 - varkor:foreign-items-diagnostic-const-generics…
…, r=cramertj Correct the polymorphic extern fn error for const parameters Before, any polymorphism on extern functions was assumed to be type polymorphism.
- Loading branch information
Showing
6 changed files
with
65 additions
and
15 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
10 changes: 10 additions & 0 deletions
10
src/test/ui/const-generics/foreign-item-const-parameter.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(const_generics)] | ||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash | ||
|
||
extern "C" { | ||
fn foo<const X: usize>(); //~ ERROR foreign items may not have const parameters | ||
|
||
fn bar<T, const X: usize>(_: T); //~ ERROR foreign items may not have type or const parameters | ||
} | ||
|
||
fn main() {} |
27 changes: 27 additions & 0 deletions
27
src/test/ui/const-generics/foreign-item-const-parameter.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,27 @@ | ||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash | ||
--> $DIR/foreign-item-const-parameter.rs:1:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0044]: foreign items may not have const parameters | ||
--> $DIR/foreign-item-const-parameter.rs:5:5 | ||
| | ||
LL | fn foo<const X: usize>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters | ||
| | ||
= help: replace the const parameters with concrete consts | ||
|
||
error[E0044]: foreign items may not have type or const parameters | ||
--> $DIR/foreign-item-const-parameter.rs:7:5 | ||
| | ||
LL | fn bar<T, const X: usize>(_: T); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters | ||
| | ||
= help: replace the type or const parameters with concrete types or consts | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0044`. |
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