From c3ab409b4fa3b1fb18f34877d9811bb502ed507f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 26 Aug 2025 11:13:03 +0200 Subject: Use captures(address) instead of captures(none) for indirect args While provenance cannot be captured through these arguments, the address / object identity can. --- tests/ui/codegen/indirect-nocapture.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/ui/codegen/indirect-nocapture.rs (limited to 'tests/ui/codegen') diff --git a/tests/ui/codegen/indirect-nocapture.rs b/tests/ui/codegen/indirect-nocapture.rs new file mode 100644 index 00000000000..78024a94c0d --- /dev/null +++ b/tests/ui/codegen/indirect-nocapture.rs @@ -0,0 +1,15 @@ +// Regression test for issue #137668 where an indirect argument have been marked as nocapture +// despite the fact that callee did in fact capture the address. +// +//@ run-pass +//@ compile-flags: -Copt-level=2 + +#[inline(never)] +pub fn f(a: [u32; 64], b: [u32; 64]) -> bool { + &a as *const _ as usize != &b as *const _ as usize +} + +fn main() { + static S: [u32; 64] = [0; 64]; + assert!(f(S, S)); +} -- cgit 1.4.1-3-g733a5 From 2e659f58940a31fa625e88f75f78111ed773f32d Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 20 Aug 2025 14:02:39 -0400 Subject: Add test batch 1 --- ...ld-generic-type-binary-assignment-error-6738.rs | 11 +++++ ...eneric-type-binary-assignment-error-6738.stderr | 16 +++++++ tests/ui/borrowck/auxiliary/aux-5518.rs | 4 ++ .../ui/borrowck/borrowed-pointer-in-struct-5884.rs | 18 +++++++ .../incorrect-loan-error-on-local-update-5550.rs | 9 ++++ .../struct-with-reference-to-trait-5708.rs | 54 +++++++++++++++++++++ .../trait-method-lifetime-substitution-5518.rs | 7 +++ tests/ui/box/box-patterns-feature-usage-6557.rs | 9 ++++ tests/ui/cast/owned-struct-to-trait-cast-6318.rs | 20 ++++++++ tests/ui/closures/closure-mut-argument-6153.rs | 13 +++++ tests/ui/codegen/static-array-comparison-7012.rs | 23 +++++++++ tests/ui/enum/enum-referred-by-submodule-5900.rs | 15 ++++++ tests/ui/enum/enum-with-generic-parameter-5997.rs | 16 +++++++ tests/ui/enum/match-either-enum-variants-6117.rs | 12 +++++ ...definition-with-outer-generic-parameter-5997.rs | 11 +++++ ...nition-with-outer-generic-parameter-5997.stderr | 13 +++++ tests/ui/issues/auxiliary/iss.rs | 12 ----- tests/ui/issues/auxiliary/issue-5518.rs | 4 -- tests/ui/issues/auxiliary/issue-5844-aux.rs | 3 -- tests/ui/issues/issue-5358-1.rs | 13 ----- tests/ui/issues/issue-5358-1.stderr | 22 --------- tests/ui/issues/issue-5439.rs | 19 -------- tests/ui/issues/issue-5439.stderr | 11 ----- tests/ui/issues/issue-5518.rs | 7 --- tests/ui/issues/issue-5550.rs | 8 ---- tests/ui/issues/issue-5554.rs | 27 ----------- tests/ui/issues/issue-5572.rs | 6 --- tests/ui/issues/issue-5666.rs | 26 ---------- tests/ui/issues/issue-5688.rs | 20 -------- tests/ui/issues/issue-5708.rs | 55 ---------------------- tests/ui/issues/issue-5718.rs | 23 --------- tests/ui/issues/issue-5741.rs | 8 ---- tests/ui/issues/issue-5844.rs | 7 --- tests/ui/issues/issue-5844.stderr | 11 ----- tests/ui/issues/issue-5883.rs | 13 ----- tests/ui/issues/issue-5883.stderr | 35 -------------- tests/ui/issues/issue-5884.rs | 17 ------- tests/ui/issues/issue-5900.rs | 14 ------ tests/ui/issues/issue-5917.rs | 9 ---- tests/ui/issues/issue-5950.rs | 8 ---- tests/ui/issues/issue-5988.rs | 23 --------- .../issue-5997-enum.rs | 10 ---- .../issue-5997-enum.stderr | 13 ----- .../issue-5997-struct.rs | 10 ---- .../issue-5997-struct.stderr | 13 ----- .../issue-5997.rs | 15 ------ tests/ui/issues/issue-6117.rs | 11 ----- tests/ui/issues/issue-6130.rs | 10 ---- tests/ui/issues/issue-6153.rs | 13 ----- tests/ui/issues/issue-6318.rs | 19 -------- tests/ui/issues/issue-6344-let.rs | 15 ------ tests/ui/issues/issue-6344-match.rs | 18 ------- tests/ui/issues/issue-6557.rs | 8 ---- tests/ui/issues/issue-6738.rs | 10 ---- tests/ui/issues/issue-6738.stderr | 16 ------- tests/ui/issues/issue-6898.rs | 32 ------------- tests/ui/issues/issue-6919.rs | 10 ---- tests/ui/issues/issue-6936.rs | 34 ------------- tests/ui/issues/issue-6936.stderr | 43 ----------------- tests/ui/issues/issue-7012.rs | 22 --------- tests/ui/loops/unreachable-while-loop-5741.rs | 9 ++++ .../macro-variable-declaration-with-bounds-5554.rs | 27 +++++++++++ .../macros/macro-variable-unused-reporting-5718.rs | 24 ++++++++++ tests/ui/match/mismatched-types-in-match-5358.rs | 18 +++++++ .../ui/match/mismatched-types-in-match-5358.stderr | 23 +++++++++ tests/ui/modules/pub-use-module-alias-5950.rs | 8 ++++ tests/ui/numeric/type-limit-comparisons-6130.rs | 11 +++++ tests/ui/parser/partial-eq-trait-bound-5572.rs | 7 +++ tests/ui/privacy/auxiliary/iss-6919.rs | 12 +++++ .../ui/privacy/deref-separate-compile-unit-6919.rs | 10 ++++ tests/ui/resolve/duplicate-name-in-module-6936.rs | 34 +++++++++++++ .../resolve/duplicate-name-in-module-6936.stderr | 43 +++++++++++++++++ tests/ui/static/static-list-initialization-5917.rs | 10 ++++ .../ui/static/static-struct-initialization-5688.rs | 21 +++++++++ .../structs/destructuring-struct-with-dtor-6344.rs | 16 +++++++ .../structs/nonexistent-struct-field-error-5439.rs | 20 ++++++++ .../nonexistent-struct-field-error-5439.stderr | 11 +++++ .../traits/dynamic-dispatch-trait-objects-5666.rs | 26 ++++++++++ tests/ui/traits/opaque-trait-size-error-5883.rs | 14 ++++++ .../ui/traits/opaque-trait-size-error-5883.stderr | 35 ++++++++++++++ .../trait-implementation-generic-access-6898.rs | 33 +++++++++++++ .../trait-implementation-restriction-5988.rs | 24 ++++++++++ tests/ui/unsafe/auxiliary/aux-5844.rs | 3 ++ .../unsafe/extern-function-requires-unsafe-5844.rs | 8 ++++ .../extern-function-requires-unsafe-5844.stderr | 11 +++++ 85 files changed, 709 insertions(+), 723 deletions(-) create mode 100644 tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.rs create mode 100644 tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.stderr create mode 100644 tests/ui/borrowck/auxiliary/aux-5518.rs create mode 100644 tests/ui/borrowck/borrowed-pointer-in-struct-5884.rs create mode 100644 tests/ui/borrowck/incorrect-loan-error-on-local-update-5550.rs create mode 100644 tests/ui/borrowck/struct-with-reference-to-trait-5708.rs create mode 100644 tests/ui/borrowck/trait-method-lifetime-substitution-5518.rs create mode 100644 tests/ui/box/box-patterns-feature-usage-6557.rs create mode 100644 tests/ui/cast/owned-struct-to-trait-cast-6318.rs create mode 100644 tests/ui/closures/closure-mut-argument-6153.rs create mode 100644 tests/ui/codegen/static-array-comparison-7012.rs create mode 100644 tests/ui/enum/enum-referred-by-submodule-5900.rs create mode 100644 tests/ui/enum/enum-with-generic-parameter-5997.rs create mode 100644 tests/ui/enum/match-either-enum-variants-6117.rs create mode 100644 tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.rs create mode 100644 tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr delete mode 100644 tests/ui/issues/auxiliary/iss.rs delete mode 100644 tests/ui/issues/auxiliary/issue-5518.rs delete mode 100644 tests/ui/issues/auxiliary/issue-5844-aux.rs delete mode 100644 tests/ui/issues/issue-5358-1.rs delete mode 100644 tests/ui/issues/issue-5358-1.stderr delete mode 100644 tests/ui/issues/issue-5439.rs delete mode 100644 tests/ui/issues/issue-5439.stderr delete mode 100644 tests/ui/issues/issue-5518.rs delete mode 100644 tests/ui/issues/issue-5550.rs delete mode 100644 tests/ui/issues/issue-5554.rs delete mode 100644 tests/ui/issues/issue-5572.rs delete mode 100644 tests/ui/issues/issue-5666.rs delete mode 100644 tests/ui/issues/issue-5688.rs delete mode 100644 tests/ui/issues/issue-5708.rs delete mode 100644 tests/ui/issues/issue-5718.rs delete mode 100644 tests/ui/issues/issue-5741.rs delete mode 100644 tests/ui/issues/issue-5844.rs delete mode 100644 tests/ui/issues/issue-5844.stderr delete mode 100644 tests/ui/issues/issue-5883.rs delete mode 100644 tests/ui/issues/issue-5883.stderr delete mode 100644 tests/ui/issues/issue-5884.rs delete mode 100644 tests/ui/issues/issue-5900.rs delete mode 100644 tests/ui/issues/issue-5917.rs delete mode 100644 tests/ui/issues/issue-5950.rs delete mode 100644 tests/ui/issues/issue-5988.rs delete mode 100644 tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.rs delete mode 100644 tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.stderr delete mode 100644 tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.rs delete mode 100644 tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.stderr delete mode 100644 tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997.rs delete mode 100644 tests/ui/issues/issue-6117.rs delete mode 100644 tests/ui/issues/issue-6130.rs delete mode 100644 tests/ui/issues/issue-6153.rs delete mode 100644 tests/ui/issues/issue-6318.rs delete mode 100644 tests/ui/issues/issue-6344-let.rs delete mode 100644 tests/ui/issues/issue-6344-match.rs delete mode 100644 tests/ui/issues/issue-6557.rs delete mode 100644 tests/ui/issues/issue-6738.rs delete mode 100644 tests/ui/issues/issue-6738.stderr delete mode 100644 tests/ui/issues/issue-6898.rs delete mode 100644 tests/ui/issues/issue-6919.rs delete mode 100644 tests/ui/issues/issue-6936.rs delete mode 100644 tests/ui/issues/issue-6936.stderr delete mode 100644 tests/ui/issues/issue-7012.rs create mode 100644 tests/ui/loops/unreachable-while-loop-5741.rs create mode 100644 tests/ui/macros/macro-variable-declaration-with-bounds-5554.rs create mode 100644 tests/ui/macros/macro-variable-unused-reporting-5718.rs create mode 100644 tests/ui/match/mismatched-types-in-match-5358.rs create mode 100644 tests/ui/match/mismatched-types-in-match-5358.stderr create mode 100644 tests/ui/modules/pub-use-module-alias-5950.rs create mode 100644 tests/ui/numeric/type-limit-comparisons-6130.rs create mode 100644 tests/ui/parser/partial-eq-trait-bound-5572.rs create mode 100644 tests/ui/privacy/auxiliary/iss-6919.rs create mode 100644 tests/ui/privacy/deref-separate-compile-unit-6919.rs create mode 100644 tests/ui/resolve/duplicate-name-in-module-6936.rs create mode 100644 tests/ui/resolve/duplicate-name-in-module-6936.stderr create mode 100644 tests/ui/static/static-list-initialization-5917.rs create mode 100644 tests/ui/static/static-struct-initialization-5688.rs create mode 100644 tests/ui/structs/destructuring-struct-with-dtor-6344.rs create mode 100644 tests/ui/structs/nonexistent-struct-field-error-5439.rs create mode 100644 tests/ui/structs/nonexistent-struct-field-error-5439.stderr create mode 100644 tests/ui/traits/dynamic-dispatch-trait-objects-5666.rs create mode 100644 tests/ui/traits/opaque-trait-size-error-5883.rs create mode 100644 tests/ui/traits/opaque-trait-size-error-5883.stderr create mode 100644 tests/ui/traits/trait-implementation-generic-access-6898.rs create mode 100644 tests/ui/traits/trait-implementation-restriction-5988.rs create mode 100644 tests/ui/unsafe/auxiliary/aux-5844.rs create mode 100644 tests/ui/unsafe/extern-function-requires-unsafe-5844.rs create mode 100644 tests/ui/unsafe/extern-function-requires-unsafe-5844.stderr (limited to 'tests/ui/codegen') diff --git a/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.rs b/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.rs new file mode 100644 index 00000000000..856caa2b297 --- /dev/null +++ b/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/6738 +struct Foo { + x: T, +} +impl Foo { + fn add(&mut self, v: Foo){ + self.x += v.x; + //~^ ERROR: binary assignment operation `+=` cannot be applied + } +} +fn main() {} diff --git a/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.stderr b/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.stderr new file mode 100644 index 00000000000..060d33079d3 --- /dev/null +++ b/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.stderr @@ -0,0 +1,16 @@ +error[E0368]: binary assignment operation `+=` cannot be applied to type `T` + --> $DIR/struct-field-generic-type-binary-assignment-error-6738.rs:7:9 + | +LL | self.x += v.x; + | ------^^^^^^^ + | | + | cannot use `+=` on type `T` + | +help: consider restricting type parameter `T` with trait `AddAssign` + | +LL | impl Foo { + | +++++++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0368`. diff --git a/tests/ui/borrowck/auxiliary/aux-5518.rs b/tests/ui/borrowck/auxiliary/aux-5518.rs new file mode 100644 index 00000000000..bfe96552a5c --- /dev/null +++ b/tests/ui/borrowck/auxiliary/aux-5518.rs @@ -0,0 +1,4 @@ +trait A<'a, T> { + fn f(&mut self) -> &'a mut T; + fn p() -> T; +} diff --git a/tests/ui/borrowck/borrowed-pointer-in-struct-5884.rs b/tests/ui/borrowck/borrowed-pointer-in-struct-5884.rs new file mode 100644 index 00000000000..d2f17cf905d --- /dev/null +++ b/tests/ui/borrowck/borrowed-pointer-in-struct-5884.rs @@ -0,0 +1,18 @@ +// https://github.com/rust-lang/rust/issues/5884 +//@ build-pass +#![allow(dead_code)] + +pub struct Foo { + a: isize, +} + +struct Bar<'a> { + a: Box>, + b: &'a Foo, +} + +fn check(a: Box) { + let _ic = Bar{ b: &*a, a: Box::new(None) }; +} + +pub fn main(){} diff --git a/tests/ui/borrowck/incorrect-loan-error-on-local-update-5550.rs b/tests/ui/borrowck/incorrect-loan-error-on-local-update-5550.rs new file mode 100644 index 00000000000..2258d768657 --- /dev/null +++ b/tests/ui/borrowck/incorrect-loan-error-on-local-update-5550.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/5550 +//@ run-pass +#![allow(unused_assignments)] + +pub fn main() { + let s: String = "foobar".to_string(); + let mut t: &str = &s; + t = &t[0..3]; // for master: str::view(t, 0, 3) maybe +} diff --git a/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs b/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs new file mode 100644 index 00000000000..5157a3bf36b --- /dev/null +++ b/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs @@ -0,0 +1,54 @@ +// https://github.com/rust-lang/rust/issues/5708 +//@ run-pass +#![allow(unused_variables)] +/* +# ICE when returning struct with reference to trait + +A function which takes a reference to a trait and returns a +struct with that reference results in an ICE. + +This does not occur with concrete types, only with references +to traits. +*/ + +// original +trait Inner { + fn print(&self); +} + +impl Inner for isize { + fn print(&self) { print!("Inner: {}\n", *self); } +} + +struct Outer<'a> { + inner: &'a (dyn Inner+'a) +} + +impl<'a> Outer<'a> { + fn new(inner: &dyn Inner) -> Outer<'_> { + Outer { + inner: inner + } + } +} + +pub fn main() { + let inner: isize = 5; + let outer = Outer::new(&inner as &dyn Inner); + outer.inner.print(); +} + +// minimal +pub trait MyTrait { + fn dummy(&self, t: T) -> T { panic!() } +} + +pub struct MyContainer<'a, T:'a> { + foos: Vec<&'a (dyn MyTrait+'a)> , +} + +impl<'a, T> MyContainer<'a, T> { + pub fn add (&mut self, foo: &'a dyn MyTrait) { + self.foos.push(foo); + } +} diff --git a/tests/ui/borrowck/trait-method-lifetime-substitution-5518.rs b/tests/ui/borrowck/trait-method-lifetime-substitution-5518.rs new file mode 100644 index 00000000000..f254030a011 --- /dev/null +++ b/tests/ui/borrowck/trait-method-lifetime-substitution-5518.rs @@ -0,0 +1,7 @@ +// https://github.com/rust-lang/rust/issues/5518 +//@ run-pass +//@ aux-build:aux-5518.rs + +extern crate aux_5518 as other; + +fn main() {} diff --git a/tests/ui/box/box-patterns-feature-usage-6557.rs b/tests/ui/box/box-patterns-feature-usage-6557.rs new file mode 100644 index 00000000000..e0d9b25c366 --- /dev/null +++ b/tests/ui/box/box-patterns-feature-usage-6557.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/6557 +//@ check-pass +#![allow(dead_code)] + +#![feature(box_patterns)] + +fn foo(box (_x, _y): Box<(isize, isize)>) {} + +pub fn main() {} diff --git a/tests/ui/cast/owned-struct-to-trait-cast-6318.rs b/tests/ui/cast/owned-struct-to-trait-cast-6318.rs new file mode 100644 index 00000000000..8cfc77c4274 --- /dev/null +++ b/tests/ui/cast/owned-struct-to-trait-cast-6318.rs @@ -0,0 +1,20 @@ +// https://github.com/rust-lang/rust/issues/6318 +//@ run-pass + +pub enum Thing { + A(Box) +} + +pub trait Foo { + fn dummy(&self) { } +} + +pub struct Struct; + +impl Foo for Struct {} + +pub fn main() { + match Thing::A(Box::new(Struct) as Box) { + Thing::A(_a) => 0, + }; +} diff --git a/tests/ui/closures/closure-mut-argument-6153.rs b/tests/ui/closures/closure-mut-argument-6153.rs new file mode 100644 index 00000000000..ac19c2bd15f --- /dev/null +++ b/tests/ui/closures/closure-mut-argument-6153.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/6153 +//@ run-pass + +fn swap(f: F) -> Vec where F: FnOnce(Vec) -> Vec { + let x = vec![1, 2, 3]; + f(x) +} + +pub fn main() { + let v = swap(|mut x| { x.push(4); x }); + let w = swap(|mut x| { x.push(4); x }); + assert_eq!(v, w); +} diff --git a/tests/ui/codegen/static-array-comparison-7012.rs b/tests/ui/codegen/static-array-comparison-7012.rs new file mode 100644 index 00000000000..c08b1c0059b --- /dev/null +++ b/tests/ui/codegen/static-array-comparison-7012.rs @@ -0,0 +1,23 @@ +// https://github.com/rust-lang/rust/issues/7012 +//@ run-pass +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +/* +# Comparison of static arrays + +The expected behaviour would be that `test == test1`, therefore 'true' +would be printed, however the below prints false. +*/ + +struct signature<'a> { pattern : &'a [u32] } + +static test1: signature<'static> = signature { + pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0] +}; + +pub fn main() { + let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e, + 0x03707344,0xa4093822,0x299f31d0]; + println!("{}",test==test1.pattern); +} diff --git a/tests/ui/enum/enum-referred-by-submodule-5900.rs b/tests/ui/enum/enum-referred-by-submodule-5900.rs new file mode 100644 index 00000000000..4ed092670a8 --- /dev/null +++ b/tests/ui/enum/enum-referred-by-submodule-5900.rs @@ -0,0 +1,15 @@ +// https://github.com/rust-lang/rust/issues/5900 +//@ check-pass +#![allow(dead_code)] + +pub mod foo { + use super::Bar; + + pub struct FooStruct { bar : Bar } +} + +pub enum Bar { + Bar0 = 0 as isize +} + +pub fn main() {} diff --git a/tests/ui/enum/enum-with-generic-parameter-5997.rs b/tests/ui/enum/enum-with-generic-parameter-5997.rs new file mode 100644 index 00000000000..fab7ebbbbdc --- /dev/null +++ b/tests/ui/enum/enum-with-generic-parameter-5997.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/5997 +//@ run-pass +#![allow(dead_code)] + +fn f() -> bool { + enum E { V(T) } + + struct S(T); + + true +} + +fn main() { + let b = f::(); + assert!(b); +} diff --git a/tests/ui/enum/match-either-enum-variants-6117.rs b/tests/ui/enum/match-either-enum-variants-6117.rs new file mode 100644 index 00000000000..7b395066166 --- /dev/null +++ b/tests/ui/enum/match-either-enum-variants-6117.rs @@ -0,0 +1,12 @@ +// https://github.com/rust-lang/rust/issues/6117 +//@ run-pass +#![allow(dead_code)] + +enum Either { Left(T), Right(U) } + +pub fn main() { + match Either::Left(Box::new(17)) { + Either::Right(()) => {} + _ => {} + } +} diff --git a/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.rs b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.rs new file mode 100644 index 00000000000..00bf66dd4e0 --- /dev/null +++ b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/5997 +fn f() -> bool { + enum E { V(Z) } + //~^ ERROR can't use generic parameters from outer item + true +} + +fn main() { + let b = f::(); + assert!(b); +} diff --git a/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr new file mode 100644 index 00000000000..aea0f049b07 --- /dev/null +++ b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr @@ -0,0 +1,13 @@ +error[E0401]: can't use generic parameters from outer item + --> $DIR/enum-definition-with-outer-generic-parameter-5997.rs:3:16 + | +LL | fn f() -> bool { + | - type parameter from outer item +LL | enum E { V(Z) } + | - ^ use of generic parameter from outer item + | | + | help: try introducing a local generic parameter here: `` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/issues/auxiliary/iss.rs b/tests/ui/issues/auxiliary/iss.rs deleted file mode 100644 index cf32f6c2d5d..00000000000 --- a/tests/ui/issues/auxiliary/iss.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![crate_name="issue6919_3"] - -// part of issue-6919.rs - -pub struct C where K: FnOnce() { - pub k: K, -} - -fn no_op() { } -pub const D : C = C { - k: no_op as fn() -}; diff --git a/tests/ui/issues/auxiliary/issue-5518.rs b/tests/ui/issues/auxiliary/issue-5518.rs deleted file mode 100644 index bfe96552a5c..00000000000 --- a/tests/ui/issues/auxiliary/issue-5518.rs +++ /dev/null @@ -1,4 +0,0 @@ -trait A<'a, T> { - fn f(&mut self) -> &'a mut T; - fn p() -> T; -} diff --git a/tests/ui/issues/auxiliary/issue-5844-aux.rs b/tests/ui/issues/auxiliary/issue-5844-aux.rs deleted file mode 100644 index ea83378cad6..00000000000 --- a/tests/ui/issues/auxiliary/issue-5844-aux.rs +++ /dev/null @@ -1,3 +0,0 @@ -extern "C" { - pub fn rand() -> u32; -} diff --git a/tests/ui/issues/issue-5358-1.rs b/tests/ui/issues/issue-5358-1.rs deleted file mode 100644 index 281f219c039..00000000000 --- a/tests/ui/issues/issue-5358-1.rs +++ /dev/null @@ -1,13 +0,0 @@ -enum Either { Left(T), Right(U) } -struct S(Either); - -fn main() { - match S(Either::Left(5)) { //~ NOTE this expression has type `S` - Either::Right(_) => {} - //~^ ERROR mismatched types - //~| NOTE expected `S`, found `Either<_, _>` - //~| NOTE expected struct `S` - //~| NOTE found enum `Either<_, _>` - _ => {} - } -} diff --git a/tests/ui/issues/issue-5358-1.stderr b/tests/ui/issues/issue-5358-1.stderr deleted file mode 100644 index e68db865dc4..00000000000 --- a/tests/ui/issues/issue-5358-1.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-5358-1.rs:6:9 - | -LL | match S(Either::Left(5)) { - | ------------------ this expression has type `S` -LL | Either::Right(_) => {} - | ^^^^^^^^^^^^^^^^ expected `S`, found `Either<_, _>` - | - = note: expected struct `S` - found enum `Either<_, _>` -help: try wrapping the pattern in `S` - | -LL | S(Either::Right(_)) => {} - | ++ + -help: you might have meant to use field `0` whose type is `Either` - | -LL | match S(Either::Left(5)).0 { - | ++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-5439.rs b/tests/ui/issues/issue-5439.rs deleted file mode 100644 index 852b264dc5d..00000000000 --- a/tests/ui/issues/issue-5439.rs +++ /dev/null @@ -1,19 +0,0 @@ -struct Foo { - foo: isize, -} - -struct Bar { - bar: isize, -} - -impl Bar { - fn make_foo (&self, i: isize) -> Box { - return Box::new(Foo { nonexistent: self, foo: i }); //~ ERROR: no field named - } -} - -fn main () { - let bar = Bar { bar: 1 }; - let foo = bar.make_foo(2); - println!("{}", foo.foo); -} diff --git a/tests/ui/issues/issue-5439.stderr b/tests/ui/issues/issue-5439.stderr deleted file mode 100644 index 6d1d74e3045..00000000000 --- a/tests/ui/issues/issue-5439.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0560]: struct `Foo` has no field named `nonexistent` - --> $DIR/issue-5439.rs:11:31 - | -LL | return Box::new(Foo { nonexistent: self, foo: i }); - | ^^^^^^^^^^^ `Foo` does not have this field - | - = note: all struct fields are already assigned - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0560`. diff --git a/tests/ui/issues/issue-5518.rs b/tests/ui/issues/issue-5518.rs deleted file mode 100644 index 333185c482f..00000000000 --- a/tests/ui/issues/issue-5518.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -//@ aux-build:issue-5518.rs - - -extern crate issue_5518 as other; - -fn main() {} diff --git a/tests/ui/issues/issue-5550.rs b/tests/ui/issues/issue-5550.rs deleted file mode 100644 index 41de8ee5d32..00000000000 --- a/tests/ui/issues/issue-5550.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -#![allow(unused_assignments)] - -pub fn main() { - let s: String = "foobar".to_string(); - let mut t: &str = &s; - t = &t[0..3]; // for master: str::view(t, 0, 3) maybe -} diff --git a/tests/ui/issues/issue-5554.rs b/tests/ui/issues/issue-5554.rs deleted file mode 100644 index 7d219a0df70..00000000000 --- a/tests/ui/issues/issue-5554.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - - -pub struct X { - a: T, -} - -// reordering these bounds stops the ICE -// -// nmatsakis: This test used to have the bounds Default + PartialEq + -// Default, but having duplicate bounds became illegal. -impl Default for X { - fn default() -> X { - X { a: Default::default() } - } -} - -macro_rules! constants { - () => { - let _ : X = Default::default(); - } -} - -pub fn main() { - constants!(); -} diff --git a/tests/ui/issues/issue-5572.rs b/tests/ui/issues/issue-5572.rs deleted file mode 100644 index f27744ef0ac..00000000000 --- a/tests/ui/issues/issue-5572.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ check-pass -#![allow(dead_code)] - -fn foo(_t: T) { } - -pub fn main() { } diff --git a/tests/ui/issues/issue-5666.rs b/tests/ui/issues/issue-5666.rs deleted file mode 100644 index 76e2f8229a0..00000000000 --- a/tests/ui/issues/issue-5666.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ run-pass - -struct Dog { - name : String -} - -trait Barks { - fn bark(&self) -> String; -} - -impl Barks for Dog { - fn bark(&self) -> String { - return format!("woof! (I'm {})", self.name); - } -} - - -pub fn main() { - let snoopy = Box::new(Dog{name: "snoopy".to_string()}); - let bubbles = Box::new(Dog{name: "bubbles".to_string()}); - let barker = [snoopy as Box, bubbles as Box]; - - for pup in &barker { - println!("{}", pup.bark()); - } -} diff --git a/tests/ui/issues/issue-5688.rs b/tests/ui/issues/issue-5688.rs deleted file mode 100644 index a7db1dfb15f..00000000000 --- a/tests/ui/issues/issue-5688.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass -/* -# Corrupted initialization in the static struct - -...should print &[1, 2, 3] but instead prints something like -&[4492532864, 24]. It is pretty evident that the compiler messed up -with the representation of [isize; n] and [isize] somehow, or at least -failed to typecheck correctly. -*/ - -#[derive(Copy, Clone)] -struct X { vec: &'static [isize] } - -static V: &'static [X] = &[X { vec: &[1, 2, 3] }]; - -pub fn main() { - for &v in V { - println!("{:?}", v.vec); - } -} diff --git a/tests/ui/issues/issue-5708.rs b/tests/ui/issues/issue-5708.rs deleted file mode 100644 index 6fa3cfa4724..00000000000 --- a/tests/ui/issues/issue-5708.rs +++ /dev/null @@ -1,55 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] -/* -# ICE when returning struct with reference to trait - -A function which takes a reference to a trait and returns a -struct with that reference results in an ICE. - -This does not occur with concrete types, only with references -to traits. -*/ - - -// original -trait Inner { - fn print(&self); -} - -impl Inner for isize { - fn print(&self) { print!("Inner: {}\n", *self); } -} - -struct Outer<'a> { - inner: &'a (dyn Inner+'a) -} - -impl<'a> Outer<'a> { - fn new(inner: &dyn Inner) -> Outer<'_> { - Outer { - inner: inner - } - } -} - -pub fn main() { - let inner: isize = 5; - let outer = Outer::new(&inner as &dyn Inner); - outer.inner.print(); -} - - -// minimal -pub trait MyTrait { - fn dummy(&self, t: T) -> T { panic!() } -} - -pub struct MyContainer<'a, T:'a> { - foos: Vec<&'a (dyn MyTrait+'a)> , -} - -impl<'a, T> MyContainer<'a, T> { - pub fn add (&mut self, foo: &'a dyn MyTrait) { - self.foos.push(foo); - } -} diff --git a/tests/ui/issues/issue-5718.rs b/tests/ui/issues/issue-5718.rs deleted file mode 100644 index 234fb2e2222..00000000000 --- a/tests/ui/issues/issue-5718.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ run-pass - -struct Element; - -macro_rules! foo { - ($tag: expr, $string: expr) => { - if $tag == $string { - let element: Box<_> = Box::new(Element); - unsafe { - return std::mem::transmute::<_, usize>(element); - } - } - } -} - -fn bar() -> usize { - foo!("a", "b"); - 0 -} - -fn main() { - bar(); -} diff --git a/tests/ui/issues/issue-5741.rs b/tests/ui/issues/issue-5741.rs deleted file mode 100644 index af4702ec22c..00000000000 --- a/tests/ui/issues/issue-5741.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -#![allow(while_true)] -#![allow(unreachable_code)] - -pub fn main() { - return; - while true {}; -} diff --git a/tests/ui/issues/issue-5844.rs b/tests/ui/issues/issue-5844.rs deleted file mode 100644 index 23021207ae1..00000000000 --- a/tests/ui/issues/issue-5844.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@aux-build:issue-5844-aux.rs - -extern crate issue_5844_aux; - -fn main() { - issue_5844_aux::rand(); //~ ERROR: requires unsafe -} diff --git a/tests/ui/issues/issue-5844.stderr b/tests/ui/issues/issue-5844.stderr deleted file mode 100644 index bae917fa72c..00000000000 --- a/tests/ui/issues/issue-5844.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe function or block - --> $DIR/issue-5844.rs:6:5 - | -LL | issue_5844_aux::rand(); - | ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/issues/issue-5883.rs b/tests/ui/issues/issue-5883.rs deleted file mode 100644 index dd4753e0344..00000000000 --- a/tests/ui/issues/issue-5883.rs +++ /dev/null @@ -1,13 +0,0 @@ -trait A {} - -struct Struct { - r: dyn A + 'static -} - -fn new_struct( - r: dyn A + 'static //~ ERROR the size for values of type -) -> Struct { //~ ERROR the size for values of type - Struct { r: r } -} - -fn main() {} diff --git a/tests/ui/issues/issue-5883.stderr b/tests/ui/issues/issue-5883.stderr deleted file mode 100644 index 2ca437b8c47..00000000000 --- a/tests/ui/issues/issue-5883.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time - --> $DIR/issue-5883.rs:9:6 - | -LL | ) -> Struct { - | ^^^^^^ doesn't have a size known at compile-time - | - = help: within `Struct`, the trait `Sized` is not implemented for `(dyn A + 'static)` -note: required because it appears within the type `Struct` - --> $DIR/issue-5883.rs:3:8 - | -LL | struct Struct { - | ^^^^^^ - = note: the return type of a function must have a statically known size - -error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time - --> $DIR/issue-5883.rs:8:8 - | -LL | r: dyn A + 'static - | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(dyn A + 'static)` - = help: unsized fn params are gated as an unstable feature -help: you can use `impl Trait` as the argument type - | -LL - r: dyn A + 'static -LL + r: impl A + 'static - | -help: function arguments must have a statically known size, borrowed types always have a known size - | -LL | r: &dyn A + 'static - | + - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-5884.rs b/tests/ui/issues/issue-5884.rs deleted file mode 100644 index 559b897395d..00000000000 --- a/tests/ui/issues/issue-5884.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ build-pass -#![allow(dead_code)] - -pub struct Foo { - a: isize, -} - -struct Bar<'a> { - a: Box>, - b: &'a Foo, -} - -fn check(a: Box) { - let _ic = Bar{ b: &*a, a: Box::new(None) }; -} - -pub fn main(){} diff --git a/tests/ui/issues/issue-5900.rs b/tests/ui/issues/issue-5900.rs deleted file mode 100644 index 14b7b8f815a..00000000000 --- a/tests/ui/issues/issue-5900.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass -#![allow(dead_code)] - -pub mod foo { - use super::Bar; - - pub struct FooStruct { bar : Bar } -} - -pub enum Bar { - Bar0 = 0 as isize -} - -pub fn main() {} diff --git a/tests/ui/issues/issue-5917.rs b/tests/ui/issues/issue-5917.rs deleted file mode 100644 index 8e91b1052a2..00000000000 --- a/tests/ui/issues/issue-5917.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -#![allow(non_upper_case_globals)] - -struct T (&'static [isize]); -static t : T = T (&[5, 4, 3]); -pub fn main () { - let T(ref v) = t; - assert_eq!(v[0], 5); -} diff --git a/tests/ui/issues/issue-5950.rs b/tests/ui/issues/issue-5950.rs deleted file mode 100644 index 6015560fcf8..00000000000 --- a/tests/ui/issues/issue-5950.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ check-pass - - -pub use local as local_alias; - -pub mod local { } - -pub fn main() {} diff --git a/tests/ui/issues/issue-5988.rs b/tests/ui/issues/issue-5988.rs deleted file mode 100644 index b7527d9bea8..00000000000 --- a/tests/ui/issues/issue-5988.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ run-pass - -trait B { - fn f(&self); -} - -trait T : B { -} - -struct A; - -impl B for U { - fn f(&self) { } -} - -impl T for A { -} - -fn main() { - let a = A; - let br = &a as &dyn B; - br.f(); -} diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.rs b/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.rs deleted file mode 100644 index 0b1857ae3df..00000000000 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.rs +++ /dev/null @@ -1,10 +0,0 @@ -fn f() -> bool { - enum E { V(Z) } - //~^ ERROR can't use generic parameters from outer item - true -} - -fn main() { - let b = f::(); - assert!(b); -} diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.stderr b/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.stderr deleted file mode 100644 index c0b3cd6de66..00000000000 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0401]: can't use generic parameters from outer item - --> $DIR/issue-5997-enum.rs:2:16 - | -LL | fn f() -> bool { - | - type parameter from outer item -LL | enum E { V(Z) } - | - ^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.rs b/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.rs deleted file mode 100644 index 19d994b0dfb..00000000000 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.rs +++ /dev/null @@ -1,10 +0,0 @@ -fn f() -> bool { - struct S(T); //~ ERROR can't use generic parameters from outer item - - true -} - -fn main() { - let b = f::(); - assert!(b); -} diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.stderr b/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.stderr deleted file mode 100644 index 670a54894b5..00000000000 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0401]: can't use generic parameters from outer item - --> $DIR/issue-5997-struct.rs:2:14 - | -LL | fn f() -> bool { - | - type parameter from outer item -LL | struct S(T); - | -^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997.rs b/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997.rs deleted file mode 100644 index 7ed8819f322..00000000000 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -fn f() -> bool { - enum E { V(T) } - - struct S(T); - - true -} - -fn main() { - let b = f::(); - assert!(b); -} diff --git a/tests/ui/issues/issue-6117.rs b/tests/ui/issues/issue-6117.rs deleted file mode 100644 index 3ccf67b0319..00000000000 --- a/tests/ui/issues/issue-6117.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -enum Either { Left(T), Right(U) } - -pub fn main() { - match Either::Left(Box::new(17)) { - Either::Right(()) => {} - _ => {} - } -} diff --git a/tests/ui/issues/issue-6130.rs b/tests/ui/issues/issue-6130.rs deleted file mode 100644 index c675a8a41dd..00000000000 --- a/tests/ui/issues/issue-6130.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -pub fn main() { - let i: usize = 0; - assert!(i <= 0xFFFF_FFFF); - - let i: isize = 0; - assert!(i >= -0x8000_0000); - assert!(i <= 0x7FFF_FFFF); -} diff --git a/tests/ui/issues/issue-6153.rs b/tests/ui/issues/issue-6153.rs deleted file mode 100644 index cd78c85d94b..00000000000 --- a/tests/ui/issues/issue-6153.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - - -fn swap(f: F) -> Vec where F: FnOnce(Vec) -> Vec { - let x = vec![1, 2, 3]; - f(x) -} - -pub fn main() { - let v = swap(|mut x| { x.push(4); x }); - let w = swap(|mut x| { x.push(4); x }); - assert_eq!(v, w); -} diff --git a/tests/ui/issues/issue-6318.rs b/tests/ui/issues/issue-6318.rs deleted file mode 100644 index d3f08285a93..00000000000 --- a/tests/ui/issues/issue-6318.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass - -pub enum Thing { - A(Box) -} - -pub trait Foo { - fn dummy(&self) { } -} - -pub struct Struct; - -impl Foo for Struct {} - -pub fn main() { - match Thing::A(Box::new(Struct) as Box) { - Thing::A(_a) => 0, - }; -} diff --git a/tests/ui/issues/issue-6344-let.rs b/tests/ui/issues/issue-6344-let.rs deleted file mode 100644 index 1e1bdfa17be..00000000000 --- a/tests/ui/issues/issue-6344-let.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass -#![allow(non_shorthand_field_patterns)] - -struct A { x: usize } - -impl Drop for A { - fn drop(&mut self) {} -} - -pub fn main() { - let a = A { x: 0 }; - - let A { x: ref x } = a; - println!("{}", x) -} diff --git a/tests/ui/issues/issue-6344-match.rs b/tests/ui/issues/issue-6344-match.rs deleted file mode 100644 index 9251e274383..00000000000 --- a/tests/ui/issues/issue-6344-match.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ run-pass -#![allow(non_shorthand_field_patterns)] - -struct A { x: usize } - -impl Drop for A { - fn drop(&mut self) {} -} - -pub fn main() { - let a = A { x: 0 }; - - match a { - A { x : ref x } => { - println!("{}", x) - } - } -} diff --git a/tests/ui/issues/issue-6557.rs b/tests/ui/issues/issue-6557.rs deleted file mode 100644 index 64a025a294f..00000000000 --- a/tests/ui/issues/issue-6557.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ check-pass -#![allow(dead_code)] - -#![feature(box_patterns)] - -fn foo(box (_x, _y): Box<(isize, isize)>) {} - -pub fn main() {} diff --git a/tests/ui/issues/issue-6738.rs b/tests/ui/issues/issue-6738.rs deleted file mode 100644 index a2f8dfe9c49..00000000000 --- a/tests/ui/issues/issue-6738.rs +++ /dev/null @@ -1,10 +0,0 @@ -struct Foo { - x: T, -} -impl Foo { - fn add(&mut self, v: Foo){ - self.x += v.x; - //~^ ERROR: binary assignment operation `+=` cannot be applied - } -} -fn main() {} diff --git a/tests/ui/issues/issue-6738.stderr b/tests/ui/issues/issue-6738.stderr deleted file mode 100644 index f22d6a2e468..00000000000 --- a/tests/ui/issues/issue-6738.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0368]: binary assignment operation `+=` cannot be applied to type `T` - --> $DIR/issue-6738.rs:6:9 - | -LL | self.x += v.x; - | ------^^^^^^^ - | | - | cannot use `+=` on type `T` - | -help: consider restricting type parameter `T` with trait `AddAssign` - | -LL | impl Foo { - | +++++++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0368`. diff --git a/tests/ui/issues/issue-6898.rs b/tests/ui/issues/issue-6898.rs deleted file mode 100644 index c810acaf61b..00000000000 --- a/tests/ui/issues/issue-6898.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ check-pass - -use std::mem; - -/// Returns the size of a type -pub fn size_of() -> usize { - TypeInfo::size_of(None::) -} - -/// Returns the size of the type that `val` points to -pub fn size_of_val(val: &T) -> usize { - val.size_of_val() -} - -pub trait TypeInfo: Sized { - fn size_of(_lame_type_hint: Option) -> usize; - fn size_of_val(&self) -> usize; -} - -impl TypeInfo for T { - /// The size of the type in bytes. - fn size_of(_lame_type_hint: Option) -> usize { - mem::size_of::() - } - - /// Returns the size of the type of `self` in bytes. - fn size_of_val(&self) -> usize { - TypeInfo::size_of(None::) - } -} - -pub fn main() {} diff --git a/tests/ui/issues/issue-6919.rs b/tests/ui/issues/issue-6919.rs deleted file mode 100644 index 7fb8a2f33bc..00000000000 --- a/tests/ui/issues/issue-6919.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -#![allow(unused_attributes)] -//@ aux-build:iss.rs - - -extern crate issue6919_3; - -pub fn main() { - let _ = issue6919_3::D.k; -} diff --git a/tests/ui/issues/issue-6936.rs b/tests/ui/issues/issue-6936.rs deleted file mode 100644 index e9aa80b4eb3..00000000000 --- a/tests/ui/issues/issue-6936.rs +++ /dev/null @@ -1,34 +0,0 @@ -struct T; - -mod t1 { - type Foo = crate::T; - mod Foo {} //~ ERROR the name `Foo` is defined multiple times -} - -mod t2 { - type Foo = crate::T; - struct Foo; //~ ERROR the name `Foo` is defined multiple times -} - -mod t3 { - type Foo = crate::T; - enum Foo {} //~ ERROR the name `Foo` is defined multiple times -} - -mod t4 { - type Foo = crate::T; - fn Foo() {} // ok -} - -mod t5 { - type Bar = T; - mod Bar {} //~ ERROR the name `Bar` is defined multiple times -} - -mod t6 { - type Foo = crate::T; - impl Foo {} // ok -} - - -fn main() {} diff --git a/tests/ui/issues/issue-6936.stderr b/tests/ui/issues/issue-6936.stderr deleted file mode 100644 index 03cc50636b4..00000000000 --- a/tests/ui/issues/issue-6936.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0428]: the name `Foo` is defined multiple times - --> $DIR/issue-6936.rs:5:5 - | -LL | type Foo = crate::T; - | -------------------- previous definition of the type `Foo` here -LL | mod Foo {} - | ^^^^^^^ `Foo` redefined here - | - = note: `Foo` must be defined only once in the type namespace of this module - -error[E0428]: the name `Foo` is defined multiple times - --> $DIR/issue-6936.rs:10:5 - | -LL | type Foo = crate::T; - | -------------------- previous definition of the type `Foo` here -LL | struct Foo; - | ^^^^^^^^^^^ `Foo` redefined here - | - = note: `Foo` must be defined only once in the type namespace of this module - -error[E0428]: the name `Foo` is defined multiple times - --> $DIR/issue-6936.rs:15:5 - | -LL | type Foo = crate::T; - | -------------------- previous definition of the type `Foo` here -LL | enum Foo {} - | ^^^^^^^^ `Foo` redefined here - | - = note: `Foo` must be defined only once in the type namespace of this module - -error[E0428]: the name `Bar` is defined multiple times - --> $DIR/issue-6936.rs:25:5 - | -LL | type Bar = T; - | ---------------- previous definition of the type `Bar` here -LL | mod Bar {} - | ^^^^^^^ `Bar` redefined here - | - = note: `Bar` must be defined only once in the type namespace of this module - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/issues/issue-7012.rs b/tests/ui/issues/issue-7012.rs deleted file mode 100644 index 69b881e2a43..00000000000 --- a/tests/ui/issues/issue-7012.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ run-pass -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] - -/* -# Comparison of static arrays - -The expected behaviour would be that `test == test1`, therefore 'true' -would be printed, however the below prints false. -*/ - -struct signature<'a> { pattern : &'a [u32] } - -static test1: signature<'static> = signature { - pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0] -}; - -pub fn main() { - let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e, - 0x03707344,0xa4093822,0x299f31d0]; - println!("{}",test==test1.pattern); -} diff --git a/tests/ui/loops/unreachable-while-loop-5741.rs b/tests/ui/loops/unreachable-while-loop-5741.rs new file mode 100644 index 00000000000..bc69df0f675 --- /dev/null +++ b/tests/ui/loops/unreachable-while-loop-5741.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/5741 +//@ run-pass +#![allow(while_true)] +#![allow(unreachable_code)] + +pub fn main() { + return; + while true {}; +} diff --git a/tests/ui/macros/macro-variable-declaration-with-bounds-5554.rs b/tests/ui/macros/macro-variable-declaration-with-bounds-5554.rs new file mode 100644 index 00000000000..8ccf8e80131 --- /dev/null +++ b/tests/ui/macros/macro-variable-declaration-with-bounds-5554.rs @@ -0,0 +1,27 @@ +// https://github.com/rust-lang/rust/issues/5554 +//@ run-pass +#![allow(dead_code)] + +pub struct X { + a: T, +} + +// reordering these bounds stops the ICE +// +// nmatsakis: This test used to have the bounds Default + PartialEq + +// Default, but having duplicate bounds became illegal. +impl Default for X { + fn default() -> X { + X { a: Default::default() } + } +} + +macro_rules! constants { + () => { + let _ : X = Default::default(); + } +} + +pub fn main() { + constants!(); +} diff --git a/tests/ui/macros/macro-variable-unused-reporting-5718.rs b/tests/ui/macros/macro-variable-unused-reporting-5718.rs new file mode 100644 index 00000000000..55da925461d --- /dev/null +++ b/tests/ui/macros/macro-variable-unused-reporting-5718.rs @@ -0,0 +1,24 @@ +// https://github.com/rust-lang/rust/issues/5718 +//@ run-pass + +struct Element; + +macro_rules! foo { + ($tag: expr, $string: expr) => { + if $tag == $string { + let element: Box<_> = Box::new(Element); + unsafe { + return std::mem::transmute::<_, usize>(element); + } + } + } +} + +fn bar() -> usize { + foo!("a", "b"); + 0 +} + +fn main() { + bar(); +} diff --git a/tests/ui/match/mismatched-types-in-match-5358.rs b/tests/ui/match/mismatched-types-in-match-5358.rs new file mode 100644 index 00000000000..d096bf3a493 --- /dev/null +++ b/tests/ui/match/mismatched-types-in-match-5358.rs @@ -0,0 +1,18 @@ +// https://github.com/rust-lang/rust/issues/5358 +enum Either { + Left(T), + Right(U), +} +struct S(Either); + +fn main() { + match S(Either::Left(5)) { + //~^ NOTE this expression has type `S` + Either::Right(_) => {} + //~^ ERROR mismatched types + //~| NOTE expected `S`, found `Either<_, _>` + //~| NOTE expected struct `S` + //~| NOTE found enum `Either<_, _>` + _ => {} + } +} diff --git a/tests/ui/match/mismatched-types-in-match-5358.stderr b/tests/ui/match/mismatched-types-in-match-5358.stderr new file mode 100644 index 00000000000..6a6cf3ee269 --- /dev/null +++ b/tests/ui/match/mismatched-types-in-match-5358.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/mismatched-types-in-match-5358.rs:11:9 + | +LL | match S(Either::Left(5)) { + | ------------------ this expression has type `S` +LL | +LL | Either::Right(_) => {} + | ^^^^^^^^^^^^^^^^ expected `S`, found `Either<_, _>` + | + = note: expected struct `S` + found enum `Either<_, _>` +help: try wrapping the pattern in `S` + | +LL | S(Either::Right(_)) => {} + | ++ + +help: you might have meant to use field `0` whose type is `Either` + | +LL | match S(Either::Left(5)).0 { + | ++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/modules/pub-use-module-alias-5950.rs b/tests/ui/modules/pub-use-module-alias-5950.rs new file mode 100644 index 00000000000..91d3f9b16ff --- /dev/null +++ b/tests/ui/modules/pub-use-module-alias-5950.rs @@ -0,0 +1,8 @@ +// https://github.com/rust-lang/rust/issues/5950 +//@ check-pass + +pub use local as local_alias; + +pub mod local { } + +pub fn main() {} diff --git a/tests/ui/numeric/type-limit-comparisons-6130.rs b/tests/ui/numeric/type-limit-comparisons-6130.rs new file mode 100644 index 00000000000..54b3f631e67 --- /dev/null +++ b/tests/ui/numeric/type-limit-comparisons-6130.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/6130 +//@ run-pass + +pub fn main() { + let i: usize = 0; + assert!(i <= 0xFFFF_FFFF); + + let i: isize = 0; + assert!(i >= -0x8000_0000); + assert!(i <= 0x7FFF_FFFF); +} diff --git a/tests/ui/parser/partial-eq-trait-bound-5572.rs b/tests/ui/parser/partial-eq-trait-bound-5572.rs new file mode 100644 index 00000000000..7ee0cdc43ee --- /dev/null +++ b/tests/ui/parser/partial-eq-trait-bound-5572.rs @@ -0,0 +1,7 @@ +// https://github.com/rust-lang/rust/issues/5572 +//@ check-pass +#![allow(dead_code)] + +fn foo(_t: T) { } + +pub fn main() { } diff --git a/tests/ui/privacy/auxiliary/iss-6919.rs b/tests/ui/privacy/auxiliary/iss-6919.rs new file mode 100644 index 00000000000..cf32f6c2d5d --- /dev/null +++ b/tests/ui/privacy/auxiliary/iss-6919.rs @@ -0,0 +1,12 @@ +#![crate_name="issue6919_3"] + +// part of issue-6919.rs + +pub struct C where K: FnOnce() { + pub k: K, +} + +fn no_op() { } +pub const D : C = C { + k: no_op as fn() +}; diff --git a/tests/ui/privacy/deref-separate-compile-unit-6919.rs b/tests/ui/privacy/deref-separate-compile-unit-6919.rs new file mode 100644 index 00000000000..5d8934987e5 --- /dev/null +++ b/tests/ui/privacy/deref-separate-compile-unit-6919.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/6919 +//@ run-pass +#![allow(unused_attributes)] +//@ aux-build:iss-6919.rs + +extern crate issue6919_3; + +pub fn main() { + let _ = issue6919_3::D.k; +} diff --git a/tests/ui/resolve/duplicate-name-in-module-6936.rs b/tests/ui/resolve/duplicate-name-in-module-6936.rs new file mode 100644 index 00000000000..ae9282c0c24 --- /dev/null +++ b/tests/ui/resolve/duplicate-name-in-module-6936.rs @@ -0,0 +1,34 @@ +// https://github.com/rust-lang/rust/issues/6936 +struct T; + +mod t1 { + type Foo = crate::T; + mod Foo {} //~ ERROR the name `Foo` is defined multiple times +} + +mod t2 { + type Foo = crate::T; + struct Foo; //~ ERROR the name `Foo` is defined multiple times +} + +mod t3 { + type Foo = crate::T; + enum Foo {} //~ ERROR the name `Foo` is defined multiple times +} + +mod t4 { + type Foo = crate::T; + fn Foo() {} // ok +} + +mod t5 { + type Bar = T; + mod Bar {} //~ ERROR the name `Bar` is defined multiple times +} + +mod t6 { + type Foo = crate::T; + impl Foo {} // ok +} + +fn main() {} diff --git a/tests/ui/resolve/duplicate-name-in-module-6936.stderr b/tests/ui/resolve/duplicate-name-in-module-6936.stderr new file mode 100644 index 00000000000..76bb8f57386 --- /dev/null +++ b/tests/ui/resolve/duplicate-name-in-module-6936.stderr @@ -0,0 +1,43 @@ +error[E0428]: the name `Foo` is defined multiple times + --> $DIR/duplicate-name-in-module-6936.rs:6:5 + | +LL | type Foo = crate::T; + | -------------------- previous definition of the type `Foo` here +LL | mod Foo {} + | ^^^^^^^ `Foo` redefined here + | + = note: `Foo` must be defined only once in the type namespace of this module + +error[E0428]: the name `Foo` is defined multiple times + --> $DIR/duplicate-name-in-module-6936.rs:11:5 + | +LL | type Foo = crate::T; + | -------------------- previous definition of the type `Foo` here +LL | struct Foo; + | ^^^^^^^^^^^ `Foo` redefined here + | + = note: `Foo` must be defined only once in the type namespace of this module + +error[E0428]: the name `Foo` is defined multiple times + --> $DIR/duplicate-name-in-module-6936.rs:16:5 + | +LL | type Foo = crate::T; + | -------------------- previous definition of the type `Foo` here +LL | enum Foo {} + | ^^^^^^^^ `Foo` redefined here + | + = note: `Foo` must be defined only once in the type namespace of this module + +error[E0428]: the name `Bar` is defined multiple times + --> $DIR/duplicate-name-in-module-6936.rs:26:5 + | +LL | type Bar = T; + | ---------------- previous definition of the type `Bar` here +LL | mod Bar {} + | ^^^^^^^ `Bar` redefined here + | + = note: `Bar` must be defined only once in the type namespace of this module + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/static/static-list-initialization-5917.rs b/tests/ui/static/static-list-initialization-5917.rs new file mode 100644 index 00000000000..c6c32f7582e --- /dev/null +++ b/tests/ui/static/static-list-initialization-5917.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/5917 +//@ run-pass +#![allow(non_upper_case_globals)] + +struct T (&'static [isize]); +static t : T = T (&[5, 4, 3]); +pub fn main () { + let T(ref v) = t; + assert_eq!(v[0], 5); +} diff --git a/tests/ui/static/static-struct-initialization-5688.rs b/tests/ui/static/static-struct-initialization-5688.rs new file mode 100644 index 00000000000..6a4c2f45b6b --- /dev/null +++ b/tests/ui/static/static-struct-initialization-5688.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/5688 +//@ run-pass +/* +# Corrupted initialization in the static struct + +...should print &[1, 2, 3] but instead prints something like +&[4492532864, 24]. It is pretty evident that the compiler messed up +with the representation of [isize; n] and [isize] somehow, or at least +failed to typecheck correctly. +*/ + +#[derive(Copy, Clone)] +struct X { vec: &'static [isize] } + +static V: &'static [X] = &[X { vec: &[1, 2, 3] }]; + +pub fn main() { + for &v in V { + println!("{:?}", v.vec); + } +} diff --git a/tests/ui/structs/destructuring-struct-with-dtor-6344.rs b/tests/ui/structs/destructuring-struct-with-dtor-6344.rs new file mode 100644 index 00000000000..b107a99e89f --- /dev/null +++ b/tests/ui/structs/destructuring-struct-with-dtor-6344.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/6344 +//@ run-pass +#![allow(non_shorthand_field_patterns)] + +struct A { x: usize } + +impl Drop for A { + fn drop(&mut self) {} +} + +pub fn main() { + let a = A { x: 0 }; + + let A { x: ref x } = a; + println!("{}", x) +} diff --git a/tests/ui/structs/nonexistent-struct-field-error-5439.rs b/tests/ui/structs/nonexistent-struct-field-error-5439.rs new file mode 100644 index 00000000000..b2b3293ac91 --- /dev/null +++ b/tests/ui/structs/nonexistent-struct-field-error-5439.rs @@ -0,0 +1,20 @@ +// https://github.com/rust-lang/rust/issues/5439 +struct Foo { + foo: isize, +} + +struct Bar { + bar: isize, +} + +impl Bar { + fn make_foo (&self, i: isize) -> Box { + return Box::new(Foo { nonexistent: self, foo: i }); //~ ERROR: no field named + } +} + +fn main () { + let bar = Bar { bar: 1 }; + let foo = bar.make_foo(2); + println!("{}", foo.foo); +} diff --git a/tests/ui/structs/nonexistent-struct-field-error-5439.stderr b/tests/ui/structs/nonexistent-struct-field-error-5439.stderr new file mode 100644 index 00000000000..b560772fbf0 --- /dev/null +++ b/tests/ui/structs/nonexistent-struct-field-error-5439.stderr @@ -0,0 +1,11 @@ +error[E0560]: struct `Foo` has no field named `nonexistent` + --> $DIR/nonexistent-struct-field-error-5439.rs:12:31 + | +LL | return Box::new(Foo { nonexistent: self, foo: i }); + | ^^^^^^^^^^^ `Foo` does not have this field + | + = note: all struct fields are already assigned + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0560`. diff --git a/tests/ui/traits/dynamic-dispatch-trait-objects-5666.rs b/tests/ui/traits/dynamic-dispatch-trait-objects-5666.rs new file mode 100644 index 00000000000..e335949d832 --- /dev/null +++ b/tests/ui/traits/dynamic-dispatch-trait-objects-5666.rs @@ -0,0 +1,26 @@ +// https://github.com/rust-lang/rust/issues/5666 +//@ run-pass + +struct Dog { + name : String +} + +trait Barks { + fn bark(&self) -> String; +} + +impl Barks for Dog { + fn bark(&self) -> String { + return format!("woof! (I'm {})", self.name); + } +} + +pub fn main() { + let snoopy = Box::new(Dog{name: "snoopy".to_string()}); + let bubbles = Box::new(Dog{name: "bubbles".to_string()}); + let barker = [snoopy as Box, bubbles as Box]; + + for pup in &barker { + println!("{}", pup.bark()); + } +} diff --git a/tests/ui/traits/opaque-trait-size-error-5883.rs b/tests/ui/traits/opaque-trait-size-error-5883.rs new file mode 100644 index 00000000000..e39e24e7342 --- /dev/null +++ b/tests/ui/traits/opaque-trait-size-error-5883.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/5883 +trait A {} + +struct Struct { + r: dyn A + 'static +} + +fn new_struct( + r: dyn A + 'static //~ ERROR the size for values of type +) -> Struct { //~ ERROR the size for values of type + Struct { r: r } +} + +fn main() {} diff --git a/tests/ui/traits/opaque-trait-size-error-5883.stderr b/tests/ui/traits/opaque-trait-size-error-5883.stderr new file mode 100644 index 00000000000..78de250b19a --- /dev/null +++ b/tests/ui/traits/opaque-trait-size-error-5883.stderr @@ -0,0 +1,35 @@ +error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time + --> $DIR/opaque-trait-size-error-5883.rs:10:6 + | +LL | ) -> Struct { + | ^^^^^^ doesn't have a size known at compile-time + | + = help: within `Struct`, the trait `Sized` is not implemented for `(dyn A + 'static)` +note: required because it appears within the type `Struct` + --> $DIR/opaque-trait-size-error-5883.rs:4:8 + | +LL | struct Struct { + | ^^^^^^ + = note: the return type of a function must have a statically known size + +error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time + --> $DIR/opaque-trait-size-error-5883.rs:9:8 + | +LL | r: dyn A + 'static + | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn A + 'static)` + = help: unsized fn params are gated as an unstable feature +help: you can use `impl Trait` as the argument type + | +LL - r: dyn A + 'static +LL + r: impl A + 'static + | +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | r: &dyn A + 'static + | + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/trait-implementation-generic-access-6898.rs b/tests/ui/traits/trait-implementation-generic-access-6898.rs new file mode 100644 index 00000000000..e9437b1c522 --- /dev/null +++ b/tests/ui/traits/trait-implementation-generic-access-6898.rs @@ -0,0 +1,33 @@ +// https://github.com/rust-lang/rust/issues/6898 +//@ check-pass + +use std::mem; + +/// Returns the size of a type +pub fn size_of() -> usize { + TypeInfo::size_of(None::) +} + +/// Returns the size of the type that `val` points to +pub fn size_of_val(val: &T) -> usize { + val.size_of_val() +} + +pub trait TypeInfo: Sized { + fn size_of(_lame_type_hint: Option) -> usize; + fn size_of_val(&self) -> usize; +} + +impl TypeInfo for T { + /// The size of the type in bytes. + fn size_of(_lame_type_hint: Option) -> usize { + mem::size_of::() + } + + /// Returns the size of the type of `self` in bytes. + fn size_of_val(&self) -> usize { + TypeInfo::size_of(None::) + } +} + +pub fn main() {} diff --git a/tests/ui/traits/trait-implementation-restriction-5988.rs b/tests/ui/traits/trait-implementation-restriction-5988.rs new file mode 100644 index 00000000000..d3a5b10569b --- /dev/null +++ b/tests/ui/traits/trait-implementation-restriction-5988.rs @@ -0,0 +1,24 @@ +// https://github.com/rust-lang/rust/issues/5988 +//@ run-pass + +trait B { + fn f(&self); +} + +trait T : B { +} + +struct A; + +impl B for U { + fn f(&self) { } +} + +impl T for A { +} + +fn main() { + let a = A; + let br = &a as &dyn B; + br.f(); +} diff --git a/tests/ui/unsafe/auxiliary/aux-5844.rs b/tests/ui/unsafe/auxiliary/aux-5844.rs new file mode 100644 index 00000000000..ea83378cad6 --- /dev/null +++ b/tests/ui/unsafe/auxiliary/aux-5844.rs @@ -0,0 +1,3 @@ +extern "C" { + pub fn rand() -> u32; +} diff --git a/tests/ui/unsafe/extern-function-requires-unsafe-5844.rs b/tests/ui/unsafe/extern-function-requires-unsafe-5844.rs new file mode 100644 index 00000000000..11863ce647a --- /dev/null +++ b/tests/ui/unsafe/extern-function-requires-unsafe-5844.rs @@ -0,0 +1,8 @@ +// https://github.com/rust-lang/rust/issues/5844 +//@aux-build:aux-5844.rs + +extern crate aux_5844; + +fn main() { + aux_5844::rand(); //~ ERROR: requires unsafe +} diff --git a/tests/ui/unsafe/extern-function-requires-unsafe-5844.stderr b/tests/ui/unsafe/extern-function-requires-unsafe-5844.stderr new file mode 100644 index 00000000000..44dee178991 --- /dev/null +++ b/tests/ui/unsafe/extern-function-requires-unsafe-5844.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe function or block + --> $DIR/extern-function-requires-unsafe-5844.rs:7:5 + | +LL | aux_5844::rand(); + | ^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0133`. -- cgit 1.4.1-3-g733a5 From 2dc4638c4637bf8ddb83577535317dad21abdf6d Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 20 Aug 2025 14:02:44 -0400 Subject: Add test batch 2 --- .../fixed-length-vector-pattern-matching-7784.rs | 31 +++++++++++++ .../matching-on-vector-slice-option-8498.rs | 28 ------------ .../pattern-matching-fixed-length-vectors-7784.rs | 31 ------------- .../array-slice-vec/vector-slice-matching-8498.rs | 28 ++++++++++++ tests/ui/binding/match-with-at-binding-8391.rs | 10 +++++ ...method-call-nonsensical-pattern-binding-7092.rs | 16 +++++++ ...od-call-nonsensical-pattern-binding-7092.stderr | 14 ++++++ tests/ui/binding/ref-pattern-drop-behavior-8860.rs | 52 ++++++++++++++++++++++ tests/ui/cast/associated-type-bounds-cast-54094.rs | 15 +++++++ tests/ui/codegen/matrix-row-swap-54462.rs | 26 +++++++++++ tests/ui/coercion/coerce-mut-trait-object-8248.rs | 15 +++++++ .../coercion/coerce-mut-trait-object-8248.stderr | 12 +++++ tests/ui/coercion/mut-trait-coercion-8248.rs | 15 ------- tests/ui/coercion/mut-trait-coercion-8248.stderr | 12 ----- .../collections/vecdeque-append-operation-54477.rs | 27 +++++++++++ tests/ui/cross-crate/auxiliary/aux-7178.rs | 7 +++ ...tic-method-returning-self-with-generics-7178.rs | 9 ++++ .../static-regions-in-cross-crate-8259.rs | 11 ----- .../static-with-cross-crate-regions-8259.rs | 11 +++++ .../cross-crate/tuple-struct-cross-crate-7899.rs | 10 +++++ .../function-pointer-comparison-54696.rs | 11 +++++ tests/ui/issues/auxiliary/issue-7178.rs | 7 --- tests/ui/issues/issue-53419.rs | 8 ---- tests/ui/issues/issue-53568.rs | 47 ------------------- tests/ui/issues/issue-53728.rs | 19 -------- tests/ui/issues/issue-54094.rs | 14 ------ tests/ui/issues/issue-54410.rs | 8 ---- tests/ui/issues/issue-54410.stderr | 12 ----- .../issue-54462-mutable-noalias-correctness.rs | 25 ----------- tests/ui/issues/issue-54477-reduced-2.rs | 26 ----------- tests/ui/issues/issue-54696.rs | 10 ----- tests/ui/issues/issue-55376.rs | 16 ------- tests/ui/issues/issue-55380.rs | 28 ------------ tests/ui/issues/issue-55380.stderr | 12 ----- tests/ui/issues/issue-7044.rs | 4 -- tests/ui/issues/issue-7044.stderr | 13 ------ tests/ui/issues/issue-7092.rs | 15 ------- tests/ui/issues/issue-7092.stderr | 14 ------ tests/ui/issues/issue-7178.rs | 9 ---- tests/ui/issues/issue-7268.rs | 9 ---- tests/ui/issues/issue-7344.rs | 21 --------- tests/ui/issues/issue-7364.rs | 8 ---- tests/ui/issues/issue-7364.stderr | 26 ----------- .../lifetimes/dyn-trait-function-pointer-53419.rs | 9 ++++ .../static-bound-fulfillment-with-pointer-7268.rs | 10 +++++ tests/ui/match/mismatched-types-in-match-7867.rs | 17 +++++++ .../ui/match/mismatched-types-in-match-7867.stderr | 17 +++++++ .../mismatched-types-in-match-pattern-7867.rs | 17 ------- .../mismatched-types-in-match-pattern-7867.stderr | 17 ------- tests/ui/methods/trait-method-resolution-7575.rs | 18 ++++++++ .../ui/methods/trait-method-resolution-7575.stderr | 10 +++++ .../methods/trait-method-self-param-error-7575.rs | 18 -------- .../trait-method-self-param-error-7575.stderr | 10 ----- .../modules/use-statement-duplicate-check-7663.rs | 33 ++++++++++++++ tests/ui/pattern/match-with-at-binding-8391.rs | 10 ----- .../ref-in-function-parameter-patterns-8860.rs | 52 ---------------------- .../ui/privacy/pub-restricted-path-usage-55376.rs | 17 +++++++ tests/ui/repr/packed-struct-with-enum-53728.rs | 20 +++++++++ tests/ui/resolve/module-import-resolution-7663.rs | 33 -------------- .../unit-like-struct-masks-constant-7044.rs | 5 +++ .../unit-like-struct-masks-constant-7044.stderr | 13 ++++++ .../trait-specialization-default-methods-55380.rs | 29 ++++++++++++ ...ait-specialization-default-methods-55380.stderr | 12 +++++ .../static/global-variable-promotion-error-7364.rs | 9 ++++ .../global-variable-promotion-error-7364.stderr | 26 +++++++++++ tests/ui/structs-enums/auxiliary/aux-8044.rs | 15 ------- .../ui/structs-enums/struct-and-enum-usage-8044.rs | 10 ----- tests/ui/structs/auxiliary/aux-8044.rs | 15 +++++++ tests/ui/structs/btree-struct-usage-8044.rs | 10 +++++ tests/ui/traits/nll-ice-custom-type-ops-53568.rs | 48 ++++++++++++++++++++ ...elf-implements-kinds-in-default-methods-8171.rs | 19 -------- .../traits/self-not-send-in-default-method-8171.rs | 19 ++++++++ .../traits/trait-implementation-and-usage-7563.rs | 29 ------------ .../ui/traits/trait-object-lifetime-bounds-7563.rs | 29 ++++++++++++ .../boolean-negation-in-unreachable-code-7344.rs | 22 +++++++++ 75 files changed, 682 insertions(+), 678 deletions(-) create mode 100644 tests/ui/array-slice-vec/fixed-length-vector-pattern-matching-7784.rs delete mode 100644 tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs delete mode 100644 tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs create mode 100644 tests/ui/array-slice-vec/vector-slice-matching-8498.rs create mode 100644 tests/ui/binding/match-with-at-binding-8391.rs create mode 100644 tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs create mode 100644 tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr create mode 100644 tests/ui/binding/ref-pattern-drop-behavior-8860.rs create mode 100644 tests/ui/cast/associated-type-bounds-cast-54094.rs create mode 100644 tests/ui/codegen/matrix-row-swap-54462.rs create mode 100644 tests/ui/coercion/coerce-mut-trait-object-8248.rs create mode 100644 tests/ui/coercion/coerce-mut-trait-object-8248.stderr delete mode 100644 tests/ui/coercion/mut-trait-coercion-8248.rs delete mode 100644 tests/ui/coercion/mut-trait-coercion-8248.stderr create mode 100644 tests/ui/collections/vecdeque-append-operation-54477.rs create mode 100644 tests/ui/cross-crate/auxiliary/aux-7178.rs create mode 100644 tests/ui/cross-crate/static-method-returning-self-with-generics-7178.rs delete mode 100644 tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs create mode 100644 tests/ui/cross-crate/static-with-cross-crate-regions-8259.rs create mode 100644 tests/ui/cross-crate/tuple-struct-cross-crate-7899.rs create mode 100644 tests/ui/function-pointer/function-pointer-comparison-54696.rs delete mode 100644 tests/ui/issues/auxiliary/issue-7178.rs delete mode 100644 tests/ui/issues/issue-53419.rs delete mode 100644 tests/ui/issues/issue-53568.rs delete mode 100644 tests/ui/issues/issue-53728.rs delete mode 100644 tests/ui/issues/issue-54094.rs delete mode 100644 tests/ui/issues/issue-54410.rs delete mode 100644 tests/ui/issues/issue-54410.stderr delete mode 100644 tests/ui/issues/issue-54462-mutable-noalias-correctness.rs delete mode 100644 tests/ui/issues/issue-54477-reduced-2.rs delete mode 100644 tests/ui/issues/issue-54696.rs delete mode 100644 tests/ui/issues/issue-55376.rs delete mode 100644 tests/ui/issues/issue-55380.rs delete mode 100644 tests/ui/issues/issue-55380.stderr delete mode 100644 tests/ui/issues/issue-7044.rs delete mode 100644 tests/ui/issues/issue-7044.stderr delete mode 100644 tests/ui/issues/issue-7092.rs delete mode 100644 tests/ui/issues/issue-7092.stderr delete mode 100644 tests/ui/issues/issue-7178.rs delete mode 100644 tests/ui/issues/issue-7268.rs delete mode 100644 tests/ui/issues/issue-7344.rs delete mode 100644 tests/ui/issues/issue-7364.rs delete mode 100644 tests/ui/issues/issue-7364.stderr create mode 100644 tests/ui/lifetimes/dyn-trait-function-pointer-53419.rs create mode 100644 tests/ui/lifetimes/static-bound-fulfillment-with-pointer-7268.rs create mode 100644 tests/ui/match/mismatched-types-in-match-7867.rs create mode 100644 tests/ui/match/mismatched-types-in-match-7867.stderr delete mode 100644 tests/ui/match/mismatched-types-in-match-pattern-7867.rs delete mode 100644 tests/ui/match/mismatched-types-in-match-pattern-7867.stderr create mode 100644 tests/ui/methods/trait-method-resolution-7575.rs create mode 100644 tests/ui/methods/trait-method-resolution-7575.stderr delete mode 100644 tests/ui/methods/trait-method-self-param-error-7575.rs delete mode 100644 tests/ui/methods/trait-method-self-param-error-7575.stderr create mode 100644 tests/ui/modules/use-statement-duplicate-check-7663.rs delete mode 100644 tests/ui/pattern/match-with-at-binding-8391.rs delete mode 100644 tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs create mode 100644 tests/ui/privacy/pub-restricted-path-usage-55376.rs create mode 100644 tests/ui/repr/packed-struct-with-enum-53728.rs delete mode 100644 tests/ui/resolve/module-import-resolution-7663.rs create mode 100644 tests/ui/resolve/unit-like-struct-masks-constant-7044.rs create mode 100644 tests/ui/resolve/unit-like-struct-masks-constant-7044.stderr create mode 100644 tests/ui/specialization/trait-specialization-default-methods-55380.rs create mode 100644 tests/ui/specialization/trait-specialization-default-methods-55380.stderr create mode 100644 tests/ui/static/global-variable-promotion-error-7364.rs create mode 100644 tests/ui/static/global-variable-promotion-error-7364.stderr delete mode 100644 tests/ui/structs-enums/auxiliary/aux-8044.rs delete mode 100644 tests/ui/structs-enums/struct-and-enum-usage-8044.rs create mode 100644 tests/ui/structs/auxiliary/aux-8044.rs create mode 100644 tests/ui/structs/btree-struct-usage-8044.rs create mode 100644 tests/ui/traits/nll-ice-custom-type-ops-53568.rs delete mode 100644 tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs create mode 100644 tests/ui/traits/self-not-send-in-default-method-8171.rs delete mode 100644 tests/ui/traits/trait-implementation-and-usage-7563.rs create mode 100644 tests/ui/traits/trait-object-lifetime-bounds-7563.rs create mode 100644 tests/ui/unreachable-code/boolean-negation-in-unreachable-code-7344.rs (limited to 'tests/ui/codegen') diff --git a/tests/ui/array-slice-vec/fixed-length-vector-pattern-matching-7784.rs b/tests/ui/array-slice-vec/fixed-length-vector-pattern-matching-7784.rs new file mode 100644 index 00000000000..7d987e92b63 --- /dev/null +++ b/tests/ui/array-slice-vec/fixed-length-vector-pattern-matching-7784.rs @@ -0,0 +1,31 @@ +// https://github.com/rust-lang/rust/issues/7784 +//@ run-pass + +use std::ops::Add; + +fn foo + Clone>([x, y, z]: [T; 3]) -> (T, T, T) { + (x.clone(), x.clone() + y.clone(), x + y + z) +} +fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] { + [a, b, b, a] +} + +fn main() { + assert_eq!(foo([1, 2, 3]), (1, 3, 6)); + + let [a, b, c, d] = bar("foo", "bar"); + assert_eq!(a, "foo"); + assert_eq!(b, "bar"); + assert_eq!(c, "bar"); + assert_eq!(d, "foo"); + + let [a, _, _, d] = bar("baz", "foo"); + assert_eq!(a, "baz"); + assert_eq!(d, "baz"); + + let out = bar("baz", "foo"); + let [a, xs @ .., d] = out; + assert_eq!(a, "baz"); + assert_eq!(xs, ["foo", "foo"]); + assert_eq!(d, "baz"); +} diff --git a/tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs b/tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs deleted file mode 100644 index e243a247ed5..00000000000 --- a/tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs +++ /dev/null @@ -1,28 +0,0 @@ -// https://github.com/rust-lang/rust/issues/8498 -//@ run-pass - -pub fn main() { - match &[(Box::new(5),Box::new(7))] { - ps => { - let (ref y, _) = ps[0]; - assert_eq!(**y, 5); - } - } - - match Some(&[(Box::new(5),)]) { - Some(ps) => { - let (ref y,) = ps[0]; - assert_eq!(**y, 5); - } - None => () - } - - match Some(&[(Box::new(5),Box::new(7))]) { - Some(ps) => { - let (ref y, ref z) = ps[0]; - assert_eq!(**y, 5); - assert_eq!(**z, 7); - } - None => () - } -} diff --git a/tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs b/tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs deleted file mode 100644 index 7d987e92b63..00000000000 --- a/tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs +++ /dev/null @@ -1,31 +0,0 @@ -// https://github.com/rust-lang/rust/issues/7784 -//@ run-pass - -use std::ops::Add; - -fn foo + Clone>([x, y, z]: [T; 3]) -> (T, T, T) { - (x.clone(), x.clone() + y.clone(), x + y + z) -} -fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] { - [a, b, b, a] -} - -fn main() { - assert_eq!(foo([1, 2, 3]), (1, 3, 6)); - - let [a, b, c, d] = bar("foo", "bar"); - assert_eq!(a, "foo"); - assert_eq!(b, "bar"); - assert_eq!(c, "bar"); - assert_eq!(d, "foo"); - - let [a, _, _, d] = bar("baz", "foo"); - assert_eq!(a, "baz"); - assert_eq!(d, "baz"); - - let out = bar("baz", "foo"); - let [a, xs @ .., d] = out; - assert_eq!(a, "baz"); - assert_eq!(xs, ["foo", "foo"]); - assert_eq!(d, "baz"); -} diff --git a/tests/ui/array-slice-vec/vector-slice-matching-8498.rs b/tests/ui/array-slice-vec/vector-slice-matching-8498.rs new file mode 100644 index 00000000000..e243a247ed5 --- /dev/null +++ b/tests/ui/array-slice-vec/vector-slice-matching-8498.rs @@ -0,0 +1,28 @@ +// https://github.com/rust-lang/rust/issues/8498 +//@ run-pass + +pub fn main() { + match &[(Box::new(5),Box::new(7))] { + ps => { + let (ref y, _) = ps[0]; + assert_eq!(**y, 5); + } + } + + match Some(&[(Box::new(5),)]) { + Some(ps) => { + let (ref y,) = ps[0]; + assert_eq!(**y, 5); + } + None => () + } + + match Some(&[(Box::new(5),Box::new(7))]) { + Some(ps) => { + let (ref y, ref z) = ps[0]; + assert_eq!(**y, 5); + assert_eq!(**z, 7); + } + None => () + } +} diff --git a/tests/ui/binding/match-with-at-binding-8391.rs b/tests/ui/binding/match-with-at-binding-8391.rs new file mode 100644 index 00000000000..bc4e7be7989 --- /dev/null +++ b/tests/ui/binding/match-with-at-binding-8391.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/8391 +//@ run-pass + +fn main() { + let x = match Some(1) { + ref _y @ Some(_) => 1, + None => 2, + }; + assert_eq!(x, 1); +} diff --git a/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs new file mode 100644 index 00000000000..4cb04cdf5be --- /dev/null +++ b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/7092 +enum Whatever { +} + +fn foo(x: Whatever) { + match x { //~ NOTE this expression has type `Whatever` + Some(field) => +//~^ ERROR mismatched types +//~| NOTE expected `Whatever`, found `Option<_>` +//~| NOTE expected enum `Whatever` +//~| NOTE found enum `Option<_>` + field.access(), + } +} + +fn main(){} diff --git a/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr new file mode 100644 index 00000000000..1f8ff2d8df1 --- /dev/null +++ b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/method-call-nonsensical-pattern-binding-7092.rs:7:9 + | +LL | match x { + | - this expression has type `Whatever` +LL | Some(field) => + | ^^^^^^^^^^^ expected `Whatever`, found `Option<_>` + | + = note: expected enum `Whatever` + found enum `Option<_>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/binding/ref-pattern-drop-behavior-8860.rs b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs new file mode 100644 index 00000000000..1a67caf021c --- /dev/null +++ b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs @@ -0,0 +1,52 @@ +// https://github.com/rust-lang/rust/issues/8860 +//@ run-pass +// FIXME(static_mut_refs): this could use an atomic +#![allow(static_mut_refs)] +#![allow(dead_code)] + +static mut DROP: isize = 0; +static mut DROP_S: isize = 0; +static mut DROP_T: isize = 0; + +struct S; +impl Drop for S { + fn drop(&mut self) { + unsafe { + DROP_S += 1; + DROP += 1; + } + } +} +fn f(ref _s: S) {} + +struct T { i: isize } +impl Drop for T { + fn drop(&mut self) { + unsafe { + DROP_T += 1; + DROP += 1; + } + } +} +fn g(ref _t: T) {} + +fn do_test() { + let s = S; + f(s); + unsafe { + assert_eq!(1, DROP); + assert_eq!(1, DROP_S); + } + let t = T { i: 1 }; + g(t); + unsafe { assert_eq!(1, DROP_T); } +} + +fn main() { + do_test(); + unsafe { + assert_eq!(2, DROP); + assert_eq!(1, DROP_S); + assert_eq!(1, DROP_T); + } +} diff --git a/tests/ui/cast/associated-type-bounds-cast-54094.rs b/tests/ui/cast/associated-type-bounds-cast-54094.rs new file mode 100644 index 00000000000..c9f307e95b9 --- /dev/null +++ b/tests/ui/cast/associated-type-bounds-cast-54094.rs @@ -0,0 +1,15 @@ +// https://github.com/rust-lang/rust/issues/54094 +//@ check-pass +trait Zoo { + type X; +} + +impl Zoo for u16 { + type X = usize; +} + +fn foo(abc: ::X) {} + +fn main() { + let x: *const u8 = foo as _; +} diff --git a/tests/ui/codegen/matrix-row-swap-54462.rs b/tests/ui/codegen/matrix-row-swap-54462.rs new file mode 100644 index 00000000000..6bfc600399a --- /dev/null +++ b/tests/ui/codegen/matrix-row-swap-54462.rs @@ -0,0 +1,26 @@ +// https://github.com/rust-lang/rust/issues/54462 +//@ run-pass +// +//@ compile-flags: -Ccodegen-units=1 -O + +fn linidx(row: usize, col: usize) -> usize { + row * 1 + col * 3 +} + +fn main() { + let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0]; + + for i in 0..2 { + for j in i+1..3 { + if mat[linidx(j, 3)] > mat[linidx(i, 3)] { + for k in 0..4 { + let (x, rest) = mat.split_at_mut(linidx(i, k) + 1); + let a = x.last_mut().unwrap(); + let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap(); + ::std::mem::swap(a, b); + } + } + } + } + assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat); +} diff --git a/tests/ui/coercion/coerce-mut-trait-object-8248.rs b/tests/ui/coercion/coerce-mut-trait-object-8248.rs new file mode 100644 index 00000000000..a45a4d94315 --- /dev/null +++ b/tests/ui/coercion/coerce-mut-trait-object-8248.rs @@ -0,0 +1,15 @@ +// https://github.com/rust-lang/rust/issues/8248 +//@ run-pass + +trait A { + fn dummy(&self) { } //~ WARN method `dummy` is never used +} +struct B; +impl A for B {} + +fn foo(_: &mut dyn A) {} + +pub fn main() { + let mut b = B; + foo(&mut b as &mut dyn A); +} diff --git a/tests/ui/coercion/coerce-mut-trait-object-8248.stderr b/tests/ui/coercion/coerce-mut-trait-object-8248.stderr new file mode 100644 index 00000000000..c3b35a7063c --- /dev/null +++ b/tests/ui/coercion/coerce-mut-trait-object-8248.stderr @@ -0,0 +1,12 @@ +warning: method `dummy` is never used + --> $DIR/coerce-mut-trait-object-8248.rs:5:8 + | +LL | trait A { + | - method in this trait +LL | fn dummy(&self) { } + | ^^^^^ + | + = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default + +warning: 1 warning emitted + diff --git a/tests/ui/coercion/mut-trait-coercion-8248.rs b/tests/ui/coercion/mut-trait-coercion-8248.rs deleted file mode 100644 index a45a4d94315..00000000000 --- a/tests/ui/coercion/mut-trait-coercion-8248.rs +++ /dev/null @@ -1,15 +0,0 @@ -// https://github.com/rust-lang/rust/issues/8248 -//@ run-pass - -trait A { - fn dummy(&self) { } //~ WARN method `dummy` is never used -} -struct B; -impl A for B {} - -fn foo(_: &mut dyn A) {} - -pub fn main() { - let mut b = B; - foo(&mut b as &mut dyn A); -} diff --git a/tests/ui/coercion/mut-trait-coercion-8248.stderr b/tests/ui/coercion/mut-trait-coercion-8248.stderr deleted file mode 100644 index 0c7d5f9dc45..00000000000 --- a/tests/ui/coercion/mut-trait-coercion-8248.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: method `dummy` is never used - --> $DIR/mut-trait-coercion-8248.rs:5:8 - | -LL | trait A { - | - method in this trait -LL | fn dummy(&self) { } - | ^^^^^ - | - = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default - -warning: 1 warning emitted - diff --git a/tests/ui/collections/vecdeque-append-operation-54477.rs b/tests/ui/collections/vecdeque-append-operation-54477.rs new file mode 100644 index 00000000000..7680fd0bb01 --- /dev/null +++ b/tests/ui/collections/vecdeque-append-operation-54477.rs @@ -0,0 +1,27 @@ +// https://github.com/rust-lang/rust/issues/54477 +//@ run-pass +// rust-lang/rust#54477: runtime bug in the VecDeque library that was +// exposed by this test case, derived from test suite of crates.io +// `collection` crate. + +use std::collections::VecDeque; + +fn main() { + let mut vecdeque_13 = VecDeque::from(vec![ ]); + let mut vecdeque_29 = VecDeque::from(vec![ 0 ]); + vecdeque_29.insert(0, 30 ); + vecdeque_29.insert(1, 31 ); + vecdeque_29.insert(2, 32 ); + vecdeque_29.insert(3, 33 ); + vecdeque_29.insert(4, 34 ); + vecdeque_29.insert(5, 35 ); + // println!("vecdeque_13: {:?}", vecdeque_13); + // println!("vecdeque_29: {:?}", vecdeque_29); + + // println!("Invoking: `vecdeque_13.append(&mut vecdeque_29)`"); + vecdeque_13.append(&mut vecdeque_29); + + // println!("vecdeque_13: {:?}", vecdeque_13); + + assert_eq!(vecdeque_13, VecDeque::from(vec![30, 31, 32, 33, 34, 35, 0])); +} diff --git a/tests/ui/cross-crate/auxiliary/aux-7178.rs b/tests/ui/cross-crate/auxiliary/aux-7178.rs new file mode 100644 index 00000000000..56ae5139af4 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/aux-7178.rs @@ -0,0 +1,7 @@ +pub struct Foo<'a, A:'a>(&'a A); + +impl<'a, A> Foo<'a, A> { + pub fn new(a: &'a A) -> Foo<'a, A> { + Foo(a) + } +} diff --git a/tests/ui/cross-crate/static-method-returning-self-with-generics-7178.rs b/tests/ui/cross-crate/static-method-returning-self-with-generics-7178.rs new file mode 100644 index 00000000000..3888d3bdaa9 --- /dev/null +++ b/tests/ui/cross-crate/static-method-returning-self-with-generics-7178.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/7178 +//@ run-pass +//@ aux-build:aux-7178.rs + +extern crate aux_7178 as cross_crate_self; + +pub fn main() { + let _ = cross_crate_self::Foo::new(&1); +} diff --git a/tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs b/tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs deleted file mode 100644 index 347cfa2aee1..00000000000 --- a/tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs +++ /dev/null @@ -1,11 +0,0 @@ -// https://github.com/rust-lang/rust/issues/8259 -//@ run-pass -#![allow(dead_code)] -#![allow(non_upper_case_globals)] - -//@ aux-build:aux-8259.rs - -extern crate aux_8259 as other; -static a: other::Foo<'static> = other::Foo::A; - -pub fn main() {} diff --git a/tests/ui/cross-crate/static-with-cross-crate-regions-8259.rs b/tests/ui/cross-crate/static-with-cross-crate-regions-8259.rs new file mode 100644 index 00000000000..347cfa2aee1 --- /dev/null +++ b/tests/ui/cross-crate/static-with-cross-crate-regions-8259.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/8259 +//@ run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +//@ aux-build:aux-8259.rs + +extern crate aux_8259 as other; +static a: other::Foo<'static> = other::Foo::A; + +pub fn main() {} diff --git a/tests/ui/cross-crate/tuple-struct-cross-crate-7899.rs b/tests/ui/cross-crate/tuple-struct-cross-crate-7899.rs new file mode 100644 index 00000000000..ce3ea7dd579 --- /dev/null +++ b/tests/ui/cross-crate/tuple-struct-cross-crate-7899.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/7899 +//@ run-pass +#![allow(unused_variables)] +//@ aux-build:aux-7899.rs + +extern crate aux_7899 as testcrate; + +fn main() { + let f = testcrate::V2(1.0f32, 2.0f32); +} diff --git a/tests/ui/function-pointer/function-pointer-comparison-54696.rs b/tests/ui/function-pointer/function-pointer-comparison-54696.rs new file mode 100644 index 00000000000..2e28dfeaaf8 --- /dev/null +++ b/tests/ui/function-pointer/function-pointer-comparison-54696.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/54696 +//@ run-pass + +#![allow(unpredictable_function_pointer_comparisons)] + +fn main() { + // We shouldn't promote this + let _ = &(main as fn() == main as fn()); + // Also check nested case + let _ = &(&(main as fn()) == &(main as fn())); +} diff --git a/tests/ui/issues/auxiliary/issue-7178.rs b/tests/ui/issues/auxiliary/issue-7178.rs deleted file mode 100644 index 56ae5139af4..00000000000 --- a/tests/ui/issues/auxiliary/issue-7178.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub struct Foo<'a, A:'a>(&'a A); - -impl<'a, A> Foo<'a, A> { - pub fn new(a: &'a A) -> Foo<'a, A> { - Foo(a) - } -} diff --git a/tests/ui/issues/issue-53419.rs b/tests/ui/issues/issue-53419.rs deleted file mode 100644 index 55d41f2005d..00000000000 --- a/tests/ui/issues/issue-53419.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ check-pass - -struct Foo { - bar: dyn for<'r> Fn(usize, &'r dyn FnMut()) -} - -fn main() { -} diff --git a/tests/ui/issues/issue-53568.rs b/tests/ui/issues/issue-53568.rs deleted file mode 100644 index 9862d4ced12..00000000000 --- a/tests/ui/issues/issue-53568.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Regression test for an NLL-related ICE (#53568) -- we failed to -// resolve inference variables in "custom type-ops". -// -//@ check-pass - -trait Future { - type Item; -} - -impl Future for F -where F: Fn() -> T -{ - type Item = T; -} - -trait Connect {} - -struct Connector { - handler: H, -} - -impl Connect for Connector -where - T: 'static, - H: Future -{ -} - -struct Client { - connector: C, -} - -fn build(_connector: C) -> Client { - unimplemented!() -} - -fn client(handler: H) -> Client -where H: Fn() + Copy -{ - let connector = Connector { - handler, - }; - let client = build(connector); - client -} - -fn main() { } diff --git a/tests/ui/issues/issue-53728.rs b/tests/ui/issues/issue-53728.rs deleted file mode 100644 index 364965228c6..00000000000 --- a/tests/ui/issues/issue-53728.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -#[repr(u16)] -enum DeviceKind { - Nil = 0, -} - -#[repr(packed)] -struct DeviceInfo { - endianness: u8, - device_kind: DeviceKind, -} - -fn main() { - let _x = None::<(DeviceInfo, u8)>; - let _y = None::<(DeviceInfo, u16)>; - let _z = None::<(DeviceInfo, u64)>; -} diff --git a/tests/ui/issues/issue-54094.rs b/tests/ui/issues/issue-54094.rs deleted file mode 100644 index 4ca7d1d81b6..00000000000 --- a/tests/ui/issues/issue-54094.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass -trait Zoo { - type X; -} - -impl Zoo for u16 { - type X = usize; -} - -fn foo(abc: ::X) {} - -fn main() { - let x: *const u8 = foo as _; -} diff --git a/tests/ui/issues/issue-54410.rs b/tests/ui/issues/issue-54410.rs deleted file mode 100644 index e3e8ca985b9..00000000000 --- a/tests/ui/issues/issue-54410.rs +++ /dev/null @@ -1,8 +0,0 @@ -extern "C" { - pub static mut symbol: [i8]; - //~^ ERROR the size for values of type `[i8]` cannot be known at compilation time -} - -fn main() { - println!("{:p}", unsafe { &symbol }); -} diff --git a/tests/ui/issues/issue-54410.stderr b/tests/ui/issues/issue-54410.stderr deleted file mode 100644 index cb68ada7e13..00000000000 --- a/tests/ui/issues/issue-54410.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: the size for values of type `[i8]` cannot be known at compilation time - --> $DIR/issue-54410.rs:2:5 - | -LL | pub static mut symbol: [i8]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[i8]` - = note: statics and constants must have a statically known size - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-54462-mutable-noalias-correctness.rs b/tests/ui/issues/issue-54462-mutable-noalias-correctness.rs deleted file mode 100644 index 70d0bee7332..00000000000 --- a/tests/ui/issues/issue-54462-mutable-noalias-correctness.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ run-pass -// -//@ compile-flags: -Ccodegen-units=1 -O - -fn linidx(row: usize, col: usize) -> usize { - row * 1 + col * 3 -} - -fn main() { - let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0]; - - for i in 0..2 { - for j in i+1..3 { - if mat[linidx(j, 3)] > mat[linidx(i, 3)] { - for k in 0..4 { - let (x, rest) = mat.split_at_mut(linidx(i, k) + 1); - let a = x.last_mut().unwrap(); - let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap(); - ::std::mem::swap(a, b); - } - } - } - } - assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat); -} diff --git a/tests/ui/issues/issue-54477-reduced-2.rs b/tests/ui/issues/issue-54477-reduced-2.rs deleted file mode 100644 index 5f65e545182..00000000000 --- a/tests/ui/issues/issue-54477-reduced-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ run-pass -// rust-lang/rust#54477: runtime bug in the VecDeque library that was -// exposed by this test case, derived from test suite of crates.io -// `collection` crate. - -use std::collections::VecDeque; - -fn main() { - let mut vecdeque_13 = VecDeque::from(vec![ ]); - let mut vecdeque_29 = VecDeque::from(vec![ 0 ]); - vecdeque_29.insert(0, 30 ); - vecdeque_29.insert(1, 31 ); - vecdeque_29.insert(2, 32 ); - vecdeque_29.insert(3, 33 ); - vecdeque_29.insert(4, 34 ); - vecdeque_29.insert(5, 35 ); - // println!("vecdeque_13: {:?}", vecdeque_13); - // println!("vecdeque_29: {:?}", vecdeque_29); - - // println!("Invoking: `vecdeque_13.append(&mut vecdeque_29)`"); - vecdeque_13.append(&mut vecdeque_29); - - // println!("vecdeque_13: {:?}", vecdeque_13); - - assert_eq!(vecdeque_13, VecDeque::from(vec![30, 31, 32, 33, 34, 35, 0])); -} diff --git a/tests/ui/issues/issue-54696.rs b/tests/ui/issues/issue-54696.rs deleted file mode 100644 index 63ffbe42bcc..00000000000 --- a/tests/ui/issues/issue-54696.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -#![allow(unpredictable_function_pointer_comparisons)] - -fn main() { - // We shouldn't promote this - let _ = &(main as fn() == main as fn()); - // Also check nested case - let _ = &(&(main as fn()) == &(main as fn())); -} diff --git a/tests/ui/issues/issue-55376.rs b/tests/ui/issues/issue-55376.rs deleted file mode 100644 index 5a6862b6530..00000000000 --- a/tests/ui/issues/issue-55376.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-pass -// Tests that paths in `pub(...)` don't fail HIR verification. - -#![allow(unused_imports)] -#![allow(dead_code)] - -pub(self) use self::my_mod::Foo; - -mod my_mod { - pub(super) use self::Foo as Bar; - pub(in super::my_mod) use self::Foo as Baz; - - pub struct Foo; -} - -fn main() {} diff --git a/tests/ui/issues/issue-55380.rs b/tests/ui/issues/issue-55380.rs deleted file mode 100644 index 54894cdede0..00000000000 --- a/tests/ui/issues/issue-55380.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ run-pass -#![feature(specialization)] -//~^ WARN the feature `specialization` is incomplete - -pub trait Foo { - fn abc() -> u32; - fn def() -> u32; -} - -pub trait Marker {} - -impl Marker for () {} - -impl Foo for T { - default fn abc() -> u32 { 16 } - default fn def() -> u32 { 42 } -} - -impl Foo for T { - fn def() -> u32 { - Self::abc() - } -} - -fn main() { - assert_eq!(<()>::def(), 16); - assert_eq!(::def(), 42); -} diff --git a/tests/ui/issues/issue-55380.stderr b/tests/ui/issues/issue-55380.stderr deleted file mode 100644 index 403844c726f..00000000000 --- a/tests/ui/issues/issue-55380.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-55380.rs:2:12 - | -LL | #![feature(specialization)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #31844 for more information - = help: consider using `min_specialization` instead, which is more stable and complete - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/issues/issue-7044.rs b/tests/ui/issues/issue-7044.rs deleted file mode 100644 index a6e22bc5237..00000000000 --- a/tests/ui/issues/issue-7044.rs +++ /dev/null @@ -1,4 +0,0 @@ -static X: isize = 0; -struct X; //~ ERROR the name `X` is defined multiple times - -fn main() {} diff --git a/tests/ui/issues/issue-7044.stderr b/tests/ui/issues/issue-7044.stderr deleted file mode 100644 index 9d1fb3a10dd..00000000000 --- a/tests/ui/issues/issue-7044.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0428]: the name `X` is defined multiple times - --> $DIR/issue-7044.rs:2:1 - | -LL | static X: isize = 0; - | -------------------- previous definition of the value `X` here -LL | struct X; - | ^^^^^^^^^ `X` redefined here - | - = note: `X` must be defined only once in the value namespace of this module - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/issues/issue-7092.rs b/tests/ui/issues/issue-7092.rs deleted file mode 100644 index fab18bd7cf7..00000000000 --- a/tests/ui/issues/issue-7092.rs +++ /dev/null @@ -1,15 +0,0 @@ -enum Whatever { -} - -fn foo(x: Whatever) { - match x { //~ NOTE this expression has type `Whatever` - Some(field) => -//~^ ERROR mismatched types -//~| NOTE expected `Whatever`, found `Option<_>` -//~| NOTE expected enum `Whatever` -//~| NOTE found enum `Option<_>` - field.access(), - } -} - -fn main(){} diff --git a/tests/ui/issues/issue-7092.stderr b/tests/ui/issues/issue-7092.stderr deleted file mode 100644 index e2e57486746..00000000000 --- a/tests/ui/issues/issue-7092.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-7092.rs:6:9 - | -LL | match x { - | - this expression has type `Whatever` -LL | Some(field) => - | ^^^^^^^^^^^ expected `Whatever`, found `Option<_>` - | - = note: expected enum `Whatever` - found enum `Option<_>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-7178.rs b/tests/ui/issues/issue-7178.rs deleted file mode 100644 index 408ce0b03eb..00000000000 --- a/tests/ui/issues/issue-7178.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -//@ aux-build:issue-7178.rs - - -extern crate issue_7178 as cross_crate_self; - -pub fn main() { - let _ = cross_crate_self::Foo::new(&1); -} diff --git a/tests/ui/issues/issue-7268.rs b/tests/ui/issues/issue-7268.rs deleted file mode 100644 index a3bc1bc3446..00000000000 --- a/tests/ui/issues/issue-7268.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ check-pass -#![allow(dead_code)] - -fn foo(_: T) {} - -fn bar(x: &'static T) { - foo(x); -} -fn main() {} diff --git a/tests/ui/issues/issue-7344.rs b/tests/ui/issues/issue-7344.rs deleted file mode 100644 index 406b24634f5..00000000000 --- a/tests/ui/issues/issue-7344.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass -#![allow(unused_must_use)] - -#![allow(unreachable_code)] - -fn foo() -> bool { false } - -fn bar() { - return; - !foo(); -} - -fn baz() { - return; - if "" == "" {} -} - -pub fn main() { - bar(); - baz(); -} diff --git a/tests/ui/issues/issue-7364.rs b/tests/ui/issues/issue-7364.rs deleted file mode 100644 index 4ce9beb68cd..00000000000 --- a/tests/ui/issues/issue-7364.rs +++ /dev/null @@ -1,8 +0,0 @@ -use std::cell::RefCell; - -// Regression test for issue 7364 -static boxed: Box> = Box::new(RefCell::new(0)); -//~^ ERROR `RefCell` cannot be shared between threads safely [E0277] -//~| ERROR cannot call non-const associated function - -fn main() { } diff --git a/tests/ui/issues/issue-7364.stderr b/tests/ui/issues/issue-7364.stderr deleted file mode 100644 index a47a90c90ce..00000000000 --- a/tests/ui/issues/issue-7364.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-7364.rs:4:15 - | -LL | static boxed: Box> = Box::new(RefCell::new(0)); - | ^^^^^^^^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead - = note: required for `Unique>` to implement `Sync` -note: required because it appears within the type `Box>` - --> $SRC_DIR/alloc/src/boxed.rs:LL:COL - = note: shared static variables must have a type that implements `Sync` - -error[E0015]: cannot call non-const associated function `Box::>::new` in statics - --> $DIR/issue-7364.rs:4:37 - | -LL | static boxed: Box> = Box::new(RefCell::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/lifetimes/dyn-trait-function-pointer-53419.rs b/tests/ui/lifetimes/dyn-trait-function-pointer-53419.rs new file mode 100644 index 00000000000..b1017b104ac --- /dev/null +++ b/tests/ui/lifetimes/dyn-trait-function-pointer-53419.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/53419 +//@ check-pass + +struct Foo { + bar: dyn for<'r> Fn(usize, &'r dyn FnMut()) +} + +fn main() { +} diff --git a/tests/ui/lifetimes/static-bound-fulfillment-with-pointer-7268.rs b/tests/ui/lifetimes/static-bound-fulfillment-with-pointer-7268.rs new file mode 100644 index 00000000000..8ec58e6cd80 --- /dev/null +++ b/tests/ui/lifetimes/static-bound-fulfillment-with-pointer-7268.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/7268 +//@ check-pass +#![allow(dead_code)] + +fn foo(_: T) {} + +fn bar(x: &'static T) { + foo(x); +} +fn main() {} diff --git a/tests/ui/match/mismatched-types-in-match-7867.rs b/tests/ui/match/mismatched-types-in-match-7867.rs new file mode 100644 index 00000000000..9ff8755c819 --- /dev/null +++ b/tests/ui/match/mismatched-types-in-match-7867.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/7867 +//@ dont-require-annotations: NOTE + +enum A { B, C } + +mod foo { pub fn bar() {} } + +fn main() { + match (true, false) { + A::B => (), + //~^ ERROR mismatched types + //~| NOTE expected `(bool, bool)`, found `A` + //~| NOTE expected tuple `(bool, bool)` + //~| NOTE found enum `A` + _ => () + } +} diff --git a/tests/ui/match/mismatched-types-in-match-7867.stderr b/tests/ui/match/mismatched-types-in-match-7867.stderr new file mode 100644 index 00000000000..e41a61e42f4 --- /dev/null +++ b/tests/ui/match/mismatched-types-in-match-7867.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/mismatched-types-in-match-7867.rs:10:9 + | +LL | enum A { B, C } + | - unit variant defined here +... +LL | match (true, false) { + | ------------- this expression has type `(bool, bool)` +LL | A::B => (), + | ^^^^ expected `(bool, bool)`, found `A` + | + = note: expected tuple `(bool, bool)` + found enum `A` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/match/mismatched-types-in-match-pattern-7867.rs b/tests/ui/match/mismatched-types-in-match-pattern-7867.rs deleted file mode 100644 index 9ff8755c819..00000000000 --- a/tests/ui/match/mismatched-types-in-match-pattern-7867.rs +++ /dev/null @@ -1,17 +0,0 @@ -// https://github.com/rust-lang/rust/issues/7867 -//@ dont-require-annotations: NOTE - -enum A { B, C } - -mod foo { pub fn bar() {} } - -fn main() { - match (true, false) { - A::B => (), - //~^ ERROR mismatched types - //~| NOTE expected `(bool, bool)`, found `A` - //~| NOTE expected tuple `(bool, bool)` - //~| NOTE found enum `A` - _ => () - } -} diff --git a/tests/ui/match/mismatched-types-in-match-pattern-7867.stderr b/tests/ui/match/mismatched-types-in-match-pattern-7867.stderr deleted file mode 100644 index 8997f36114a..00000000000 --- a/tests/ui/match/mismatched-types-in-match-pattern-7867.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/mismatched-types-in-match-pattern-7867.rs:10:9 - | -LL | enum A { B, C } - | - unit variant defined here -... -LL | match (true, false) { - | ------------- this expression has type `(bool, bool)` -LL | A::B => (), - | ^^^^ expected `(bool, bool)`, found `A` - | - = note: expected tuple `(bool, bool)` - found enum `A` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/methods/trait-method-resolution-7575.rs b/tests/ui/methods/trait-method-resolution-7575.rs new file mode 100644 index 00000000000..9793d43cc24 --- /dev/null +++ b/tests/ui/methods/trait-method-resolution-7575.rs @@ -0,0 +1,18 @@ +// https://github.com/rust-lang/rust/issues/7575 +//@ run-pass + +trait Foo { //~ WARN trait `Foo` is never used + fn new() -> bool { false } + fn dummy(&self) { } +} + +trait Bar { + fn new(&self) -> bool { true } +} + +impl Bar for isize {} +impl Foo for isize {} + +fn main() { + assert!(1.new()); +} diff --git a/tests/ui/methods/trait-method-resolution-7575.stderr b/tests/ui/methods/trait-method-resolution-7575.stderr new file mode 100644 index 00000000000..8bbc360de57 --- /dev/null +++ b/tests/ui/methods/trait-method-resolution-7575.stderr @@ -0,0 +1,10 @@ +warning: trait `Foo` is never used + --> $DIR/trait-method-resolution-7575.rs:4:7 + | +LL | trait Foo { + | ^^^ + | + = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default + +warning: 1 warning emitted + diff --git a/tests/ui/methods/trait-method-self-param-error-7575.rs b/tests/ui/methods/trait-method-self-param-error-7575.rs deleted file mode 100644 index 9793d43cc24..00000000000 --- a/tests/ui/methods/trait-method-self-param-error-7575.rs +++ /dev/null @@ -1,18 +0,0 @@ -// https://github.com/rust-lang/rust/issues/7575 -//@ run-pass - -trait Foo { //~ WARN trait `Foo` is never used - fn new() -> bool { false } - fn dummy(&self) { } -} - -trait Bar { - fn new(&self) -> bool { true } -} - -impl Bar for isize {} -impl Foo for isize {} - -fn main() { - assert!(1.new()); -} diff --git a/tests/ui/methods/trait-method-self-param-error-7575.stderr b/tests/ui/methods/trait-method-self-param-error-7575.stderr deleted file mode 100644 index 656db30352d..00000000000 --- a/tests/ui/methods/trait-method-self-param-error-7575.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: trait `Foo` is never used - --> $DIR/trait-method-self-param-error-7575.rs:4:7 - | -LL | trait Foo { - | ^^^ - | - = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default - -warning: 1 warning emitted - diff --git a/tests/ui/modules/use-statement-duplicate-check-7663.rs b/tests/ui/modules/use-statement-duplicate-check-7663.rs new file mode 100644 index 00000000000..872806594fc --- /dev/null +++ b/tests/ui/modules/use-statement-duplicate-check-7663.rs @@ -0,0 +1,33 @@ +// https://github.com/rust-lang/rust/issues/7663 +//@ run-pass + +#![allow(unused_imports, dead_code)] + +mod test1 { + + mod foo { pub fn p() -> isize { 1 } } + mod bar { pub fn p() -> isize { 2 } } + + pub mod baz { + use crate::test1::bar::p; + + pub fn my_main() { assert_eq!(p(), 2); } + } +} + +mod test2 { + + mod foo { pub fn p() -> isize { 1 } } + mod bar { pub fn p() -> isize { 2 } } + + pub mod baz { + use crate::test2::bar::p; + + pub fn my_main() { assert_eq!(p(), 2); } + } +} + +fn main() { + test1::baz::my_main(); + test2::baz::my_main(); +} diff --git a/tests/ui/pattern/match-with-at-binding-8391.rs b/tests/ui/pattern/match-with-at-binding-8391.rs deleted file mode 100644 index bc4e7be7989..00000000000 --- a/tests/ui/pattern/match-with-at-binding-8391.rs +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/rust-lang/rust/issues/8391 -//@ run-pass - -fn main() { - let x = match Some(1) { - ref _y @ Some(_) => 1, - None => 2, - }; - assert_eq!(x, 1); -} diff --git a/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs b/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs deleted file mode 100644 index 1a67caf021c..00000000000 --- a/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs +++ /dev/null @@ -1,52 +0,0 @@ -// https://github.com/rust-lang/rust/issues/8860 -//@ run-pass -// FIXME(static_mut_refs): this could use an atomic -#![allow(static_mut_refs)] -#![allow(dead_code)] - -static mut DROP: isize = 0; -static mut DROP_S: isize = 0; -static mut DROP_T: isize = 0; - -struct S; -impl Drop for S { - fn drop(&mut self) { - unsafe { - DROP_S += 1; - DROP += 1; - } - } -} -fn f(ref _s: S) {} - -struct T { i: isize } -impl Drop for T { - fn drop(&mut self) { - unsafe { - DROP_T += 1; - DROP += 1; - } - } -} -fn g(ref _t: T) {} - -fn do_test() { - let s = S; - f(s); - unsafe { - assert_eq!(1, DROP); - assert_eq!(1, DROP_S); - } - let t = T { i: 1 }; - g(t); - unsafe { assert_eq!(1, DROP_T); } -} - -fn main() { - do_test(); - unsafe { - assert_eq!(2, DROP); - assert_eq!(1, DROP_S); - assert_eq!(1, DROP_T); - } -} diff --git a/tests/ui/privacy/pub-restricted-path-usage-55376.rs b/tests/ui/privacy/pub-restricted-path-usage-55376.rs new file mode 100644 index 00000000000..ca4e27c30a8 --- /dev/null +++ b/tests/ui/privacy/pub-restricted-path-usage-55376.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/55376 +//@ run-pass +// Tests that paths in `pub(...)` don't fail HIR verification. + +#![allow(unused_imports)] +#![allow(dead_code)] + +pub(self) use self::my_mod::Foo; + +mod my_mod { + pub(super) use self::Foo as Bar; + pub(in super::my_mod) use self::Foo as Baz; + + pub struct Foo; +} + +fn main() {} diff --git a/tests/ui/repr/packed-struct-with-enum-53728.rs b/tests/ui/repr/packed-struct-with-enum-53728.rs new file mode 100644 index 00000000000..6ce65ed634f --- /dev/null +++ b/tests/ui/repr/packed-struct-with-enum-53728.rs @@ -0,0 +1,20 @@ +// https://github.com/rust-lang/rust/issues/53728 +//@ run-pass + +#![allow(dead_code)] +#[repr(u16)] +enum DeviceKind { + Nil = 0, +} + +#[repr(packed)] +struct DeviceInfo { + endianness: u8, + device_kind: DeviceKind, +} + +fn main() { + let _x = None::<(DeviceInfo, u8)>; + let _y = None::<(DeviceInfo, u16)>; + let _z = None::<(DeviceInfo, u64)>; +} diff --git a/tests/ui/resolve/module-import-resolution-7663.rs b/tests/ui/resolve/module-import-resolution-7663.rs deleted file mode 100644 index 872806594fc..00000000000 --- a/tests/ui/resolve/module-import-resolution-7663.rs +++ /dev/null @@ -1,33 +0,0 @@ -// https://github.com/rust-lang/rust/issues/7663 -//@ run-pass - -#![allow(unused_imports, dead_code)] - -mod test1 { - - mod foo { pub fn p() -> isize { 1 } } - mod bar { pub fn p() -> isize { 2 } } - - pub mod baz { - use crate::test1::bar::p; - - pub fn my_main() { assert_eq!(p(), 2); } - } -} - -mod test2 { - - mod foo { pub fn p() -> isize { 1 } } - mod bar { pub fn p() -> isize { 2 } } - - pub mod baz { - use crate::test2::bar::p; - - pub fn my_main() { assert_eq!(p(), 2); } - } -} - -fn main() { - test1::baz::my_main(); - test2::baz::my_main(); -} diff --git a/tests/ui/resolve/unit-like-struct-masks-constant-7044.rs b/tests/ui/resolve/unit-like-struct-masks-constant-7044.rs new file mode 100644 index 00000000000..f48dd695f01 --- /dev/null +++ b/tests/ui/resolve/unit-like-struct-masks-constant-7044.rs @@ -0,0 +1,5 @@ +// https://github.com/rust-lang/rust/issues/7044 +static X: isize = 0; +struct X; //~ ERROR the name `X` is defined multiple times + +fn main() {} diff --git a/tests/ui/resolve/unit-like-struct-masks-constant-7044.stderr b/tests/ui/resolve/unit-like-struct-masks-constant-7044.stderr new file mode 100644 index 00000000000..48aa6fce455 --- /dev/null +++ b/tests/ui/resolve/unit-like-struct-masks-constant-7044.stderr @@ -0,0 +1,13 @@ +error[E0428]: the name `X` is defined multiple times + --> $DIR/unit-like-struct-masks-constant-7044.rs:3:1 + | +LL | static X: isize = 0; + | -------------------- previous definition of the value `X` here +LL | struct X; + | ^^^^^^^^^ `X` redefined here + | + = note: `X` must be defined only once in the value namespace of this module + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/specialization/trait-specialization-default-methods-55380.rs b/tests/ui/specialization/trait-specialization-default-methods-55380.rs new file mode 100644 index 00000000000..b3d79fb5ffb --- /dev/null +++ b/tests/ui/specialization/trait-specialization-default-methods-55380.rs @@ -0,0 +1,29 @@ +// https://github.com/rust-lang/rust/issues/55380 +//@ run-pass +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +pub trait Foo { + fn abc() -> u32; + fn def() -> u32; +} + +pub trait Marker {} + +impl Marker for () {} + +impl Foo for T { + default fn abc() -> u32 { 16 } + default fn def() -> u32 { 42 } +} + +impl Foo for T { + fn def() -> u32 { + Self::abc() + } +} + +fn main() { + assert_eq!(<()>::def(), 16); + assert_eq!(::def(), 42); +} diff --git a/tests/ui/specialization/trait-specialization-default-methods-55380.stderr b/tests/ui/specialization/trait-specialization-default-methods-55380.stderr new file mode 100644 index 00000000000..f7c1903da62 --- /dev/null +++ b/tests/ui/specialization/trait-specialization-default-methods-55380.stderr @@ -0,0 +1,12 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/trait-specialization-default-methods-55380.rs:3:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/static/global-variable-promotion-error-7364.rs b/tests/ui/static/global-variable-promotion-error-7364.rs new file mode 100644 index 00000000000..dba4a484d61 --- /dev/null +++ b/tests/ui/static/global-variable-promotion-error-7364.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/7364 +use std::cell::RefCell; + +// Regression test for issue 7364 +static boxed: Box> = Box::new(RefCell::new(0)); +//~^ ERROR `RefCell` cannot be shared between threads safely [E0277] +//~| ERROR cannot call non-const associated function + +fn main() { } diff --git a/tests/ui/static/global-variable-promotion-error-7364.stderr b/tests/ui/static/global-variable-promotion-error-7364.stderr new file mode 100644 index 00000000000..b9d75676bef --- /dev/null +++ b/tests/ui/static/global-variable-promotion-error-7364.stderr @@ -0,0 +1,26 @@ +error[E0277]: `RefCell` cannot be shared between threads safely + --> $DIR/global-variable-promotion-error-7364.rs:5:15 + | +LL | static boxed: Box> = Box::new(RefCell::new(0)); + | ^^^^^^^^^^^^^^^^^^^ `RefCell` cannot be shared between threads safely + | + = help: the trait `Sync` is not implemented for `RefCell` + = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead + = note: required for `Unique>` to implement `Sync` +note: required because it appears within the type `Box>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + = note: shared static variables must have a type that implements `Sync` + +error[E0015]: cannot call non-const associated function `Box::>::new` in statics + --> $DIR/global-variable-promotion-error-7364.rs:5:37 + | +LL | static boxed: Box> = Box::new(RefCell::new(0)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/structs-enums/auxiliary/aux-8044.rs b/tests/ui/structs-enums/auxiliary/aux-8044.rs deleted file mode 100644 index 2ec25f51cde..00000000000 --- a/tests/ui/structs-enums/auxiliary/aux-8044.rs +++ /dev/null @@ -1,15 +0,0 @@ -pub struct BTree { - pub node: TreeItem, -} - -pub enum TreeItem { - TreeLeaf { value: V }, -} - -pub fn leaf(value: V) -> TreeItem { - TreeItem::TreeLeaf { value: value } -} - -fn main() { - BTree:: { node: leaf(1) }; -} diff --git a/tests/ui/structs-enums/struct-and-enum-usage-8044.rs b/tests/ui/structs-enums/struct-and-enum-usage-8044.rs deleted file mode 100644 index 9b544f33f1c..00000000000 --- a/tests/ui/structs-enums/struct-and-enum-usage-8044.rs +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/rust-lang/rust/issues/8044 -//@ run-pass -//@ aux-build:aux-8044.rs - -extern crate aux_8044 as minimal; -use minimal::{BTree, leaf}; - -pub fn main() { - BTree:: { node: leaf(1) }; -} diff --git a/tests/ui/structs/auxiliary/aux-8044.rs b/tests/ui/structs/auxiliary/aux-8044.rs new file mode 100644 index 00000000000..2ec25f51cde --- /dev/null +++ b/tests/ui/structs/auxiliary/aux-8044.rs @@ -0,0 +1,15 @@ +pub struct BTree { + pub node: TreeItem, +} + +pub enum TreeItem { + TreeLeaf { value: V }, +} + +pub fn leaf(value: V) -> TreeItem { + TreeItem::TreeLeaf { value: value } +} + +fn main() { + BTree:: { node: leaf(1) }; +} diff --git a/tests/ui/structs/btree-struct-usage-8044.rs b/tests/ui/structs/btree-struct-usage-8044.rs new file mode 100644 index 00000000000..9b544f33f1c --- /dev/null +++ b/tests/ui/structs/btree-struct-usage-8044.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/8044 +//@ run-pass +//@ aux-build:aux-8044.rs + +extern crate aux_8044 as minimal; +use minimal::{BTree, leaf}; + +pub fn main() { + BTree:: { node: leaf(1) }; +} diff --git a/tests/ui/traits/nll-ice-custom-type-ops-53568.rs b/tests/ui/traits/nll-ice-custom-type-ops-53568.rs new file mode 100644 index 00000000000..9b240cdc190 --- /dev/null +++ b/tests/ui/traits/nll-ice-custom-type-ops-53568.rs @@ -0,0 +1,48 @@ +// https://github.com/rust-lang/rust/issues/53568 +// Regression test for an NLL-related ICE (#53568) -- we failed to +// resolve inference variables in "custom type-ops". +// +//@ check-pass + +trait Future { + type Item; +} + +impl Future for F +where F: Fn() -> T +{ + type Item = T; +} + +trait Connect {} + +struct Connector { + handler: H, +} + +impl Connect for Connector +where + T: 'static, + H: Future +{ +} + +struct Client { + connector: C, +} + +fn build(_connector: C) -> Client { + unimplemented!() +} + +fn client(handler: H) -> Client +where H: Fn() + Copy +{ + let connector = Connector { + handler, + }; + let client = build(connector); + client +} + +fn main() { } diff --git a/tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs b/tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs deleted file mode 100644 index 59ea62c7690..00000000000 --- a/tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs +++ /dev/null @@ -1,19 +0,0 @@ -// https://github.com/rust-lang/rust/issues/8171 -//@ check-pass -#![allow(dead_code)] - -/* - -#8171 Self is not recognised as implementing kinds in default method implementations - -*/ - -fn require_send(_: T){} - -trait TragicallySelfIsNotSend: Send + Sized { - fn x(self) { - require_send(self); - } -} - -pub fn main(){} diff --git a/tests/ui/traits/self-not-send-in-default-method-8171.rs b/tests/ui/traits/self-not-send-in-default-method-8171.rs new file mode 100644 index 00000000000..59ea62c7690 --- /dev/null +++ b/tests/ui/traits/self-not-send-in-default-method-8171.rs @@ -0,0 +1,19 @@ +// https://github.com/rust-lang/rust/issues/8171 +//@ check-pass +#![allow(dead_code)] + +/* + +#8171 Self is not recognised as implementing kinds in default method implementations + +*/ + +fn require_send(_: T){} + +trait TragicallySelfIsNotSend: Send + Sized { + fn x(self) { + require_send(self); + } +} + +pub fn main(){} diff --git a/tests/ui/traits/trait-implementation-and-usage-7563.rs b/tests/ui/traits/trait-implementation-and-usage-7563.rs deleted file mode 100644 index 8cfc7a14ffe..00000000000 --- a/tests/ui/traits/trait-implementation-and-usage-7563.rs +++ /dev/null @@ -1,29 +0,0 @@ -// https://github.com/rust-lang/rust/issues/7563 -//@ run-pass -#![allow(dead_code)] -trait IDummy { - fn do_nothing(&self); -} - -#[derive(Debug)] -struct A { a: isize } -#[derive(Debug)] -struct B<'a> { b: isize, pa: &'a A } - - impl IDummy for A { - fn do_nothing(&self) { - println!("A::do_nothing() is called"); - } - } - -impl<'a> B<'a> { - fn get_pa(&self) -> &'a dyn IDummy { self.pa as &'a dyn IDummy } -} - -pub fn main() { - let sa = A { a: 100 }; - let sb = B { b: 200, pa: &sa }; - - println!("sa is {:?}", sa); - println!("sb is {:?}", sb); -} diff --git a/tests/ui/traits/trait-object-lifetime-bounds-7563.rs b/tests/ui/traits/trait-object-lifetime-bounds-7563.rs new file mode 100644 index 00000000000..8cfc7a14ffe --- /dev/null +++ b/tests/ui/traits/trait-object-lifetime-bounds-7563.rs @@ -0,0 +1,29 @@ +// https://github.com/rust-lang/rust/issues/7563 +//@ run-pass +#![allow(dead_code)] +trait IDummy { + fn do_nothing(&self); +} + +#[derive(Debug)] +struct A { a: isize } +#[derive(Debug)] +struct B<'a> { b: isize, pa: &'a A } + + impl IDummy for A { + fn do_nothing(&self) { + println!("A::do_nothing() is called"); + } + } + +impl<'a> B<'a> { + fn get_pa(&self) -> &'a dyn IDummy { self.pa as &'a dyn IDummy } +} + +pub fn main() { + let sa = A { a: 100 }; + let sb = B { b: 200, pa: &sa }; + + println!("sa is {:?}", sa); + println!("sb is {:?}", sb); +} diff --git a/tests/ui/unreachable-code/boolean-negation-in-unreachable-code-7344.rs b/tests/ui/unreachable-code/boolean-negation-in-unreachable-code-7344.rs new file mode 100644 index 00000000000..8fd091872c3 --- /dev/null +++ b/tests/ui/unreachable-code/boolean-negation-in-unreachable-code-7344.rs @@ -0,0 +1,22 @@ +// https://github.com/rust-lang/rust/issues/7344 +//@ run-pass +#![allow(unused_must_use)] + +#![allow(unreachable_code)] + +fn foo() -> bool { false } + +fn bar() { + return; + !foo(); +} + +fn baz() { + return; + if "" == "" {} +} + +pub fn main() { + bar(); + baz(); +} -- cgit 1.4.1-3-g733a5