forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#115467 - compiler-errors:assoc-ty-object-safe…
…ty, r=oli-obk Do not require associated types with Self: Sized to uphold bounds when confirming object candidate RPITITs and associated types that have `Self: Sized` bounds are opted out of the `dyn Trait` well-formedness check that happens during confirmation. This ensures that we can actually *use* `dyn Trait`s that have associated types that, e.g., have GATs and RPITITs and other naughty things as long as those are opted-out of object safety via a `Self: Sized` bound. Fixes rust-lang#115464 This seems like a natural part of rust-lang#112319 (comment), and I don't think needs re-litigation. r? `@oli-obk`
- Loading branch information
Showing
7 changed files
with
68 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// check-pass | ||
// revisions: current next | ||
//[next] compile-flags: -Ztrait-solver=next | ||
|
||
#![feature(return_position_impl_trait_in_trait)] | ||
|
||
fn main() { | ||
let vec: Vec<Box<dyn Trait>> = Vec::new(); | ||
|
||
for i in vec { | ||
i.fn_2(); | ||
} | ||
} | ||
|
||
trait OtherTrait {} | ||
|
||
trait Trait { | ||
fn fn_1(&self) -> impl OtherTrait | ||
where | ||
Self: Sized; | ||
|
||
fn fn_2(&self) -> bool; | ||
} |
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,25 @@ | ||
// check-pass | ||
// revisions: current next | ||
//[next] compile-flags: -Ztrait-solver=next | ||
|
||
trait Foo { | ||
type Bar<'a> | ||
where | ||
Self: Sized; | ||
|
||
fn test(&self); | ||
} | ||
|
||
impl Foo for () { | ||
type Bar<'a> = () where Self: Sized; | ||
|
||
fn test(&self) {} | ||
} | ||
|
||
fn test(x: &dyn Foo) { | ||
x.test(); | ||
} | ||
|
||
fn main() { | ||
test(&()); | ||
} |