Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify alias-relate to also normalize ambiguous opaques #120549

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add revisions
  • Loading branch information
lcnr committed Feb 13, 2024
commit e5541cf895fc3b59f627faa6226fbd99ad5e2ed3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: can't compare `i32` with `Foo`
--> $DIR/self-referential-2.rs:6:13
--> $DIR/self-referential-2.rs:9:13
|
LL | fn bar() -> Bar {
| ^^^ no implementation for `i32 == Foo`
Expand Down
5 changes: 4 additions & 1 deletion tests/ui/type-alias-impl-trait/self-referential-2.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// revisions: current next
//[next] compile-flags: -Znext-solver
//[next] check-pass
#![feature(type_alias_impl_trait)]

type Foo = impl std::fmt::Debug;
type Bar = impl PartialEq<Foo>;

fn bar() -> Bar {
42_i32 //~^ ERROR can't compare `i32` with `Foo`
42_i32 //[current]~^ ERROR can't compare `i32` with `Foo`
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0284]: type annotations needed: cannot satisfy `Foo == _`
--> $DIR/type-alias-impl-trait-tuple.rs:21:24
|
LL | Blah { my_foo: make_foo(), my_u8: 12 }
| ^^^^^^^^^^ cannot satisfy `Foo == _`

error[E0282]: type annotations needed
--> $DIR/type-alias-impl-trait-tuple.rs:24:28
|
LL | fn into_inner(self) -> (Foo, u8, Foo) {
| ^^^^^^^^^^^^^^ cannot infer type for tuple `(Foo, u8, Foo)`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0282, E0284.
For more information about an error, try `rustc --explain E0282`.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// check-pass
// revisions: current next
//[next] compile-flags: -Znext-solver
//[current] check-pass

#![feature(type_alias_impl_trait)]
#![allow(dead_code)]
Expand All @@ -17,8 +19,10 @@ struct Blah {
impl Blah {
fn new() -> Blah {
Blah { my_foo: make_foo(), my_u8: 12 }
//[next]~^ ERROR type annotations needed: cannot satisfy `Foo == _`
}
fn into_inner(self) -> (Foo, u8, Foo) {
//[next]~^ ERROR type annotations needed
(self.my_foo, self.my_u8, make_foo())
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0382]: use of moved value: `x`
--> $DIR/type_of_a_let.rs:16:16
--> $DIR/type_of_a_let.rs:20:16
|
LL | let x: Foo = 22_u32;
| - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait
Expand All @@ -9,7 +9,7 @@ LL | same_type((x, y));
| ^ value used here after move

error[E0382]: use of moved value: `y`
--> $DIR/type_of_a_let.rs:17:6
--> $DIR/type_of_a_let.rs:21:6
|
LL | let y: Foo = x;
| - move occurs because `y` has type `Foo`, which does not implement the `Copy` trait
Expand Down
8 changes: 6 additions & 2 deletions tests/ui/type-alias-impl-trait/type_of_a_let.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: current next
//[next] compile-flags: -Znext-solver
//[next] check-pass

#![feature(type_alias_impl_trait)]
#![allow(dead_code)]

Expand All @@ -13,8 +17,8 @@ fn foo1() -> (u32, Foo) {
fn foo2() -> (u32, Foo) {
let x: Foo = 22_u32;
let y: Foo = x;
same_type((x, y)); //~ ERROR use of moved value
(y, todo!()) //~ ERROR use of moved value
same_type((x, y)); //[current]~ ERROR use of moved value
(y, todo!()) //[current]~ ERROR use of moved value
}

fn same_type<T>(x: (T, T)) {}
Expand Down