diff options
Diffstat (limited to 'tests')
15 files changed, 145 insertions, 3 deletions
diff --git a/tests/ui/async-await/async-fn/auxiliary/block-on.rs b/tests/ui/async-await/async-fn/auxiliary/block-on.rs new file mode 100644 index 00000000000..dcb710fc97c --- /dev/null +++ b/tests/ui/async-await/async-fn/auxiliary/block-on.rs @@ -0,0 +1,20 @@ +//@ edition: 2021 + +#![feature(async_closure, noop_waker)] + +use std::future::Future; +use std::pin::pin; +use std::task::*; + +pub fn block_on<T>(fut: impl Future<Output = T>) -> T { + let mut fut = pin!(fut); + // Poll loop, just to test the future... + let ctx = &mut Context::from_waker(Waker::noop()); + + loop { + match unsafe { fut.as_mut().poll(ctx) } { + Poll::Pending => {} + Poll::Ready(t) => break t, + } + } +} diff --git a/tests/ui/async-await/async-fn/simple.rs b/tests/ui/async-await/async-fn/simple.rs index e2a183a8c0b..21972ba5aef 100644 --- a/tests/ui/async-await/async-fn/simple.rs +++ b/tests/ui/async-await/async-fn/simple.rs @@ -1,8 +1,11 @@ +//@ aux-build:block-on.rs //@ edition: 2021 //@ build-pass #![feature(async_fn_traits)] +extern crate block_on; + use std::ops::AsyncFn; async fn foo() {} @@ -12,5 +15,7 @@ async fn call_asyncly(f: impl AsyncFn(i32) -> i32) -> i32 { } fn main() { - let fut = call_asyncly(|x| async move { x + 1 }); + block_on::block_on(async { + call_asyncly(|x| async move { x + 1 }).await; + }); } diff --git a/tests/ui/issues/issue-30123.stderr b/tests/ui/issues/issue-30123.stderr index cf71a01b58a..c086b45ac9b 100644 --- a/tests/ui/issues/issue-30123.stderr +++ b/tests/ui/issues/issue-30123.stderr @@ -4,6 +4,11 @@ error[E0599]: no function or associated item named `new_undirected` found for st LL | let ug = Graph::<i32, i32>::new_undirected(); | ^^^^^^^^^^^^^^ function or associated item not found in `Graph<i32, i32>` | +note: if you're trying to build a new `issue_30123_aux::Graph<i32, i32>`, consider using `issue_30123_aux::Graph::<N, E>::new` which returns `issue_30123_aux::Graph<_, _>` + --> $DIR/auxiliary/issue-30123-aux.rs:14:5 + | +LL | pub fn new() -> Self { + | ^^^^^^^^^^^^^^^^^^^^ = note: the function or associated item was found for - `issue_30123_aux::Graph<N, E, Undirected>` diff --git a/tests/ui/lazy-type-alias/constrained-late-bound-regions.rs b/tests/ui/lazy-type-alias/constrained-late-bound-regions.rs new file mode 100644 index 00000000000..e759e72d745 --- /dev/null +++ b/tests/ui/lazy-type-alias/constrained-late-bound-regions.rs @@ -0,0 +1,15 @@ +//@ check-pass +// Weak alias types constrain late-bound regions if their normalized form constrains them. + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +type Ref<'a> = &'a (); + +type FnPtr = for<'a> fn(Ref<'a>) -> &'a (); // OK +type DynCl = dyn for<'a> Fn(Ref<'a>) -> &'a (); // OK + +fn map0(_: Ref) -> Ref { &() } // OK +fn map1(_: Ref<'_>) -> Ref<'_> { &() } // OK + +fn main() {} diff --git a/tests/ui/lazy-type-alias/constrained-params.rs b/tests/ui/lazy-type-alias/constrained-params-in-impl.rs index 59693dd5461..59693dd5461 100644 --- a/tests/ui/lazy-type-alias/constrained-params.rs +++ b/tests/ui/lazy-type-alias/constrained-params-in-impl.rs diff --git a/tests/ui/lazy-type-alias/unconstrained-late-bound-regions.rs b/tests/ui/lazy-type-alias/unconstrained-late-bound-regions.rs new file mode 100644 index 00000000000..844570e22d2 --- /dev/null +++ b/tests/ui/lazy-type-alias/unconstrained-late-bound-regions.rs @@ -0,0 +1,23 @@ +// Weak alias types only constrain late-bound regions if their normalized form constrains them. + +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +type NotInjective<'a> = <() as Discard>::Output<'a>; + +type FnPtr0 = for<'a> fn(NotInjective<'a>) -> &'a (); +//~^ ERROR references lifetime `'a`, which is not constrained by the fn input types +type FnPtr1 = for<'a> fn(NotInjectiveEither<'a, ()>) -> NotInjectiveEither<'a, ()>; +//~^ ERROR references lifetime `'a`, which is not constrained by the fn input types +type DynCl = dyn for<'a> Fn(NotInjective<'a>) -> &'a (); +//~^ ERROR references lifetime `'a`, which does not appear in the trait input types + +trait Discard { type Output<'a>; } +impl Discard for () { type Output<'_a> = (); } + +type NotInjectiveEither<'a, Linchpin> = Linchpin +where + Linchpin: Fn() -> &'a (); + + +fn main() {} diff --git a/tests/ui/lazy-type-alias/unconstrained-late-bound-regions.stderr b/tests/ui/lazy-type-alias/unconstrained-late-bound-regions.stderr new file mode 100644 index 00000000000..241c7761c60 --- /dev/null +++ b/tests/ui/lazy-type-alias/unconstrained-late-bound-regions.stderr @@ -0,0 +1,22 @@ +error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types + --> $DIR/unconstrained-late-bound-regions.rs:8:47 + | +LL | type FnPtr0 = for<'a> fn(NotInjective<'a>) -> &'a (); + | ^^^^^^ + +error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types + --> $DIR/unconstrained-late-bound-regions.rs:10:57 + | +LL | type FnPtr1 = for<'a> fn(NotInjectiveEither<'a, ()>) -> NotInjectiveEither<'a, ()>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/unconstrained-late-bound-regions.rs:12:50 + | +LL | type DynCl = dyn for<'a> Fn(NotInjective<'a>) -> &'a (); + | ^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0581, E0582. +For more information about an error, try `rustc --explain E0581`. diff --git a/tests/ui/lazy-type-alias/unconstrained-param-due-to-overflow.rs b/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.rs index eceefa719ec..eceefa719ec 100644 --- a/tests/ui/lazy-type-alias/unconstrained-param-due-to-overflow.rs +++ b/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.rs diff --git a/tests/ui/lazy-type-alias/unconstrained-param-due-to-overflow.stderr b/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr index 9af6f5dda0b..b65c84226ce 100644 --- a/tests/ui/lazy-type-alias/unconstrained-param-due-to-overflow.stderr +++ b/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr @@ -1,5 +1,5 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates - --> $DIR/unconstrained-param-due-to-overflow.rs:4:6 + --> $DIR/unconstrained-params-in-impl-due-to-overflow.rs:4:6 | LL | impl<T> Loop<T> {} | ^ unconstrained type parameter diff --git a/tests/ui/lazy-type-alias/unconstrained-params.rs b/tests/ui/lazy-type-alias/unconstrained-params-in-impl.rs index d58938b3070..d58938b3070 100644 --- a/tests/ui/lazy-type-alias/unconstrained-params.rs +++ b/tests/ui/lazy-type-alias/unconstrained-params-in-impl.rs diff --git a/tests/ui/lazy-type-alias/unconstrained-params.stderr b/tests/ui/lazy-type-alias/unconstrained-params-in-impl.stderr index 3c52a06c319..2419c78cba8 100644 --- a/tests/ui/lazy-type-alias/unconstrained-params.stderr +++ b/tests/ui/lazy-type-alias/unconstrained-params-in-impl.stderr @@ -1,5 +1,5 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates - --> $DIR/unconstrained-params.rs:4:6 + --> $DIR/unconstrained-params-in-impl.rs:4:6 | LL | impl<T> NotInjective<T> {} | ^ unconstrained type parameter diff --git a/tests/ui/traits/next-solver/coherence-fulfill-overflow.rs b/tests/ui/traits/next-solver/coherence-fulfill-overflow.rs new file mode 100644 index 00000000000..ff577da32c2 --- /dev/null +++ b/tests/ui/traits/next-solver/coherence-fulfill-overflow.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Znext-solver=coherence + +#![recursion_limit = "10"] + +trait Trait {} + +struct W<T: ?Sized>(*const T); +trait TwoW {} +impl<T: ?Sized + TwoW> TwoW for W<W<T>> {} + +impl<T: ?Sized + TwoW> Trait for W<T> {} +impl<T: ?Sized + TwoW> Trait for T {} +//~^ ERROR conflicting implementations of trait `Trait` for type `W + +fn main() {} diff --git a/tests/ui/traits/next-solver/coherence-fulfill-overflow.stderr b/tests/ui/traits/next-solver/coherence-fulfill-overflow.stderr new file mode 100644 index 00000000000..406c0ccca97 --- /dev/null +++ b/tests/ui/traits/next-solver/coherence-fulfill-overflow.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/coherence-fulfill-overflow.rs:12:1 + | +LL | impl<T: ?Sized + TwoW> Trait for W<T> {} + | ------------------------------------- first implementation here +LL | impl<T: ?Sized + TwoW> Trait for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/ufcs/bad-builder.rs b/tests/ui/ufcs/bad-builder.rs new file mode 100644 index 00000000000..350c96acca0 --- /dev/null +++ b/tests/ui/ufcs/bad-builder.rs @@ -0,0 +1,6 @@ +fn hello<Q>() -> Vec<Q> { + Vec::<Q>::mew() + //~^ ERROR no function or associated item named `mew` found for struct `Vec<Q>` in the current scope +} + +fn main() {} diff --git a/tests/ui/ufcs/bad-builder.stderr b/tests/ui/ufcs/bad-builder.stderr new file mode 100644 index 00000000000..7fa47c82de2 --- /dev/null +++ b/tests/ui/ufcs/bad-builder.stderr @@ -0,0 +1,20 @@ +error[E0599]: no function or associated item named `mew` found for struct `Vec<Q>` in the current scope + --> $DIR/bad-builder.rs:2:15 + | +LL | Vec::<Q>::mew() + | ^^^ + | | + | function or associated item not found in `Vec<Q>` + | help: there is an associated function with a similar name: `new` + | +note: if you're trying to build a new `Vec<Q>` consider using one of the following associated functions: + Vec::<T>::new + Vec::<T>::with_capacity + Vec::<T>::from_raw_parts + Vec::<T, A>::new_in + and 2 others + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. |
