Skip to content

Commit 105fc5c

Browse files
committed
Auto merge of rust-lang#126453 - cuviper:beta-next, r=cuviper
[beta] backports and stage0 bump - Bump stage0 to 1.79.0 - Do not define opaque types when selecting impls rust-lang#126258 - Remove failing GUI test to stop blocking CI until it is fixed rust-lang#126445 r? cuviper
2 parents 544e5fb + b78497c commit 105fc5c

24 files changed

+472
-569
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
25632563
let InferOk { obligations, .. } = self
25642564
.infcx
25652565
.at(&cause, obligation.param_env)
2566-
.eq(DefineOpaqueTypes::Yes, placeholder_obligation_trait_ref, impl_trait_ref)
2566+
.eq(DefineOpaqueTypes::No, placeholder_obligation_trait_ref, impl_trait_ref)
25672567
.map_err(|e| {
25682568
debug!("match_impl: failed eq_trait_refs due to `{}`", e.to_string(self.tcx()))
25692569
})?;

src/stage0

+332-430
Large diffs are not rendered by default.

tests/rustdoc-gui/help-page.goml

-69
This file was deleted.

tests/ui/impl-trait/equality.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn sum_to(n: u32) -> impl Foo {
2222
0
2323
} else {
2424
n + sum_to(n - 1)
25-
//~^ ERROR cannot satisfy `<u32 as Add<impl Foo>>::Output == i32`
25+
//~^ ERROR cannot add `impl Foo` to `u32`
2626
}
2727
}
2828

@@ -32,15 +32,12 @@ trait Leak: Sized {
3232
}
3333
impl<T> Leak for T {
3434
default type T = ();
35-
default fn leak(self) -> Self::T {
36-
panic!()
37-
}
35+
default fn leak(self) -> Self::T { panic!() }
3836
}
3937
impl Leak for i32 {
4038
type T = i32;
41-
fn leak(self) -> i32 {
42-
self
43-
}
39+
fn leak(self) -> i32 { self }
4440
}
4541

46-
fn main() {}
42+
fn main() {
43+
}

tests/ui/impl-trait/equality.stderr

+11-4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@ help: change the type of the numeric literal from `u32` to `i32`
2222
LL | 0_i32
2323
| ~~~
2424

25-
error[E0284]: type annotations needed: cannot satisfy `<u32 as Add<impl Foo>>::Output == i32`
25+
error[E0277]: cannot add `impl Foo` to `u32`
2626
--> $DIR/equality.rs:24:11
2727
|
2828
LL | n + sum_to(n - 1)
29-
| ^ cannot satisfy `<u32 as Add<impl Foo>>::Output == i32`
29+
| ^ no implementation for `u32 + impl Foo`
30+
|
31+
= help: the trait `Add<impl Foo>` is not implemented for `u32`
32+
= help: the following other types implement trait `Add<Rhs>`:
33+
<&'a u32 as Add<u32>>
34+
<&u32 as Add<&u32>>
35+
<u32 as Add<&u32>>
36+
<u32 as Add>
3037

3138
error: aborting due to 2 previous errors; 1 warning emitted
3239

33-
Some errors have detailed explanations: E0284, E0308.
34-
For more information about an error, try `rustc --explain E0284`.
40+
Some errors have detailed explanations: E0277, E0308.
41+
For more information about an error, try `rustc --explain E0277`.

tests/ui/impl-trait/nested_impl_trait.stderr

+6-10
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,19 @@ error[E0277]: the trait bound `impl Into<u32>: Into<impl Debug>` is not satisfie
4646
--> $DIR/nested_impl_trait.rs:6:46
4747
|
4848
LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
49-
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `impl Into<u32>`
49+
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Into<u32>`, which is required by `impl Into<u32>: Into<impl Debug>`
5050
|
51-
help: consider further restricting this bound
52-
|
53-
LL | fn bad_in_ret_position(x: impl Into<u32> + std::fmt::Debug) -> impl Into<impl Debug> { x }
54-
| +++++++++++++++++
51+
= help: the trait `Into<U>` is implemented for `T`
52+
= note: required for `impl Into<u32>` to implement `Into<impl Debug>`
5553

5654
error[E0277]: the trait bound `impl Into<u32>: Into<impl Debug>` is not satisfied
5755
--> $DIR/nested_impl_trait.rs:19:34
5856
|
5957
LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
60-
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `impl Into<u32>`
61-
|
62-
help: consider further restricting this bound
58+
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Into<u32>`, which is required by `impl Into<u32>: Into<impl Debug>`
6359
|
64-
LL | fn bad(x: impl Into<u32> + std::fmt::Debug) -> impl Into<impl Debug> { x }
65-
| +++++++++++++++++
60+
= help: the trait `Into<U>` is implemented for `T`
61+
= note: required for `impl Into<u32>` to implement `Into<impl Debug>`
6662

6763
error: aborting due to 7 previous errors
6864

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/recursive-bound-eval.rs:20:13
3+
|
4+
LL | move || recursive_fn().parse()
5+
| ^^^^^^^^^^^^^^ cannot infer type
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0282`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! Test that we can evaluate nested obligations when invoking methods on recursive calls on
2+
//! an RPIT.
3+
4+
//@revisions: next current
5+
//@[next] compile-flags: -Znext-solver
6+
7+
//@[current] check-pass
8+
9+
pub trait Parser<E> {
10+
fn parse(&self) -> E;
11+
}
12+
13+
impl<E, T: Fn() -> E> Parser<E> for T {
14+
fn parse(&self) -> E {
15+
self()
16+
}
17+
}
18+
19+
pub fn recursive_fn<E>() -> impl Parser<E> {
20+
move || recursive_fn().parse()
21+
//[next]~^ ERROR: type annotations needed
22+
}
23+
24+
fn main() {}

tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl PartialEq<(Bar, i32)> for Bar {
1111
}
1212

1313
fn foo() -> Foo {
14-
//~^ ERROR overflow evaluating the requirement `Bar: PartialEq<(Foo, i32)>`
14+
//~^ ERROR can't compare `Bar` with `(Foo, i32)`
1515
Bar
1616
}
1717

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
error[E0275]: overflow evaluating the requirement `Bar: PartialEq<(Foo, i32)>`
1+
error[E0277]: can't compare `Bar` with `(Foo, i32)`
22
--> $DIR/recursive-type-alias-impl-trait-declaration.rs:13:13
33
|
44
LL | fn foo() -> Foo {
5-
| ^^^
5+
| ^^^ no implementation for `Bar == (Foo, i32)`
6+
LL |
7+
LL | Bar
8+
| --- return type was inferred to be `Bar` here
9+
|
10+
= help: the trait `PartialEq<(Foo, i32)>` is not implemented for `Bar`
11+
= help: the trait `PartialEq<(Bar, i32)>` is implemented for `Bar`
612

713
error: aborting due to 1 previous error
814

9-
For more information about this error, try `rustc --explain E0275`.
15+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0277]: the trait bound `Foo: Trait<Bar>` is not satisfied
2+
--> $DIR/constrain_in_projection.rs:24:14
3+
|
4+
LL | let x = <Foo as Trait<Bar>>::Assoc::default();
5+
| ^^^ the trait `Trait<Bar>` is not implemented for `Foo`
6+
|
7+
= help: the trait `Trait<()>` is implemented for `Foo`
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0277`.

tests/ui/type-alias-impl-trait/constrain_in_projection.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@ revisions: current next
55
//@ ignore-compare-mode-next-solver (explicit revisions)
66
//@[next] compile-flags: -Znext-solver
7-
//@check-pass
7+
//@[next]check-pass
88

99
#![feature(type_alias_impl_trait)]
1010

@@ -22,6 +22,7 @@ impl Trait<()> for Foo {
2222

2323
fn bop(_: Bar) {
2424
let x = <Foo as Trait<Bar>>::Assoc::default();
25+
//[current]~^ `Foo: Trait<Bar>` is not satisfied
2526
}
2627

2728
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
error[E0283]: type annotations needed: cannot satisfy `Foo: Trait<Bar>`
1+
error[E0277]: the trait bound `Foo: Trait<Bar>` is not satisfied
22
--> $DIR/constrain_in_projection2.rs:27:14
33
|
44
LL | let x = <Foo as Trait<Bar>>::Assoc::default();
5-
| ^^^ help: use the fully qualified path to an implementation: `<Type as Trait>::Assoc`
5+
| ^^^ the trait `Trait<Bar>` is not implemented for `Foo`
66
|
7-
note: multiple `impl`s satisfying `Foo: Trait<Bar>` found
8-
--> $DIR/constrain_in_projection2.rs:18:1
9-
|
10-
LL | impl Trait<()> for Foo {
11-
| ^^^^^^^^^^^^^^^^^^^^^^
12-
...
13-
LL | impl Trait<u32> for Foo {
14-
| ^^^^^^^^^^^^^^^^^^^^^^^
15-
= note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
7+
= help: the following other types implement trait `Trait<T>`:
8+
<Foo as Trait<()>>
9+
<Foo as Trait<u32>>
1610

1711
error: aborting due to 1 previous error
1812

19-
For more information about this error, try `rustc --explain E0283`.
13+
For more information about this error, try `rustc --explain E0277`.

tests/ui/type-alias-impl-trait/constrain_in_projection2.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ impl Trait<u32> for Foo {
2525

2626
fn bop(_: Bar) {
2727
let x = <Foo as Trait<Bar>>::Assoc::default();
28-
//~^ ERROR: cannot satisfy `Foo: Trait<Bar>`
28+
//[next]~^ ERROR: cannot satisfy `Foo: Trait<Bar>`
29+
//[current]~^^ ERROR: `Foo: Trait<Bar>` is not satisfied
2930
}
3031

3132
fn main() {}

tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait Trait<T, In> {
2020
impl<In, Out> Trait<Bar, In> for Out {
2121
type Out = Out;
2222
fn convert(_i: In) -> Self::Out {
23-
//[next]~^ ERROR: type annotations needed
23+
//[next]~^ ERROR: cannot satisfy `<Out as Trait<Bar, In>>::Out == ()`
2424
unreachable!();
2525
}
2626
}

tests/ui/type-alias-impl-trait/nested-tait-inference.stderr renamed to tests/ui/type-alias-impl-trait/nested-tait-inference.current.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied
2-
--> $DIR/nested-tait-inference.rs:12:13
2+
--> $DIR/nested-tait-inference.rs:17:13
33
|
44
LL | fn foo() -> impl Foo<FooX> {
55
| ^^^^^^^^^^^^^^ the trait `Foo<FooX>` is not implemented for `()`

tests/ui/type-alias-impl-trait/nested-tait-inference.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@ revisions: current next
55
//@ ignore-compare-mode-next-solver (explicit revisions)
66
//@[next] compile-flags: -Znext-solver
7-
//@check-pass
7+
//@[next] check-pass
88

99
use std::fmt::Debug;
1010

@@ -15,6 +15,8 @@ trait Foo<A> {}
1515
impl Foo<()> for () {}
1616

1717
fn foo() -> impl Foo<FooX> {
18+
//[current]~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied
19+
// FIXME(type-alias-impl-trait): We could probably make this work.
1820
()
1921
}
2022

Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
error[E0283]: type annotations needed: cannot satisfy `(): Foo<FooX>`
1+
error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied
22
--> $DIR/nested-tait-inference2.rs:17:13
33
|
44
LL | fn foo() -> impl Foo<FooX> {
5-
| ^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^ the trait `Foo<FooX>` is not implemented for `()`
6+
LL |
7+
LL | ()
8+
| -- return type was inferred to be `()` here
69
|
7-
note: multiple `impl`s satisfying `(): Foo<FooX>` found
8-
--> $DIR/nested-tait-inference2.rs:14:1
9-
|
10-
LL | impl Foo<()> for () {}
11-
| ^^^^^^^^^^^^^^^^^^^
12-
LL | impl Foo<u32> for () {}
13-
| ^^^^^^^^^^^^^^^^^^^^
10+
= help: the following other types implement trait `Foo<A>`:
11+
<() as Foo<()>>
12+
<() as Foo<u32>>
1413

1514
error: aborting due to 1 previous error
1615

17-
For more information about this error, try `rustc --explain E0283`.
16+
For more information about this error, try `rustc --explain E0277`.

tests/ui/type-alias-impl-trait/nested-tait-inference2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl Foo<()> for () {}
1515
impl Foo<u32> for () {}
1616

1717
fn foo() -> impl Foo<FooX> {
18-
//[current]~^ ERROR: cannot satisfy `(): Foo<FooX>`
18+
//[current]~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied
1919
()
2020
//[next]~^ ERROR: cannot satisfy `impl Foo<FooX> == ()`
2121
}

tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr

+13-8
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,21 @@ note: previous use here
2222
LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) }
2323
| ^^^^^^^^^^^^^^^^^
2424

25-
error: concrete type differs from previous defining opaque type use
25+
error[E0308]: mismatched types
2626
--> $DIR/normalize-hidden-types.rs:43:25
2727
|
28+
LL | type Opaque = impl Sized;
29+
| ---------- the expected opaque type
30+
...
2831
LL | let _: Opaque = dyn_hoops::<u8>(0);
29-
| ^^^^^^^^^^^^^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(<u8 as Trait>::Gat<'a>)`
30-
|
31-
note: previous use here
32-
--> $DIR/normalize-hidden-types.rs:44:9
33-
|
34-
LL | None
35-
| ^^^^
32+
| ------ ^^^^^^^^^^^^^^^^^^ expected opaque type, found `*const dyn FnOnce(())`
33+
| |
34+
| expected due to this
35+
|
36+
= note: expected opaque type `typeck::Opaque`
37+
found raw pointer `*const (dyn FnOnce(()) + 'static)`
38+
= help: consider constraining the associated type `<u8 as Trait>::Gat<'_>` to `()` or calling a method that returns `<u8 as Trait>::Gat<'_>`
39+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
3640

3741
error: concrete type differs from previous defining opaque type use
3842
--> $DIR/normalize-hidden-types.rs:52:25
@@ -48,3 +52,4 @@ LL | None
4852

4953
error: aborting due to 4 previous errors
5054

55+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)