From eebf871feaca10886f80a76a36b3771e960c047e Mon Sep 17 00:00:00 2001 From: lcnr Date: Wed, 24 Sep 2025 10:08:00 +0200 Subject: move tests --- tests/ui/impl-trait/method-resolution.rs | 26 ------------------ tests/ui/impl-trait/method-resolution2.next.stderr | 20 -------------- tests/ui/impl-trait/method-resolution2.rs | 31 ---------------------- .../impl-trait/method-resolution3.current.stderr | 20 -------------- tests/ui/impl-trait/method-resolution3.next.stderr | 20 -------------- tests/ui/impl-trait/method-resolution3.rs | 27 ------------------- tests/ui/impl-trait/method-resolution4.rs | 18 ------------- ...d-resolution5-deref-no-constrain.current.stderr | 19 ------------- .../method-resolution5-deref-no-constrain.rs | 23 ---------------- tests/ui/impl-trait/method-resolution5-deref.rs | 30 --------------------- tests/ui/impl-trait/method/method-resolution.rs | 26 ++++++++++++++++++ .../method/method-resolution2.next.stderr | 20 ++++++++++++++ tests/ui/impl-trait/method/method-resolution2.rs | 31 ++++++++++++++++++++++ .../method/method-resolution3.current.stderr | 20 ++++++++++++++ .../method/method-resolution3.next.stderr | 20 ++++++++++++++ tests/ui/impl-trait/method/method-resolution3.rs | 27 +++++++++++++++++++ tests/ui/impl-trait/method/method-resolution4.rs | 18 +++++++++++++ ...d-resolution5-deref-no-constrain.current.stderr | 19 +++++++++++++ .../method-resolution5-deref-no-constrain.rs | 23 ++++++++++++++++ .../impl-trait/method/method-resolution5-deref.rs | 30 +++++++++++++++++++++ 20 files changed, 234 insertions(+), 234 deletions(-) delete mode 100644 tests/ui/impl-trait/method-resolution.rs delete mode 100644 tests/ui/impl-trait/method-resolution2.next.stderr delete mode 100644 tests/ui/impl-trait/method-resolution2.rs delete mode 100644 tests/ui/impl-trait/method-resolution3.current.stderr delete mode 100644 tests/ui/impl-trait/method-resolution3.next.stderr delete mode 100644 tests/ui/impl-trait/method-resolution3.rs delete mode 100644 tests/ui/impl-trait/method-resolution4.rs delete mode 100644 tests/ui/impl-trait/method-resolution5-deref-no-constrain.current.stderr delete mode 100644 tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs delete mode 100644 tests/ui/impl-trait/method-resolution5-deref.rs create mode 100644 tests/ui/impl-trait/method/method-resolution.rs create mode 100644 tests/ui/impl-trait/method/method-resolution2.next.stderr create mode 100644 tests/ui/impl-trait/method/method-resolution2.rs create mode 100644 tests/ui/impl-trait/method/method-resolution3.current.stderr create mode 100644 tests/ui/impl-trait/method/method-resolution3.next.stderr create mode 100644 tests/ui/impl-trait/method/method-resolution3.rs create mode 100644 tests/ui/impl-trait/method/method-resolution4.rs create mode 100644 tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.current.stderr create mode 100644 tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs create mode 100644 tests/ui/impl-trait/method/method-resolution5-deref.rs diff --git a/tests/ui/impl-trait/method-resolution.rs b/tests/ui/impl-trait/method-resolution.rs deleted file mode 100644 index 60fbacd8646..00000000000 --- a/tests/ui/impl-trait/method-resolution.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! Since there is only one possible `bar` method, we invoke it and subsequently -//! constrain `foo`'s RPIT to `u32`. - -//@ revisions: current next -//@[next] compile-flags: -Znext-solver -//@ check-pass - -trait Trait {} - -impl Trait for u32 {} - -struct Bar(T); - -impl Bar { - fn bar(self) {} -} - -fn foo(x: bool) -> Bar { - if x { - let x = foo(false); - x.bar(); - } - todo!() -} - -fn main() {} diff --git a/tests/ui/impl-trait/method-resolution2.next.stderr b/tests/ui/impl-trait/method-resolution2.next.stderr deleted file mode 100644 index 223430e1658..00000000000 --- a/tests/ui/impl-trait/method-resolution2.next.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0034]: multiple applicable items in scope - --> $DIR/method-resolution2.rs:25:11 - | -LL | x.bar(); - | ^^^ multiple `bar` found - | -note: candidate #1 is defined in an impl for the type `Bar` - --> $DIR/method-resolution2.rs:19:5 - | -LL | fn bar(self) {} - | ^^^^^^^^^^^^ -note: candidate #2 is defined in an impl for the type `Bar` - --> $DIR/method-resolution2.rs:15:5 - | -LL | fn bar(self) {} - | ^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0034`. diff --git a/tests/ui/impl-trait/method-resolution2.rs b/tests/ui/impl-trait/method-resolution2.rs deleted file mode 100644 index 88d4f3d9896..00000000000 --- a/tests/ui/impl-trait/method-resolution2.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! Check that the method call does not constrain the RPIT to `i32`, even though -//! `i32` is the only type that satisfies the RPIT's trait bounds. - -//@ revisions: current next -//@[next] compile-flags: -Znext-solver -//@[current] check-pass - -trait Trait {} - -impl Trait for i32 {} - -struct Bar(T); - -impl Bar { - fn bar(self) {} -} - -impl Bar { - fn bar(self) {} -} - -fn foo(x: bool) -> Bar { - if x { - let x = foo(false); - x.bar(); - //[next]~^ ERROR: multiple applicable items in scope - } - Bar(42_i32) -} - -fn main() {} diff --git a/tests/ui/impl-trait/method-resolution3.current.stderr b/tests/ui/impl-trait/method-resolution3.current.stderr deleted file mode 100644 index 87dd862ef8f..00000000000 --- a/tests/ui/impl-trait/method-resolution3.current.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0034]: multiple applicable items in scope - --> $DIR/method-resolution3.rs:21:11 - | -LL | x.bar(); - | ^^^ multiple `bar` found - | -note: candidate #1 is defined in an impl for the type `Bar` - --> $DIR/method-resolution3.rs:15:5 - | -LL | fn bar(self) {} - | ^^^^^^^^^^^^ -note: candidate #2 is defined in an impl for the type `Bar` - --> $DIR/method-resolution3.rs:11:5 - | -LL | fn bar(self) {} - | ^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0034`. diff --git a/tests/ui/impl-trait/method-resolution3.next.stderr b/tests/ui/impl-trait/method-resolution3.next.stderr deleted file mode 100644 index 87dd862ef8f..00000000000 --- a/tests/ui/impl-trait/method-resolution3.next.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0034]: multiple applicable items in scope - --> $DIR/method-resolution3.rs:21:11 - | -LL | x.bar(); - | ^^^ multiple `bar` found - | -note: candidate #1 is defined in an impl for the type `Bar` - --> $DIR/method-resolution3.rs:15:5 - | -LL | fn bar(self) {} - | ^^^^^^^^^^^^ -note: candidate #2 is defined in an impl for the type `Bar` - --> $DIR/method-resolution3.rs:11:5 - | -LL | fn bar(self) {} - | ^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0034`. diff --git a/tests/ui/impl-trait/method-resolution3.rs b/tests/ui/impl-trait/method-resolution3.rs deleted file mode 100644 index 8c47ef4fc75..00000000000 --- a/tests/ui/impl-trait/method-resolution3.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! Check that we consider `Bar` to successfully unify -//! with both `Bar` and `Bar` (in isolation), so we bail -//! out with ambiguity. - -//@ revisions: current next -//@[next] compile-flags: -Znext-solver - -struct Bar(T); - -impl Bar { - fn bar(self) {} -} - -impl Bar { - fn bar(self) {} -} - -fn foo(x: bool) -> Bar { - if x { - let x = foo(false); - x.bar(); - //~^ ERROR: multiple applicable items in scope - } - todo!() -} - -fn main() {} diff --git a/tests/ui/impl-trait/method-resolution4.rs b/tests/ui/impl-trait/method-resolution4.rs deleted file mode 100644 index f90a9309cda..00000000000 --- a/tests/ui/impl-trait/method-resolution4.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! The recursive method call yields the opaque type. The -//! `next` method call then constrains the hidden type to `&mut _` -//! because `next` takes `&mut self`. We never resolve the inference -//! variable, but get a type mismatch when comparing `&mut _` with -//! `std::iter::Empty`. - -//@ revisions: current next -//@[next] compile-flags: -Znext-solver -//@ check-pass - -fn foo(b: bool) -> impl Iterator { - if b { - foo(false).next().unwrap(); - } - std::iter::empty() -} - -fn main() {} diff --git a/tests/ui/impl-trait/method-resolution5-deref-no-constrain.current.stderr b/tests/ui/impl-trait/method-resolution5-deref-no-constrain.current.stderr deleted file mode 100644 index 08578de426a..00000000000 --- a/tests/ui/impl-trait/method-resolution5-deref-no-constrain.current.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/method-resolution5-deref-no-constrain.rs:20:5 - | -LL | fn via_deref() -> impl Deref { - | --- expected `&Foo` because of return type -... -LL | Box::new(Foo) - | ^^^^^^^^^^^^^ expected `&Foo`, found `Box` - | - = note: expected reference `&Foo` - found struct `Box` -help: consider borrowing here - | -LL | &Box::new(Foo) - | + - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs b/tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs deleted file mode 100644 index 2c41f62b9fd..00000000000 --- a/tests/ui/impl-trait/method-resolution5-deref-no-constrain.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! The recursive method call yields the opaque type. We want -//! to use the impl candidate for `Foo` here without constraining -//! the opaque to `&Foo`. - -//@ revisions: current next -//@[next] compile-flags: -Znext-solver -//@[next] check-pass - -use std::ops::Deref; -struct Foo; -impl Foo { - fn method(&self) {} -} -fn via_deref() -> impl Deref { - // Currently errors on stable, but should not - if false { - via_deref().method(); - } - - Box::new(Foo) - //[current]~^ ERROR mismatched types -} -fn main() {} diff --git a/tests/ui/impl-trait/method-resolution5-deref.rs b/tests/ui/impl-trait/method-resolution5-deref.rs deleted file mode 100644 index 6133a8efe24..00000000000 --- a/tests/ui/impl-trait/method-resolution5-deref.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! The recursive method call yields the opaque type. We want -//! to use the trait candidate for `impl Foo` here while not -//! applying it for the `impl Deref`. - -//@ revisions: current next -//@[next] compile-flags: -Znext-solver -//@ check-pass - -use std::ops::Deref; -trait Foo { - fn method(&self) {} -} -impl Foo for u32 {} -fn via_deref() -> impl Deref { - if false { - via_deref().method(); - } - - Box::new(1u32) -} - -fn via_deref_nested() -> Box> { - if false { - via_deref_nested().method(); - } - - Box::new(Box::new(1u32)) -} - -fn main() {} diff --git a/tests/ui/impl-trait/method/method-resolution.rs b/tests/ui/impl-trait/method/method-resolution.rs new file mode 100644 index 00000000000..60fbacd8646 --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution.rs @@ -0,0 +1,26 @@ +//! Since there is only one possible `bar` method, we invoke it and subsequently +//! constrain `foo`'s RPIT to `u32`. + +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +trait Trait {} + +impl Trait for u32 {} + +struct Bar(T); + +impl Bar { + fn bar(self) {} +} + +fn foo(x: bool) -> Bar { + if x { + let x = foo(false); + x.bar(); + } + todo!() +} + +fn main() {} diff --git a/tests/ui/impl-trait/method/method-resolution2.next.stderr b/tests/ui/impl-trait/method/method-resolution2.next.stderr new file mode 100644 index 00000000000..223430e1658 --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution2.next.stderr @@ -0,0 +1,20 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/method-resolution2.rs:25:11 + | +LL | x.bar(); + | ^^^ multiple `bar` found + | +note: candidate #1 is defined in an impl for the type `Bar` + --> $DIR/method-resolution2.rs:19:5 + | +LL | fn bar(self) {} + | ^^^^^^^^^^^^ +note: candidate #2 is defined in an impl for the type `Bar` + --> $DIR/method-resolution2.rs:15:5 + | +LL | fn bar(self) {} + | ^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/tests/ui/impl-trait/method/method-resolution2.rs b/tests/ui/impl-trait/method/method-resolution2.rs new file mode 100644 index 00000000000..88d4f3d9896 --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution2.rs @@ -0,0 +1,31 @@ +//! Check that the method call does not constrain the RPIT to `i32`, even though +//! `i32` is the only type that satisfies the RPIT's trait bounds. + +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@[current] check-pass + +trait Trait {} + +impl Trait for i32 {} + +struct Bar(T); + +impl Bar { + fn bar(self) {} +} + +impl Bar { + fn bar(self) {} +} + +fn foo(x: bool) -> Bar { + if x { + let x = foo(false); + x.bar(); + //[next]~^ ERROR: multiple applicable items in scope + } + Bar(42_i32) +} + +fn main() {} diff --git a/tests/ui/impl-trait/method/method-resolution3.current.stderr b/tests/ui/impl-trait/method/method-resolution3.current.stderr new file mode 100644 index 00000000000..87dd862ef8f --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution3.current.stderr @@ -0,0 +1,20 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/method-resolution3.rs:21:11 + | +LL | x.bar(); + | ^^^ multiple `bar` found + | +note: candidate #1 is defined in an impl for the type `Bar` + --> $DIR/method-resolution3.rs:15:5 + | +LL | fn bar(self) {} + | ^^^^^^^^^^^^ +note: candidate #2 is defined in an impl for the type `Bar` + --> $DIR/method-resolution3.rs:11:5 + | +LL | fn bar(self) {} + | ^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/tests/ui/impl-trait/method/method-resolution3.next.stderr b/tests/ui/impl-trait/method/method-resolution3.next.stderr new file mode 100644 index 00000000000..87dd862ef8f --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution3.next.stderr @@ -0,0 +1,20 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/method-resolution3.rs:21:11 + | +LL | x.bar(); + | ^^^ multiple `bar` found + | +note: candidate #1 is defined in an impl for the type `Bar` + --> $DIR/method-resolution3.rs:15:5 + | +LL | fn bar(self) {} + | ^^^^^^^^^^^^ +note: candidate #2 is defined in an impl for the type `Bar` + --> $DIR/method-resolution3.rs:11:5 + | +LL | fn bar(self) {} + | ^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/tests/ui/impl-trait/method/method-resolution3.rs b/tests/ui/impl-trait/method/method-resolution3.rs new file mode 100644 index 00000000000..8c47ef4fc75 --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution3.rs @@ -0,0 +1,27 @@ +//! Check that we consider `Bar` to successfully unify +//! with both `Bar` and `Bar` (in isolation), so we bail +//! out with ambiguity. + +//@ revisions: current next +//@[next] compile-flags: -Znext-solver + +struct Bar(T); + +impl Bar { + fn bar(self) {} +} + +impl Bar { + fn bar(self) {} +} + +fn foo(x: bool) -> Bar { + if x { + let x = foo(false); + x.bar(); + //~^ ERROR: multiple applicable items in scope + } + todo!() +} + +fn main() {} diff --git a/tests/ui/impl-trait/method/method-resolution4.rs b/tests/ui/impl-trait/method/method-resolution4.rs new file mode 100644 index 00000000000..f90a9309cda --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution4.rs @@ -0,0 +1,18 @@ +//! The recursive method call yields the opaque type. The +//! `next` method call then constrains the hidden type to `&mut _` +//! because `next` takes `&mut self`. We never resolve the inference +//! variable, but get a type mismatch when comparing `&mut _` with +//! `std::iter::Empty`. + +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +fn foo(b: bool) -> impl Iterator { + if b { + foo(false).next().unwrap(); + } + std::iter::empty() +} + +fn main() {} diff --git a/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.current.stderr b/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.current.stderr new file mode 100644 index 00000000000..08578de426a --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.current.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/method-resolution5-deref-no-constrain.rs:20:5 + | +LL | fn via_deref() -> impl Deref { + | --- expected `&Foo` because of return type +... +LL | Box::new(Foo) + | ^^^^^^^^^^^^^ expected `&Foo`, found `Box` + | + = note: expected reference `&Foo` + found struct `Box` +help: consider borrowing here + | +LL | &Box::new(Foo) + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs b/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs new file mode 100644 index 00000000000..2c41f62b9fd --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution5-deref-no-constrain.rs @@ -0,0 +1,23 @@ +//! The recursive method call yields the opaque type. We want +//! to use the impl candidate for `Foo` here without constraining +//! the opaque to `&Foo`. + +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@[next] check-pass + +use std::ops::Deref; +struct Foo; +impl Foo { + fn method(&self) {} +} +fn via_deref() -> impl Deref { + // Currently errors on stable, but should not + if false { + via_deref().method(); + } + + Box::new(Foo) + //[current]~^ ERROR mismatched types +} +fn main() {} diff --git a/tests/ui/impl-trait/method/method-resolution5-deref.rs b/tests/ui/impl-trait/method/method-resolution5-deref.rs new file mode 100644 index 00000000000..6133a8efe24 --- /dev/null +++ b/tests/ui/impl-trait/method/method-resolution5-deref.rs @@ -0,0 +1,30 @@ +//! The recursive method call yields the opaque type. We want +//! to use the trait candidate for `impl Foo` here while not +//! applying it for the `impl Deref`. + +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ check-pass + +use std::ops::Deref; +trait Foo { + fn method(&self) {} +} +impl Foo for u32 {} +fn via_deref() -> impl Deref { + if false { + via_deref().method(); + } + + Box::new(1u32) +} + +fn via_deref_nested() -> Box> { + if false { + via_deref_nested().method(); + } + + Box::new(Box::new(1u32)) +} + +fn main() {} -- cgit 1.4.1-3-g733a5