-
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.
Rollup merge of #94689 - compiler-errors:on-unimplemented-substs, r=p…
…etrochenkov Use impl substs in `#[rustc_on_unimplemented]` We were using the trait-ref substs instead of impl substs in `rustc_on_unimplemented`, even when computing the `rustc_on_unimplemented` attached to an impl block. Let's not do that. This PR also untangles impl and trait def-ids in the logic in `on_unimplemented` a bit. Fixes #94675
- Loading branch information
Showing
10 changed files
with
129 additions
and
42 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
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`. |