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#124080 - oli-obk:define_opaque_types10, r=c…
…ompiler-errors Some unstable changes to where opaque types get defined None of these can be reached from stable afaict. r? ``@compiler-errors`` cc rust-lang#116652
- Loading branch information
Showing
35 changed files
with
364 additions
and
122 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
12 changes: 3 additions & 9 deletions
12
tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.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 |
---|---|---|
@@ -1,15 +1,9 @@ | ||
error[E0277]: can't compare `Bar` with `(Foo, i32)` | ||
error[E0275]: overflow evaluating the requirement `Bar: PartialEq<(Foo, i32)>` | ||
--> $DIR/recursive-type-alias-impl-trait-declaration.rs:13:13 | ||
| | ||
LL | fn foo() -> Foo { | ||
| ^^^ no implementation for `Bar == (Foo, i32)` | ||
LL | | ||
LL | Bar | ||
| --- return type was inferred to be `Bar` here | ||
| | ||
= help: the trait `PartialEq<(Foo, i32)>` is not implemented for `Bar` | ||
= help: the trait `PartialEq<(Bar, i32)>` is implemented for `Bar` | ||
| ^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. | ||
For more information about this error, try `rustc --explain E0275`. |
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,14 @@ | ||
//! Test that we do not allow unsizing `Foo<[Opaque; N]>` to `Foo<[Concrete]>`. | ||
struct Foo<T: ?Sized>(T); | ||
|
||
fn hello() -> Foo<[impl Sized; 2]> { | ||
if false { | ||
let x = hello(); | ||
let _: &Foo<[i32]> = &x; | ||
//~^ ERROR: mismatched types | ||
} | ||
todo!() | ||
} | ||
|
||
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,17 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/unsize_adt.rs:8:30 | ||
| | ||
LL | fn hello() -> Foo<[impl Sized; 2]> { | ||
| ---------- the found opaque type | ||
... | ||
LL | let _: &Foo<[i32]> = &x; | ||
| ----------- ^^ expected `&Foo<[i32]>`, found `&Foo<[impl Sized; 2]>` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected reference `&Foo<[i32]>` | ||
found reference `&Foo<[impl Sized; 2]>` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,12 @@ | ||
//! Test that we do not allow unsizing `[Opaque; N]` to `[Concrete]`. | ||
fn hello() -> [impl Sized; 2] { | ||
if false { | ||
let x = hello(); | ||
let _: &[i32] = &x; | ||
//~^ ERROR: mismatched types | ||
} | ||
todo!() | ||
} | ||
|
||
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,17 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/unsize_slice.rs:6:25 | ||
| | ||
LL | fn hello() -> [impl Sized; 2] { | ||
| ---------- the found opaque type | ||
... | ||
LL | let _: &[i32] = &x; | ||
| ------ ^^ expected `&[i32]`, found `&[impl Sized; 2]` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected reference `&[i32]` | ||
found reference `&[impl Sized; 2]` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,14 @@ | ||
//! Test that we do not allow unsizing `([Opaque; N],)` to `([Concrete],)`. | ||
#![feature(unsized_tuple_coercion)] | ||
|
||
fn hello() -> ([impl Sized; 2],) { | ||
if false { | ||
let x = hello(); | ||
let _: &([i32],) = &x; | ||
//~^ ERROR: mismatched types | ||
} | ||
todo!() | ||
} | ||
|
||
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,17 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/unsize_tuple.rs:8:28 | ||
| | ||
LL | fn hello() -> ([impl Sized; 2],) { | ||
| ---------- the found opaque type | ||
... | ||
LL | let _: &([i32],) = &x; | ||
| --------- ^^ expected `&([i32],)`, found `&([impl Sized; 2],)` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected reference `&([i32],)` | ||
found reference `&([impl Sized; 2],)` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
28 changes: 28 additions & 0 deletions
28
tests/ui/traits/trait-upcasting/illegal-upcast-to-impl-opaque.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,28 @@ | ||
//@ revisions: current next | ||
//@[next] compile-flags: -Znext-solver | ||
//@[next] failure-status: 101 | ||
//@[next] known-bug: unknown | ||
//@[next] normalize-stderr-test "note: .*\n\n" -> "" | ||
//@[next] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> "" | ||
//@[next] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " | ||
//@[next] normalize-stderr-test "delayed at .*" -> "" | ||
//@[next] rustc-env:RUST_BACKTRACE=0 | ||
//@ check-pass | ||
|
||
#![feature(trait_upcasting)] | ||
|
||
trait Super { | ||
type Assoc; | ||
} | ||
|
||
trait Sub: Super {} | ||
|
||
impl<T: ?Sized> Super for T { | ||
type Assoc = i32; | ||
} | ||
|
||
fn illegal(x: &dyn Sub<Assoc = i32>) -> &dyn Super<Assoc = impl Sized> { | ||
x | ||
} | ||
|
||
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
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
22 changes: 22 additions & 0 deletions
22
tests/ui/traits/trait-upcasting/type-checking-test-opaques.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,22 @@ | ||
#![feature(trait_upcasting, type_alias_impl_trait)] | ||
|
||
//@ check-pass | ||
|
||
type Tait = impl Sized; | ||
|
||
trait Foo<'a>: Bar<'a, 'a, Tait> {} | ||
trait Bar<'a, 'b, T> {} | ||
|
||
fn test_correct(x: &dyn Foo<'static>) { | ||
let _ = x as &dyn Bar<'static, 'static, Tait>; | ||
} | ||
|
||
fn test_correct2<'a>(x: &dyn Foo<'a>) { | ||
let _ = x as &dyn Bar<'_, '_, Tait>; | ||
} | ||
|
||
fn test_correct3<'a>(x: &dyn Foo<'a>, _: Tait) { | ||
let _ = x as &dyn Bar<'_, '_, ()>; | ||
} | ||
|
||
fn main() {} |
17 changes: 0 additions & 17 deletions
17
tests/ui/traits/trait-upcasting/upcast-defining-opaque.current.stderr
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.