forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#121281 - kadiwa4:test_103626, r=estebank,lcnr
regression test for rust-lang#103626 I don't know what a descriptive filename for this would be. Fixes rust-lang#103626
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.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,15 @@ | ||
trait FromResidual<R = <Self as Try>::Residual> { | ||
fn from_residual(residual: R) -> Self; | ||
} | ||
|
||
trait Try { | ||
type Residual; | ||
} | ||
|
||
fn w<'a, T: 'a, F: Fn(&'a T)>() { | ||
let b: &dyn FromResidual = &(); | ||
//~^ ERROR: the trait `FromResidual` cannot be made into an object | ||
//~| ERROR: the trait `FromResidual` cannot be made into an object | ||
} | ||
|
||
fn main() {} |
33 changes: 33 additions & 0 deletions
33
tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.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,33 @@ | ||
error[E0038]: the trait `FromResidual` cannot be made into an object | ||
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:17 | ||
| | ||
LL | let b: &dyn FromResidual = &(); | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: it cannot use `Self` as a type parameter in a supertrait or `where`-clause | ||
|
||
error[E0038]: the trait `FromResidual` cannot be made into an object | ||
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:12 | ||
| | ||
LL | let b: &dyn FromResidual = &(); | ||
| ^^^^^^^^^^^^^^^^^ `FromResidual` 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/canonicalize-fresh-infer-vars-issue-103626.rs:2:8 | ||
| | ||
LL | trait FromResidual<R = <Self as Try>::Residual> { | ||
| ------------ this trait cannot be made into an object... | ||
LL | fn from_residual(residual: R) -> Self; | ||
| ^^^^^^^^^^^^^ ...because associated function `from_residual` has no `self` parameter | ||
help: consider turning `from_residual` into a method by giving it a `&self` argument | ||
| | ||
LL | fn from_residual(&self, residual: R) -> Self; | ||
| ++++++ | ||
help: alternatively, consider constraining `from_residual` so it does not apply to trait objects | ||
| | ||
LL | fn from_residual(residual: R) -> Self where Self: Sized; | ||
| +++++++++++++++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0038`. |