-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autotrait bounds on dyn-safe trait methods
- Loading branch information
Showing
4 changed files
with
102 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// check-fail | ||
|
||
#![feature(auto_traits)] | ||
#![deny(where_clauses_object_safety)] | ||
|
||
auto trait AutoTrait {} | ||
|
||
trait Trait { | ||
fn static_lifetime_bound(&self) where Self: 'static {} | ||
|
||
fn arg_lifetime_bound<'a>(&self, _arg: &'a ()) where Self: 'a {} | ||
|
||
fn autotrait_bound(&self) where Self: AutoTrait {} | ||
} | ||
|
||
impl Trait for () {} | ||
|
||
fn main() { | ||
let trait_object = &() as &dyn Trait; | ||
trait_object.static_lifetime_bound(); | ||
trait_object.arg_lifetime_bound(&()); | ||
trait_object.autotrait_bound(); //~ ERROR: the trait bound `dyn Trait: AutoTrait` is not satisfied | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/ui/where-clauses/self-in-where-clause-allowed.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,15 @@ | ||
error[E0277]: the trait bound `dyn Trait: AutoTrait` is not satisfied | ||
--> $DIR/self-in-where-clause-allowed.rs:22:18 | ||
| | ||
LL | trait_object.autotrait_bound(); | ||
| ^^^^^^^^^^^^^^^ the trait `AutoTrait` is not implemented for `dyn Trait` | ||
| | ||
note: required by a bound in `Trait::autotrait_bound` | ||
--> $DIR/self-in-where-clause-allowed.rs:13:43 | ||
| | ||
LL | fn autotrait_bound(&self) where Self: AutoTrait {} | ||
| ^^^^^^^^^ required by this bound in `Trait::autotrait_bound` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |