From aa543963c68061d9ca46037071d66a028626ff3f Mon Sep 17 00:00:00 2001 From: Oneirical Date: Sun, 13 Jul 2025 16:39:45 -0400 Subject: Rehome tests/ui/issues/ tests [4/?] --- .../unioned-keys-with-associated-type-23442.rs | 24 +++++++ .../auto-deref-on-cow-regression-91489.rs | 41 ++++++++++++ .../struct-destructuring-repeated-bindings-9725.rs | 8 +++ ...uct-destructuring-repeated-bindings-9725.stderr | 18 ++++++ tests/ui/cast/constant-expression-cast-9942.rs | 6 ++ .../closure-type-inference-in-context-9129.rs | 32 +++++++++ .../trait-object-coercion-distribution-9951.rs | 21 ++++++ .../trait-object-coercion-distribution-9951.stderr | 12 ++++ .../try-from-with-const-genericsrs-98299.rs | 21 ++++++ .../try-from-with-const-genericsrs-98299.stderr | 61 ++++++++++++++++++ tests/ui/cross-crate/auxiliary/aux-9155.rs | 7 ++ tests/ui/cross-crate/auxiliary/aux-9906.rs | 15 +++++ .../generic-newtypes-cross-crate-usage-9155.rs | 11 ++++ .../reexported-structs-impls-link-error-9906.rs | 10 +++ .../deref/dereferenceable-type-behavior-22992.rs | 75 ++++++++++++++++++++++ tests/ui/drop/multiple-drop-safe-code-25549.rs | 34 ++++++++++ .../drop/static-variable-with-drop-trait-9243.rs | 17 +++++ .../edition-specific-identifier-shadowing-53333.rs | 10 +++ ...enum-discriminant-const-eval-truncation-9837.rs | 12 ++++ .../enum/single-variant-enum-deref-error-9814.rs | 9 +++ .../single-variant-enum-deref-error-9814.stderr | 9 +++ .../zero-variant-enum-pattern-matching-3037.rs | 16 +++++ tests/ui/imports/auxiliary/aux-9968.rs | 22 +++++++ tests/ui/imports/pub-use-link-errors-9968.rs | 12 ++++ tests/ui/issues/auxiliary/issue-9155.rs | 7 -- tests/ui/issues/auxiliary/issue-9906.rs | 15 ----- tests/ui/issues/auxiliary/issue-9968.rs | 22 ------- tests/ui/issues/issue-21655.rs | 12 ---- tests/ui/issues/issue-22992.rs | 75 ---------------------- tests/ui/issues/issue-23442.rs | 23 ------- tests/ui/issues/issue-24365.rs | 19 ------ tests/ui/issues/issue-24365.stderr | 21 ------ tests/ui/issues/issue-25386.rs | 27 -------- tests/ui/issues/issue-25386.stderr | 14 ---- tests/ui/issues/issue-25549-multiple-drop.rs | 33 ---------- tests/ui/issues/issue-29710.rs | 11 ---- tests/ui/issues/issue-30236.rs | 7 -- tests/ui/issues/issue-30236.stderr | 12 ---- tests/ui/issues/issue-3037.rs | 15 ----- tests/ui/issues/issue-30756.rs | 7 -- tests/ui/issues/issue-53333.rs | 9 --- tests/ui/issues/issue-88150.rs | 21 ------ tests/ui/issues/issue-9047.rs | 14 ---- tests/ui/issues/issue-9110.rs | 16 ----- tests/ui/issues/issue-9129.rs | 31 --------- tests/ui/issues/issue-91489.rs | 40 ------------ tests/ui/issues/issue-9155.rs | 11 ---- tests/ui/issues/issue-9243.rs | 16 ----- tests/ui/issues/issue-9249.rs | 5 -- tests/ui/issues/issue-9259.rs | 16 ----- tests/ui/issues/issue-92741.fixed | 13 ---- tests/ui/issues/issue-92741.rs | 17 ----- tests/ui/issues/issue-92741.stderr | 49 -------------- tests/ui/issues/issue-9725.rs | 7 -- tests/ui/issues/issue-9725.stderr | 18 ------ tests/ui/issues/issue-9737.rs | 10 --- tests/ui/issues/issue-9814.rs | 8 --- tests/ui/issues/issue-9814.stderr | 9 --- tests/ui/issues/issue-98299.rs | 20 ------ tests/ui/issues/issue-98299.stderr | 61 ------------------ tests/ui/issues/issue-9837.rs | 11 ---- tests/ui/issues/issue-9906.rs | 10 --- tests/ui/issues/issue-9942.rs | 5 -- tests/ui/issues/issue-9951.rs | 20 ------ tests/ui/issues/issue-9951.stderr | 12 ---- tests/ui/issues/issue-9968.rs | 12 ---- tests/ui/issues/issue-99838.rs | 40 ------------ tests/ui/issues/issue-pr29383.rs | 14 ---- tests/ui/issues/issue-pr29383.stderr | 21 ------ .../iterators/for-loop-over-mut-iterator-21655.rs | 13 ++++ .../struct-with-lifetime-parameters-9259.rs | 17 +++++ ...results-lint-triggered-by-derive-debug-29710.rs | 12 ++++ tests/ui/loops/loop-with-label-9047.rs | 15 +++++ .../macro-expansion-module-structure-9110.rs | 17 +++++ ...macro-invocation-with-variable-in-scope-9737.rs | 11 ++++ .../private-struct-member-macro-access-25386.rs | 28 ++++++++ ...private-struct-member-macro-access-25386.stderr | 14 ++++ ...lines-in-diagnostic-fix-suggestions-92741.fixed | 14 ++++ ...newlines-in-diagnostic-fix-suggestions-92741.rs | 18 ++++++ ...ines-in-diagnostic-fix-suggestions-92741.stderr | 49 ++++++++++++++ .../misaligned-reference-drop-field-99838.rs | 41 ++++++++++++ .../pattern/unit-variant-pattern-matching-29383.rs | 15 +++++ .../unit-variant-pattern-matching-29383.stderr | 21 ++++++ tests/ui/static/static-string-slice-9249.rs | 6 ++ .../ui/structs/struct-field-access-errors-24365.rs | 20 ++++++ .../struct-field-access-errors-24365.stderr | 21 ++++++ .../thread-local-with-attributes-30756.rs | 8 +++ .../ui/typeck/unused-type-parameter-span-30236.rs | 8 +++ .../typeck/unused-type-parameter-span-30236.stderr | 12 ++++ .../uninhabited-type-layout-computation-88150.rs | 22 +++++++ 90 files changed, 885 insertions(+), 856 deletions(-) create mode 100644 tests/ui/associated-types/unioned-keys-with-associated-type-23442.rs create mode 100644 tests/ui/autoref-autoderef/auto-deref-on-cow-regression-91489.rs create mode 100644 tests/ui/binding/struct-destructuring-repeated-bindings-9725.rs create mode 100644 tests/ui/binding/struct-destructuring-repeated-bindings-9725.stderr create mode 100644 tests/ui/cast/constant-expression-cast-9942.rs create mode 100644 tests/ui/closures/closure-type-inference-in-context-9129.rs create mode 100644 tests/ui/coercion/trait-object-coercion-distribution-9951.rs create mode 100644 tests/ui/coercion/trait-object-coercion-distribution-9951.stderr create mode 100644 tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs create mode 100644 tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr create mode 100644 tests/ui/cross-crate/auxiliary/aux-9155.rs create mode 100644 tests/ui/cross-crate/auxiliary/aux-9906.rs create mode 100644 tests/ui/cross-crate/generic-newtypes-cross-crate-usage-9155.rs create mode 100644 tests/ui/cross-crate/reexported-structs-impls-link-error-9906.rs create mode 100644 tests/ui/deref/dereferenceable-type-behavior-22992.rs create mode 100644 tests/ui/drop/multiple-drop-safe-code-25549.rs create mode 100644 tests/ui/drop/static-variable-with-drop-trait-9243.rs create mode 100644 tests/ui/editions/edition-specific-identifier-shadowing-53333.rs create mode 100644 tests/ui/enum-discriminant/enum-discriminant-const-eval-truncation-9837.rs create mode 100644 tests/ui/enum/single-variant-enum-deref-error-9814.rs create mode 100644 tests/ui/enum/single-variant-enum-deref-error-9814.stderr create mode 100644 tests/ui/enum/zero-variant-enum-pattern-matching-3037.rs create mode 100644 tests/ui/imports/auxiliary/aux-9968.rs create mode 100644 tests/ui/imports/pub-use-link-errors-9968.rs delete mode 100644 tests/ui/issues/auxiliary/issue-9155.rs delete mode 100644 tests/ui/issues/auxiliary/issue-9906.rs delete mode 100644 tests/ui/issues/auxiliary/issue-9968.rs delete mode 100644 tests/ui/issues/issue-21655.rs delete mode 100644 tests/ui/issues/issue-22992.rs delete mode 100644 tests/ui/issues/issue-23442.rs delete mode 100644 tests/ui/issues/issue-24365.rs delete mode 100644 tests/ui/issues/issue-24365.stderr delete mode 100644 tests/ui/issues/issue-25386.rs delete mode 100644 tests/ui/issues/issue-25386.stderr delete mode 100644 tests/ui/issues/issue-25549-multiple-drop.rs delete mode 100644 tests/ui/issues/issue-29710.rs delete mode 100644 tests/ui/issues/issue-30236.rs delete mode 100644 tests/ui/issues/issue-30236.stderr delete mode 100644 tests/ui/issues/issue-3037.rs delete mode 100644 tests/ui/issues/issue-30756.rs delete mode 100644 tests/ui/issues/issue-53333.rs delete mode 100644 tests/ui/issues/issue-88150.rs delete mode 100644 tests/ui/issues/issue-9047.rs delete mode 100644 tests/ui/issues/issue-9110.rs delete mode 100644 tests/ui/issues/issue-9129.rs delete mode 100644 tests/ui/issues/issue-91489.rs delete mode 100644 tests/ui/issues/issue-9155.rs delete mode 100644 tests/ui/issues/issue-9243.rs delete mode 100644 tests/ui/issues/issue-9249.rs delete mode 100644 tests/ui/issues/issue-9259.rs delete mode 100644 tests/ui/issues/issue-92741.fixed delete mode 100644 tests/ui/issues/issue-92741.rs delete mode 100644 tests/ui/issues/issue-92741.stderr delete mode 100644 tests/ui/issues/issue-9725.rs delete mode 100644 tests/ui/issues/issue-9725.stderr delete mode 100644 tests/ui/issues/issue-9737.rs delete mode 100644 tests/ui/issues/issue-9814.rs delete mode 100644 tests/ui/issues/issue-9814.stderr delete mode 100644 tests/ui/issues/issue-98299.rs delete mode 100644 tests/ui/issues/issue-98299.stderr delete mode 100644 tests/ui/issues/issue-9837.rs delete mode 100644 tests/ui/issues/issue-9906.rs delete mode 100644 tests/ui/issues/issue-9942.rs delete mode 100644 tests/ui/issues/issue-9951.rs delete mode 100644 tests/ui/issues/issue-9951.stderr delete mode 100644 tests/ui/issues/issue-9968.rs delete mode 100644 tests/ui/issues/issue-99838.rs delete mode 100644 tests/ui/issues/issue-pr29383.rs delete mode 100644 tests/ui/issues/issue-pr29383.stderr create mode 100644 tests/ui/iterators/for-loop-over-mut-iterator-21655.rs create mode 100644 tests/ui/lifetimes/struct-with-lifetime-parameters-9259.rs create mode 100644 tests/ui/lint/unused-results-lint-triggered-by-derive-debug-29710.rs create mode 100644 tests/ui/loops/loop-with-label-9047.rs create mode 100644 tests/ui/macros/macro-expansion-module-structure-9110.rs create mode 100644 tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs create mode 100644 tests/ui/macros/private-struct-member-macro-access-25386.rs create mode 100644 tests/ui/macros/private-struct-member-macro-access-25386.stderr create mode 100644 tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.fixed create mode 100644 tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.rs create mode 100644 tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.stderr create mode 100644 tests/ui/packed/misaligned-reference-drop-field-99838.rs create mode 100644 tests/ui/pattern/unit-variant-pattern-matching-29383.rs create mode 100644 tests/ui/pattern/unit-variant-pattern-matching-29383.stderr create mode 100644 tests/ui/static/static-string-slice-9249.rs create mode 100644 tests/ui/structs/struct-field-access-errors-24365.rs create mode 100644 tests/ui/structs/struct-field-access-errors-24365.stderr create mode 100644 tests/ui/thread-local/thread-local-with-attributes-30756.rs create mode 100644 tests/ui/typeck/unused-type-parameter-span-30236.rs create mode 100644 tests/ui/typeck/unused-type-parameter-span-30236.stderr create mode 100644 tests/ui/uninhabited/uninhabited-type-layout-computation-88150.rs diff --git a/tests/ui/associated-types/unioned-keys-with-associated-type-23442.rs b/tests/ui/associated-types/unioned-keys-with-associated-type-23442.rs new file mode 100644 index 00000000000..89a2d0177a3 --- /dev/null +++ b/tests/ui/associated-types/unioned-keys-with-associated-type-23442.rs @@ -0,0 +1,24 @@ +// https://github.com/rust-lang/rust/issues/23442 +//@ check-pass +#![allow(dead_code)] +use std::marker::PhantomData; + +pub struct UnionedKeys<'a,K> + where K: UnifyKey + 'a +{ + table: &'a mut UnificationTable, + root_key: K, + stack: Vec, +} + +pub trait UnifyKey { + type Value; +} + +pub struct UnificationTable { + values: Delegate, +} + +pub struct Delegate(PhantomData); + +fn main() {} diff --git a/tests/ui/autoref-autoderef/auto-deref-on-cow-regression-91489.rs b/tests/ui/autoref-autoderef/auto-deref-on-cow-regression-91489.rs new file mode 100644 index 00000000000..929e98ad719 --- /dev/null +++ b/tests/ui/autoref-autoderef/auto-deref-on-cow-regression-91489.rs @@ -0,0 +1,41 @@ +// https://github.com/rust-lang/rust/issues/91489 +//@ check-pass + +// regression test for #91489 + +use std::borrow::Borrow; +use std::borrow::Cow; + +pub struct VariantType {} +pub struct VariantTy {} + +impl Borrow for VariantType { + fn borrow(&self) -> &VariantTy { + unimplemented!() + } +} + +impl ToOwned for VariantTy { + type Owned = VariantType; + fn to_owned(&self) -> VariantType { + unimplemented!() + } +} + +impl VariantTy { + pub fn as_str(&self) -> () {} +} + +// the presence of this was causing all attempts to call `as_str` on +// `Cow<'_, VariantTy>, including in itself, to not find the method +static _TYP: () = { + let _ = || { + // should be found + Cow::Borrowed(&VariantTy {}).as_str(); + }; +}; + +fn main() { + // should be found + Cow::Borrowed(&VariantTy {}).as_str() +} diff --git a/tests/ui/binding/struct-destructuring-repeated-bindings-9725.rs b/tests/ui/binding/struct-destructuring-repeated-bindings-9725.rs new file mode 100644 index 00000000000..6b0b8e37b8c --- /dev/null +++ b/tests/ui/binding/struct-destructuring-repeated-bindings-9725.rs @@ -0,0 +1,8 @@ +// https://github.com/rust-lang/rust/issues/9725 +struct A { foo: isize } + +fn main() { + let A { foo, foo } = A { foo: 3 }; + //~^ ERROR: identifier `foo` is bound more than once in the same pattern + //~^^ ERROR: field `foo` bound multiple times +} diff --git a/tests/ui/binding/struct-destructuring-repeated-bindings-9725.stderr b/tests/ui/binding/struct-destructuring-repeated-bindings-9725.stderr new file mode 100644 index 00000000000..f4d19bed419 --- /dev/null +++ b/tests/ui/binding/struct-destructuring-repeated-bindings-9725.stderr @@ -0,0 +1,18 @@ +error[E0416]: identifier `foo` is bound more than once in the same pattern + --> $DIR/struct-destructuring-repeated-bindings-9725.rs:5:18 + | +LL | let A { foo, foo } = A { foo: 3 }; + | ^^^ used in a pattern more than once + +error[E0025]: field `foo` bound multiple times in the pattern + --> $DIR/struct-destructuring-repeated-bindings-9725.rs:5:18 + | +LL | let A { foo, foo } = A { foo: 3 }; + | --- ^^^ multiple uses of `foo` in pattern + | | + | first use of `foo` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0025, E0416. +For more information about an error, try `rustc --explain E0025`. diff --git a/tests/ui/cast/constant-expression-cast-9942.rs b/tests/ui/cast/constant-expression-cast-9942.rs new file mode 100644 index 00000000000..d0a6f27b7e3 --- /dev/null +++ b/tests/ui/cast/constant-expression-cast-9942.rs @@ -0,0 +1,6 @@ +// https://github.com/rust-lang/rust/issues/9942 +//@ run-pass + +pub fn main() { + const S: usize = 23 as usize; [0; S]; () +} diff --git a/tests/ui/closures/closure-type-inference-in-context-9129.rs b/tests/ui/closures/closure-type-inference-in-context-9129.rs new file mode 100644 index 00000000000..53ee8faab85 --- /dev/null +++ b/tests/ui/closures/closure-type-inference-in-context-9129.rs @@ -0,0 +1,32 @@ +// https://github.com/rust-lang/rust/issues/9129 +//@ run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +pub trait bomb { fn boom(&self, _: Ident); } +pub struct S; +impl bomb for S { fn boom(&self, _: Ident) { } } + +pub struct Ident { name: usize } + +macro_rules! int3 { () => ( { } ) } + +fn Ident_new() -> Ident { + int3!(); + Ident {name: 0x6789ABCD } +} + +pub fn light_fuse(fld: Box) { + int3!(); + let f = || { + int3!(); + fld.boom(Ident_new()); // *** 1 + }; + f(); +} + +pub fn main() { + let b = Box::new(S) as Box; + light_fuse(b); +} diff --git a/tests/ui/coercion/trait-object-coercion-distribution-9951.rs b/tests/ui/coercion/trait-object-coercion-distribution-9951.rs new file mode 100644 index 00000000000..526d6561510 --- /dev/null +++ b/tests/ui/coercion/trait-object-coercion-distribution-9951.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/9951 +//@ run-pass + +#![allow(unused_variables)] + +trait Bar { + fn noop(&self); //~ WARN method `noop` is never used +} +impl Bar for u8 { + fn noop(&self) {} +} + +fn main() { + let (a, b) = (&5u8 as &dyn Bar, &9u8 as &dyn Bar); + let (c, d): (&dyn Bar, &dyn Bar) = (a, b); + + let (a, b) = (Box::new(5u8) as Box, Box::new(9u8) as Box); + let (c, d): (&dyn Bar, &dyn Bar) = (&*a, &*b); + + let (c, d): (&dyn Bar, &dyn Bar) = (&5, &9); +} diff --git a/tests/ui/coercion/trait-object-coercion-distribution-9951.stderr b/tests/ui/coercion/trait-object-coercion-distribution-9951.stderr new file mode 100644 index 00000000000..0c672aa9b33 --- /dev/null +++ b/tests/ui/coercion/trait-object-coercion-distribution-9951.stderr @@ -0,0 +1,12 @@ +warning: method `noop` is never used + --> $DIR/trait-object-coercion-distribution-9951.rs:7:6 + | +LL | trait Bar { + | --- method in this trait +LL | fn noop(&self); + | ^^^^ + | + = note: `#[warn(dead_code)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs new file mode 100644 index 00000000000..49c88856bc9 --- /dev/null +++ b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/98299 +use std::convert::TryFrom; + +pub fn test_usage(p: ()) { + SmallCString::try_from(p).map(|cstr| cstr); + //~^ ERROR: type annotations needed + //~| ERROR: type annotations needed + //~| ERROR: type annotations needed +} + +pub struct SmallCString {} + +impl TryFrom<()> for SmallCString { + type Error = (); + + fn try_from(path: ()) -> Result { + unimplemented!(); + } +} + +fn main() {} diff --git a/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr new file mode 100644 index 00000000000..1557b83b00e --- /dev/null +++ b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr @@ -0,0 +1,61 @@ +error[E0284]: type annotations needed for `SmallCString<_>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:5:36 + | +LL | SmallCString::try_from(p).map(|cstr| cstr); + | ------------ ^^^^ + | | + | type must be known at this point + | +note: required by a const generic parameter in `SmallCString` + --> $DIR/try-from-with-const-genericsrs-98299.rs:11:25 + | +LL | pub struct SmallCString {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `SmallCString` +help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified + | +LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); + | +++++++++++++++++ + +error[E0284]: type annotations needed for `SmallCString<_>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:5:36 + | +LL | SmallCString::try_from(p).map(|cstr| cstr); + | ------------ ^^^^ + | | + | type must be known at this point + | +note: required for `SmallCString<_>` to implement `TryFrom<()>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:13:22 + | +LL | impl TryFrom<()> for SmallCString { + | -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified + | +LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); + | +++++++++++++++++ + +error[E0284]: type annotations needed for `SmallCString<_>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:5:36 + | +LL | SmallCString::try_from(p).map(|cstr| cstr); + | ------------------------- ^^^^ + | | + | type must be known at this point + | +note: required for `SmallCString<_>` to implement `TryFrom<()>` + --> $DIR/try-from-with-const-genericsrs-98299.rs:13:22 + | +LL | impl TryFrom<()> for SmallCString { + | -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified + | +LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); + | +++++++++++++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/cross-crate/auxiliary/aux-9155.rs b/tests/ui/cross-crate/auxiliary/aux-9155.rs new file mode 100644 index 00000000000..049a96a655a --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/aux-9155.rs @@ -0,0 +1,7 @@ +pub struct Foo(T); + +impl Foo { + pub fn new(t: T) -> Foo { + Foo(t) + } +} diff --git a/tests/ui/cross-crate/auxiliary/aux-9906.rs b/tests/ui/cross-crate/auxiliary/aux-9906.rs new file mode 100644 index 00000000000..8a3eea790a2 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/aux-9906.rs @@ -0,0 +1,15 @@ +pub use other::FooBar; +pub use other::foo; + +mod other { + pub struct FooBar{value: isize} + impl FooBar{ + pub fn new(val: isize) -> FooBar { + FooBar{value: val} + } + } + + pub fn foo(){ + 1+1; + } +} diff --git a/tests/ui/cross-crate/generic-newtypes-cross-crate-usage-9155.rs b/tests/ui/cross-crate/generic-newtypes-cross-crate-usage-9155.rs new file mode 100644 index 00000000000..35286615980 --- /dev/null +++ b/tests/ui/cross-crate/generic-newtypes-cross-crate-usage-9155.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/9155 +//@ run-pass +//@ aux-build:aux-9155.rs + +extern crate aux_9155; + +struct Baz; + +pub fn main() { + aux_9155::Foo::new(Baz); +} diff --git a/tests/ui/cross-crate/reexported-structs-impls-link-error-9906.rs b/tests/ui/cross-crate/reexported-structs-impls-link-error-9906.rs new file mode 100644 index 00000000000..b49951bd1f9 --- /dev/null +++ b/tests/ui/cross-crate/reexported-structs-impls-link-error-9906.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/9906 +//@ run-pass +//@ aux-build:aux-9906.rs + +extern crate aux_9906 as testmod; + +pub fn main() { + testmod::foo(); + testmod::FooBar::new(1); +} diff --git a/tests/ui/deref/dereferenceable-type-behavior-22992.rs b/tests/ui/deref/dereferenceable-type-behavior-22992.rs new file mode 100644 index 00000000000..19fc2e7eb0b --- /dev/null +++ b/tests/ui/deref/dereferenceable-type-behavior-22992.rs @@ -0,0 +1,75 @@ +// https://github.com/rust-lang/rust/issues/22992 +//@ run-pass + +struct X { val: i32 } +impl std::ops::Deref for X { + type Target = i32; + fn deref(&self) -> &i32 { &self.val } +} + +trait M { fn m(self); } +impl M for i32 { fn m(self) { println!("i32::m()"); } } +impl M for X { fn m(self) { println!("X::m()"); } } +impl<'a> M for &'a X { fn m(self) { println!("&X::m()"); } } +impl<'a, 'b> M for &'a &'b X { fn m(self) { println!("&&X::m()"); } } +impl<'a, 'b, 'c> M for &'a &'b &'c X { fn m(self) { println!("&&&X::m()"); } } + +trait RefM { fn refm(&self); } +impl RefM for i32 { fn refm(&self) { println!("i32::refm()"); } } +impl RefM for X { fn refm(&self) { println!("X::refm()"); } } +impl<'a> RefM for &'a X { fn refm(&self) { println!("&X::refm()"); } } +impl<'a, 'b> RefM for &'a &'b X { fn refm(&self) { println!("&&X::refm()"); } } +impl<'a, 'b, 'c> RefM for &'a &'b &'c X { fn refm(&self) { println!("&&&X::refm()"); } } + +struct Y { val: i32 } +impl std::ops::Deref for Y { + type Target = i32; + fn deref(&self) -> &i32 { &self.val } +} + +struct Z { val: Y } +impl std::ops::Deref for Z { + type Target = Y; + fn deref(&self) -> &Y { &self.val } +} + +struct A; +impl std::marker::Copy for A {} +impl Clone for A { fn clone(&self) -> Self { *self } } +impl M for A { fn m(self) { println!("A::m()"); } } +impl<'a, 'b, 'c> M for &'a &'b &'c A { fn m(self) { println!("&&&A::m()"); } } +impl RefM for A { fn refm(&self) { println!("A::refm()"); } } +impl<'a, 'b, 'c> RefM for &'a &'b &'c A { fn refm(&self) { println!("&&&A::refm()"); } } + +fn main() { + // I'll use @ to denote left side of the dot operator + (*X{val:42}).m(); // i32::refm() , self == @ + X{val:42}.m(); // X::m() , self == @ + (&X{val:42}).m(); // &X::m() , self == @ + (&&X{val:42}).m(); // &&X::m() , self == @ + (&&&X{val:42}).m(); // &&&X:m() , self == @ + (&&&&X{val:42}).m(); // &&&X::m() , self == *@ + (&&&&&X{val:42}).m(); // &&&X::m() , self == **@ + + (*X{val:42}).refm(); // i32::refm() , self == @ + X{val:42}.refm(); // X::refm() , self == @ + (&X{val:42}).refm(); // X::refm() , self == *@ + (&&X{val:42}).refm(); // &X::refm() , self == *@ + (&&&X{val:42}).refm(); // &&X::refm() , self == *@ + (&&&&X{val:42}).refm(); // &&&X::refm(), self == *@ + (&&&&&X{val:42}).refm(); // &&&X::refm(), self == **@ + + Y{val:42}.refm(); // i32::refm() , self == *@ + Z{val:Y{val:42}}.refm(); // i32::refm() , self == **@ + + A.m(); // A::m() , self == @ + // without the Copy trait, (&A).m() would be a compilation error: + // cannot move out of borrowed content + (&A).m(); // A::m() , self == *@ + (&&A).m(); // &&&A::m() , self == &@ + (&&&A).m(); // &&&A::m() , self == @ + A.refm(); // A::refm() , self == @ + (&A).refm(); // A::refm() , self == *@ + (&&A).refm(); // A::refm() , self == **@ + (&&&A).refm(); // &&&A::refm(), self == @ +} diff --git a/tests/ui/drop/multiple-drop-safe-code-25549.rs b/tests/ui/drop/multiple-drop-safe-code-25549.rs new file mode 100644 index 00000000000..dcf7a3fc79c --- /dev/null +++ b/tests/ui/drop/multiple-drop-safe-code-25549.rs @@ -0,0 +1,34 @@ +// https://github.com/rust-lang/rust/issues/25549 +//@ run-pass +#![allow(unused_variables)] +struct Foo<'r>(&'r mut i32); + +impl<'r> Drop for Foo<'r> { + fn drop(&mut self) { + *self.0 += 1; + } +} + +trait Trait {} +impl<'r> Trait for Foo<'r> {} + +struct Holder(T); + +fn main() { + let mut drops = 0; + + { + let y = &Holder([Foo(&mut drops)]) as &Holder<[Foo]>; + // this used to cause an extra drop of the Foo instance + let x = &y.0; + } + assert_eq!(1, drops); + + drops = 0; + { + let y = &Holder(Foo(&mut drops)) as &Holder; + // this used to cause an extra drop of the Foo instance + let x = &y.0; + } + assert_eq!(1, drops); +} diff --git a/tests/ui/drop/static-variable-with-drop-trait-9243.rs b/tests/ui/drop/static-variable-with-drop-trait-9243.rs new file mode 100644 index 00000000000..0ae32c983e9 --- /dev/null +++ b/tests/ui/drop/static-variable-with-drop-trait-9243.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/9243 +//@ build-pass +#![allow(dead_code)] +// Regression test for issue 9243 +#![allow(non_upper_case_globals)] + +pub struct Test { + mem: isize, +} + +pub static g_test: Test = Test {mem: 0}; + +impl Drop for Test { + fn drop(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/editions/edition-specific-identifier-shadowing-53333.rs b/tests/ui/editions/edition-specific-identifier-shadowing-53333.rs new file mode 100644 index 00000000000..dd973bb8439 --- /dev/null +++ b/tests/ui/editions/edition-specific-identifier-shadowing-53333.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/53333 +//@ run-pass +#![allow(unused_imports)] +//@ edition:2018 + +fn main() { + use std; + let std = "std"; + println!("{}", std); +} diff --git a/tests/ui/enum-discriminant/enum-discriminant-const-eval-truncation-9837.rs b/tests/ui/enum-discriminant/enum-discriminant-const-eval-truncation-9837.rs new file mode 100644 index 00000000000..8768d81b93f --- /dev/null +++ b/tests/ui/enum-discriminant/enum-discriminant-const-eval-truncation-9837.rs @@ -0,0 +1,12 @@ +// https://github.com/rust-lang/rust/issues/9837 +//@ run-pass +const C1: i32 = 0x12345678; +const C2: isize = C1 as i16 as isize; + +enum E { + V = C2 +} + +fn main() { + assert_eq!(C2 as u64, E::V as u64); +} diff --git a/tests/ui/enum/single-variant-enum-deref-error-9814.rs b/tests/ui/enum/single-variant-enum-deref-error-9814.rs new file mode 100644 index 00000000000..f10d665299c --- /dev/null +++ b/tests/ui/enum/single-variant-enum-deref-error-9814.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/9814 +// Verify that single-variant enums can't be de-referenced +// Regression test for issue #9814 + +enum Foo { Bar(isize) } + +fn main() { + let _ = *Foo::Bar(2); //~ ERROR type `Foo` cannot be dereferenced +} diff --git a/tests/ui/enum/single-variant-enum-deref-error-9814.stderr b/tests/ui/enum/single-variant-enum-deref-error-9814.stderr new file mode 100644 index 00000000000..5e069f4c21d --- /dev/null +++ b/tests/ui/enum/single-variant-enum-deref-error-9814.stderr @@ -0,0 +1,9 @@ +error[E0614]: type `Foo` cannot be dereferenced + --> $DIR/single-variant-enum-deref-error-9814.rs:8:13 + | +LL | let _ = *Foo::Bar(2); + | ^^^^^^^^^^^^ can't be dereferenced + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0614`. diff --git a/tests/ui/enum/zero-variant-enum-pattern-matching-3037.rs b/tests/ui/enum/zero-variant-enum-pattern-matching-3037.rs new file mode 100644 index 00000000000..7a7abb1c67c --- /dev/null +++ b/tests/ui/enum/zero-variant-enum-pattern-matching-3037.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/3037 +//@ run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +enum what { } + +fn what_to_string(x: what) -> String +{ + match x { + } +} + +pub fn main() +{ +} diff --git a/tests/ui/imports/auxiliary/aux-9968.rs b/tests/ui/imports/auxiliary/aux-9968.rs new file mode 100644 index 00000000000..8d795b59ea8 --- /dev/null +++ b/tests/ui/imports/auxiliary/aux-9968.rs @@ -0,0 +1,22 @@ +pub use internal::core::{Trait, Struct}; + +mod internal { + pub mod core { + pub struct Struct; + impl Struct { + pub fn init() -> Struct { + Struct + } + } + + pub trait Trait { + fn test(&self) { + private(); + } + } + + impl Trait for Struct {} + + fn private() { } + } +} diff --git a/tests/ui/imports/pub-use-link-errors-9968.rs b/tests/ui/imports/pub-use-link-errors-9968.rs new file mode 100644 index 00000000000..517a0049ce0 --- /dev/null +++ b/tests/ui/imports/pub-use-link-errors-9968.rs @@ -0,0 +1,12 @@ +// https://github.com/rust-lang/rust/issues/9968 +//@ run-pass +//@ aux-build:aux-9968.rs + +extern crate aux_9968 as lib; + +use lib::{Trait, Struct}; + +pub fn main() +{ + Struct::init().test(); +} diff --git a/tests/ui/issues/auxiliary/issue-9155.rs b/tests/ui/issues/auxiliary/issue-9155.rs deleted file mode 100644 index 049a96a655a..00000000000 --- a/tests/ui/issues/auxiliary/issue-9155.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub struct Foo(T); - -impl Foo { - pub fn new(t: T) -> Foo { - Foo(t) - } -} diff --git a/tests/ui/issues/auxiliary/issue-9906.rs b/tests/ui/issues/auxiliary/issue-9906.rs deleted file mode 100644 index 8a3eea790a2..00000000000 --- a/tests/ui/issues/auxiliary/issue-9906.rs +++ /dev/null @@ -1,15 +0,0 @@ -pub use other::FooBar; -pub use other::foo; - -mod other { - pub struct FooBar{value: isize} - impl FooBar{ - pub fn new(val: isize) -> FooBar { - FooBar{value: val} - } - } - - pub fn foo(){ - 1+1; - } -} diff --git a/tests/ui/issues/auxiliary/issue-9968.rs b/tests/ui/issues/auxiliary/issue-9968.rs deleted file mode 100644 index 8d795b59ea8..00000000000 --- a/tests/ui/issues/auxiliary/issue-9968.rs +++ /dev/null @@ -1,22 +0,0 @@ -pub use internal::core::{Trait, Struct}; - -mod internal { - pub mod core { - pub struct Struct; - impl Struct { - pub fn init() -> Struct { - Struct - } - } - - pub trait Trait { - fn test(&self) { - private(); - } - } - - impl Trait for Struct {} - - fn private() { } - } -} diff --git a/tests/ui/issues/issue-21655.rs b/tests/ui/issues/issue-21655.rs deleted file mode 100644 index 1068b28b338..00000000000 --- a/tests/ui/issues/issue-21655.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass - -fn test(it: &mut dyn Iterator) { - for x in it { - assert_eq!(x, 1) - } -} - -fn main() { - let v = vec![1]; - test(&mut v.into_iter()) -} diff --git a/tests/ui/issues/issue-22992.rs b/tests/ui/issues/issue-22992.rs deleted file mode 100644 index 3bc15cc948a..00000000000 --- a/tests/ui/issues/issue-22992.rs +++ /dev/null @@ -1,75 +0,0 @@ -//@ run-pass - -struct X { val: i32 } -impl std::ops::Deref for X { - type Target = i32; - fn deref(&self) -> &i32 { &self.val } -} - - -trait M { fn m(self); } -impl M for i32 { fn m(self) { println!("i32::m()"); } } -impl M for X { fn m(self) { println!("X::m()"); } } -impl<'a> M for &'a X { fn m(self) { println!("&X::m()"); } } -impl<'a, 'b> M for &'a &'b X { fn m(self) { println!("&&X::m()"); } } -impl<'a, 'b, 'c> M for &'a &'b &'c X { fn m(self) { println!("&&&X::m()"); } } - -trait RefM { fn refm(&self); } -impl RefM for i32 { fn refm(&self) { println!("i32::refm()"); } } -impl RefM for X { fn refm(&self) { println!("X::refm()"); } } -impl<'a> RefM for &'a X { fn refm(&self) { println!("&X::refm()"); } } -impl<'a, 'b> RefM for &'a &'b X { fn refm(&self) { println!("&&X::refm()"); } } -impl<'a, 'b, 'c> RefM for &'a &'b &'c X { fn refm(&self) { println!("&&&X::refm()"); } } - -struct Y { val: i32 } -impl std::ops::Deref for Y { - type Target = i32; - fn deref(&self) -> &i32 { &self.val } -} - -struct Z { val: Y } -impl std::ops::Deref for Z { - type Target = Y; - fn deref(&self) -> &Y { &self.val } -} - -struct A; -impl std::marker::Copy for A {} -impl Clone for A { fn clone(&self) -> Self { *self } } -impl M for A { fn m(self) { println!("A::m()"); } } -impl<'a, 'b, 'c> M for &'a &'b &'c A { fn m(self) { println!("&&&A::m()"); } } -impl RefM for A { fn refm(&self) { println!("A::refm()"); } } -impl<'a, 'b, 'c> RefM for &'a &'b &'c A { fn refm(&self) { println!("&&&A::refm()"); } } - -fn main() { - // I'll use @ to denote left side of the dot operator - (*X{val:42}).m(); // i32::refm() , self == @ - X{val:42}.m(); // X::m() , self == @ - (&X{val:42}).m(); // &X::m() , self == @ - (&&X{val:42}).m(); // &&X::m() , self == @ - (&&&X{val:42}).m(); // &&&X:m() , self == @ - (&&&&X{val:42}).m(); // &&&X::m() , self == *@ - (&&&&&X{val:42}).m(); // &&&X::m() , self == **@ - - (*X{val:42}).refm(); // i32::refm() , self == @ - X{val:42}.refm(); // X::refm() , self == @ - (&X{val:42}).refm(); // X::refm() , self == *@ - (&&X{val:42}).refm(); // &X::refm() , self == *@ - (&&&X{val:42}).refm(); // &&X::refm() , self == *@ - (&&&&X{val:42}).refm(); // &&&X::refm(), self == *@ - (&&&&&X{val:42}).refm(); // &&&X::refm(), self == **@ - - Y{val:42}.refm(); // i32::refm() , self == *@ - Z{val:Y{val:42}}.refm(); // i32::refm() , self == **@ - - A.m(); // A::m() , self == @ - // without the Copy trait, (&A).m() would be a compilation error: - // cannot move out of borrowed content - (&A).m(); // A::m() , self == *@ - (&&A).m(); // &&&A::m() , self == &@ - (&&&A).m(); // &&&A::m() , self == @ - A.refm(); // A::refm() , self == @ - (&A).refm(); // A::refm() , self == *@ - (&&A).refm(); // A::refm() , self == **@ - (&&&A).refm(); // &&&A::refm(), self == @ -} diff --git a/tests/ui/issues/issue-23442.rs b/tests/ui/issues/issue-23442.rs deleted file mode 100644 index 883c5bb511a..00000000000 --- a/tests/ui/issues/issue-23442.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ check-pass -#![allow(dead_code)] -use std::marker::PhantomData; - -pub struct UnionedKeys<'a,K> - where K: UnifyKey + 'a -{ - table: &'a mut UnificationTable, - root_key: K, - stack: Vec, -} - -pub trait UnifyKey { - type Value; -} - -pub struct UnificationTable { - values: Delegate, -} - -pub struct Delegate(PhantomData); - -fn main() {} diff --git a/tests/ui/issues/issue-24365.rs b/tests/ui/issues/issue-24365.rs deleted file mode 100644 index da195116047..00000000000 --- a/tests/ui/issues/issue-24365.rs +++ /dev/null @@ -1,19 +0,0 @@ -pub enum Attribute { - Code {attr_name_idx: u16}, -} - -pub enum Foo { - Bar -} - -fn test(a: Foo) { - println!("{}", a.b); //~ ERROR no field `b` on type `Foo` -} - -fn main() { - let x = Attribute::Code { - attr_name_idx: 42, - }; - let z = (&x).attr_name_idx; //~ ERROR no field `attr_name_idx` on type `&Attribute` - let y = x.attr_name_idx; //~ ERROR no field `attr_name_idx` on type `Attribute` -} diff --git a/tests/ui/issues/issue-24365.stderr b/tests/ui/issues/issue-24365.stderr deleted file mode 100644 index 3f6ed0231d8..00000000000 --- a/tests/ui/issues/issue-24365.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0609]: no field `b` on type `Foo` - --> $DIR/issue-24365.rs:10:22 - | -LL | println!("{}", a.b); - | ^ unknown field - -error[E0609]: no field `attr_name_idx` on type `&Attribute` - --> $DIR/issue-24365.rs:17:18 - | -LL | let z = (&x).attr_name_idx; - | ^^^^^^^^^^^^^ unknown field - -error[E0609]: no field `attr_name_idx` on type `Attribute` - --> $DIR/issue-24365.rs:18:15 - | -LL | let y = x.attr_name_idx; - | ^^^^^^^^^^^^^ unknown field - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/issues/issue-25386.rs b/tests/ui/issues/issue-25386.rs deleted file mode 100644 index b26cc77680d..00000000000 --- a/tests/ui/issues/issue-25386.rs +++ /dev/null @@ -1,27 +0,0 @@ -mod stuff { - pub struct Item { - c_object: Box, - } - pub struct CObj { - name: Option, - } - impl Item { - pub fn new() -> Item { - Item { - c_object: Box::new(CObj { name: None }), - } - } - } -} - -macro_rules! check_ptr_exist { - ($var:expr, $member:ident) => ( - (*$var.c_object).$member.is_some() - //~^ ERROR field `c_object` of struct `Item` is private - ); -} - -fn main() { - let item = stuff::Item::new(); - println!("{}", check_ptr_exist!(item, name)); -} diff --git a/tests/ui/issues/issue-25386.stderr b/tests/ui/issues/issue-25386.stderr deleted file mode 100644 index 720b77866a5..00000000000 --- a/tests/ui/issues/issue-25386.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0616]: field `c_object` of struct `Item` is private - --> $DIR/issue-25386.rs:19:16 - | -LL | (*$var.c_object).$member.is_some() - | ^^^^^^^^ private field -... -LL | println!("{}", check_ptr_exist!(item, name)); - | ---------------------------- in this macro invocation - | - = note: this error originates in the macro `check_ptr_exist` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0616`. diff --git a/tests/ui/issues/issue-25549-multiple-drop.rs b/tests/ui/issues/issue-25549-multiple-drop.rs deleted file mode 100644 index 1eec15a4aa2..00000000000 --- a/tests/ui/issues/issue-25549-multiple-drop.rs +++ /dev/null @@ -1,33 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] -struct Foo<'r>(&'r mut i32); - -impl<'r> Drop for Foo<'r> { - fn drop(&mut self) { - *self.0 += 1; - } -} - -trait Trait {} -impl<'r> Trait for Foo<'r> {} - -struct Holder(T); - -fn main() { - let mut drops = 0; - - { - let y = &Holder([Foo(&mut drops)]) as &Holder<[Foo]>; - // this used to cause an extra drop of the Foo instance - let x = &y.0; - } - assert_eq!(1, drops); - - drops = 0; - { - let y = &Holder(Foo(&mut drops)) as &Holder; - // this used to cause an extra drop of the Foo instance - let x = &y.0; - } - assert_eq!(1, drops); -} diff --git a/tests/ui/issues/issue-29710.rs b/tests/ui/issues/issue-29710.rs deleted file mode 100644 index 906ffe9e77b..00000000000 --- a/tests/ui/issues/issue-29710.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ check-pass -#![deny(unused_results)] -#![allow(dead_code)] - -#[derive(Debug)] -struct A(usize); - -#[derive(Debug)] -struct B { a: usize } - -fn main() {} diff --git a/tests/ui/issues/issue-30236.rs b/tests/ui/issues/issue-30236.rs deleted file mode 100644 index 08d08a54402..00000000000 --- a/tests/ui/issues/issue-30236.rs +++ /dev/null @@ -1,7 +0,0 @@ -type Foo< - Unused //~ ERROR type parameter `Unused` is never used - > = u8; - -fn main() { - -} diff --git a/tests/ui/issues/issue-30236.stderr b/tests/ui/issues/issue-30236.stderr deleted file mode 100644 index bfe374a653f..00000000000 --- a/tests/ui/issues/issue-30236.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0091]: type parameter `Unused` is never used - --> $DIR/issue-30236.rs:2:5 - | -LL | Unused - | ^^^^^^ unused type parameter - | - = help: consider removing `Unused` or referring to it in the body of the type alias - = help: if you intended `Unused` to be a const parameter, use `const Unused: /* Type */` instead - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0091`. diff --git a/tests/ui/issues/issue-3037.rs b/tests/ui/issues/issue-3037.rs deleted file mode 100644 index 933b450ac8e..00000000000 --- a/tests/ui/issues/issue-3037.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] - -enum what { } - -fn what_to_string(x: what) -> String -{ - match x { - } -} - -pub fn main() -{ -} diff --git a/tests/ui/issues/issue-30756.rs b/tests/ui/issues/issue-30756.rs deleted file mode 100644 index d103776406c..00000000000 --- a/tests/ui/issues/issue-30756.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -#![forbid(unsafe_code)] - -thread_local!(static FOO: u8 = 1); - -fn main() { -} diff --git a/tests/ui/issues/issue-53333.rs b/tests/ui/issues/issue-53333.rs deleted file mode 100644 index 468b7d8075f..00000000000 --- a/tests/ui/issues/issue-53333.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -#![allow(unused_imports)] -//@ edition:2018 - -fn main() { - use std; - let std = "std"; - println!("{}", std); -} diff --git a/tests/ui/issues/issue-88150.rs b/tests/ui/issues/issue-88150.rs deleted file mode 100644 index 1dadba307c0..00000000000 --- a/tests/ui/issues/issue-88150.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass -//@ compile-flags:-C debuginfo=2 -//@ edition:2018 - -use core::marker::PhantomData; - -pub struct Foo( - PhantomData<(A, T)>, -); - -enum Never {} - -impl Foo { - fn new_foo() -> Foo { - Foo(PhantomData) - } -} - -fn main() { - let _ = Foo::<[()], Never>::new_foo(); -} diff --git a/tests/ui/issues/issue-9047.rs b/tests/ui/issues/issue-9047.rs deleted file mode 100644 index 97733588d51..00000000000 --- a/tests/ui/issues/issue-9047.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass -#![allow(unused_mut)] -#![allow(unused_variables)] -fn decode() -> String { - 'outer: loop { - let mut ch_start: usize; - break 'outer; - } - "".to_string() -} - -pub fn main() { - println!("{}", decode()); -} diff --git a/tests/ui/issues/issue-9110.rs b/tests/ui/issues/issue-9110.rs deleted file mode 100644 index 47533dc43b5..00000000000 --- a/tests/ui/issues/issue-9110.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ check-pass -#![allow(dead_code)] -#![allow(non_snake_case)] - -macro_rules! silly_macro { - () => ( - pub mod Qux { - pub struct Foo { x : u8 } - pub fn bar(_foo : Foo) {} - } - ); -} - -silly_macro!(); - -pub fn main() {} diff --git a/tests/ui/issues/issue-9129.rs b/tests/ui/issues/issue-9129.rs deleted file mode 100644 index 3856cd133e8..00000000000 --- a/tests/ui/issues/issue-9129.rs +++ /dev/null @@ -1,31 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -pub trait bomb { fn boom(&self, _: Ident); } -pub struct S; -impl bomb for S { fn boom(&self, _: Ident) { } } - -pub struct Ident { name: usize } - -macro_rules! int3 { () => ( { } ) } - -fn Ident_new() -> Ident { - int3!(); - Ident {name: 0x6789ABCD } -} - -pub fn light_fuse(fld: Box) { - int3!(); - let f = || { - int3!(); - fld.boom(Ident_new()); // *** 1 - }; - f(); -} - -pub fn main() { - let b = Box::new(S) as Box; - light_fuse(b); -} diff --git a/tests/ui/issues/issue-91489.rs b/tests/ui/issues/issue-91489.rs deleted file mode 100644 index 0566302c481..00000000000 --- a/tests/ui/issues/issue-91489.rs +++ /dev/null @@ -1,40 +0,0 @@ -//@ check-pass - -// regression test for #91489 - -use std::borrow::Borrow; -use std::borrow::Cow; - -pub struct VariantType {} -pub struct VariantTy {} - -impl Borrow for VariantType { - fn borrow(&self) -> &VariantTy { - unimplemented!() - } -} - -impl ToOwned for VariantTy { - type Owned = VariantType; - fn to_owned(&self) -> VariantType { - unimplemented!() - } -} - -impl VariantTy { - pub fn as_str(&self) -> () {} -} - -// the presence of this was causing all attempts to call `as_str` on -// `Cow<'_, VariantTy>, including in itself, to not find the method -static _TYP: () = { - let _ = || { - // should be found - Cow::Borrowed(&VariantTy {}).as_str(); - }; -}; - -fn main() { - // should be found - Cow::Borrowed(&VariantTy {}).as_str() -} diff --git a/tests/ui/issues/issue-9155.rs b/tests/ui/issues/issue-9155.rs deleted file mode 100644 index dfd9dea2009..00000000000 --- a/tests/ui/issues/issue-9155.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -//@ aux-build:issue-9155.rs - - -extern crate issue_9155; - -struct Baz; - -pub fn main() { - issue_9155::Foo::new(Baz); -} diff --git a/tests/ui/issues/issue-9243.rs b/tests/ui/issues/issue-9243.rs deleted file mode 100644 index 34ae944d1d8..00000000000 --- a/tests/ui/issues/issue-9243.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ build-pass -#![allow(dead_code)] -// Regression test for issue 9243 -#![allow(non_upper_case_globals)] - -pub struct Test { - mem: isize, -} - -pub static g_test: Test = Test {mem: 0}; - -impl Drop for Test { - fn drop(&mut self) {} -} - -fn main() {} diff --git a/tests/ui/issues/issue-9249.rs b/tests/ui/issues/issue-9249.rs deleted file mode 100644 index b98ba050521..00000000000 --- a/tests/ui/issues/issue-9249.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ check-pass -#![allow(dead_code)] - -static DATA:&'static [&'static str] = &["my string"]; -fn main() { } diff --git a/tests/ui/issues/issue-9259.rs b/tests/ui/issues/issue-9259.rs deleted file mode 100644 index c45288f7d65..00000000000 --- a/tests/ui/issues/issue-9259.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -struct A<'a> { - a: &'a [String], - b: Option<&'a [String]>, -} - -pub fn main() { - let b: &[String] = &["foo".to_string()]; - let a = A { - a: &["test".to_string()], - b: Some(b), - }; - assert_eq!(a.b.as_ref().unwrap()[0], "foo"); -} diff --git a/tests/ui/issues/issue-92741.fixed b/tests/ui/issues/issue-92741.fixed deleted file mode 100644 index cb37d25273f..00000000000 --- a/tests/ui/issues/issue-92741.fixed +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-rustfix -fn main() {} -fn _foo() -> bool { - if true { true } else { false } -} - -fn _bar() -> bool { - if true { true } else { false } -} - -fn _baz() -> bool { - if true { true } else { false } -} diff --git a/tests/ui/issues/issue-92741.rs b/tests/ui/issues/issue-92741.rs deleted file mode 100644 index 1c5d5810a57..00000000000 --- a/tests/ui/issues/issue-92741.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-rustfix -fn main() {} -fn _foo() -> bool { - & //~ ERROR mismatched types [E0308] - mut - if true { true } else { false } -} - -fn _bar() -> bool { - & //~ ERROR mismatched types [E0308] - mut if true { true } else { false } -} - -fn _baz() -> bool { - & mut //~ ERROR mismatched types [E0308] - if true { true } else { false } -} diff --git a/tests/ui/issues/issue-92741.stderr b/tests/ui/issues/issue-92741.stderr deleted file mode 100644 index 49315e7a8bf..00000000000 --- a/tests/ui/issues/issue-92741.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-92741.rs:4:5 - | -LL | fn _foo() -> bool { - | ---- expected `bool` because of return type -LL | / & -LL | | mut -LL | | if true { true } else { false } - | |___________________________________^ expected `bool`, found `&mut bool` - | -help: consider removing the borrow - | -LL - & -LL - mut - | - -error[E0308]: mismatched types - --> $DIR/issue-92741.rs:10:5 - | -LL | fn _bar() -> bool { - | ---- expected `bool` because of return type -LL | / & -LL | | mut if true { true } else { false } - | |_______________________________________^ expected `bool`, found `&mut bool` - | -help: consider removing the borrow - | -LL - & -LL - mut if true { true } else { false } -LL + if true { true } else { false } - | - -error[E0308]: mismatched types - --> $DIR/issue-92741.rs:15:5 - | -LL | fn _baz() -> bool { - | ---- expected `bool` because of return type -LL | / & mut -LL | | if true { true } else { false } - | |___________________________________^ expected `bool`, found `&mut bool` - | -help: consider removing the borrow - | -LL - & mut - | - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-9725.rs b/tests/ui/issues/issue-9725.rs deleted file mode 100644 index 360effbd119..00000000000 --- a/tests/ui/issues/issue-9725.rs +++ /dev/null @@ -1,7 +0,0 @@ -struct A { foo: isize } - -fn main() { - let A { foo, foo } = A { foo: 3 }; - //~^ ERROR: identifier `foo` is bound more than once in the same pattern - //~^^ ERROR: field `foo` bound multiple times -} diff --git a/tests/ui/issues/issue-9725.stderr b/tests/ui/issues/issue-9725.stderr deleted file mode 100644 index 687e0cc0f3e..00000000000 --- a/tests/ui/issues/issue-9725.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0416]: identifier `foo` is bound more than once in the same pattern - --> $DIR/issue-9725.rs:4:18 - | -LL | let A { foo, foo } = A { foo: 3 }; - | ^^^ used in a pattern more than once - -error[E0025]: field `foo` bound multiple times in the pattern - --> $DIR/issue-9725.rs:4:18 - | -LL | let A { foo, foo } = A { foo: 3 }; - | --- ^^^ multiple uses of `foo` in pattern - | | - | first use of `foo` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0025, E0416. -For more information about an error, try `rustc --explain E0025`. diff --git a/tests/ui/issues/issue-9737.rs b/tests/ui/issues/issue-9737.rs deleted file mode 100644 index a8a17e58dd6..00000000000 --- a/tests/ui/issues/issue-9737.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] -macro_rules! f { - (v: $x:expr) => ( println!("{}", $x) ) -} - -fn main () { - let v = 5; - f!(v: 3); -} diff --git a/tests/ui/issues/issue-9814.rs b/tests/ui/issues/issue-9814.rs deleted file mode 100644 index a87478e221b..00000000000 --- a/tests/ui/issues/issue-9814.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Verify that single-variant enums can't be de-referenced -// Regression test for issue #9814 - -enum Foo { Bar(isize) } - -fn main() { - let _ = *Foo::Bar(2); //~ ERROR type `Foo` cannot be dereferenced -} diff --git a/tests/ui/issues/issue-9814.stderr b/tests/ui/issues/issue-9814.stderr deleted file mode 100644 index fa23fb7c176..00000000000 --- a/tests/ui/issues/issue-9814.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0614]: type `Foo` cannot be dereferenced - --> $DIR/issue-9814.rs:7:13 - | -LL | let _ = *Foo::Bar(2); - | ^^^^^^^^^^^^ can't be dereferenced - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0614`. diff --git a/tests/ui/issues/issue-98299.rs b/tests/ui/issues/issue-98299.rs deleted file mode 100644 index ba63d963475..00000000000 --- a/tests/ui/issues/issue-98299.rs +++ /dev/null @@ -1,20 +0,0 @@ -use std::convert::TryFrom; - -pub fn test_usage(p: ()) { - SmallCString::try_from(p).map(|cstr| cstr); - //~^ ERROR: type annotations needed - //~| ERROR: type annotations needed - //~| ERROR: type annotations needed -} - -pub struct SmallCString {} - -impl TryFrom<()> for SmallCString { - type Error = (); - - fn try_from(path: ()) -> Result { - unimplemented!(); - } -} - -fn main() {} diff --git a/tests/ui/issues/issue-98299.stderr b/tests/ui/issues/issue-98299.stderr deleted file mode 100644 index b645267e3b9..00000000000 --- a/tests/ui/issues/issue-98299.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error[E0284]: type annotations needed for `SmallCString<_>` - --> $DIR/issue-98299.rs:4:36 - | -LL | SmallCString::try_from(p).map(|cstr| cstr); - | ------------ ^^^^ - | | - | type must be known at this point - | -note: required by a const generic parameter in `SmallCString` - --> $DIR/issue-98299.rs:10:25 - | -LL | pub struct SmallCString {} - | ^^^^^^^^^^^^^^ required by this const generic parameter in `SmallCString` -help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified - | -LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); - | +++++++++++++++++ - -error[E0284]: type annotations needed for `SmallCString<_>` - --> $DIR/issue-98299.rs:4:36 - | -LL | SmallCString::try_from(p).map(|cstr| cstr); - | ------------ ^^^^ - | | - | type must be known at this point - | -note: required for `SmallCString<_>` to implement `TryFrom<()>` - --> $DIR/issue-98299.rs:12:22 - | -LL | impl TryFrom<()> for SmallCString { - | -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ - | | - | unsatisfied trait bound introduced here -help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified - | -LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); - | +++++++++++++++++ - -error[E0284]: type annotations needed for `SmallCString<_>` - --> $DIR/issue-98299.rs:4:36 - | -LL | SmallCString::try_from(p).map(|cstr| cstr); - | ------------------------- ^^^^ - | | - | type must be known at this point - | -note: required for `SmallCString<_>` to implement `TryFrom<()>` - --> $DIR/issue-98299.rs:12:22 - | -LL | impl TryFrom<()> for SmallCString { - | -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ - | | - | unsatisfied trait bound introduced here -help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified - | -LL | SmallCString::try_from(p).map(|cstr: SmallCString| cstr); - | +++++++++++++++++ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/issues/issue-9837.rs b/tests/ui/issues/issue-9837.rs deleted file mode 100644 index 33152a5d077..00000000000 --- a/tests/ui/issues/issue-9837.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -const C1: i32 = 0x12345678; -const C2: isize = C1 as i16 as isize; - -enum E { - V = C2 -} - -fn main() { - assert_eq!(C2 as u64, E::V as u64); -} diff --git a/tests/ui/issues/issue-9906.rs b/tests/ui/issues/issue-9906.rs deleted file mode 100644 index 50417d3e456..00000000000 --- a/tests/ui/issues/issue-9906.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -//@ aux-build:issue-9906.rs - - -extern crate issue_9906 as testmod; - -pub fn main() { - testmod::foo(); - testmod::FooBar::new(1); -} diff --git a/tests/ui/issues/issue-9942.rs b/tests/ui/issues/issue-9942.rs deleted file mode 100644 index 6332d9b3e08..00000000000 --- a/tests/ui/issues/issue-9942.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ run-pass - -pub fn main() { - const S: usize = 23 as usize; [0; S]; () -} diff --git a/tests/ui/issues/issue-9951.rs b/tests/ui/issues/issue-9951.rs deleted file mode 100644 index 2cd7cd4f430..00000000000 --- a/tests/ui/issues/issue-9951.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass - -#![allow(unused_variables)] - -trait Bar { - fn noop(&self); //~ WARN method `noop` is never used -} -impl Bar for u8 { - fn noop(&self) {} -} - -fn main() { - let (a, b) = (&5u8 as &dyn Bar, &9u8 as &dyn Bar); - let (c, d): (&dyn Bar, &dyn Bar) = (a, b); - - let (a, b) = (Box::new(5u8) as Box, Box::new(9u8) as Box); - let (c, d): (&dyn Bar, &dyn Bar) = (&*a, &*b); - - let (c, d): (&dyn Bar, &dyn Bar) = (&5, &9); -} diff --git a/tests/ui/issues/issue-9951.stderr b/tests/ui/issues/issue-9951.stderr deleted file mode 100644 index 62ed9f3e0cc..00000000000 --- a/tests/ui/issues/issue-9951.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: method `noop` is never used - --> $DIR/issue-9951.rs:6:6 - | -LL | trait Bar { - | --- method in this trait -LL | fn noop(&self); - | ^^^^ - | - = note: `#[warn(dead_code)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/issues/issue-9968.rs b/tests/ui/issues/issue-9968.rs deleted file mode 100644 index 89e60ba5ac7..00000000000 --- a/tests/ui/issues/issue-9968.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass -//@ aux-build:issue-9968.rs - - -extern crate issue_9968 as lib; - -use lib::{Trait, Struct}; - -pub fn main() -{ - Struct::init().test(); -} diff --git a/tests/ui/issues/issue-99838.rs b/tests/ui/issues/issue-99838.rs deleted file mode 100644 index 687b47fbe71..00000000000 --- a/tests/ui/issues/issue-99838.rs +++ /dev/null @@ -1,40 +0,0 @@ -//@ run-pass - -use std::hint; - -struct U16(#[allow(dead_code)] u16); - -impl Drop for U16 { - fn drop(&mut self) { - // Prevent LLVM from optimizing away our alignment check. - assert!(hint::black_box(self as *mut U16 as usize) % 2 == 0); - } -} - -struct HasDrop; - -impl Drop for HasDrop { - fn drop(&mut self) {} -} - -struct Wrapper { - _a: U16, - b: HasDrop, -} - -#[repr(packed)] -struct Misalign(#[allow(dead_code)] u8, Wrapper); - -fn main() { - let m = Misalign( - 0, - Wrapper { - _a: U16(10), - b: HasDrop, - }, - ); - // Put it somewhere definitely even (so the `a` field is definitely at an odd address). - let m: ([u16; 0], Misalign) = ([], m); - // Move out one field, so we run custom per-field drop logic below. - let _x = m.1.1.b; -} diff --git a/tests/ui/issues/issue-pr29383.rs b/tests/ui/issues/issue-pr29383.rs deleted file mode 100644 index 2bcc0aa2782..00000000000 --- a/tests/ui/issues/issue-pr29383.rs +++ /dev/null @@ -1,14 +0,0 @@ -enum E { - A, - B, -} - -fn main() { - match None { - None => {} - Some(E::A(..)) => {} - //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::A` - Some(E::B(..)) => {} - //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::B` - } -} diff --git a/tests/ui/issues/issue-pr29383.stderr b/tests/ui/issues/issue-pr29383.stderr deleted file mode 100644 index 57783d75ba1..00000000000 --- a/tests/ui/issues/issue-pr29383.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0532]: expected tuple struct or tuple variant, found unit variant `E::A` - --> $DIR/issue-pr29383.rs:9:14 - | -LL | A, - | - `E::A` defined here -... -LL | Some(E::A(..)) => {} - | ^^^^^^^^ help: use this syntax instead: `E::A` - -error[E0532]: expected tuple struct or tuple variant, found unit variant `E::B` - --> $DIR/issue-pr29383.rs:11:14 - | -LL | B, - | - `E::B` defined here -... -LL | Some(E::B(..)) => {} - | ^^^^^^^^ help: use this syntax instead: `E::B` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0532`. diff --git a/tests/ui/iterators/for-loop-over-mut-iterator-21655.rs b/tests/ui/iterators/for-loop-over-mut-iterator-21655.rs new file mode 100644 index 00000000000..b5c9826bd45 --- /dev/null +++ b/tests/ui/iterators/for-loop-over-mut-iterator-21655.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/21655 +//@ run-pass + +fn test(it: &mut dyn Iterator) { + for x in it { + assert_eq!(x, 1) + } +} + +fn main() { + let v = vec![1]; + test(&mut v.into_iter()) +} diff --git a/tests/ui/lifetimes/struct-with-lifetime-parameters-9259.rs b/tests/ui/lifetimes/struct-with-lifetime-parameters-9259.rs new file mode 100644 index 00000000000..7e39fdc3f10 --- /dev/null +++ b/tests/ui/lifetimes/struct-with-lifetime-parameters-9259.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/9259 +//@ run-pass +#![allow(dead_code)] + +struct A<'a> { + a: &'a [String], + b: Option<&'a [String]>, +} + +pub fn main() { + let b: &[String] = &["foo".to_string()]; + let a = A { + a: &["test".to_string()], + b: Some(b), + }; + assert_eq!(a.b.as_ref().unwrap()[0], "foo"); +} diff --git a/tests/ui/lint/unused-results-lint-triggered-by-derive-debug-29710.rs b/tests/ui/lint/unused-results-lint-triggered-by-derive-debug-29710.rs new file mode 100644 index 00000000000..51702f69c20 --- /dev/null +++ b/tests/ui/lint/unused-results-lint-triggered-by-derive-debug-29710.rs @@ -0,0 +1,12 @@ +// https://github.com/rust-lang/rust/issues/29710 +//@ check-pass +#![deny(unused_results)] +#![allow(dead_code)] + +#[derive(Debug)] +struct A(usize); + +#[derive(Debug)] +struct B { a: usize } + +fn main() {} diff --git a/tests/ui/loops/loop-with-label-9047.rs b/tests/ui/loops/loop-with-label-9047.rs new file mode 100644 index 00000000000..29e6dba0b9e --- /dev/null +++ b/tests/ui/loops/loop-with-label-9047.rs @@ -0,0 +1,15 @@ +// https://github.com/rust-lang/rust/issues/9047 +//@ run-pass +#![allow(unused_mut)] +#![allow(unused_variables)] +fn decode() -> String { + 'outer: loop { + let mut ch_start: usize; + break 'outer; + } + "".to_string() +} + +pub fn main() { + println!("{}", decode()); +} diff --git a/tests/ui/macros/macro-expansion-module-structure-9110.rs b/tests/ui/macros/macro-expansion-module-structure-9110.rs new file mode 100644 index 00000000000..b6241a7c18e --- /dev/null +++ b/tests/ui/macros/macro-expansion-module-structure-9110.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/9110 +//@ check-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +macro_rules! silly_macro { + () => ( + pub mod Qux { + pub struct Foo { x : u8 } + pub fn bar(_foo : Foo) {} + } + ); +} + +silly_macro!(); + +pub fn main() {} diff --git a/tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs b/tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs new file mode 100644 index 00000000000..957c2e3f103 --- /dev/null +++ b/tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/9737 +//@ run-pass +#![allow(unused_variables)] +macro_rules! f { + (v: $x:expr) => ( println!("{}", $x) ) +} + +fn main () { + let v = 5; + f!(v: 3); +} diff --git a/tests/ui/macros/private-struct-member-macro-access-25386.rs b/tests/ui/macros/private-struct-member-macro-access-25386.rs new file mode 100644 index 00000000000..88e5a22a699 --- /dev/null +++ b/tests/ui/macros/private-struct-member-macro-access-25386.rs @@ -0,0 +1,28 @@ +// https://github.com/rust-lang/rust/issues/25386 +mod stuff { + pub struct Item { + c_object: Box, + } + pub struct CObj { + name: Option, + } + impl Item { + pub fn new() -> Item { + Item { + c_object: Box::new(CObj { name: None }), + } + } + } +} + +macro_rules! check_ptr_exist { + ($var:expr, $member:ident) => ( + (*$var.c_object).$member.is_some() + //~^ ERROR field `c_object` of struct `Item` is private + ); +} + +fn main() { + let item = stuff::Item::new(); + println!("{}", check_ptr_exist!(item, name)); +} diff --git a/tests/ui/macros/private-struct-member-macro-access-25386.stderr b/tests/ui/macros/private-struct-member-macro-access-25386.stderr new file mode 100644 index 00000000000..d02a41848f4 --- /dev/null +++ b/tests/ui/macros/private-struct-member-macro-access-25386.stderr @@ -0,0 +1,14 @@ +error[E0616]: field `c_object` of struct `Item` is private + --> $DIR/private-struct-member-macro-access-25386.rs:20:16 + | +LL | (*$var.c_object).$member.is_some() + | ^^^^^^^^ private field +... +LL | println!("{}", check_ptr_exist!(item, name)); + | ---------------------------- in this macro invocation + | + = note: this error originates in the macro `check_ptr_exist` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0616`. diff --git a/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.fixed b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.fixed new file mode 100644 index 00000000000..c165779e402 --- /dev/null +++ b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.fixed @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/92741 +//@ run-rustfix +fn main() {} +fn _foo() -> bool { + if true { true } else { false } +} + +fn _bar() -> bool { + if true { true } else { false } +} + +fn _baz() -> bool { + if true { true } else { false } +} diff --git a/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.rs b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.rs new file mode 100644 index 00000000000..b3fa5f77308 --- /dev/null +++ b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.rs @@ -0,0 +1,18 @@ +// https://github.com/rust-lang/rust/issues/92741 +//@ run-rustfix +fn main() {} +fn _foo() -> bool { + & //~ ERROR mismatched types [E0308] + mut + if true { true } else { false } +} + +fn _bar() -> bool { + & //~ ERROR mismatched types [E0308] + mut if true { true } else { false } +} + +fn _baz() -> bool { + & mut //~ ERROR mismatched types [E0308] + if true { true } else { false } +} diff --git a/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.stderr b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.stderr new file mode 100644 index 00000000000..60917d9a63e --- /dev/null +++ b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.stderr @@ -0,0 +1,49 @@ +error[E0308]: mismatched types + --> $DIR/newlines-in-diagnostic-fix-suggestions-92741.rs:5:5 + | +LL | fn _foo() -> bool { + | ---- expected `bool` because of return type +LL | / & +LL | | mut +LL | | if true { true } else { false } + | |___________________________________^ expected `bool`, found `&mut bool` + | +help: consider removing the borrow + | +LL - & +LL - mut + | + +error[E0308]: mismatched types + --> $DIR/newlines-in-diagnostic-fix-suggestions-92741.rs:11:5 + | +LL | fn _bar() -> bool { + | ---- expected `bool` because of return type +LL | / & +LL | | mut if true { true } else { false } + | |_______________________________________^ expected `bool`, found `&mut bool` + | +help: consider removing the borrow + | +LL - & +LL - mut if true { true } else { false } +LL + if true { true } else { false } + | + +error[E0308]: mismatched types + --> $DIR/newlines-in-diagnostic-fix-suggestions-92741.rs:16:5 + | +LL | fn _baz() -> bool { + | ---- expected `bool` because of return type +LL | / & mut +LL | | if true { true } else { false } + | |___________________________________^ expected `bool`, found `&mut bool` + | +help: consider removing the borrow + | +LL - & mut + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/packed/misaligned-reference-drop-field-99838.rs b/tests/ui/packed/misaligned-reference-drop-field-99838.rs new file mode 100644 index 00000000000..58e168162cb --- /dev/null +++ b/tests/ui/packed/misaligned-reference-drop-field-99838.rs @@ -0,0 +1,41 @@ +// https://github.com/rust-lang/rust/issues/99838 +//@ run-pass + +use std::hint; + +struct U16(#[allow(dead_code)] u16); + +impl Drop for U16 { + fn drop(&mut self) { + // Prevent LLVM from optimizing away our alignment check. + assert!(hint::black_box(self as *mut U16 as usize) % 2 == 0); + } +} + +struct HasDrop; + +impl Drop for HasDrop { + fn drop(&mut self) {} +} + +struct Wrapper { + _a: U16, + b: HasDrop, +} + +#[repr(packed)] +struct Misalign(#[allow(dead_code)] u8, Wrapper); + +fn main() { + let m = Misalign( + 0, + Wrapper { + _a: U16(10), + b: HasDrop, + }, + ); + // Put it somewhere definitely even (so the `a` field is definitely at an odd address). + let m: ([u16; 0], Misalign) = ([], m); + // Move out one field, so we run custom per-field drop logic below. + let _x = m.1.1.b; +} diff --git a/tests/ui/pattern/unit-variant-pattern-matching-29383.rs b/tests/ui/pattern/unit-variant-pattern-matching-29383.rs new file mode 100644 index 00000000000..e339dc01f46 --- /dev/null +++ b/tests/ui/pattern/unit-variant-pattern-matching-29383.rs @@ -0,0 +1,15 @@ +// https://github.com/rust-lang/rust/issues/29383 +enum E { + A, + B, +} + +fn main() { + match None { + None => {} + Some(E::A(..)) => {} + //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::A` + Some(E::B(..)) => {} + //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::B` + } +} diff --git a/tests/ui/pattern/unit-variant-pattern-matching-29383.stderr b/tests/ui/pattern/unit-variant-pattern-matching-29383.stderr new file mode 100644 index 00000000000..e30837568a5 --- /dev/null +++ b/tests/ui/pattern/unit-variant-pattern-matching-29383.stderr @@ -0,0 +1,21 @@ +error[E0532]: expected tuple struct or tuple variant, found unit variant `E::A` + --> $DIR/unit-variant-pattern-matching-29383.rs:10:14 + | +LL | A, + | - `E::A` defined here +... +LL | Some(E::A(..)) => {} + | ^^^^^^^^ help: use this syntax instead: `E::A` + +error[E0532]: expected tuple struct or tuple variant, found unit variant `E::B` + --> $DIR/unit-variant-pattern-matching-29383.rs:12:14 + | +LL | B, + | - `E::B` defined here +... +LL | Some(E::B(..)) => {} + | ^^^^^^^^ help: use this syntax instead: `E::B` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0532`. diff --git a/tests/ui/static/static-string-slice-9249.rs b/tests/ui/static/static-string-slice-9249.rs new file mode 100644 index 00000000000..da099117bd4 --- /dev/null +++ b/tests/ui/static/static-string-slice-9249.rs @@ -0,0 +1,6 @@ +// https://github.com/rust-lang/rust/issues/9249 +//@ check-pass +#![allow(dead_code)] + +static DATA:&'static [&'static str] = &["my string"]; +fn main() { } diff --git a/tests/ui/structs/struct-field-access-errors-24365.rs b/tests/ui/structs/struct-field-access-errors-24365.rs new file mode 100644 index 00000000000..13a95cd1cca --- /dev/null +++ b/tests/ui/structs/struct-field-access-errors-24365.rs @@ -0,0 +1,20 @@ +// https://github.com/rust-lang/rust/issues/24365 +pub enum Attribute { + Code {attr_name_idx: u16}, +} + +pub enum Foo { + Bar +} + +fn test(a: Foo) { + println!("{}", a.b); //~ ERROR no field `b` on type `Foo` +} + +fn main() { + let x = Attribute::Code { + attr_name_idx: 42, + }; + let z = (&x).attr_name_idx; //~ ERROR no field `attr_name_idx` on type `&Attribute` + let y = x.attr_name_idx; //~ ERROR no field `attr_name_idx` on type `Attribute` +} diff --git a/tests/ui/structs/struct-field-access-errors-24365.stderr b/tests/ui/structs/struct-field-access-errors-24365.stderr new file mode 100644 index 00000000000..65275af4701 --- /dev/null +++ b/tests/ui/structs/struct-field-access-errors-24365.stderr @@ -0,0 +1,21 @@ +error[E0609]: no field `b` on type `Foo` + --> $DIR/struct-field-access-errors-24365.rs:11:22 + | +LL | println!("{}", a.b); + | ^ unknown field + +error[E0609]: no field `attr_name_idx` on type `&Attribute` + --> $DIR/struct-field-access-errors-24365.rs:18:18 + | +LL | let z = (&x).attr_name_idx; + | ^^^^^^^^^^^^^ unknown field + +error[E0609]: no field `attr_name_idx` on type `Attribute` + --> $DIR/struct-field-access-errors-24365.rs:19:15 + | +LL | let y = x.attr_name_idx; + | ^^^^^^^^^^^^^ unknown field + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/thread-local/thread-local-with-attributes-30756.rs b/tests/ui/thread-local/thread-local-with-attributes-30756.rs new file mode 100644 index 00000000000..fcf7bb813c8 --- /dev/null +++ b/tests/ui/thread-local/thread-local-with-attributes-30756.rs @@ -0,0 +1,8 @@ +// https://github.com/rust-lang/rust/issues/30756 +//@ run-pass +#![forbid(unsafe_code)] + +thread_local!(static FOO: u8 = 1); + +fn main() { +} diff --git a/tests/ui/typeck/unused-type-parameter-span-30236.rs b/tests/ui/typeck/unused-type-parameter-span-30236.rs new file mode 100644 index 00000000000..bcdc922a71b --- /dev/null +++ b/tests/ui/typeck/unused-type-parameter-span-30236.rs @@ -0,0 +1,8 @@ +// https://github.com/rust-lang/rust/issues/30236 +type Foo< + Unused //~ ERROR type parameter `Unused` is never used + > = u8; + +fn main() { + +} diff --git a/tests/ui/typeck/unused-type-parameter-span-30236.stderr b/tests/ui/typeck/unused-type-parameter-span-30236.stderr new file mode 100644 index 00000000000..038bd1ebd28 --- /dev/null +++ b/tests/ui/typeck/unused-type-parameter-span-30236.stderr @@ -0,0 +1,12 @@ +error[E0091]: type parameter `Unused` is never used + --> $DIR/unused-type-parameter-span-30236.rs:3:5 + | +LL | Unused + | ^^^^^^ unused type parameter + | + = help: consider removing `Unused` or referring to it in the body of the type alias + = help: if you intended `Unused` to be a const parameter, use `const Unused: /* Type */` instead + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0091`. diff --git a/tests/ui/uninhabited/uninhabited-type-layout-computation-88150.rs b/tests/ui/uninhabited/uninhabited-type-layout-computation-88150.rs new file mode 100644 index 00000000000..1387c5b6c10 --- /dev/null +++ b/tests/ui/uninhabited/uninhabited-type-layout-computation-88150.rs @@ -0,0 +1,22 @@ +// https://github.com/rust-lang/rust/issues/88150 +//@ run-pass +//@ compile-flags:-C debuginfo=2 +//@ edition:2018 + +use core::marker::PhantomData; + +pub struct Foo( + PhantomData<(A, T)>, +); + +enum Never {} + +impl Foo { + fn new_foo() -> Foo { + Foo(PhantomData) + } +} + +fn main() { + let _ = Foo::<[()], Never>::new_foo(); +} -- cgit 1.4.1-3-g733a5