forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#121620 - nnethercote:fix-even-more-121208-f…
…allout, r=lcnr Fix more rust-lang#121208 fallout (round 3) rust-lang#121208 converted lots of delayed bugs to bugs. Unsurprisingly, there were a few invalid conversion found via fuzzing. r? `@lcnr`
- Loading branch information
Showing
6 changed files
with
113 additions
and
2 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
20 changes: 20 additions & 0 deletions
20
tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.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,20 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(non_lifetime_binders)] | ||
|
||
trait Foo: for<T> Bar<T> {} | ||
|
||
trait Bar<T: ?Sized> { | ||
fn method(&self) {} | ||
} | ||
|
||
struct Type2; | ||
fn needs_bar(_: *mut Type2) {} | ||
|
||
fn main() { | ||
let x: &dyn Foo = &(); | ||
//~^ ERROR the trait `Foo` cannot be made into an object | ||
//~| ERROR the trait `Foo` cannot be made into an object | ||
|
||
needs_bar(x); | ||
//~^ ERROR mismatched types | ||
} |
49 changes: 49 additions & 0 deletions
49
tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.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,49 @@ | ||
error[E0038]: the trait `Foo` cannot be made into an object | ||
--> $DIR/span-bug-issue-121597.rs:14:23 | ||
| | ||
LL | let x: &dyn Foo = &(); | ||
| ^^^ `Foo` cannot be made into an object | ||
| | ||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> | ||
--> $DIR/span-bug-issue-121597.rs:4:12 | ||
| | ||
LL | trait Foo: for<T> Bar<T> {} | ||
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | ||
| | | ||
| this trait cannot be made into an object... | ||
= note: required for the cast from `&()` to `&dyn Foo` | ||
|
||
error[E0038]: the trait `Foo` cannot be made into an object | ||
--> $DIR/span-bug-issue-121597.rs:14:12 | ||
| | ||
LL | let x: &dyn Foo = &(); | ||
| ^^^^^^^^ `Foo` cannot be made into an object | ||
| | ||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> | ||
--> $DIR/span-bug-issue-121597.rs:4:12 | ||
| | ||
LL | trait Foo: for<T> Bar<T> {} | ||
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | ||
| | | ||
| this trait cannot be made into an object... | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/span-bug-issue-121597.rs:18:15 | ||
| | ||
LL | needs_bar(x); | ||
| --------- ^ types differ in mutability | ||
| | | ||
| arguments to this function are incorrect | ||
| | ||
= note: expected raw pointer `*mut Type2` | ||
found reference `&dyn Foo` | ||
note: function defined here | ||
--> $DIR/span-bug-issue-121597.rs:11:4 | ||
| | ||
LL | fn needs_bar(_: *mut Type2) {} | ||
| ^^^^^^^^^ ------------- | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0038, E0308. | ||
For more information about an error, try `rustc --explain E0038`. |
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 @@ | ||
//@ edition:2018 | ||
|
||
#![feature(allocator_api)] | ||
struct Struct; | ||
impl Struct { | ||
async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 { | ||
//~^ ERROR the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied | ||
//~| ERROR Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without | ||
&1 | ||
} | ||
} | ||
|
||
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,28 @@ | ||
error[E0277]: the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied | ||
--> $DIR/could-not-resolve-issue-121503.rs:6:5 | ||
| | ||
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Allocator` is not implemented for `impl FnMut(&mut Self)` | ||
| | ||
note: required by a bound in `Box` | ||
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL | ||
help: consider further restricting this bound | ||
| | ||
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self) + std::alloc::Allocator>) -> &u32 { | ||
| +++++++++++++++++++++++ | ||
|
||
error[E0658]: `Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without the `arbitrary_self_types` feature | ||
--> $DIR/could-not-resolve-issue-121503.rs:6:35 | ||
| | ||
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information | ||
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0658. | ||
For more information about an error, try `rustc --explain E0277`. |