diff options
Diffstat (limited to 'tests')
11 files changed, 181 insertions, 3 deletions
diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed new file mode 100644 index 00000000000..b9f26a40219 --- /dev/null +++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed @@ -0,0 +1,14 @@ +// run-rustfix +trait O { + type M; +} +trait U<A: O> { + const N: A::M; +} +impl<D> O for D { + type M = u8; +} +impl<C: O<M = u8>> U<C> for u16 { + const N: C::M = 4u8; //~ ERROR mismatched types +} +fn main() {} diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs new file mode 100644 index 00000000000..abff6af73e2 --- /dev/null +++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs @@ -0,0 +1,14 @@ +// run-rustfix +trait O { + type M; +} +trait U<A: O> { + const N: A::M; +} +impl<D> O for D { + type M = u8; +} +impl<C: O> U<C> for u16 { + const N: C::M = 4u8; //~ ERROR mismatched types +} +fn main() {} diff --git a/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr new file mode 100644 index 00000000000..b104f38ce90 --- /dev/null +++ b/tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:12:21 + | +LL | const N: C::M = 4u8; + | ^^^ expected associated type, found `u8` + | + = note: expected associated type `<C as O>::M` + found type `u8` +help: consider constraining the associated type `<C as O>::M` to `u8` + | +LL | impl<C: O<M = u8>> U<C> for u16 { + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/consts/effect_param.rs b/tests/ui/consts/effect_param.rs new file mode 100644 index 00000000000..f11ec739fce --- /dev/null +++ b/tests/ui/consts/effect_param.rs @@ -0,0 +1,11 @@ +//! Ensure we don't allow accessing const effect parameters from stable Rust. + +fn main() { + i8::checked_sub::<true>(42, 43); + //~^ ERROR: method takes 0 generic arguments but 1 generic argument was supplied +} + +const FOO: () = { + i8::checked_sub::<false>(42, 43); + //~^ ERROR: method takes 0 generic arguments but 1 generic argument was supplied +}; diff --git a/tests/ui/consts/effect_param.stderr b/tests/ui/consts/effect_param.stderr new file mode 100644 index 00000000000..f8c4bfc02e5 --- /dev/null +++ b/tests/ui/consts/effect_param.stderr @@ -0,0 +1,19 @@ +error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/effect_param.rs:9:9 + | +LL | i8::checked_sub::<false>(42, 43); + | ^^^^^^^^^^^--------- help: remove these generics + | | + | expected 0 generic arguments + +error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/effect_param.rs:4:9 + | +LL | i8::checked_sub::<true>(42, 43); + | ^^^^^^^^^^^-------- help: remove these generics + | | + | expected 0 generic arguments + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr b/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr new file mode 100644 index 00000000000..83791f0d3af --- /dev/null +++ b/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr @@ -0,0 +1,29 @@ +error: internal compiler error: no errors encountered even though `delay_span_bug` issued + +error: internal compiler error: {OpaqueTypeKey { def_id: DefId(rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(foo::{opaque#0}) }) } }} + | + = + + +error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(foo::{opaque#0}) }))), bound_vars: [] } } } + --> $DIR/equality-in-canonical-query.rs:19:5 + | +LL | same_output(foo, rpit); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + + --> $DIR/equality-in-canonical-query.rs:19:5 + | +LL | same_output(foo, rpit); + | ^^^^^^^^^^^^^^^^^^^^^^ + + + + + + + +query stack during panic: +end of query stack +error: aborting due to 3 previous errors + diff --git a/tests/ui/impl-trait/equality-in-canonical-query.rs b/tests/ui/impl-trait/equality-in-canonical-query.rs new file mode 100644 index 00000000000..672b1eeeab6 --- /dev/null +++ b/tests/ui/impl-trait/equality-in-canonical-query.rs @@ -0,0 +1,23 @@ +// issue: #116877 +// revisions: sized clone +//[sized] check-pass + +//[clone] known-bug: #108498 +//[clone] failure-status: 101 +//[clone] normalize-stderr-test: "DefId\(.*?\]::" -> "DefId(" +//[clone] normalize-stderr-test: "(?m)note: .*$" -> "" +//[clone] normalize-stderr-test: "(?m)^ *\d+: .*\n" -> "" +//[clone] normalize-stderr-test: "(?m)^ *at .*\n" -> "" + +#[cfg(sized)] fn rpit() -> impl Sized {} +#[cfg(clone)] fn rpit() -> impl Clone {} + +fn same_output<Out>(_: impl Fn() -> Out, _: impl Fn() -> Out) {} + +pub fn foo() -> impl Sized { + same_output(rpit, foo); + same_output(foo, rpit); + rpit() +} + +fn main () {} diff --git a/tests/ui/lint/missing-copy-implementations-non-exhaustive.rs b/tests/ui/lint/missing-copy-implementations-non-exhaustive.rs new file mode 100644 index 00000000000..2d5e90720ef --- /dev/null +++ b/tests/ui/lint/missing-copy-implementations-non-exhaustive.rs @@ -0,0 +1,25 @@ +// Test for issue #116766. +// Ensure that we don't suggest impl'ing `Copy` for a type if it or at least one +// of it's variants are marked as `non_exhaustive`. + +// check-pass + +#![deny(missing_copy_implementations)] + +#[non_exhaustive] +pub enum MyEnum { + A, +} + +#[non_exhaustive] +pub struct MyStruct { + foo: usize, +} + +pub enum MyEnum2 { + #[non_exhaustive] + A, + B, +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr index 4b09a9e743b..844103d77a8 100644 --- a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr @@ -1,11 +1,17 @@ error: internal compiler error: no errors encountered even though `delay_span_bug` issued -error: internal compiler error: ambiguity performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(get_rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }))), bound_vars: [] } } } +error: internal compiler error: {OpaqueTypeKey { def_id: DefId(get_rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }) } }} + | + = + + +error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(get_rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }))), bound_vars: [] } } } --> $DIR/rpit_tait_equality_in_canonical_query.rs:28:5 | LL | query(get_rpit); | ^^^^^^^^^^^^^^^ | + --> $DIR/rpit_tait_equality_in_canonical_query.rs:28:5 | LL | query(get_rpit); @@ -14,7 +20,10 @@ LL | query(get_rpit); + + + query stack during panic: end of query stack -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs index 8dccd2ed46f..0f0002f7797 100644 --- a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs @@ -12,7 +12,7 @@ //[current] known-bug: #108498 //[current] failure-status: 101 //[current] normalize-stderr-test: "DefId\(.*?\]::" -> "DefId(" -//[current] normalize-stderr-test: "(?m)^note: .*\n" -> "" +//[current] normalize-stderr-test: "(?m)note: .*$" -> "" //[current] normalize-stderr-test: "(?m)^ *\d+: .*\n" -> "" //[current] normalize-stderr-test: "(?m)^ *at .*\n" -> "" diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs new file mode 100644 index 00000000000..9d7e647dd94 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs @@ -0,0 +1,18 @@ +// The canonical query `Projection(<get_rpit as FnOnce>::Output = Opaque)` +// is the *only* site that defines `Opaque` in MIR typeck. +// +// check-pass + +#![feature(type_alias_impl_trait)] + +type Opaque = impl Sized; + +fn get_rpit() -> impl Sized {} + +fn query(_: impl FnOnce() -> Opaque) {} + +fn test(_: Opaque) { + query(get_rpit); +} + +fn main() {} |
