-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use impl substs in #[rustc_on_unimplemented]
#94689
Merged
bors
merged 2 commits into
rust-lang:master
from
compiler-errors:on-unimplemented-substs
Mar 9, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![feature(const_trait_impl, const_mut_refs)] | ||
|
||
struct Foo<'a> { | ||
bar: &'a mut Vec<usize>, | ||
} | ||
|
||
impl<'a> Foo<'a> { | ||
const fn spam(&mut self, baz: &mut Vec<u32>) { | ||
self.bar[0] = baz.len(); | ||
//~^ ERROR cannot call non-const fn `Vec::<u32>::len` in constant functions | ||
//~| ERROR the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied | ||
//~| ERROR cannot call non-const operator in constant functions | ||
} | ||
} | ||
|
||
fn main() {} |
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[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions | ||
--> $DIR/issue-94675.rs:9:27 | ||
| | ||
LL | self.bar[0] = baz.len(); | ||
| ^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied | ||
--> $DIR/issue-94675.rs:9:9 | ||
| | ||
LL | self.bar[0] = baz.len(); | ||
| ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` | ||
| | ||
= help: the trait `~const IndexMut<usize>` is not implemented for `Vec<usize>` | ||
note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that implementation is not `const` | ||
--> $DIR/issue-94675.rs:9:9 | ||
| | ||
LL | self.bar[0] = baz.len(); | ||
| ^^^^^^^^^^^ | ||
|
||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/issue-94675.rs:9:9 | ||
| | ||
LL | self.bar[0] = baz.len(); | ||
| ^^^^^^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | ||
| | ||
LL | impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0015, E0277. | ||
For more information about an error, try `rustc --explain E0015`. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:12:24 | ||
thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:13:24 | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:14:7 | ||
thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:15:7 |
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,15 @@ | ||
#![feature(rustc_attrs)] | ||
|
||
trait Foo<A> { | ||
fn foo(self); | ||
} | ||
|
||
#[rustc_on_unimplemented = "an impl did not match: {A} {B} {C}"] | ||
impl<A, B, C> Foo<A> for (A, B, C) { | ||
fn foo(self) {} | ||
} | ||
|
||
fn main() { | ||
Foo::<usize>::foo((1i32, 1i32, 1i32)); | ||
//~^ ERROR the trait bound `(i32, i32, i32): Foo<usize>` is not satisfied | ||
} |
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,13 @@ | ||
error[E0277]: the trait bound `(i32, i32, i32): Foo<usize>` is not satisfied | ||
--> $DIR/impl-substs.rs:13:23 | ||
| | ||
LL | Foo::<usize>::foo((1i32, 1i32, 1i32)); | ||
| ----------------- ^^^^^^^^^^^^^^^^^^ an impl did not match: usize _ _ | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Foo<usize>` is not implemented for `(i32, i32, i32)` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by so I don't keep accidentally changing the output of
issue-87707.run.stderr
because my environment hasRUST_BACKTRACE=full
by default.