Add regression tests

This commit is contained in:
Oli Scherer 2024-06-04 13:55:15 +00:00
parent acba6449f8
commit 548c44760f
4 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,22 @@
error[E0283]: type annotations needed
--> $DIR/auto-trait-selection-freeze.rs:20:16
|
LL | if false { is_trait(foo()) } else { Default::default() }
| ^^^^^^^^ ----- type must be known at this point
| |
| cannot infer type of the type parameter `T` declared on the function `is_trait`
|
= note: cannot satisfy `_: Trait<_>`
note: required by a bound in `is_trait`
--> $DIR/auto-trait-selection-freeze.rs:12:16
|
LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
| ^^^^^^^^ required by this bound in `is_trait`
help: consider specifying the generic arguments
|
LL | if false { is_trait::<T, U>(foo()) } else { Default::default() }
| ++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0283`.

View File

@ -0,0 +1,24 @@
//! This test shows how we fail selection in a way that can influence
//! selection in a code path that succeeds.
//@ revisions: next old
//@[next] compile-flags: -Znext-solver
//@[old]check-pass
#![feature(freeze)]
use std::marker::Freeze;
fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
Default::default()
}
trait Trait<T> {}
impl<T: Freeze> Trait<u32> for T {}
impl<T> Trait<i32> for T {}
fn foo() -> impl Sized {
if false { is_trait(foo()) } else { Default::default() }
//[next]~^ ERROR: type annotations needed
}
fn main() {}

View File

@ -0,0 +1,22 @@
error[E0283]: type annotations needed
--> $DIR/auto-trait-selection.rs:16:16
|
LL | if false { is_trait(foo()) } else { Default::default() }
| ^^^^^^^^ ----- type must be known at this point
| |
| cannot infer type of the type parameter `T` declared on the function `is_trait`
|
= note: cannot satisfy `_: Trait<_>`
note: required by a bound in `is_trait`
--> $DIR/auto-trait-selection.rs:8:16
|
LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
| ^^^^^^^^ required by this bound in `is_trait`
help: consider specifying the generic arguments
|
LL | if false { is_trait::<T, U>(foo()) } else { Default::default() }
| ++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0283`.

View File

@ -0,0 +1,20 @@
//! This test shows how we fail selection in a way that can influence
//! selection in a code path that succeeds.
//@ revisions: next old
//@[next] compile-flags: -Znext-solver
//@[old]check-pass
fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
Default::default()
}
trait Trait<T> {}
impl<T: Send> Trait<u32> for T {}
impl<T> Trait<i32> for T {}
fn foo() -> impl Sized {
if false { is_trait(foo()) } else { Default::default() }
//[next]~^ ERROR: type annotations needed
}
fn main() {}