From a4a5bf5a71bd0c3fb52a28f81d88ce1755b3bc30 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Thu, 24 Jul 2025 17:22:54 +0500 Subject: comments --- .../deref-chain-method-calls-13264.rs | 76 +++++++++ .../block-result/blocks-without-results-11709.rs | 39 +++++ tests/ui/block-result/blocks-without-results.rs | 37 ----- .../borrowck/moved-value-in-thread-loop-12041.rs | 15 ++ .../moved-value-in-thread-loop-12041.stderr | 11 ++ .../ui/borrowck/refcell-borrow-comparison-12033.rs | 9 ++ tests/ui/borrowck/refcell-borrow-comparison.rs | 7 - .../string-literal-match-patterns-11869.rs | 18 +++ tests/ui/closures/fnonce-moved-twice-12127.rs | 16 ++ tests/ui/closures/fnonce-moved-twice-12127.stderr | 18 +++ tests/ui/closures/fnonce-moved-twice.rs | 14 -- tests/ui/closures/moved-upvar-mut-rebind-11958.rs | 13 ++ .../closures/moved-upvar-mut-rebind-11958.stderr | 20 +++ tests/ui/closures/moved-upvar-mut-rebind.rs | 11 -- tests/ui/coercion/any-trait-object-debug-12744.rs | 7 + .../collections/hashset-connected-border-12860.rs | 51 ++++++ tests/ui/collections/hashset-connected-border.rs | 49 ------ .../ui/const-generics/vec-macro-in-static-array.rs | 2 + .../vec-macro-in-static-array.stderr | 13 ++ tests/ui/extern/format-message-windows-ffi.rs | 39 ----- tests/ui/extern/windows-tcb-trash-13259.rs | 49 ++++++ tests/ui/fn/anonymous-parameters-trait-13105.rs | 11 ++ tests/ui/fn/anonymous-parameters-trait.rs | 9 -- tests/ui/imports/use-in-impl-scope.rs | 14 -- tests/ui/issues/issue-11771.stderr | 39 ----- tests/ui/issues/issue-11844.stderr | 14 -- tests/ui/issues/issue-11958.stderr | 20 --- tests/ui/issues/issue-12041.stderr | 11 -- tests/ui/issues/issue-12127.stderr | 18 --- tests/ui/issues/issue-12567.stderr | 51 ------ tests/ui/issues/issue-12863.stderr | 9 -- tests/ui/issues/issue-13058.stderr | 14 -- tests/ui/issues/issue-13359.stderr | 39 ----- tests/ui/issues/issue-13407.stderr | 27 ---- tests/ui/issues/issue-13446.stderr | 13 -- tests/ui/issues/issue-13466.stderr | 26 --- tests/ui/iterators/bytes-iterator-clone-12677.rs | 11 ++ tests/ui/iterators/bytes-iterator-clone.rs | 9 -- tests/ui/iterators/phf-map-entries-iterator.rs | 24 --- .../iterator-trait-lifetime-error-13058.rs | 29 ++++ .../iterator-trait-lifetime-error-13058.stderr | 14 ++ .../ui/lifetimes/iterator-trait-lifetime-error.rs | 27 ---- .../lifetime-inference-destructuring-arg.rs | 26 +++ tests/ui/lifetimes/matcher-trait-equality-13323.rs | 60 +++++++ .../struct-lifetime-field-assignment-13405.rs | 21 +++ .../lifetimes/struct-lifetime-field-assignment.rs | 19 --- .../ui/lifetimes/unsafe-transmute-in-find-11740.rs | 28 ++++ tests/ui/match/function-in-pattern-error.rs | 8 - tests/ui/match/guard-literal-range-shadow.rs | 178 -------------------- tests/ui/match/option-result-mismatch-11844.rs | 10 ++ tests/ui/match/option-result-mismatch-11844.stderr | 14 ++ tests/ui/match/option-result-mismatch.rs | 8 - .../option-result-type-param-mismatch-13466.rs | 24 +++ .../option-result-type-param-mismatch-13466.stderr | 26 +++ .../ui/match/option-result-type-param-mismatch.rs | 22 --- .../ui/match/overeager-sub-match-pruning-13027.rs | 180 +++++++++++++++++++++ tests/ui/match/slice-move-out-error-12567.rs | 15 ++ tests/ui/match/slice-move-out-error-12567.stderr | 51 ++++++ tests/ui/match/slice-move-out-error.rs | 13 -- tests/ui/match/string-literal-match-patterns.rs | 16 -- tests/ui/match/struct-reference-patterns-12285.rs | 16 ++ tests/ui/match/struct-reference-patterns.rs | 14 -- tests/ui/panics/explicit-panic-unreachable.rs | 8 - tests/ui/panics/unwrap-or-panic-input.rs | 7 - tests/ui/parser/encode-symbol-ice-12920.rs | 10 ++ tests/ui/privacy/private-unit-struct-assignment.rs | 2 + .../privacy/private-unit-struct-assignment.stderr | 27 ++++ tests/ui/privacy/use-in-impl-scope-12729.rs | 16 ++ tests/ui/resolve/reference-clone-nonclone-11820.rs | 15 ++ .../statics/enum-with-static-str-variant-13214.rs | 24 +++ tests/ui/statics/enum-with-static-str-variant.rs | 22 --- tests/ui/threads/moved-value-in-thread-loop.rs | 13 -- tests/ui/traits/any-trait-object-debug.rs | 5 - .../traits/default-method-lifetime-params-13204.rs | 27 ++++ tests/ui/traits/default-method-lifetime-params.rs | 25 --- tests/ui/traits/deref-chain-method-calls.rs | 74 --------- tests/ui/traits/fnonce-repro-trait-impl-13434.rs | 23 +++ tests/ui/traits/fnonce-repro-trait-impl.rs | 21 --- tests/ui/traits/matcher-trait-equality.rs | 58 ------- tests/ui/traits/reference-clone-noclone.rs | 13 -- .../type-inference/isize-usize-mismatch-error.rs | 15 -- tests/ui/type-inference/partial-type-hint-12909.rs | 21 +++ tests/ui/type-inference/type-collect-inference.rs | 19 --- tests/ui/type-inference/unit-type-add-error.rs | 11 -- tests/ui/typeck/function-in-pattern-error-12863.rs | 10 ++ .../typeck/function-in-pattern-error-12863.stderr | 9 ++ tests/ui/typeck/isize-usize-mismatch-error.rs | 17 ++ tests/ui/typeck/isize-usize-mismatch-error.stderr | 39 +++++ tests/ui/typeck/unit-type-add-error-11771.rs | 13 ++ tests/ui/typeck/unit-type-add-error-11771.stderr | 39 +++++ tests/ui/typeck/unwrap-or-panic-input-13202.rs | 9 ++ tests/ui/unsafe/unsafe-transmute-in-find.rs | 26 --- 92 files changed, 1194 insertions(+), 1116 deletions(-) create mode 100644 tests/ui/autoref-autoderef/deref-chain-method-calls-13264.rs create mode 100644 tests/ui/block-result/blocks-without-results-11709.rs delete mode 100644 tests/ui/block-result/blocks-without-results.rs create mode 100644 tests/ui/borrowck/moved-value-in-thread-loop-12041.rs create mode 100644 tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr create mode 100644 tests/ui/borrowck/refcell-borrow-comparison-12033.rs delete mode 100644 tests/ui/borrowck/refcell-borrow-comparison.rs create mode 100644 tests/ui/borrowck/string-literal-match-patterns-11869.rs create mode 100644 tests/ui/closures/fnonce-moved-twice-12127.rs create mode 100644 tests/ui/closures/fnonce-moved-twice-12127.stderr delete mode 100644 tests/ui/closures/fnonce-moved-twice.rs create mode 100644 tests/ui/closures/moved-upvar-mut-rebind-11958.rs create mode 100644 tests/ui/closures/moved-upvar-mut-rebind-11958.stderr delete mode 100644 tests/ui/closures/moved-upvar-mut-rebind.rs create mode 100644 tests/ui/coercion/any-trait-object-debug-12744.rs create mode 100644 tests/ui/collections/hashset-connected-border-12860.rs delete mode 100644 tests/ui/collections/hashset-connected-border.rs create mode 100644 tests/ui/const-generics/vec-macro-in-static-array.stderr delete mode 100644 tests/ui/extern/format-message-windows-ffi.rs create mode 100644 tests/ui/extern/windows-tcb-trash-13259.rs create mode 100644 tests/ui/fn/anonymous-parameters-trait-13105.rs delete mode 100644 tests/ui/fn/anonymous-parameters-trait.rs delete mode 100644 tests/ui/imports/use-in-impl-scope.rs delete mode 100644 tests/ui/issues/issue-11771.stderr delete mode 100644 tests/ui/issues/issue-11844.stderr delete mode 100644 tests/ui/issues/issue-11958.stderr delete mode 100644 tests/ui/issues/issue-12041.stderr delete mode 100644 tests/ui/issues/issue-12127.stderr delete mode 100644 tests/ui/issues/issue-12567.stderr delete mode 100644 tests/ui/issues/issue-12863.stderr delete mode 100644 tests/ui/issues/issue-13058.stderr delete mode 100644 tests/ui/issues/issue-13359.stderr delete mode 100644 tests/ui/issues/issue-13407.stderr delete mode 100644 tests/ui/issues/issue-13446.stderr delete mode 100644 tests/ui/issues/issue-13466.stderr create mode 100644 tests/ui/iterators/bytes-iterator-clone-12677.rs delete mode 100644 tests/ui/iterators/bytes-iterator-clone.rs delete mode 100644 tests/ui/iterators/phf-map-entries-iterator.rs create mode 100644 tests/ui/lifetimes/iterator-trait-lifetime-error-13058.rs create mode 100644 tests/ui/lifetimes/iterator-trait-lifetime-error-13058.stderr delete mode 100644 tests/ui/lifetimes/iterator-trait-lifetime-error.rs create mode 100644 tests/ui/lifetimes/lifetime-inference-destructuring-arg.rs create mode 100644 tests/ui/lifetimes/matcher-trait-equality-13323.rs create mode 100644 tests/ui/lifetimes/struct-lifetime-field-assignment-13405.rs delete mode 100644 tests/ui/lifetimes/struct-lifetime-field-assignment.rs create mode 100644 tests/ui/lifetimes/unsafe-transmute-in-find-11740.rs delete mode 100644 tests/ui/match/function-in-pattern-error.rs delete mode 100644 tests/ui/match/guard-literal-range-shadow.rs create mode 100644 tests/ui/match/option-result-mismatch-11844.rs create mode 100644 tests/ui/match/option-result-mismatch-11844.stderr delete mode 100644 tests/ui/match/option-result-mismatch.rs create mode 100644 tests/ui/match/option-result-type-param-mismatch-13466.rs create mode 100644 tests/ui/match/option-result-type-param-mismatch-13466.stderr delete mode 100644 tests/ui/match/option-result-type-param-mismatch.rs create mode 100644 tests/ui/match/overeager-sub-match-pruning-13027.rs create mode 100644 tests/ui/match/slice-move-out-error-12567.rs create mode 100644 tests/ui/match/slice-move-out-error-12567.stderr delete mode 100644 tests/ui/match/slice-move-out-error.rs delete mode 100644 tests/ui/match/string-literal-match-patterns.rs create mode 100644 tests/ui/match/struct-reference-patterns-12285.rs delete mode 100644 tests/ui/match/struct-reference-patterns.rs delete mode 100644 tests/ui/panics/explicit-panic-unreachable.rs delete mode 100644 tests/ui/panics/unwrap-or-panic-input.rs create mode 100644 tests/ui/parser/encode-symbol-ice-12920.rs create mode 100644 tests/ui/privacy/private-unit-struct-assignment.stderr create mode 100644 tests/ui/privacy/use-in-impl-scope-12729.rs create mode 100644 tests/ui/resolve/reference-clone-nonclone-11820.rs create mode 100644 tests/ui/statics/enum-with-static-str-variant-13214.rs delete mode 100644 tests/ui/statics/enum-with-static-str-variant.rs delete mode 100644 tests/ui/threads/moved-value-in-thread-loop.rs delete mode 100644 tests/ui/traits/any-trait-object-debug.rs create mode 100644 tests/ui/traits/default-method-lifetime-params-13204.rs delete mode 100644 tests/ui/traits/default-method-lifetime-params.rs delete mode 100644 tests/ui/traits/deref-chain-method-calls.rs create mode 100644 tests/ui/traits/fnonce-repro-trait-impl-13434.rs delete mode 100644 tests/ui/traits/fnonce-repro-trait-impl.rs delete mode 100644 tests/ui/traits/matcher-trait-equality.rs delete mode 100644 tests/ui/traits/reference-clone-noclone.rs delete mode 100644 tests/ui/type-inference/isize-usize-mismatch-error.rs create mode 100644 tests/ui/type-inference/partial-type-hint-12909.rs delete mode 100644 tests/ui/type-inference/type-collect-inference.rs delete mode 100644 tests/ui/type-inference/unit-type-add-error.rs create mode 100644 tests/ui/typeck/function-in-pattern-error-12863.rs create mode 100644 tests/ui/typeck/function-in-pattern-error-12863.stderr create mode 100644 tests/ui/typeck/isize-usize-mismatch-error.rs create mode 100644 tests/ui/typeck/isize-usize-mismatch-error.stderr create mode 100644 tests/ui/typeck/unit-type-add-error-11771.rs create mode 100644 tests/ui/typeck/unit-type-add-error-11771.stderr create mode 100644 tests/ui/typeck/unwrap-or-panic-input-13202.rs delete mode 100644 tests/ui/unsafe/unsafe-transmute-in-find.rs (limited to 'tests') diff --git a/tests/ui/autoref-autoderef/deref-chain-method-calls-13264.rs b/tests/ui/autoref-autoderef/deref-chain-method-calls-13264.rs new file mode 100644 index 00000000000..f471c1c7eef --- /dev/null +++ b/tests/ui/autoref-autoderef/deref-chain-method-calls-13264.rs @@ -0,0 +1,76 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13264 + +//@ run-pass +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +use std::ops::Deref; + +struct Root { + jsref: JSRef +} + +impl Deref for Root { + type Target = JSRef; + + fn deref<'a>(&'a self) -> &'a JSRef { + &self.jsref + } +} + +#[derive(Copy, Clone)] +struct JSRef { + node: *const Node +} + +impl Deref for JSRef { + type Target = Node; + + fn deref<'a>(&'a self) -> &'a Node { + self.get() + } +} + +trait INode { + fn RemoveChild(&self); +} + +impl INode for JSRef { + fn RemoveChild(&self) { + self.get().RemoveChild(0) + } +} + +impl JSRef { + fn AddChild(&self) { + self.get().AddChild(0); + } + + fn get<'a>(&'a self) -> &'a Node { + unsafe { + &*self.node + } + } +} + +struct Node; + +impl Node { + fn RemoveChild(&self, _a: usize) { + } + + fn AddChild(&self, _a: usize) { + } +} + +fn main() { + let n = Node; + let jsref = JSRef { node: &n }; + let root = Root { jsref: jsref }; + + root.AddChild(); + jsref.AddChild(); + + root.RemoveChild(); + jsref.RemoveChild(); +} diff --git a/tests/ui/block-result/blocks-without-results-11709.rs b/tests/ui/block-result/blocks-without-results-11709.rs new file mode 100644 index 00000000000..97ea6f9e19e --- /dev/null +++ b/tests/ui/block-result/blocks-without-results-11709.rs @@ -0,0 +1,39 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11709 + +//@ run-pass +#![allow(dead_code)] + +// Don't panic on blocks without results +// There are several tests in this run-pass that raised +// when this bug was opened. The cases where the compiler +// panics before the fix have a comment. + +struct S {x:()} + +fn test(slot: &mut Option Box>>) -> () { + let a = slot.take(); + let _a: () = match a { + // `{let .. a(); }` would break + Some(mut a) => { let _a = a(); }, + None => (), + }; +} + +fn not(b: bool) -> bool { + if b { + !b + } else { + // `panic!(...)` would break + panic!("Break the compiler"); + } +} + +pub fn main() { + // {} would break + let _r: () = {}; + let mut slot = None; + // `{ test(...); }` would break + let _s : S = S{ x: { test(&mut slot); } }; + + let _b = not(true); +} diff --git a/tests/ui/block-result/blocks-without-results.rs b/tests/ui/block-result/blocks-without-results.rs deleted file mode 100644 index 8a11074eca8..00000000000 --- a/tests/ui/block-result/blocks-without-results.rs +++ /dev/null @@ -1,37 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -// Don't panic on blocks without results -// There are several tests in this run-pass that raised -// when this bug was opened. The cases where the compiler -// panics before the fix have a comment. - -struct S {x:()} - -fn test(slot: &mut Option Box>>) -> () { - let a = slot.take(); - let _a: () = match a { - // `{let .. a(); }` would break - Some(mut a) => { let _a = a(); }, - None => (), - }; -} - -fn not(b: bool) -> bool { - if b { - !b - } else { - // `panic!(...)` would break - panic!("Break the compiler"); - } -} - -pub fn main() { - // {} would break - let _r: () = {}; - let mut slot = None; - // `{ test(...); }` would break - let _s : S = S{ x: { test(&mut slot); } }; - - let _b = not(true); -} diff --git a/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs b/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs new file mode 100644 index 00000000000..98f9cdbdef7 --- /dev/null +++ b/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs @@ -0,0 +1,15 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12041 + +use std::sync::mpsc::channel; +use std::thread; + +fn main() { + let (tx, rx) = channel(); + let _t = thread::spawn(move|| -> () { + loop { + let tx = tx; + //~^ ERROR: use of moved value: `tx` + tx.send(1); + } + }); +} diff --git a/tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr b/tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr new file mode 100644 index 00000000000..627dd193dad --- /dev/null +++ b/tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `tx` + --> $DIR/moved-value-in-thread-loop-12041.rs:10:22 + | +LL | let tx = tx; + | ^^ value moved here, in previous iteration of loop + | + = note: move occurs because `tx` has type `std::sync::mpsc::Sender`, which does not implement the `Copy` trait + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/borrowck/refcell-borrow-comparison-12033.rs b/tests/ui/borrowck/refcell-borrow-comparison-12033.rs new file mode 100644 index 00000000000..de22cedd5b9 --- /dev/null +++ b/tests/ui/borrowck/refcell-borrow-comparison-12033.rs @@ -0,0 +1,9 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12033 + +//@ run-pass +use std::cell::RefCell; + +fn main() { + let x = RefCell::new(0); + if *x.borrow() == 0 {} else {} +} diff --git a/tests/ui/borrowck/refcell-borrow-comparison.rs b/tests/ui/borrowck/refcell-borrow-comparison.rs deleted file mode 100644 index 0bf6490bafe..00000000000 --- a/tests/ui/borrowck/refcell-borrow-comparison.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -use std::cell::RefCell; - -fn main() { - let x = RefCell::new(0); - if *x.borrow() == 0 {} else {} -} diff --git a/tests/ui/borrowck/string-literal-match-patterns-11869.rs b/tests/ui/borrowck/string-literal-match-patterns-11869.rs new file mode 100644 index 00000000000..4c159e457cf --- /dev/null +++ b/tests/ui/borrowck/string-literal-match-patterns-11869.rs @@ -0,0 +1,18 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11869 + +//@ check-pass +#![allow(dead_code)] + +struct A { + a: String +} + +fn borrow<'a>(binding: &'a A) -> &'a str { + match &*binding.a { + "in" => "in_", + "ref" => "ref_", + ident => ident + } +} + +fn main() {} diff --git a/tests/ui/closures/fnonce-moved-twice-12127.rs b/tests/ui/closures/fnonce-moved-twice-12127.rs new file mode 100644 index 00000000000..369ddcafaab --- /dev/null +++ b/tests/ui/closures/fnonce-moved-twice-12127.rs @@ -0,0 +1,16 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12127 + +#![feature(unboxed_closures, tuple_trait)] + +fn to_fn_once>(f: F) -> F { f } +fn do_it(x: &isize) { } + +fn main() { + let x: Box<_> = Box::new(22); + let f = to_fn_once(move|| do_it(&*x)); + to_fn_once(move|| { + f(); + f(); + //~^ ERROR: use of moved value: `f` + })() +} diff --git a/tests/ui/closures/fnonce-moved-twice-12127.stderr b/tests/ui/closures/fnonce-moved-twice-12127.stderr new file mode 100644 index 00000000000..c2e12827527 --- /dev/null +++ b/tests/ui/closures/fnonce-moved-twice-12127.stderr @@ -0,0 +1,18 @@ +error[E0382]: use of moved value: `f` + --> $DIR/fnonce-moved-twice-12127.rs:13:9 + | +LL | f(); + | --- `f` moved due to this call +LL | f(); + | ^ value used here after move + | +note: this value implements `FnOnce`, which causes it to be moved when called + --> $DIR/fnonce-moved-twice-12127.rs:12:9 + | +LL | f(); + | ^ + = note: move occurs because `f` has type `{closure@$DIR/fnonce-moved-twice-12127.rs:10:24: 10:30}`, which does not implement the `Copy` trait + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/closures/fnonce-moved-twice.rs b/tests/ui/closures/fnonce-moved-twice.rs deleted file mode 100644 index 199d542e816..00000000000 --- a/tests/ui/closures/fnonce-moved-twice.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(unboxed_closures, tuple_trait)] - -fn to_fn_once>(f: F) -> F { f } -fn do_it(x: &isize) { } - -fn main() { - let x: Box<_> = Box::new(22); - let f = to_fn_once(move|| do_it(&*x)); - to_fn_once(move|| { - f(); - f(); - //~^ ERROR: use of moved value: `f` - })() -} diff --git a/tests/ui/closures/moved-upvar-mut-rebind-11958.rs b/tests/ui/closures/moved-upvar-mut-rebind-11958.rs new file mode 100644 index 00000000000..701dc1a2cef --- /dev/null +++ b/tests/ui/closures/moved-upvar-mut-rebind-11958.rs @@ -0,0 +1,13 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11958 + +//@ run-pass + +// We shouldn't need to rebind a moved upvar as mut if it's already +// marked as mut + +pub fn main() { + let mut x = 1; + let _thunk = Box::new(move|| { x = 2; }); + //~^ WARN value assigned to `x` is never read + //~| WARN unused variable: `x` +} diff --git a/tests/ui/closures/moved-upvar-mut-rebind-11958.stderr b/tests/ui/closures/moved-upvar-mut-rebind-11958.stderr new file mode 100644 index 00000000000..b12bbcad925 --- /dev/null +++ b/tests/ui/closures/moved-upvar-mut-rebind-11958.stderr @@ -0,0 +1,20 @@ +warning: value assigned to `x` is never read + --> $DIR/moved-upvar-mut-rebind-11958.rs:10:36 + | +LL | let _thunk = Box::new(move|| { x = 2; }); + | ^ + | + = help: maybe it is overwritten before being read? + = note: `#[warn(unused_assignments)]` on by default + +warning: unused variable: `x` + --> $DIR/moved-upvar-mut-rebind-11958.rs:10:36 + | +LL | let _thunk = Box::new(move|| { x = 2; }); + | ^ + | + = help: did you mean to capture by reference instead? + = note: `#[warn(unused_variables)]` on by default + +warning: 2 warnings emitted + diff --git a/tests/ui/closures/moved-upvar-mut-rebind.rs b/tests/ui/closures/moved-upvar-mut-rebind.rs deleted file mode 100644 index 9185c5158af..00000000000 --- a/tests/ui/closures/moved-upvar-mut-rebind.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass - -// We shouldn't need to rebind a moved upvar as mut if it's already -// marked as mut - -pub fn main() { - let mut x = 1; - let _thunk = Box::new(move|| { x = 2; }); - //~^ WARN value assigned to `x` is never read - //~| WARN unused variable: `x` -} diff --git a/tests/ui/coercion/any-trait-object-debug-12744.rs b/tests/ui/coercion/any-trait-object-debug-12744.rs new file mode 100644 index 00000000000..4d981c077ee --- /dev/null +++ b/tests/ui/coercion/any-trait-object-debug-12744.rs @@ -0,0 +1,7 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12744 + +//@ run-pass +fn main() { + fn test() -> Box { Box::new(1) } + println!("{:?}", test()) +} diff --git a/tests/ui/collections/hashset-connected-border-12860.rs b/tests/ui/collections/hashset-connected-border-12860.rs new file mode 100644 index 00000000000..40185bef7c8 --- /dev/null +++ b/tests/ui/collections/hashset-connected-border-12860.rs @@ -0,0 +1,51 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12860 + +//@ run-pass +use std::collections::HashSet; + +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +struct XYZ { + x: isize, + y: isize, + z: isize +} + +fn main() { + let mut connected = HashSet::new(); + let mut border = HashSet::new(); + + let middle = XYZ{x: 0, y: 0, z: 0}; + border.insert(middle); + + while !border.is_empty() && connected.len() < 10000 { + let choice = *(border.iter().next().unwrap()); + border.remove(&choice); + connected.insert(choice); + + let cxp = XYZ{x: choice.x + 1, y: choice.y, z: choice.z}; + let cxm = XYZ{x: choice.x - 1, y: choice.y, z: choice.z}; + let cyp = XYZ{x: choice.x, y: choice.y + 1, z: choice.z}; + let cym = XYZ{x: choice.x, y: choice.y - 1, z: choice.z}; + let czp = XYZ{x: choice.x, y: choice.y, z: choice.z + 1}; + let czm = XYZ{x: choice.x, y: choice.y, z: choice.z - 1}; + + if !connected.contains(&cxp) { + border.insert(cxp); + } + if !connected.contains(&cxm){ + border.insert(cxm); + } + if !connected.contains(&cyp){ + border.insert(cyp); + } + if !connected.contains(&cym) { + border.insert(cym); + } + if !connected.contains(&czp){ + border.insert(czp); + } + if !connected.contains(&czm) { + border.insert(czm); + } + } +} diff --git a/tests/ui/collections/hashset-connected-border.rs b/tests/ui/collections/hashset-connected-border.rs deleted file mode 100644 index 255f6670793..00000000000 --- a/tests/ui/collections/hashset-connected-border.rs +++ /dev/null @@ -1,49 +0,0 @@ -//@ run-pass -use std::collections::HashSet; - -#[derive(Copy, Clone, PartialEq, Eq, Hash)] -struct XYZ { - x: isize, - y: isize, - z: isize -} - -fn main() { - let mut connected = HashSet::new(); - let mut border = HashSet::new(); - - let middle = XYZ{x: 0, y: 0, z: 0}; - border.insert(middle); - - while !border.is_empty() && connected.len() < 10000 { - let choice = *(border.iter().next().unwrap()); - border.remove(&choice); - connected.insert(choice); - - let cxp = XYZ{x: choice.x + 1, y: choice.y, z: choice.z}; - let cxm = XYZ{x: choice.x - 1, y: choice.y, z: choice.z}; - let cyp = XYZ{x: choice.x, y: choice.y + 1, z: choice.z}; - let cym = XYZ{x: choice.x, y: choice.y - 1, z: choice.z}; - let czp = XYZ{x: choice.x, y: choice.y, z: choice.z + 1}; - let czm = XYZ{x: choice.x, y: choice.y, z: choice.z - 1}; - - if !connected.contains(&cxp) { - border.insert(cxp); - } - if !connected.contains(&cxm){ - border.insert(cxm); - } - if !connected.contains(&cyp){ - border.insert(cyp); - } - if !connected.contains(&cym) { - border.insert(cym); - } - if !connected.contains(&czp){ - border.insert(czp); - } - if !connected.contains(&czm) { - border.insert(czm); - } - } -} diff --git a/tests/ui/const-generics/vec-macro-in-static-array.rs b/tests/ui/const-generics/vec-macro-in-static-array.rs index 9f1fc42774f..7a81836e255 100644 --- a/tests/ui/const-generics/vec-macro-in-static-array.rs +++ b/tests/ui/const-generics/vec-macro-in-static-array.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13446 + // Used to cause ICE static VEC: [u32; 256] = vec![]; diff --git a/tests/ui/const-generics/vec-macro-in-static-array.stderr b/tests/ui/const-generics/vec-macro-in-static-array.stderr new file mode 100644 index 00000000000..de21f2274f3 --- /dev/null +++ b/tests/ui/const-generics/vec-macro-in-static-array.stderr @@ -0,0 +1,13 @@ +error[E0308]: mismatched types + --> $DIR/vec-macro-in-static-array.rs:5:26 + | +LL | static VEC: [u32; 256] = vec![]; + | ^^^^^^ expected `[u32; 256]`, found `Vec<_>` + | + = note: expected array `[u32; 256]` + found struct `Vec<_>` + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/extern/format-message-windows-ffi.rs b/tests/ui/extern/format-message-windows-ffi.rs deleted file mode 100644 index 381e3f15259..00000000000 --- a/tests/ui/extern/format-message-windows-ffi.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ run-pass - -#[cfg(windows)] -mod imp { - type LPVOID = *mut u8; - type DWORD = u32; - type LPWSTR = *mut u16; - - extern "system" { - fn FormatMessageW(flags: DWORD, - lpSrc: LPVOID, - msgId: DWORD, - langId: DWORD, - buf: LPWSTR, - nsize: DWORD, - args: *const u8) - -> DWORD; - } - - pub fn test() { - let mut buf: [u16; 50] = [0; 50]; - let ret = unsafe { - FormatMessageW(0x1000, core::ptr::null_mut(), 1, 0x400, - buf.as_mut_ptr(), buf.len() as u32, core::ptr::null()) - }; - // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented - // stacks taking control of pvArbitrary - assert!(ret != 0); - } -} - -#[cfg(not(windows))] -mod imp { - pub fn test() { } -} - -fn main() { - imp::test() -} diff --git a/tests/ui/extern/windows-tcb-trash-13259.rs b/tests/ui/extern/windows-tcb-trash-13259.rs new file mode 100644 index 00000000000..0852e31251a --- /dev/null +++ b/tests/ui/extern/windows-tcb-trash-13259.rs @@ -0,0 +1,49 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13259 + +//@ run-pass + +#[cfg(windows)] +mod imp { + type LPVOID = *mut u8; + type DWORD = u32; + type LPWSTR = *mut u16; + + extern "system" { + fn FormatMessageW( + flags: DWORD, + lpSrc: LPVOID, + msgId: DWORD, + langId: DWORD, + buf: LPWSTR, + nsize: DWORD, + args: *const u8, + ) -> DWORD; + } + + pub fn test() { + let mut buf: [u16; 50] = [0; 50]; + let ret = unsafe { + FormatMessageW( + 0x1000, + core::ptr::null_mut(), + 1, + 0x400, + buf.as_mut_ptr(), + buf.len() as u32, + core::ptr::null(), + ) + }; + // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented + // stacks taking control of pvArbitrary + assert!(ret != 0); + } +} + +#[cfg(not(windows))] +mod imp { + pub fn test() {} +} + +fn main() { + imp::test() +} diff --git a/tests/ui/fn/anonymous-parameters-trait-13105.rs b/tests/ui/fn/anonymous-parameters-trait-13105.rs new file mode 100644 index 00000000000..171dab15fe7 --- /dev/null +++ b/tests/ui/fn/anonymous-parameters-trait-13105.rs @@ -0,0 +1,11 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13105 + +//@ edition: 2015 +//@ check-pass + +trait Foo { + #[allow(anonymous_parameters)] + fn quux(u8) {} +} + +fn main() {} diff --git a/tests/ui/fn/anonymous-parameters-trait.rs b/tests/ui/fn/anonymous-parameters-trait.rs deleted file mode 100644 index d119aa9c788..00000000000 --- a/tests/ui/fn/anonymous-parameters-trait.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ edition: 2015 -//@ check-pass - -trait Foo { - #[allow(anonymous_parameters)] - fn quux(u8) {} -} - -fn main() {} diff --git a/tests/ui/imports/use-in-impl-scope.rs b/tests/ui/imports/use-in-impl-scope.rs deleted file mode 100644 index 4d45846bc60..00000000000 --- a/tests/ui/imports/use-in-impl-scope.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ edition: 2015 -//@ check-pass -#![allow(dead_code)] - -pub struct Foo; - -mod bar { - use Foo; - - impl Foo { - fn baz(&self) {} - } -} -fn main() {} diff --git a/tests/ui/issues/issue-11771.stderr b/tests/ui/issues/issue-11771.stderr deleted file mode 100644 index 5603dc18b63..00000000000 --- a/tests/ui/issues/issue-11771.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0277]: cannot add `()` to `{integer}` - --> $DIR/issue-11771.rs:3:7 - | -LL | 1 + - | ^ no implementation for `{integer} + ()` - | - = help: the trait `Add<()>` is not implemented for `{integer}` - = help: the following other types implement trait `Add`: - `&f128` implements `Add` - `&f128` implements `Add` - `&f16` implements `Add` - `&f16` implements `Add` - `&f32` implements `Add` - `&f32` implements `Add` - `&f64` implements `Add` - `&f64` implements `Add` - and 56 others - -error[E0277]: cannot add `()` to `{integer}` - --> $DIR/issue-11771.rs:8:7 - | -LL | 1 + - | ^ no implementation for `{integer} + ()` - | - = help: the trait `Add<()>` is not implemented for `{integer}` - = help: the following other types implement trait `Add`: - `&f128` implements `Add` - `&f128` implements `Add` - `&f16` implements `Add` - `&f16` implements `Add` - `&f32` implements `Add` - `&f32` implements `Add` - `&f64` implements `Add` - `&f64` implements `Add` - and 56 others - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-11844.stderr b/tests/ui/issues/issue-11844.stderr deleted file mode 100644 index 9ff66eaef49..00000000000 --- a/tests/ui/issues/issue-11844.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-11844.rs:4:9 - | -LL | match a { - | - this expression has type `Option>` -LL | Ok(a) => - | ^^^^^ expected `Option>`, found `Result<_, _>` - | - = note: expected enum `Option>` - found enum `Result<_, _>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-11958.stderr b/tests/ui/issues/issue-11958.stderr deleted file mode 100644 index 5dca4c2f01d..00000000000 --- a/tests/ui/issues/issue-11958.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: value assigned to `x` is never read - --> $DIR/issue-11958.rs:8:36 - | -LL | let _thunk = Box::new(move|| { x = 2; }); - | ^ - | - = help: maybe it is overwritten before being read? - = note: `#[warn(unused_assignments)]` on by default - -warning: unused variable: `x` - --> $DIR/issue-11958.rs:8:36 - | -LL | let _thunk = Box::new(move|| { x = 2; }); - | ^ - | - = help: did you mean to capture by reference instead? - = note: `#[warn(unused_variables)]` on by default - -warning: 2 warnings emitted - diff --git a/tests/ui/issues/issue-12041.stderr b/tests/ui/issues/issue-12041.stderr deleted file mode 100644 index f2c10b83383..00000000000 --- a/tests/ui/issues/issue-12041.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0382]: use of moved value: `tx` - --> $DIR/issue-12041.rs:8:22 - | -LL | let tx = tx; - | ^^ value moved here, in previous iteration of loop - | - = note: move occurs because `tx` has type `std::sync::mpsc::Sender`, which does not implement the `Copy` trait - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/issues/issue-12127.stderr b/tests/ui/issues/issue-12127.stderr deleted file mode 100644 index 2a6233547ee..00000000000 --- a/tests/ui/issues/issue-12127.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0382]: use of moved value: `f` - --> $DIR/issue-12127.rs:11:9 - | -LL | f(); - | --- `f` moved due to this call -LL | f(); - | ^ value used here after move - | -note: this value implements `FnOnce`, which causes it to be moved when called - --> $DIR/issue-12127.rs:10:9 - | -LL | f(); - | ^ - = note: move occurs because `f` has type `{closure@$DIR/issue-12127.rs:8:24: 8:30}`, which does not implement the `Copy` trait - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/issues/issue-12567.stderr b/tests/ui/issues/issue-12567.stderr deleted file mode 100644 index 0b19299ece3..00000000000 --- a/tests/ui/issues/issue-12567.stderr +++ /dev/null @@ -1,51 +0,0 @@ -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:2:11 - | -LL | match (l1, l2) { - | ^^^^^^^^ cannot move out of here -... -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | -- data moved here -LL | => println!("one empty"), -LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here - | - = note: move occurs because these variables have types that don't implement the `Copy` trait -help: consider removing the borrow - | -LL - (&[], &[hd, ..]) | (&[hd, ..], &[]) -LL + (&[], [hd, ..]) | (&[hd, ..], &[]) - | -help: consider removing the borrow - | -LL - (&[hd1, ..], &[hd2, ..]) -LL + (&[hd1, ..], [hd2, ..]) - | - -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:2:11 - | -LL | match (l1, l2) { - | ^^^^^^^^ cannot move out of here -... -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | -- data moved here -LL | => println!("one empty"), -LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here - | - = note: move occurs because these variables have types that don't implement the `Copy` trait -help: consider removing the borrow - | -LL - (&[], &[hd, ..]) | (&[hd, ..], &[]) -LL + (&[], [hd, ..]) | (&[hd, ..], &[]) - | -help: consider removing the borrow - | -LL - (&[hd1, ..], &[hd2, ..]) -LL + ([hd1, ..], &[hd2, ..]) - | - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0508`. diff --git a/tests/ui/issues/issue-12863.stderr b/tests/ui/issues/issue-12863.stderr deleted file mode 100644 index 95d4a704e72..00000000000 --- a/tests/ui/issues/issue-12863.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0532]: expected unit struct, unit variant or constant, found function `foo::bar` - --> $DIR/issue-12863.rs:5:9 - | -LL | foo::bar => {} - | ^^^^^^^^ not a unit struct, unit variant or constant - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0532`. diff --git a/tests/ui/issues/issue-13058.stderr b/tests/ui/issues/issue-13058.stderr deleted file mode 100644 index 4f4108fa182..00000000000 --- a/tests/ui/issues/issue-13058.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `cont` - --> $DIR/issue-13058.rs:14:21 - | -LL | let cont_iter = cont.iter(); - | ^^^^^^^^^^^ lifetime `'r` required - | -help: add explicit lifetime `'r` to the type of `cont` - | -LL | fn check<'r, I: Iterator, T: Itble<'r, usize, I>>(cont: &'r T) -> bool - | ++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/issues/issue-13359.stderr b/tests/ui/issues/issue-13359.stderr deleted file mode 100644 index 91f5de8e8f3..00000000000 --- a/tests/ui/issues/issue-13359.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-13359.rs:8:9 - | -LL | foo(1*(1 as isize)); - | --- ^^^^^^^^^^^^^^ expected `i16`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/issue-13359.rs:3:4 - | -LL | fn foo(_s: i16) { } - | ^^^ ------- -help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit - | -LL | foo((1*(1 as isize)).try_into().unwrap()); - | + +++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/issue-13359.rs:12:9 - | -LL | bar(1*(1 as usize)); - | --- ^^^^^^^^^^^^^^ expected `u32`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/issue-13359.rs:5:4 - | -LL | fn bar(_s: u32) { } - | ^^^ ------- -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit - | -LL | bar((1*(1 as usize)).try_into().unwrap()); - | + +++++++++++++++++++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-13407.stderr b/tests/ui/issues/issue-13407.stderr deleted file mode 100644 index ac2eb6581fe..00000000000 --- a/tests/ui/issues/issue-13407.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0603]: unit struct `C` is private - --> $DIR/issue-13407.rs:6:8 - | -LL | A::C = 1; - | ^ private unit struct - | -note: the unit struct `C` is defined here - --> $DIR/issue-13407.rs:2:5 - | -LL | struct C; - | ^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/issue-13407.rs:6:5 - | -LL | struct C; - | -------- unit struct defined here -... -LL | A::C = 1; - | ^^^^ - this expression has type `{integer}` - | | - | expected integer, found `C` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0308, E0603. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-13446.stderr b/tests/ui/issues/issue-13446.stderr deleted file mode 100644 index 28c459e6e62..00000000000 --- a/tests/ui/issues/issue-13446.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-13446.rs:3:26 - | -LL | static VEC: [u32; 256] = vec![]; - | ^^^^^^ expected `[u32; 256]`, found `Vec<_>` - | - = note: expected array `[u32; 256]` - found struct `Vec<_>` - = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-13466.stderr b/tests/ui/issues/issue-13466.stderr deleted file mode 100644 index 68a555a1626..00000000000 --- a/tests/ui/issues/issue-13466.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-13466.rs:10:9 - | -LL | let _x: usize = match Some(1) { - | ------- this expression has type `Option<{integer}>` -LL | Ok(u) => u, - | ^^^^^ expected `Option<{integer}>`, found `Result<_, _>` - | - = note: expected enum `Option<{integer}>` - found enum `Result<_, _>` - -error[E0308]: mismatched types - --> $DIR/issue-13466.rs:16:9 - | -LL | let _x: usize = match Some(1) { - | ------- this expression has type `Option<{integer}>` -... -LL | Err(e) => panic!(e) - | ^^^^^^ expected `Option<{integer}>`, found `Result<_, _>` - | - = note: expected enum `Option<{integer}>` - found enum `Result<_, _>` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/iterators/bytes-iterator-clone-12677.rs b/tests/ui/iterators/bytes-iterator-clone-12677.rs new file mode 100644 index 00000000000..cfbb85a3ecb --- /dev/null +++ b/tests/ui/iterators/bytes-iterator-clone-12677.rs @@ -0,0 +1,11 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12677 + +//@ run-pass + +fn main() { + let s = "Hello"; + let first = s.bytes(); + let second = first.clone(); + + assert_eq!(first.collect::>(), second.collect::>()) +} diff --git a/tests/ui/iterators/bytes-iterator-clone.rs b/tests/ui/iterators/bytes-iterator-clone.rs deleted file mode 100644 index dbc2dbc8527..00000000000 --- a/tests/ui/iterators/bytes-iterator-clone.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass - -fn main() { - let s = "Hello"; - let first = s.bytes(); - let second = first.clone(); - - assert_eq!(first.collect::>(), second.collect::>()) -} diff --git a/tests/ui/iterators/phf-map-entries-iterator.rs b/tests/ui/iterators/phf-map-entries-iterator.rs deleted file mode 100644 index 5f733e85948..00000000000 --- a/tests/ui/iterators/phf-map-entries-iterator.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ check-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver - -use std::slice; - -pub struct PhfMapEntries<'a, T: 'a> { - iter: slice::Iter<'a, (&'static str, T)>, -} - -impl<'a, T> Iterator for PhfMapEntries<'a, T> { - type Item = (&'static str, &'a T); - - fn next(&mut self) -> Option<(&'static str, &'a T)> { - self.iter.by_ref().map(|&(key, ref value)| (key, value)).next() - } - - fn size_hint(&self) -> (usize, Option) { - self.iter.size_hint() - } -} - -fn main() {} diff --git a/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.rs b/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.rs new file mode 100644 index 00000000000..6cfe440b43d --- /dev/null +++ b/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.rs @@ -0,0 +1,29 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13058 + +use std::ops::Range; + +trait Itble<'r, T, I: Iterator> { fn iter(&'r self) -> I; } + +impl<'r> Itble<'r, usize, Range> for (usize, usize) { + fn iter(&'r self) -> Range { + let &(min, max) = self; + min..max + } +} + +fn check<'r, I: Iterator, T: Itble<'r, usize, I>>(cont: &T) -> bool +{ + let cont_iter = cont.iter(); +//~^ ERROR explicit lifetime required in the type of `cont` [E0621] + let result = cont_iter.fold(Some(0), |state, val| { + state.map_or(None, |mask| { + let bit = 1 << val; + if mask & bit == 0 {Some(mask|bit)} else {None} + }) + }); + result.is_some() +} + +fn main() { + check(&(3, 5)); +} diff --git a/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.stderr b/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.stderr new file mode 100644 index 00000000000..e6564e36b21 --- /dev/null +++ b/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.stderr @@ -0,0 +1,14 @@ +error[E0621]: explicit lifetime required in the type of `cont` + --> $DIR/iterator-trait-lifetime-error-13058.rs:16:21 + | +LL | let cont_iter = cont.iter(); + | ^^^^^^^^^^^ lifetime `'r` required + | +help: add explicit lifetime `'r` to the type of `cont` + | +LL | fn check<'r, I: Iterator, T: Itble<'r, usize, I>>(cont: &'r T) -> bool + | ++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lifetimes/iterator-trait-lifetime-error.rs b/tests/ui/lifetimes/iterator-trait-lifetime-error.rs deleted file mode 100644 index a5806feb720..00000000000 --- a/tests/ui/lifetimes/iterator-trait-lifetime-error.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::ops::Range; - -trait Itble<'r, T, I: Iterator> { fn iter(&'r self) -> I; } - -impl<'r> Itble<'r, usize, Range> for (usize, usize) { - fn iter(&'r self) -> Range { - let &(min, max) = self; - min..max - } -} - -fn check<'r, I: Iterator, T: Itble<'r, usize, I>>(cont: &T) -> bool -{ - let cont_iter = cont.iter(); -//~^ ERROR explicit lifetime required in the type of `cont` [E0621] - let result = cont_iter.fold(Some(0), |state, val| { - state.map_or(None, |mask| { - let bit = 1 << val; - if mask & bit == 0 {Some(mask|bit)} else {None} - }) - }); - result.is_some() -} - -fn main() { - check(&(3, 5)); -} diff --git a/tests/ui/lifetimes/lifetime-inference-destructuring-arg.rs b/tests/ui/lifetimes/lifetime-inference-destructuring-arg.rs new file mode 100644 index 00000000000..7a019a71d75 --- /dev/null +++ b/tests/ui/lifetimes/lifetime-inference-destructuring-arg.rs @@ -0,0 +1,26 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13167 + +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +use std::slice; + +pub struct PhfMapEntries<'a, T: 'a> { + iter: slice::Iter<'a, (&'static str, T)>, +} + +impl<'a, T> Iterator for PhfMapEntries<'a, T> { + type Item = (&'static str, &'a T); + + fn next(&mut self) -> Option<(&'static str, &'a T)> { + self.iter.by_ref().map(|&(key, ref value)| (key, value)).next() + } + + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } +} + +fn main() {} diff --git a/tests/ui/lifetimes/matcher-trait-equality-13323.rs b/tests/ui/lifetimes/matcher-trait-equality-13323.rs new file mode 100644 index 00000000000..efd56294b39 --- /dev/null +++ b/tests/ui/lifetimes/matcher-trait-equality-13323.rs @@ -0,0 +1,60 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13323 + +//@ run-pass + +struct StrWrap { + s: String +} + +impl StrWrap { + fn new(s: &str) -> StrWrap { + StrWrap { s: s.to_string() } + } + + fn get_s<'a>(&'a self) -> &'a str { + &self.s + } +} + +struct MyStruct { + s: StrWrap +} + +impl MyStruct { + fn new(s: &str) -> MyStruct { + MyStruct { s: StrWrap::new(s) } + } + + fn get_str_wrap<'a>(&'a self) -> &'a StrWrap { + &self.s + } +} + +trait Matcher { + fn matches(&self, actual: T) -> bool; +} + +fn assert_that>(actual: T, matcher: &U) { + assert!(matcher.matches(actual)); +} + +struct EqualTo { + expected: T +} + +impl Matcher for EqualTo { + fn matches(&self, actual: T) -> bool { + self.expected.eq(&actual) + } +} + +fn equal_to(expected: T) -> Box> { + Box::new(EqualTo { expected: expected }) +} + +pub fn main() { + let my_struct = MyStruct::new("zomg"); + let s = my_struct.get_str_wrap(); + + assert_that(s.get_s(), &*equal_to("zomg")); +} diff --git a/tests/ui/lifetimes/struct-lifetime-field-assignment-13405.rs b/tests/ui/lifetimes/struct-lifetime-field-assignment-13405.rs new file mode 100644 index 00000000000..9482d89681b --- /dev/null +++ b/tests/ui/lifetimes/struct-lifetime-field-assignment-13405.rs @@ -0,0 +1,21 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13405 + +//@ check-pass +#![allow(dead_code)] +#![allow(unused_variables)] + +struct Foo<'a> { + i: &'a bool, + j: Option<&'a isize>, +} + +impl<'a> Foo<'a> { + fn bar(&mut self, j: &isize) { + let child = Foo { + i: self.i, + j: Some(j) + }; + } +} + +fn main() {} diff --git a/tests/ui/lifetimes/struct-lifetime-field-assignment.rs b/tests/ui/lifetimes/struct-lifetime-field-assignment.rs deleted file mode 100644 index 80b298d2f37..00000000000 --- a/tests/ui/lifetimes/struct-lifetime-field-assignment.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ check-pass -#![allow(dead_code)] -#![allow(unused_variables)] - -struct Foo<'a> { - i: &'a bool, - j: Option<&'a isize>, -} - -impl<'a> Foo<'a> { - fn bar(&mut self, j: &isize) { - let child = Foo { - i: self.i, - j: Some(j) - }; - } -} - -fn main() {} diff --git a/tests/ui/lifetimes/unsafe-transmute-in-find-11740.rs b/tests/ui/lifetimes/unsafe-transmute-in-find-11740.rs new file mode 100644 index 00000000000..eeecd2e9e40 --- /dev/null +++ b/tests/ui/lifetimes/unsafe-transmute-in-find-11740.rs @@ -0,0 +1,28 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11740 + +//@ check-pass + +struct Attr { + name: String, + value: String, +} + +struct Element { + attrs: Vec>, +} + +impl Element { + pub unsafe fn get_attr<'a>(&'a self, name: &str) { + self.attrs + .iter() + .find(|attr| { + let attr: &&Box = std::mem::transmute(attr); + true + }); + } +} + +fn main() { + let element = Element { attrs: Vec::new() }; + unsafe { let () = element.get_attr("foo"); }; +} diff --git a/tests/ui/match/function-in-pattern-error.rs b/tests/ui/match/function-in-pattern-error.rs deleted file mode 100644 index 1ac1c3d818e..00000000000 --- a/tests/ui/match/function-in-pattern-error.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod foo { pub fn bar() {} } - -fn main() { - match () { - foo::bar => {} - //~^ ERROR expected unit struct, unit variant or constant, found function `foo::bar` - } -} diff --git a/tests/ui/match/guard-literal-range-shadow.rs b/tests/ui/match/guard-literal-range-shadow.rs deleted file mode 100644 index fbd1d75067b..00000000000 --- a/tests/ui/match/guard-literal-range-shadow.rs +++ /dev/null @@ -1,178 +0,0 @@ -//@ run-pass - -// Tests that match expression handles overlapped literal and range -// properly in the presence of guard function. - -fn val() -> usize { 1 } - -static CONST: usize = 1; - -pub fn main() { - lit_shadow_range(); - range_shadow_lit(); - range_shadow_range(); - multi_pats_shadow_lit(); - multi_pats_shadow_range(); - lit_shadow_multi_pats(); - range_shadow_multi_pats(); - misc(); -} - -fn lit_shadow_range() { - assert_eq!(2, match 1 { - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); - - let x = 0; - assert_eq!(2, match x+1 { - 0 => 0, - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); - - assert_eq!(2, match val() { - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); - - assert_eq!(2, match CONST { - 0 => 0, - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); - - // value is out of the range of second arm, should match wildcard pattern - assert_eq!(3, match 3 { - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); -} - -fn range_shadow_lit() { - assert_eq!(2, match 1 { - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); - - let x = 0; - assert_eq!(2, match x+1 { - 0 => 0, - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); - - assert_eq!(2, match val() { - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); - - assert_eq!(2, match CONST { - 0 => 0, - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); - - // ditto - assert_eq!(3, match 3 { - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); -} - -fn range_shadow_range() { - assert_eq!(2, match 1 { - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); - - let x = 0; - assert_eq!(2, match x+1 { - 100 => 0, - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); - - assert_eq!(2, match val() { - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); - - assert_eq!(2, match CONST { - 100 => 0, - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); - - // ditto - assert_eq!(3, match 5 { - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); -} - -fn multi_pats_shadow_lit() { - assert_eq!(2, match 1 { - 100 => 0, - 0 | 1..=10 if false => 1, - 1 => 2, - _ => 3, - }); -} - -fn multi_pats_shadow_range() { - assert_eq!(2, match 1 { - 100 => 0, - 0 | 1..=10 if false => 1, - 1..=3 => 2, - _ => 3, - }); -} - -fn lit_shadow_multi_pats() { - assert_eq!(2, match 1 { - 100 => 0, - 1 if false => 1, - 0 | 1..=10 => 2, - _ => 3, - }); -} - -fn range_shadow_multi_pats() { - assert_eq!(2, match 1 { - 100 => 0, - 1..=3 if false => 1, - 0 | 1..=10 => 2, - _ => 3, - }); -} - -fn misc() { - enum Foo { - Bar(#[allow(dead_code)] usize, bool) - } - // This test basically mimics how trace_macros! macro is implemented, - // which is a rare combination of vector patterns, multiple wild-card - // patterns and guard functions. - let r = match [Foo::Bar(0, false)] { - [Foo::Bar(_, pred)] if pred => 1, - [Foo::Bar(_, pred)] if !pred => 2, - _ => 0, - }; - assert_eq!(2, r); -} diff --git a/tests/ui/match/option-result-mismatch-11844.rs b/tests/ui/match/option-result-mismatch-11844.rs new file mode 100644 index 00000000000..24a2004134d --- /dev/null +++ b/tests/ui/match/option-result-mismatch-11844.rs @@ -0,0 +1,10 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11844 + +fn main() { + let a = Some(Box::new(1)); + match a { + Ok(a) => //~ ERROR: mismatched types + println!("{}",a), + None => panic!() + } +} diff --git a/tests/ui/match/option-result-mismatch-11844.stderr b/tests/ui/match/option-result-mismatch-11844.stderr new file mode 100644 index 00000000000..8a84b7b8a48 --- /dev/null +++ b/tests/ui/match/option-result-mismatch-11844.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/option-result-mismatch-11844.rs:6:9 + | +LL | match a { + | - this expression has type `Option>` +LL | Ok(a) => + | ^^^^^ expected `Option>`, found `Result<_, _>` + | + = note: expected enum `Option>` + found enum `Result<_, _>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/match/option-result-mismatch.rs b/tests/ui/match/option-result-mismatch.rs deleted file mode 100644 index f974a470296..00000000000 --- a/tests/ui/match/option-result-mismatch.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - let a = Some(Box::new(1)); - match a { - Ok(a) => //~ ERROR: mismatched types - println!("{}",a), - None => panic!() - } -} diff --git a/tests/ui/match/option-result-type-param-mismatch-13466.rs b/tests/ui/match/option-result-type-param-mismatch-13466.rs new file mode 100644 index 00000000000..05dbdfdee0e --- /dev/null +++ b/tests/ui/match/option-result-type-param-mismatch-13466.rs @@ -0,0 +1,24 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13466 + +// Regression test for #13466 + +//@ dont-require-annotations: NOTE + +pub fn main() { + // The expected arm type `Option` has one type parameter, while + // the actual arm `Result` has two. typeck should not be + // tricked into looking up a non-existing second type parameter. + let _x: usize = match Some(1) { + Ok(u) => u, + //~^ ERROR mismatched types + //~| NOTE expected enum `Option<{integer}>` + //~| NOTE found enum `Result<_, _>` + //~| NOTE expected `Option<{integer}>`, found `Result<_, _>` + + Err(e) => panic!(e) + //~^ ERROR mismatched types + //~| NOTE expected enum `Option<{integer}>` + //~| NOTE found enum `Result<_, _>` + //~| NOTE expected `Option<{integer}>`, found `Result<_, _>` + }; +} diff --git a/tests/ui/match/option-result-type-param-mismatch-13466.stderr b/tests/ui/match/option-result-type-param-mismatch-13466.stderr new file mode 100644 index 00000000000..b0cf1591f5e --- /dev/null +++ b/tests/ui/match/option-result-type-param-mismatch-13466.stderr @@ -0,0 +1,26 @@ +error[E0308]: mismatched types + --> $DIR/option-result-type-param-mismatch-13466.rs:12:9 + | +LL | let _x: usize = match Some(1) { + | ------- this expression has type `Option<{integer}>` +LL | Ok(u) => u, + | ^^^^^ expected `Option<{integer}>`, found `Result<_, _>` + | + = note: expected enum `Option<{integer}>` + found enum `Result<_, _>` + +error[E0308]: mismatched types + --> $DIR/option-result-type-param-mismatch-13466.rs:18:9 + | +LL | let _x: usize = match Some(1) { + | ------- this expression has type `Option<{integer}>` +... +LL | Err(e) => panic!(e) + | ^^^^^^ expected `Option<{integer}>`, found `Result<_, _>` + | + = note: expected enum `Option<{integer}>` + found enum `Result<_, _>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/match/option-result-type-param-mismatch.rs b/tests/ui/match/option-result-type-param-mismatch.rs deleted file mode 100644 index 78ce4c1d2f6..00000000000 --- a/tests/ui/match/option-result-type-param-mismatch.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Regression test for #13466 - -//@ dont-require-annotations: NOTE - -pub fn main() { - // The expected arm type `Option` has one type parameter, while - // the actual arm `Result` has two. typeck should not be - // tricked into looking up a non-existing second type parameter. - let _x: usize = match Some(1) { - Ok(u) => u, - //~^ ERROR mismatched types - //~| NOTE expected enum `Option<{integer}>` - //~| NOTE found enum `Result<_, _>` - //~| NOTE expected `Option<{integer}>`, found `Result<_, _>` - - Err(e) => panic!(e) - //~^ ERROR mismatched types - //~| NOTE expected enum `Option<{integer}>` - //~| NOTE found enum `Result<_, _>` - //~| NOTE expected `Option<{integer}>`, found `Result<_, _>` - }; -} diff --git a/tests/ui/match/overeager-sub-match-pruning-13027.rs b/tests/ui/match/overeager-sub-match-pruning-13027.rs new file mode 100644 index 00000000000..c4feb697f7d --- /dev/null +++ b/tests/ui/match/overeager-sub-match-pruning-13027.rs @@ -0,0 +1,180 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13027 + +//@ run-pass + +// Tests that match expression handles overlapped literal and range +// properly in the presence of guard function. + +fn val() -> usize { 1 } + +static CONST: usize = 1; + +pub fn main() { + lit_shadow_range(); + range_shadow_lit(); + range_shadow_range(); + multi_pats_shadow_lit(); + multi_pats_shadow_range(); + lit_shadow_multi_pats(); + range_shadow_multi_pats(); + misc(); +} + +fn lit_shadow_range() { + assert_eq!(2, match 1 { + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); + + let x = 0; + assert_eq!(2, match x+1 { + 0 => 0, + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); + + assert_eq!(2, match val() { + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); + + assert_eq!(2, match CONST { + 0 => 0, + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); + + // value is out of the range of second arm, should match wildcard pattern + assert_eq!(3, match 3 { + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); +} + +fn range_shadow_lit() { + assert_eq!(2, match 1 { + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); + + let x = 0; + assert_eq!(2, match x+1 { + 0 => 0, + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); + + assert_eq!(2, match val() { + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); + + assert_eq!(2, match CONST { + 0 => 0, + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); + + // ditto + assert_eq!(3, match 3 { + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); +} + +fn range_shadow_range() { + assert_eq!(2, match 1 { + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); + + let x = 0; + assert_eq!(2, match x+1 { + 100 => 0, + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); + + assert_eq!(2, match val() { + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); + + assert_eq!(2, match CONST { + 100 => 0, + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); + + // ditto + assert_eq!(3, match 5 { + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); +} + +fn multi_pats_shadow_lit() { + assert_eq!(2, match 1 { + 100 => 0, + 0 | 1..=10 if false => 1, + 1 => 2, + _ => 3, + }); +} + +fn multi_pats_shadow_range() { + assert_eq!(2, match 1 { + 100 => 0, + 0 | 1..=10 if false => 1, + 1..=3 => 2, + _ => 3, + }); +} + +fn lit_shadow_multi_pats() { + assert_eq!(2, match 1 { + 100 => 0, + 1 if false => 1, + 0 | 1..=10 => 2, + _ => 3, + }); +} + +fn range_shadow_multi_pats() { + assert_eq!(2, match 1 { + 100 => 0, + 1..=3 if false => 1, + 0 | 1..=10 => 2, + _ => 3, + }); +} + +fn misc() { + enum Foo { + Bar(#[allow(dead_code)] usize, bool) + } + // This test basically mimics how trace_macros! macro is implemented, + // which is a rare combination of vector patterns, multiple wild-card + // patterns and guard functions. + let r = match [Foo::Bar(0, false)] { + [Foo::Bar(_, pred)] if pred => 1, + [Foo::Bar(_, pred)] if !pred => 2, + _ => 0, + }; + assert_eq!(2, r); +} diff --git a/tests/ui/match/slice-move-out-error-12567.rs b/tests/ui/match/slice-move-out-error-12567.rs new file mode 100644 index 00000000000..3f9bf9c76cf --- /dev/null +++ b/tests/ui/match/slice-move-out-error-12567.rs @@ -0,0 +1,15 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12567 + +fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) { + match (l1, l2) { + //~^ ERROR: cannot move out of type `[T]`, a non-copy slice + //~| ERROR: cannot move out of type `[T]`, a non-copy slice + (&[], &[]) => println!("both empty"), + (&[], &[hd, ..]) | (&[hd, ..], &[]) + => println!("one empty"), + (&[hd1, ..], &[hd2, ..]) + => println!("both nonempty"), + } +} + +fn main() {} diff --git a/tests/ui/match/slice-move-out-error-12567.stderr b/tests/ui/match/slice-move-out-error-12567.stderr new file mode 100644 index 00000000000..ab5377d4701 --- /dev/null +++ b/tests/ui/match/slice-move-out-error-12567.stderr @@ -0,0 +1,51 @@ +error[E0508]: cannot move out of type `[T]`, a non-copy slice + --> $DIR/slice-move-out-error-12567.rs:4:11 + | +LL | match (l1, l2) { + | ^^^^^^^^ cannot move out of here +... +LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) + | -- data moved here +LL | => println!("one empty"), +LL | (&[hd1, ..], &[hd2, ..]) + | --- ...and here + | + = note: move occurs because these variables have types that don't implement the `Copy` trait +help: consider removing the borrow + | +LL - (&[], &[hd, ..]) | (&[hd, ..], &[]) +LL + (&[], [hd, ..]) | (&[hd, ..], &[]) + | +help: consider removing the borrow + | +LL - (&[hd1, ..], &[hd2, ..]) +LL + (&[hd1, ..], [hd2, ..]) + | + +error[E0508]: cannot move out of type `[T]`, a non-copy slice + --> $DIR/slice-move-out-error-12567.rs:4:11 + | +LL | match (l1, l2) { + | ^^^^^^^^ cannot move out of here +... +LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) + | -- data moved here +LL | => println!("one empty"), +LL | (&[hd1, ..], &[hd2, ..]) + | --- ...and here + | + = note: move occurs because these variables have types that don't implement the `Copy` trait +help: consider removing the borrow + | +LL - (&[], &[hd, ..]) | (&[hd, ..], &[]) +LL + (&[], [hd, ..]) | (&[hd, ..], &[]) + | +help: consider removing the borrow + | +LL - (&[hd1, ..], &[hd2, ..]) +LL + ([hd1, ..], &[hd2, ..]) + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0508`. diff --git a/tests/ui/match/slice-move-out-error.rs b/tests/ui/match/slice-move-out-error.rs deleted file mode 100644 index 1b2a37de475..00000000000 --- a/tests/ui/match/slice-move-out-error.rs +++ /dev/null @@ -1,13 +0,0 @@ -fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) { - match (l1, l2) { - //~^ ERROR: cannot move out of type `[T]`, a non-copy slice - //~| ERROR: cannot move out of type `[T]`, a non-copy slice - (&[], &[]) => println!("both empty"), - (&[], &[hd, ..]) | (&[hd, ..], &[]) - => println!("one empty"), - (&[hd1, ..], &[hd2, ..]) - => println!("both nonempty"), - } -} - -fn main() {} diff --git a/tests/ui/match/string-literal-match-patterns.rs b/tests/ui/match/string-literal-match-patterns.rs deleted file mode 100644 index dd752227bbe..00000000000 --- a/tests/ui/match/string-literal-match-patterns.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ check-pass -#![allow(dead_code)] - -struct A { - a: String -} - -fn borrow<'a>(binding: &'a A) -> &'a str { - match &*binding.a { - "in" => "in_", - "ref" => "ref_", - ident => ident - } -} - -fn main() {} diff --git a/tests/ui/match/struct-reference-patterns-12285.rs b/tests/ui/match/struct-reference-patterns-12285.rs new file mode 100644 index 00000000000..246e230b0de --- /dev/null +++ b/tests/ui/match/struct-reference-patterns-12285.rs @@ -0,0 +1,16 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12285 + +//@ run-pass + +struct S; + +fn main() { + match Some(&S) { + Some(&S) => {}, + _x => unreachable!() + } + match Some(&S) { + Some(&S) => {}, + None => unreachable!() + } +} diff --git a/tests/ui/match/struct-reference-patterns.rs b/tests/ui/match/struct-reference-patterns.rs deleted file mode 100644 index fe199147128..00000000000 --- a/tests/ui/match/struct-reference-patterns.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass - -struct S; - -fn main() { - match Some(&S) { - Some(&S) => {}, - _x => unreachable!() - } - match Some(&S) { - Some(&S) => {}, - None => unreachable!() - } -} diff --git a/tests/ui/panics/explicit-panic-unreachable.rs b/tests/ui/panics/explicit-panic-unreachable.rs deleted file mode 100644 index f3b1b643c45..00000000000 --- a/tests/ui/panics/explicit-panic-unreachable.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-fail -//@ error-pattern:explicit panic -//@ needs-subprocess - -pub fn main() { - panic!(); - println!("{}", 1); -} diff --git a/tests/ui/panics/unwrap-or-panic-input.rs b/tests/ui/panics/unwrap-or-panic-input.rs deleted file mode 100644 index 99ffba3fba5..00000000000 --- a/tests/ui/panics/unwrap-or-panic-input.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-fail -//@ error-pattern:bad input -//@ needs-subprocess - -fn main() { - Some("foo").unwrap_or(panic!("bad input")).to_string(); -} diff --git a/tests/ui/parser/encode-symbol-ice-12920.rs b/tests/ui/parser/encode-symbol-ice-12920.rs new file mode 100644 index 00000000000..87389c0ffb4 --- /dev/null +++ b/tests/ui/parser/encode-symbol-ice-12920.rs @@ -0,0 +1,10 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12920 + +//@ run-fail +//@ error-pattern:explicit panic +//@ needs-subprocess + +pub fn main() { + panic!(); + println!("{}", 1); +} diff --git a/tests/ui/privacy/private-unit-struct-assignment.rs b/tests/ui/privacy/private-unit-struct-assignment.rs index 7794be37b85..b8e1c4ecb18 100644 --- a/tests/ui/privacy/private-unit-struct-assignment.rs +++ b/tests/ui/privacy/private-unit-struct-assignment.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13407 + mod A { struct C; } diff --git a/tests/ui/privacy/private-unit-struct-assignment.stderr b/tests/ui/privacy/private-unit-struct-assignment.stderr new file mode 100644 index 00000000000..8c36a08846d --- /dev/null +++ b/tests/ui/privacy/private-unit-struct-assignment.stderr @@ -0,0 +1,27 @@ +error[E0603]: unit struct `C` is private + --> $DIR/private-unit-struct-assignment.rs:8:8 + | +LL | A::C = 1; + | ^ private unit struct + | +note: the unit struct `C` is defined here + --> $DIR/private-unit-struct-assignment.rs:4:5 + | +LL | struct C; + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/private-unit-struct-assignment.rs:8:5 + | +LL | struct C; + | -------- unit struct defined here +... +LL | A::C = 1; + | ^^^^ - this expression has type `{integer}` + | | + | expected integer, found `C` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0603. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/privacy/use-in-impl-scope-12729.rs b/tests/ui/privacy/use-in-impl-scope-12729.rs new file mode 100644 index 00000000000..58fe042beec --- /dev/null +++ b/tests/ui/privacy/use-in-impl-scope-12729.rs @@ -0,0 +1,16 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12729 + +//@ edition: 2015 +//@ check-pass +#![allow(dead_code)] + +pub struct Foo; + +mod bar { + use Foo; + + impl Foo { + fn baz(&self) {} + } +} +fn main() {} diff --git a/tests/ui/resolve/reference-clone-nonclone-11820.rs b/tests/ui/resolve/reference-clone-nonclone-11820.rs new file mode 100644 index 00000000000..74dad96da94 --- /dev/null +++ b/tests/ui/resolve/reference-clone-nonclone-11820.rs @@ -0,0 +1,15 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11820 + +//@ run-pass + +#![allow(noop_method_call)] + +struct NoClone; + +fn main() { + let rnc = &NoClone; + let rsnc = &Some(NoClone); + + let _: &NoClone = rnc.clone(); + let _: &Option = rsnc.clone(); +} diff --git a/tests/ui/statics/enum-with-static-str-variant-13214.rs b/tests/ui/statics/enum-with-static-str-variant-13214.rs new file mode 100644 index 00000000000..1db37da632d --- /dev/null +++ b/tests/ui/statics/enum-with-static-str-variant-13214.rs @@ -0,0 +1,24 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13214 + +//@ build-pass +#![allow(dead_code)] +// defining static with struct that contains enum +// with &'static str variant used to cause ICE + + +pub enum Foo { + Bar, + Baz(&'static str), +} + +pub static TEST: Test = Test { + foo: Foo::Bar, + c: 'a' +}; + +pub struct Test { + foo: Foo, + c: char, +} + +fn main() {} diff --git a/tests/ui/statics/enum-with-static-str-variant.rs b/tests/ui/statics/enum-with-static-str-variant.rs deleted file mode 100644 index 8140ec943a0..00000000000 --- a/tests/ui/statics/enum-with-static-str-variant.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ build-pass -#![allow(dead_code)] -// defining static with struct that contains enum -// with &'static str variant used to cause ICE - - -pub enum Foo { - Bar, - Baz(&'static str), -} - -pub static TEST: Test = Test { - foo: Foo::Bar, - c: 'a' -}; - -pub struct Test { - foo: Foo, - c: char, -} - -fn main() {} diff --git a/tests/ui/threads/moved-value-in-thread-loop.rs b/tests/ui/threads/moved-value-in-thread-loop.rs deleted file mode 100644 index 091e8fe8b2a..00000000000 --- a/tests/ui/threads/moved-value-in-thread-loop.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::sync::mpsc::channel; -use std::thread; - -fn main() { - let (tx, rx) = channel(); - let _t = thread::spawn(move|| -> () { - loop { - let tx = tx; - //~^ ERROR: use of moved value: `tx` - tx.send(1); - } - }); -} diff --git a/tests/ui/traits/any-trait-object-debug.rs b/tests/ui/traits/any-trait-object-debug.rs deleted file mode 100644 index eaf92d413d5..00000000000 --- a/tests/ui/traits/any-trait-object-debug.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ run-pass -fn main() { - fn test() -> Box { Box::new(1) } - println!("{:?}", test()) -} diff --git a/tests/ui/traits/default-method-lifetime-params-13204.rs b/tests/ui/traits/default-method-lifetime-params-13204.rs new file mode 100644 index 00000000000..cdf34ab773c --- /dev/null +++ b/tests/ui/traits/default-method-lifetime-params-13204.rs @@ -0,0 +1,27 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13204 + +//@ run-pass +#![allow(unused_mut)] +// Test that when instantiating trait default methods, typeck handles +// lifetime parameters defined on the method bound correctly. + + +pub trait Foo { + fn bar<'a, I: Iterator>(&self, it: I) -> usize { + let mut xs = it.filter(|_| true); + xs.count() + } +} + +pub struct Baz; + +impl Foo for Baz { + // When instantiating `Foo::bar` for `Baz` here, typeck used to + // ICE due to the lifetime parameter of `bar`. +} + +fn main() { + let x = Baz; + let y = vec![(), (), ()]; + assert_eq!(x.bar(y.iter()), 3); +} diff --git a/tests/ui/traits/default-method-lifetime-params.rs b/tests/ui/traits/default-method-lifetime-params.rs deleted file mode 100644 index 01362f6fe61..00000000000 --- a/tests/ui/traits/default-method-lifetime-params.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ run-pass -#![allow(unused_mut)] -// Test that when instantiating trait default methods, typeck handles -// lifetime parameters defined on the method bound correctly. - - -pub trait Foo { - fn bar<'a, I: Iterator>(&self, it: I) -> usize { - let mut xs = it.filter(|_| true); - xs.count() - } -} - -pub struct Baz; - -impl Foo for Baz { - // When instantiating `Foo::bar` for `Baz` here, typeck used to - // ICE due to the lifetime parameter of `bar`. -} - -fn main() { - let x = Baz; - let y = vec![(), (), ()]; - assert_eq!(x.bar(y.iter()), 3); -} diff --git a/tests/ui/traits/deref-chain-method-calls.rs b/tests/ui/traits/deref-chain-method-calls.rs deleted file mode 100644 index bf4ec388c4f..00000000000 --- a/tests/ui/traits/deref-chain-method-calls.rs +++ /dev/null @@ -1,74 +0,0 @@ -//@ run-pass -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -use std::ops::Deref; - -struct Root { - jsref: JSRef -} - -impl Deref for Root { - type Target = JSRef; - - fn deref<'a>(&'a self) -> &'a JSRef { - &self.jsref - } -} - -#[derive(Copy, Clone)] -struct JSRef { - node: *const Node -} - -impl Deref for JSRef { - type Target = Node; - - fn deref<'a>(&'a self) -> &'a Node { - self.get() - } -} - -trait INode { - fn RemoveChild(&self); -} - -impl INode for JSRef { - fn RemoveChild(&self) { - self.get().RemoveChild(0) - } -} - -impl JSRef { - fn AddChild(&self) { - self.get().AddChild(0); - } - - fn get<'a>(&'a self) -> &'a Node { - unsafe { - &*self.node - } - } -} - -struct Node; - -impl Node { - fn RemoveChild(&self, _a: usize) { - } - - fn AddChild(&self, _a: usize) { - } -} - -fn main() { - let n = Node; - let jsref = JSRef { node: &n }; - let root = Root { jsref: jsref }; - - root.AddChild(); - jsref.AddChild(); - - root.RemoveChild(); - jsref.RemoveChild(); -} diff --git a/tests/ui/traits/fnonce-repro-trait-impl-13434.rs b/tests/ui/traits/fnonce-repro-trait-impl-13434.rs new file mode 100644 index 00000000000..61d5a1d74ae --- /dev/null +++ b/tests/ui/traits/fnonce-repro-trait-impl-13434.rs @@ -0,0 +1,23 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13434 + +//@ run-pass +#[derive(Debug)] +struct MyStruct; + +trait Repro { + fn repro(self, s: MyStruct) -> String; +} + +impl Repro for F where F: FnOnce(MyStruct) -> String { + fn repro(self, s: MyStruct) -> String { + self(s) + } +} + +fn do_stuff(r: R) -> String { + r.repro(MyStruct) +} + +pub fn main() { + assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s))); +} diff --git a/tests/ui/traits/fnonce-repro-trait-impl.rs b/tests/ui/traits/fnonce-repro-trait-impl.rs deleted file mode 100644 index caf7b632393..00000000000 --- a/tests/ui/traits/fnonce-repro-trait-impl.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass -#[derive(Debug)] -struct MyStruct; - -trait Repro { - fn repro(self, s: MyStruct) -> String; -} - -impl Repro for F where F: FnOnce(MyStruct) -> String { - fn repro(self, s: MyStruct) -> String { - self(s) - } -} - -fn do_stuff(r: R) -> String { - r.repro(MyStruct) -} - -pub fn main() { - assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s))); -} diff --git a/tests/ui/traits/matcher-trait-equality.rs b/tests/ui/traits/matcher-trait-equality.rs deleted file mode 100644 index 8f334404f9a..00000000000 --- a/tests/ui/traits/matcher-trait-equality.rs +++ /dev/null @@ -1,58 +0,0 @@ -//@ run-pass - -struct StrWrap { - s: String -} - -impl StrWrap { - fn new(s: &str) -> StrWrap { - StrWrap { s: s.to_string() } - } - - fn get_s<'a>(&'a self) -> &'a str { - &self.s - } -} - -struct MyStruct { - s: StrWrap -} - -impl MyStruct { - fn new(s: &str) -> MyStruct { - MyStruct { s: StrWrap::new(s) } - } - - fn get_str_wrap<'a>(&'a self) -> &'a StrWrap { - &self.s - } -} - -trait Matcher { - fn matches(&self, actual: T) -> bool; -} - -fn assert_that>(actual: T, matcher: &U) { - assert!(matcher.matches(actual)); -} - -struct EqualTo { - expected: T -} - -impl Matcher for EqualTo { - fn matches(&self, actual: T) -> bool { - self.expected.eq(&actual) - } -} - -fn equal_to(expected: T) -> Box> { - Box::new(EqualTo { expected: expected }) -} - -pub fn main() { - let my_struct = MyStruct::new("zomg"); - let s = my_struct.get_str_wrap(); - - assert_that(s.get_s(), &*equal_to("zomg")); -} diff --git a/tests/ui/traits/reference-clone-noclone.rs b/tests/ui/traits/reference-clone-noclone.rs deleted file mode 100644 index ada844f8ee1..00000000000 --- a/tests/ui/traits/reference-clone-noclone.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -#![allow(noop_method_call)] - -struct NoClone; - -fn main() { - let rnc = &NoClone; - let rsnc = &Some(NoClone); - - let _: &NoClone = rnc.clone(); - let _: &Option = rsnc.clone(); -} diff --git a/tests/ui/type-inference/isize-usize-mismatch-error.rs b/tests/ui/type-inference/isize-usize-mismatch-error.rs deleted file mode 100644 index 5d31d7f861c..00000000000 --- a/tests/ui/type-inference/isize-usize-mismatch-error.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ dont-require-annotations: NOTE - -fn foo(_s: i16) { } - -fn bar(_s: u32) { } - -fn main() { - foo(1*(1 as isize)); - //~^ ERROR mismatched types - //~| NOTE expected `i16`, found `isize` - - bar(1*(1 as usize)); - //~^ ERROR mismatched types - //~| NOTE expected `u32`, found `usize` -} diff --git a/tests/ui/type-inference/partial-type-hint-12909.rs b/tests/ui/type-inference/partial-type-hint-12909.rs new file mode 100644 index 00000000000..d7017f451e3 --- /dev/null +++ b/tests/ui/type-inference/partial-type-hint-12909.rs @@ -0,0 +1,21 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12909 + +//@ run-pass +#![allow(unused_variables)] + +use std::collections::HashMap; + +fn copy(&x: &T) -> T { + x +} + +fn main() { + let arr = [(1, 1), (2, 2), (3, 3)]; + + let v1: Vec<&_> = arr.iter().collect(); + let v2: Vec<_> = arr.iter().map(copy).collect(); + + let m1: HashMap<_, _> = arr.iter().map(copy).collect(); + let m2: HashMap = arr.iter().map(copy).collect(); + let m3: HashMap<_, usize> = arr.iter().map(copy).collect(); +} diff --git a/tests/ui/type-inference/type-collect-inference.rs b/tests/ui/type-inference/type-collect-inference.rs deleted file mode 100644 index f2c33806aae..00000000000 --- a/tests/ui/type-inference/type-collect-inference.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] - -use std::collections::HashMap; - -fn copy(&x: &T) -> T { - x -} - -fn main() { - let arr = [(1, 1), (2, 2), (3, 3)]; - - let v1: Vec<&_> = arr.iter().collect(); - let v2: Vec<_> = arr.iter().map(copy).collect(); - - let m1: HashMap<_, _> = arr.iter().map(copy).collect(); - let m2: HashMap = arr.iter().map(copy).collect(); - let m3: HashMap<_, usize> = arr.iter().map(copy).collect(); -} diff --git a/tests/ui/type-inference/unit-type-add-error.rs b/tests/ui/type-inference/unit-type-add-error.rs deleted file mode 100644 index c69cd1e79e3..00000000000 --- a/tests/ui/type-inference/unit-type-add-error.rs +++ /dev/null @@ -1,11 +0,0 @@ -fn main() { - let x = (); - 1 + - x //~^ ERROR E0277 - ; - - let x: () = (); - 1 + - x //~^ ERROR E0277 - ; -} diff --git a/tests/ui/typeck/function-in-pattern-error-12863.rs b/tests/ui/typeck/function-in-pattern-error-12863.rs new file mode 100644 index 00000000000..d2fa2555658 --- /dev/null +++ b/tests/ui/typeck/function-in-pattern-error-12863.rs @@ -0,0 +1,10 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12863 + +mod foo { pub fn bar() {} } + +fn main() { + match () { + foo::bar => {} + //~^ ERROR expected unit struct, unit variant or constant, found function `foo::bar` + } +} diff --git a/tests/ui/typeck/function-in-pattern-error-12863.stderr b/tests/ui/typeck/function-in-pattern-error-12863.stderr new file mode 100644 index 00000000000..f28874b5d48 --- /dev/null +++ b/tests/ui/typeck/function-in-pattern-error-12863.stderr @@ -0,0 +1,9 @@ +error[E0532]: expected unit struct, unit variant or constant, found function `foo::bar` + --> $DIR/function-in-pattern-error-12863.rs:7:9 + | +LL | foo::bar => {} + | ^^^^^^^^ not a unit struct, unit variant or constant + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0532`. diff --git a/tests/ui/typeck/isize-usize-mismatch-error.rs b/tests/ui/typeck/isize-usize-mismatch-error.rs new file mode 100644 index 00000000000..2fb5cf489c0 --- /dev/null +++ b/tests/ui/typeck/isize-usize-mismatch-error.rs @@ -0,0 +1,17 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13359 + +//@ dont-require-annotations: NOTE + +fn foo(_s: i16) { } + +fn bar(_s: u32) { } + +fn main() { + foo(1*(1 as isize)); + //~^ ERROR mismatched types + //~| NOTE expected `i16`, found `isize` + + bar(1*(1 as usize)); + //~^ ERROR mismatched types + //~| NOTE expected `u32`, found `usize` +} diff --git a/tests/ui/typeck/isize-usize-mismatch-error.stderr b/tests/ui/typeck/isize-usize-mismatch-error.stderr new file mode 100644 index 00000000000..d5724665a03 --- /dev/null +++ b/tests/ui/typeck/isize-usize-mismatch-error.stderr @@ -0,0 +1,39 @@ +error[E0308]: mismatched types + --> $DIR/isize-usize-mismatch-error.rs:10:9 + | +LL | foo(1*(1 as isize)); + | --- ^^^^^^^^^^^^^^ expected `i16`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/isize-usize-mismatch-error.rs:5:4 + | +LL | fn foo(_s: i16) { } + | ^^^ ------- +help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit + | +LL | foo((1*(1 as isize)).try_into().unwrap()); + | + +++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/isize-usize-mismatch-error.rs:14:9 + | +LL | bar(1*(1 as usize)); + | --- ^^^^^^^^^^^^^^ expected `u32`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/isize-usize-mismatch-error.rs:7:4 + | +LL | fn bar(_s: u32) { } + | ^^^ ------- +help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit + | +LL | bar((1*(1 as usize)).try_into().unwrap()); + | + +++++++++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/unit-type-add-error-11771.rs b/tests/ui/typeck/unit-type-add-error-11771.rs new file mode 100644 index 00000000000..d009f50f4b9 --- /dev/null +++ b/tests/ui/typeck/unit-type-add-error-11771.rs @@ -0,0 +1,13 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11771 + +fn main() { + let x = (); + 1 + + x //~^ ERROR E0277 + ; + + let x: () = (); + 1 + + x //~^ ERROR E0277 + ; +} diff --git a/tests/ui/typeck/unit-type-add-error-11771.stderr b/tests/ui/typeck/unit-type-add-error-11771.stderr new file mode 100644 index 00000000000..155cc093524 --- /dev/null +++ b/tests/ui/typeck/unit-type-add-error-11771.stderr @@ -0,0 +1,39 @@ +error[E0277]: cannot add `()` to `{integer}` + --> $DIR/unit-type-add-error-11771.rs:5:7 + | +LL | 1 + + | ^ no implementation for `{integer} + ()` + | + = help: the trait `Add<()>` is not implemented for `{integer}` + = help: the following other types implement trait `Add`: + `&f128` implements `Add` + `&f128` implements `Add` + `&f16` implements `Add` + `&f16` implements `Add` + `&f32` implements `Add` + `&f32` implements `Add` + `&f64` implements `Add` + `&f64` implements `Add` + and 56 others + +error[E0277]: cannot add `()` to `{integer}` + --> $DIR/unit-type-add-error-11771.rs:10:7 + | +LL | 1 + + | ^ no implementation for `{integer} + ()` + | + = help: the trait `Add<()>` is not implemented for `{integer}` + = help: the following other types implement trait `Add`: + `&f128` implements `Add` + `&f128` implements `Add` + `&f16` implements `Add` + `&f16` implements `Add` + `&f32` implements `Add` + `&f32` implements `Add` + `&f64` implements `Add` + `&f64` implements `Add` + and 56 others + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/unwrap-or-panic-input-13202.rs b/tests/ui/typeck/unwrap-or-panic-input-13202.rs new file mode 100644 index 00000000000..29833a727c5 --- /dev/null +++ b/tests/ui/typeck/unwrap-or-panic-input-13202.rs @@ -0,0 +1,9 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13202 + +//@ run-fail +//@ error-pattern:bad input +//@ needs-subprocess + +fn main() { + Some("foo").unwrap_or(panic!("bad input")).to_string(); +} diff --git a/tests/ui/unsafe/unsafe-transmute-in-find.rs b/tests/ui/unsafe/unsafe-transmute-in-find.rs deleted file mode 100644 index c6099c2a0c0..00000000000 --- a/tests/ui/unsafe/unsafe-transmute-in-find.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ check-pass - -struct Attr { - name: String, - value: String, -} - -struct Element { - attrs: Vec>, -} - -impl Element { - pub unsafe fn get_attr<'a>(&'a self, name: &str) { - self.attrs - .iter() - .find(|attr| { - let attr: &&Box = std::mem::transmute(attr); - true - }); - } -} - -fn main() { - let element = Element { attrs: Vec::new() }; - unsafe { let () = element.get_attr("foo"); }; -} -- cgit 1.4.1-3-g733a5