diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-13 21:55:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-13 21:55:36 +0100 |
| commit | 6cec8cb5c2e3653b9d533e2d280b91a9114cf15a (patch) | |
| tree | 91e4057a6ef6f1f8d436a84aa6eab6571d8df7b9 /tests | |
| parent | b4c7fc4ea16cd0fd0589f064530cb3213ebcb048 (diff) | |
| parent | 84d254ead0527c8b098cc35b156d73f9f9c3ec8b (diff) | |
| download | rust-6cec8cb5c2e3653b9d533e2d280b91a9114cf15a.tar.gz rust-6cec8cb5c2e3653b9d533e2d280b91a9114cf15a.zip | |
Rollup merge of #108830 - compiler-errors:new-solver-fast-reject-faster, r=lcnr
Treat projections with infer as placeholder during fast reject in new solver r? ``@lcnr`` Kind of a shame that we need to change all of the call sites for `for_each_relevant_impl`, etc. to pass an extra parameter. I guess I could have the "default" fn which calls a configurable fn?
Diffstat (limited to 'tests')
3 files changed, 67 insertions, 0 deletions
diff --git a/tests/ui/traits/new-solver/nested-obligations-with-bound-vars-gat.rs b/tests/ui/traits/new-solver/nested-obligations-with-bound-vars-gat.rs new file mode 100644 index 00000000000..92bad959095 --- /dev/null +++ b/tests/ui/traits/new-solver/nested-obligations-with-bound-vars-gat.rs @@ -0,0 +1,43 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 96230 + +use std::fmt::Debug; + +trait Classic { + type Assoc; +} + +trait Gat { + type Assoc<'a>; +} + +struct Foo; + +impl Classic for Foo { + type Assoc = (); +} + +impl Gat for Foo { + type Assoc<'i> = (); +} + +fn classic_debug<T: Classic>(_: T) +where + T::Assoc: Debug, +{ +} + +fn gat_debug<T: Gat>(_: T) +where + for<'a> T::Assoc<'a>: Debug, +{ +} + +fn main() { + classic_debug::<Foo>(Foo); // fine + classic_debug(Foo); // fine + + gat_debug::<Foo>(Foo); // fine + gat_debug(Foo); // boom +} diff --git a/tests/ui/traits/new-solver/runaway-impl-candidate-selection.rs b/tests/ui/traits/new-solver/runaway-impl-candidate-selection.rs new file mode 100644 index 00000000000..1dca86d3630 --- /dev/null +++ b/tests/ui/traits/new-solver/runaway-impl-candidate-selection.rs @@ -0,0 +1,15 @@ +// compile-flags: -Ztrait-solver=next + +// In the new solver, we are trying to select `<?0 as Iterator>::Item: Debug`, +// which, naively can be unified with every impl of `Debug` if we're not careful. +// This test makes sure that we treat projections with inference var substs as +// placeholders during fast reject. + +fn iter<T: Iterator>() -> <T as Iterator>::Item { + todo!() +} + +fn main() { + println!("{:?}", iter::<_>()); + //~^ ERROR type annotations needed +} diff --git a/tests/ui/traits/new-solver/runaway-impl-candidate-selection.stderr b/tests/ui/traits/new-solver/runaway-impl-candidate-selection.stderr new file mode 100644 index 00000000000..47004821ad7 --- /dev/null +++ b/tests/ui/traits/new-solver/runaway-impl-candidate-selection.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/runaway-impl-candidate-selection.rs:13:22 + | +LL | println!("{:?}", iter::<_>()); + | ^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `iter` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. |
