mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Add regression tests
This commit is contained in:
parent
acba6449f8
commit
548c44760f
22
tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr
Normal file
22
tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr
Normal 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`.
|
24
tests/ui/impl-trait/auto-trait-selection-freeze.rs
Normal file
24
tests/ui/impl-trait/auto-trait-selection-freeze.rs
Normal 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() {}
|
22
tests/ui/impl-trait/auto-trait-selection.next.stderr
Normal file
22
tests/ui/impl-trait/auto-trait-selection.next.stderr
Normal 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`.
|
20
tests/ui/impl-trait/auto-trait-selection.rs
Normal file
20
tests/ui/impl-trait/auto-trait-selection.rs
Normal 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() {}
|
Loading…
Reference in New Issue
Block a user