From 16765639b30741dde85da0dbcb44c343eb82b1a2 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Thu, 24 Jul 2025 19:07:20 +0500 Subject: comments --- .../array-slice-coercion-mismatch-15783.rs | 18 +++++ .../array-slice-coercion-mismatch-15783.stderr | 19 +++++ tests/ui/closures/unused-closure-ice-16256.rs | 8 ++ tests/ui/closures/unused-closure-ice-16256.stderr | 11 +++ tests/ui/closures/unused-closure-warning-16256.rs | 6 -- .../nested-enum-match-optimization-15793.rs | 29 +++++++ .../array-slice-coercion-mismatch-15783.rs | 16 ---- .../derive-partial-ord-discriminant-64bit.rs | 3 +- .../ui/derives/derive-partial-ord-discriminant.rs | 2 + tests/ui/drop/early-return-drop-order.rs | 88 --------------------- tests/ui/drop/enum-drop-impl-15063.rs | 2 + tests/ui/drop/generic-drop-trait-bound-15858.rs | 2 + .../ui/drop/generic-drop-trait-bound-15858.stderr | 12 +++ tests/ui/drop/nested-return-drop-order.rs | 90 ++++++++++++++++++++++ .../same-alloca-reassigned-match-binding-16151.rs | 34 ++++++++ tests/ui/drop/struct-field-drop-order.rs | 2 + tests/ui/drop/vec-replace-skip-while-drop.rs | 32 -------- tests/ui/extern/empty-struct-extern-fn-16441.rs | 2 + tests/ui/fn/fn-traits-call-once-signature-15094.rs | 29 +++++++ .../fn/fn-traits-call-once-signature-15094.stderr | 12 +++ tests/ui/fn/fn-traits-call-once-signature.rs | 27 ------- tests/ui/imports/enum-variant-import-path-15774.rs | 2 + tests/ui/inference/iterator-sum-array-15673.rs | 11 +++ .../inference/return-block-type-inference-15965.rs | 2 + .../return-block-type-inference-15965.stderr | 11 +++ tests/ui/issues/issue-15034.stderr | 14 ---- tests/ui/issues/issue-15094.stderr | 12 --- tests/ui/issues/issue-15167.stderr | 47 ----------- tests/ui/issues/issue-15207.stderr | 9 --- tests/ui/issues/issue-15260.stderr | 36 --------- tests/ui/issues/issue-15381.stderr | 11 --- tests/ui/issues/issue-15756.stderr | 12 --- tests/ui/issues/issue-15783.stderr | 19 ----- tests/ui/issues/issue-15858.stderr | 12 --- tests/ui/issues/issue-15896.stderr | 12 --- tests/ui/issues/issue-15965.stderr | 11 --- tests/ui/issues/issue-16048.stderr | 25 ------ tests/ui/issues/issue-16149.stderr | 12 --- tests/ui/issues/issue-16256.stderr | 11 --- tests/ui/issues/issue-16401.stderr | 14 ---- tests/ui/iterators/chunk-iterator-mut-pattern.rs | 14 ---- .../explicit-deref-non-deref-type-15756.rs | 16 ++++ .../explicit-deref-non-deref-type-15756.stderr | 12 +++ tests/ui/iterators/iterator-sum-array-15673.rs | 9 --- .../lifetimes/explicit-lifetime-required-15034.rs | 22 ------ .../nondeterministic-lifetime-errors-15034.rs | 24 ++++++ .../nondeterministic-lifetime-errors-15034.stderr | 14 ++++ .../lifetimes/struct-lifetime-inference-15735.rs | 2 + tests/ui/macros/for-loop-macro-rules-hygiene.rs | 12 +++ tests/ui/macros/macro-hygiene-scope-15167.rs | 2 + tests/ui/macros/macro-hygiene-scope-15167.stderr | 47 +++++++++++ tests/ui/macros/macro-variable-capture-15189.rs | 10 --- tests/ui/match/nested-enum-match-optimization.rs | 27 ------- tests/ui/moves/match-move-same-binding-15571.rs | 2 + tests/ui/never/never-type-method-call-15207.rs | 2 + tests/ui/never/never-type-method-call-15207.stderr | 9 +++ tests/ui/parser/generics-rangle-eq-15043.rs | 15 ++++ .../pattern/enum-struct-pattern-mismatch-15896.rs | 17 ++++ .../enum-struct-pattern-mismatch-15896.stderr | 12 +++ tests/ui/pattern/enum-struct-pattern-mismatch.rs | 15 ---- .../ui/pattern/refutable-pattern-for-loop-15381.rs | 2 + .../refutable-pattern-for-loop-15381.stderr | 11 +++ tests/ui/pattern/slice-pattern-recursion-15104.rs | 2 + tests/ui/pattern/static-binding-shadow-16149.rs | 2 + .../ui/pattern/static-binding-shadow-16149.stderr | 12 +++ .../struct-field-duplicate-binding-15260.rs | 27 +++++++ .../struct-field-duplicate-binding-15260.stderr | 36 +++++++++ tests/ui/pattern/struct-field-duplicate-binding.rs | 25 ------ tests/ui/pattern/tuple-enum-match-15129.rs | 13 ++-- .../unit-type-struct-pattern-mismatch-16401.rs | 17 ++++ .../unit-type-struct-pattern-mismatch-16401.stderr | 14 ++++ .../pattern/unit-type-struct-pattern-mismatch.rs | 15 ---- .../conditional-static-declaration-16010.rs | 11 +++ tests/ui/statics/conditional-static-declaration.rs | 9 --- tests/ui/structs/static-struct-init-15043.rs | 13 ---- tests/ui/traits/fn-type-trait-impl-15444.rs | 2 + .../ui/traits/index-trait-multiple-impls-15734.rs | 61 +++++++++++++++ tests/ui/traits/index-trait-multiple-impls.rs | 59 -------------- .../traits/lifetime-mismatch-trait-impl-16048.rs | 32 ++++++++ .../lifetime-mismatch-trait-impl-16048.stderr | 25 ++++++ tests/ui/traits/lifetime-mismatch-trait-impl.rs | 30 -------- 81 files changed, 747 insertions(+), 681 deletions(-) create mode 100644 tests/ui/borrowck/array-slice-coercion-mismatch-15783.rs create mode 100644 tests/ui/borrowck/array-slice-coercion-mismatch-15783.stderr create mode 100644 tests/ui/closures/unused-closure-ice-16256.rs create mode 100644 tests/ui/closures/unused-closure-ice-16256.stderr delete mode 100644 tests/ui/closures/unused-closure-warning-16256.rs create mode 100644 tests/ui/codegen/nested-enum-match-optimization-15793.rs delete mode 100644 tests/ui/coercion/array-slice-coercion-mismatch-15783.rs delete mode 100644 tests/ui/drop/early-return-drop-order.rs create mode 100644 tests/ui/drop/generic-drop-trait-bound-15858.stderr create mode 100644 tests/ui/drop/nested-return-drop-order.rs create mode 100644 tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs delete mode 100644 tests/ui/drop/vec-replace-skip-while-drop.rs create mode 100644 tests/ui/fn/fn-traits-call-once-signature-15094.rs create mode 100644 tests/ui/fn/fn-traits-call-once-signature-15094.stderr delete mode 100644 tests/ui/fn/fn-traits-call-once-signature.rs create mode 100644 tests/ui/inference/iterator-sum-array-15673.rs create mode 100644 tests/ui/inference/return-block-type-inference-15965.stderr delete mode 100644 tests/ui/issues/issue-15034.stderr delete mode 100644 tests/ui/issues/issue-15094.stderr delete mode 100644 tests/ui/issues/issue-15167.stderr delete mode 100644 tests/ui/issues/issue-15207.stderr delete mode 100644 tests/ui/issues/issue-15260.stderr delete mode 100644 tests/ui/issues/issue-15381.stderr delete mode 100644 tests/ui/issues/issue-15756.stderr delete mode 100644 tests/ui/issues/issue-15783.stderr delete mode 100644 tests/ui/issues/issue-15858.stderr delete mode 100644 tests/ui/issues/issue-15896.stderr delete mode 100644 tests/ui/issues/issue-15965.stderr delete mode 100644 tests/ui/issues/issue-16048.stderr delete mode 100644 tests/ui/issues/issue-16149.stderr delete mode 100644 tests/ui/issues/issue-16256.stderr delete mode 100644 tests/ui/issues/issue-16401.stderr delete mode 100644 tests/ui/iterators/chunk-iterator-mut-pattern.rs create mode 100644 tests/ui/iterators/explicit-deref-non-deref-type-15756.rs create mode 100644 tests/ui/iterators/explicit-deref-non-deref-type-15756.stderr delete mode 100644 tests/ui/iterators/iterator-sum-array-15673.rs delete mode 100644 tests/ui/lifetimes/explicit-lifetime-required-15034.rs create mode 100644 tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.rs create mode 100644 tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.stderr create mode 100644 tests/ui/macros/for-loop-macro-rules-hygiene.rs create mode 100644 tests/ui/macros/macro-hygiene-scope-15167.stderr delete mode 100644 tests/ui/macros/macro-variable-capture-15189.rs delete mode 100644 tests/ui/match/nested-enum-match-optimization.rs create mode 100644 tests/ui/never/never-type-method-call-15207.stderr create mode 100644 tests/ui/parser/generics-rangle-eq-15043.rs create mode 100644 tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs create mode 100644 tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr delete mode 100644 tests/ui/pattern/enum-struct-pattern-mismatch.rs create mode 100644 tests/ui/pattern/refutable-pattern-for-loop-15381.stderr create mode 100644 tests/ui/pattern/static-binding-shadow-16149.stderr create mode 100644 tests/ui/pattern/struct-field-duplicate-binding-15260.rs create mode 100644 tests/ui/pattern/struct-field-duplicate-binding-15260.stderr delete mode 100644 tests/ui/pattern/struct-field-duplicate-binding.rs create mode 100644 tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs create mode 100644 tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr delete mode 100644 tests/ui/pattern/unit-type-struct-pattern-mismatch.rs create mode 100644 tests/ui/statics/conditional-static-declaration-16010.rs delete mode 100644 tests/ui/statics/conditional-static-declaration.rs delete mode 100644 tests/ui/structs/static-struct-init-15043.rs create mode 100644 tests/ui/traits/index-trait-multiple-impls-15734.rs delete mode 100644 tests/ui/traits/index-trait-multiple-impls.rs create mode 100644 tests/ui/traits/lifetime-mismatch-trait-impl-16048.rs create mode 100644 tests/ui/traits/lifetime-mismatch-trait-impl-16048.stderr delete mode 100644 tests/ui/traits/lifetime-mismatch-trait-impl.rs diff --git a/tests/ui/borrowck/array-slice-coercion-mismatch-15783.rs b/tests/ui/borrowck/array-slice-coercion-mismatch-15783.rs new file mode 100644 index 00000000000..3322ed71c60 --- /dev/null +++ b/tests/ui/borrowck/array-slice-coercion-mismatch-15783.rs @@ -0,0 +1,18 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15783 + +//@ dont-require-annotations: NOTE + +pub fn foo(params: Option<&[&str]>) -> usize { + params.unwrap().first().unwrap().len() +} + +fn main() { + let name = "Foo"; + let x = Some(&[name]); + let msg = foo(x); + //~^ ERROR mismatched types + //~| NOTE expected enum `Option<&[&str]>` + //~| NOTE found enum `Option<&[&str; 1]>` + //~| NOTE expected `Option<&[&str]>`, found `Option<&[&str; 1]>` + assert_eq!(msg, 3); +} diff --git a/tests/ui/borrowck/array-slice-coercion-mismatch-15783.stderr b/tests/ui/borrowck/array-slice-coercion-mismatch-15783.stderr new file mode 100644 index 00000000000..050eb4baa41 --- /dev/null +++ b/tests/ui/borrowck/array-slice-coercion-mismatch-15783.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/array-slice-coercion-mismatch-15783.rs:12:19 + | +LL | let msg = foo(x); + | --- ^ expected `Option<&[&str]>`, found `Option<&[&str; 1]>` + | | + | arguments to this function are incorrect + | + = note: expected enum `Option<&[&str]>` + found enum `Option<&[&str; 1]>` +note: function defined here + --> $DIR/array-slice-coercion-mismatch-15783.rs:5:8 + | +LL | pub fn foo(params: Option<&[&str]>) -> usize { + | ^^^ ----------------------- + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/closures/unused-closure-ice-16256.rs b/tests/ui/closures/unused-closure-ice-16256.rs new file mode 100644 index 00000000000..fd569dd8a0a --- /dev/null +++ b/tests/ui/closures/unused-closure-ice-16256.rs @@ -0,0 +1,8 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16256 + +//@ run-pass + +fn main() { + let mut buf = Vec::new(); + |c: u8| buf.push(c); //~ WARN unused closure that must be used +} diff --git a/tests/ui/closures/unused-closure-ice-16256.stderr b/tests/ui/closures/unused-closure-ice-16256.stderr new file mode 100644 index 00000000000..9df433add5d --- /dev/null +++ b/tests/ui/closures/unused-closure-ice-16256.stderr @@ -0,0 +1,11 @@ +warning: unused closure that must be used + --> $DIR/unused-closure-ice-16256.rs:7:5 + | +LL | |c: u8| buf.push(c); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: closures are lazy and do nothing unless called + = note: `#[warn(unused_must_use)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/closures/unused-closure-warning-16256.rs b/tests/ui/closures/unused-closure-warning-16256.rs deleted file mode 100644 index 1024e4511d6..00000000000 --- a/tests/ui/closures/unused-closure-warning-16256.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - -fn main() { - let mut buf = Vec::new(); - |c: u8| buf.push(c); //~ WARN unused closure that must be used -} diff --git a/tests/ui/codegen/nested-enum-match-optimization-15793.rs b/tests/ui/codegen/nested-enum-match-optimization-15793.rs new file mode 100644 index 00000000000..420e3ad82b2 --- /dev/null +++ b/tests/ui/codegen/nested-enum-match-optimization-15793.rs @@ -0,0 +1,29 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15793 + +//@ run-pass +#![allow(dead_code)] + +enum NestedEnum { + First, + Second, + Third +} +enum Enum { + Variant1(bool), + Variant2(NestedEnum) +} + +#[inline(never)] +fn foo(x: Enum) -> isize { + match x { + Enum::Variant1(true) => 1, + Enum::Variant1(false) => 2, + Enum::Variant2(NestedEnum::Second) => 3, + Enum::Variant2(NestedEnum::Third) => 4, + Enum::Variant2(NestedEnum::First) => 5 + } +} + +fn main() { + assert_eq!(foo(Enum::Variant2(NestedEnum::Third)), 4); +} diff --git a/tests/ui/coercion/array-slice-coercion-mismatch-15783.rs b/tests/ui/coercion/array-slice-coercion-mismatch-15783.rs deleted file mode 100644 index ef948a1a88c..00000000000 --- a/tests/ui/coercion/array-slice-coercion-mismatch-15783.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ dont-require-annotations: NOTE - -pub fn foo(params: Option<&[&str]>) -> usize { - params.unwrap().first().unwrap().len() -} - -fn main() { - let name = "Foo"; - let x = Some(&[name]); - let msg = foo(x); - //~^ ERROR mismatched types - //~| NOTE expected enum `Option<&[&str]>` - //~| NOTE found enum `Option<&[&str; 1]>` - //~| NOTE expected `Option<&[&str]>`, found `Option<&[&str; 1]>` - assert_eq!(msg, 3); -} diff --git a/tests/ui/derives/derive-partial-ord-discriminant-64bit.rs b/tests/ui/derives/derive-partial-ord-discriminant-64bit.rs index 7214a4fb1d5..5b6bf6fbf1f 100644 --- a/tests/ui/derives/derive-partial-ord-discriminant-64bit.rs +++ b/tests/ui/derives/derive-partial-ord-discriminant-64bit.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15523 + //@ run-pass // Issue 15523: derive(PartialOrd) should use the provided // discriminant values for the derived ordering. @@ -28,7 +30,6 @@ fn main() { assert!(Eu64::Pos2 < Eu64::PosMax); assert!(Eu64::Pos1 < Eu64::PosMax); - assert!(Ei64::Pos2 > Ei64::Pos1); assert!(Ei64::Pos2 > Ei64::Neg1); assert!(Ei64::Pos1 > Ei64::Neg1); diff --git a/tests/ui/derives/derive-partial-ord-discriminant.rs b/tests/ui/derives/derive-partial-ord-discriminant.rs index 9fc2e51c6ab..28f325ec966 100644 --- a/tests/ui/derives/derive-partial-ord-discriminant.rs +++ b/tests/ui/derives/derive-partial-ord-discriminant.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15523 + //@ run-pass // Issue 15523: derive(PartialOrd) should use the provided // discriminant values for the derived ordering. diff --git a/tests/ui/drop/early-return-drop-order.rs b/tests/ui/drop/early-return-drop-order.rs deleted file mode 100644 index 0ebadd80541..00000000000 --- a/tests/ui/drop/early-return-drop-order.rs +++ /dev/null @@ -1,88 +0,0 @@ -//@ run-pass -#![allow(unreachable_code)] - -#[derive(PartialEq, Debug)] -struct Bar { - x: isize -} -impl Drop for Bar { - fn drop(&mut self) { - assert_eq!(self.x, 22); - } -} - -#[derive(PartialEq, Debug)] -struct Foo { - x: Bar, - a: isize -} - -fn foo() -> Result { - return Ok(Foo { - x: Bar { x: 22 }, - a: return Err(32) - }); -} - -fn baz() -> Result { - Ok(Foo { - x: Bar { x: 22 }, - a: return Err(32) - }) -} - -// explicit immediate return -fn aa() -> isize { - return 3; -} - -// implicit immediate return -fn bb() -> isize { - 3 -} - -// implicit outptr return -fn cc() -> Result { - Ok(3) -} - -// explicit outptr return -fn dd() -> Result { - return Ok(3); -} - -trait A { - fn aaa(&self) -> isize { - 3 - } - fn bbb(&self) -> isize { - return 3; - } - fn ccc(&self) -> Result { - Ok(3) - } - fn ddd(&self) -> Result { - return Ok(3); - } -} - -impl A for isize {} - -fn main() { - assert_eq!(foo(), Err(32)); - assert_eq!(baz(), Err(32)); - - assert_eq!(aa(), 3); - assert_eq!(bb(), 3); - assert_eq!(cc().unwrap(), 3); - assert_eq!(dd().unwrap(), 3); - - let i = Box::new(32isize) as Box; - assert_eq!(i.aaa(), 3); - let i = Box::new(32isize) as Box; - assert_eq!(i.bbb(), 3); - let i = Box::new(32isize) as Box; - assert_eq!(i.ccc().unwrap(), 3); - let i = Box::new(32isize) as Box; - assert_eq!(i.ddd().unwrap(), 3); -} diff --git a/tests/ui/drop/enum-drop-impl-15063.rs b/tests/ui/drop/enum-drop-impl-15063.rs index 969dbe5fad2..a8198abafa0 100644 --- a/tests/ui/drop/enum-drop-impl-15063.rs +++ b/tests/ui/drop/enum-drop-impl-15063.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15063 + //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/drop/generic-drop-trait-bound-15858.rs b/tests/ui/drop/generic-drop-trait-bound-15858.rs index 27887d49e3e..682604d17d8 100644 --- a/tests/ui/drop/generic-drop-trait-bound-15858.rs +++ b/tests/ui/drop/generic-drop-trait-bound-15858.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15858 + //@ run-pass // FIXME(static_mut_refs): this could use an atomic #![allow(static_mut_refs)] diff --git a/tests/ui/drop/generic-drop-trait-bound-15858.stderr b/tests/ui/drop/generic-drop-trait-bound-15858.stderr new file mode 100644 index 00000000000..86cd6cb6026 --- /dev/null +++ b/tests/ui/drop/generic-drop-trait-bound-15858.stderr @@ -0,0 +1,12 @@ +warning: method `do_something` is never used + --> $DIR/generic-drop-trait-bound-15858.rs:9:8 + | +LL | trait Bar { + | --- method in this trait +LL | fn do_something(&mut self); + | ^^^^^^^^^^^^ + | + = note: `#[warn(dead_code)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/drop/nested-return-drop-order.rs b/tests/ui/drop/nested-return-drop-order.rs new file mode 100644 index 00000000000..67ab52e6250 --- /dev/null +++ b/tests/ui/drop/nested-return-drop-order.rs @@ -0,0 +1,90 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15763 + +//@ run-pass +#![allow(unreachable_code)] + +#[derive(PartialEq, Debug)] +struct Bar { + x: isize +} +impl Drop for Bar { + fn drop(&mut self) { + assert_eq!(self.x, 22); + } +} + +#[derive(PartialEq, Debug)] +struct Foo { + x: Bar, + a: isize +} + +fn foo() -> Result { + return Ok(Foo { + x: Bar { x: 22 }, + a: return Err(32) + }); +} + +fn baz() -> Result { + Ok(Foo { + x: Bar { x: 22 }, + a: return Err(32) + }) +} + +// explicit immediate return +fn aa() -> isize { + return 3; +} + +// implicit immediate return +fn bb() -> isize { + 3 +} + +// implicit outptr return +fn cc() -> Result { + Ok(3) +} + +// explicit outptr return +fn dd() -> Result { + return Ok(3); +} + +trait A { + fn aaa(&self) -> isize { + 3 + } + fn bbb(&self) -> isize { + return 3; + } + fn ccc(&self) -> Result { + Ok(3) + } + fn ddd(&self) -> Result { + return Ok(3); + } +} + +impl A for isize {} + +fn main() { + assert_eq!(foo(), Err(32)); + assert_eq!(baz(), Err(32)); + + assert_eq!(aa(), 3); + assert_eq!(bb(), 3); + assert_eq!(cc().unwrap(), 3); + assert_eq!(dd().unwrap(), 3); + + let i = Box::new(32isize) as Box; + assert_eq!(i.aaa(), 3); + let i = Box::new(32isize) as Box; + assert_eq!(i.bbb(), 3); + let i = Box::new(32isize) as Box; + assert_eq!(i.ccc().unwrap(), 3); + let i = Box::new(32isize) as Box; + assert_eq!(i.ddd().unwrap(), 3); +} diff --git a/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs b/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs new file mode 100644 index 00000000000..ecc862ec7be --- /dev/null +++ b/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs @@ -0,0 +1,34 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16151 + +//@ run-pass + +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + +use std::mem; + +static mut DROP_COUNT: usize = 0; + +struct Fragment; + +impl Drop for Fragment { + fn drop(&mut self) { + unsafe { + DROP_COUNT += 1; + } + } +} + +fn main() { + { + let mut fragments = vec![Fragment, Fragment, Fragment]; + let _new_fragments: Vec = mem::replace(&mut fragments, vec![]) + .into_iter() + .skip_while(|_fragment| { + true + }).collect(); + } + unsafe { + assert_eq!(DROP_COUNT, 3); + } +} diff --git a/tests/ui/drop/struct-field-drop-order.rs b/tests/ui/drop/struct-field-drop-order.rs index cfdba5fda35..80e3ea616a5 100644 --- a/tests/ui/drop/struct-field-drop-order.rs +++ b/tests/ui/drop/struct-field-drop-order.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16492 + //@ run-pass #![allow(non_snake_case)] diff --git a/tests/ui/drop/vec-replace-skip-while-drop.rs b/tests/ui/drop/vec-replace-skip-while-drop.rs deleted file mode 100644 index b18108e0a8a..00000000000 --- a/tests/ui/drop/vec-replace-skip-while-drop.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ run-pass - -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint -#![allow(static_mut_refs)] - -use std::mem; - -static mut DROP_COUNT: usize = 0; - -struct Fragment; - -impl Drop for Fragment { - fn drop(&mut self) { - unsafe { - DROP_COUNT += 1; - } - } -} - -fn main() { - { - let mut fragments = vec![Fragment, Fragment, Fragment]; - let _new_fragments: Vec = mem::replace(&mut fragments, vec![]) - .into_iter() - .skip_while(|_fragment| { - true - }).collect(); - } - unsafe { - assert_eq!(DROP_COUNT, 3); - } -} diff --git a/tests/ui/extern/empty-struct-extern-fn-16441.rs b/tests/ui/extern/empty-struct-extern-fn-16441.rs index 58cfb389297..82f2eee611d 100644 --- a/tests/ui/extern/empty-struct-extern-fn-16441.rs +++ b/tests/ui/extern/empty-struct-extern-fn-16441.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16441 + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/fn/fn-traits-call-once-signature-15094.rs b/tests/ui/fn/fn-traits-call-once-signature-15094.rs new file mode 100644 index 00000000000..f550bafe43d --- /dev/null +++ b/tests/ui/fn/fn-traits-call-once-signature-15094.rs @@ -0,0 +1,29 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15094 + +#![feature(fn_traits, unboxed_closures)] + +use std::{fmt, ops}; + +struct Debuger { + x: T +} + +impl ops::FnOnce<(),> for Debuger { + type Output = (); + fn call_once(self, _args: ()) { + //~^ ERROR `call_once` has an incompatible type for trait + //~| NOTE expected signature `extern "rust-call" fn + //~| NOTE found signature `fn + //~| NOTE expected "rust-call" fn, found "Rust" fn + println!("{:?}", self.x); + } +} + +fn make_shower(x: T) -> Debuger { + Debuger { x: x } +} + +pub fn main() { + let show3 = make_shower(3); + show3(); +} diff --git a/tests/ui/fn/fn-traits-call-once-signature-15094.stderr b/tests/ui/fn/fn-traits-call-once-signature-15094.stderr new file mode 100644 index 00000000000..bb1d336e848 --- /dev/null +++ b/tests/ui/fn/fn-traits-call-once-signature-15094.stderr @@ -0,0 +1,12 @@ +error[E0053]: method `call_once` has an incompatible type for trait + --> $DIR/fn-traits-call-once-signature-15094.rs:13:5 + | +LL | fn call_once(self, _args: ()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "Rust" fn + | + = note: expected signature `extern "rust-call" fn(Debuger<_>, ())` + found signature `fn(Debuger<_>, ())` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/fn/fn-traits-call-once-signature.rs b/tests/ui/fn/fn-traits-call-once-signature.rs deleted file mode 100644 index 408ab82eb8c..00000000000 --- a/tests/ui/fn/fn-traits-call-once-signature.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![feature(fn_traits, unboxed_closures)] - -use std::{fmt, ops}; - -struct Debuger { - x: T -} - -impl ops::FnOnce<(),> for Debuger { - type Output = (); - fn call_once(self, _args: ()) { - //~^ ERROR `call_once` has an incompatible type for trait - //~| NOTE expected signature `extern "rust-call" fn - //~| NOTE found signature `fn - //~| NOTE expected "rust-call" fn, found "Rust" fn - println!("{:?}", self.x); - } -} - -fn make_shower(x: T) -> Debuger { - Debuger { x: x } -} - -pub fn main() { - let show3 = make_shower(3); - show3(); -} diff --git a/tests/ui/imports/enum-variant-import-path-15774.rs b/tests/ui/imports/enum-variant-import-path-15774.rs index dadd59cc077..583fe4da179 100644 --- a/tests/ui/imports/enum-variant-import-path-15774.rs +++ b/tests/ui/imports/enum-variant-import-path-15774.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15774 + //@ edition: 2015 //@ run-pass diff --git a/tests/ui/inference/iterator-sum-array-15673.rs b/tests/ui/inference/iterator-sum-array-15673.rs new file mode 100644 index 00000000000..c3d94415aff --- /dev/null +++ b/tests/ui/inference/iterator-sum-array-15673.rs @@ -0,0 +1,11 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15673 + +//@ run-pass +#![allow(stable_features)] + +#![feature(iter_arith)] + +fn main() { + let x: [u64; 3] = [1, 2, 3]; + assert_eq!(6, (0..3).map(|i| x[i]).sum::()); +} diff --git a/tests/ui/inference/return-block-type-inference-15965.rs b/tests/ui/inference/return-block-type-inference-15965.rs index eef4900d432..50753e309e8 100644 --- a/tests/ui/inference/return-block-type-inference-15965.rs +++ b/tests/ui/inference/return-block-type-inference-15965.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15965 + fn main() { return { return () } diff --git a/tests/ui/inference/return-block-type-inference-15965.stderr b/tests/ui/inference/return-block-type-inference-15965.stderr new file mode 100644 index 00000000000..fc4f2defe7f --- /dev/null +++ b/tests/ui/inference/return-block-type-inference-15965.stderr @@ -0,0 +1,11 @@ +error[E0282]: type annotations needed + --> $DIR/return-block-type-inference-15965.rs:5:9 + | +LL | / { return () } +LL | | +LL | | () + | |______^ cannot infer type + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-15034.stderr b/tests/ui/issues/issue-15034.stderr deleted file mode 100644 index 7db8ade2e48..00000000000 --- a/tests/ui/issues/issue-15034.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `lexer` - --> $DIR/issue-15034.rs:17:9 - | -LL | Parser { lexer: lexer } - | ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required - | -help: add explicit lifetime `'a` to the type of `lexer` - | -LL | pub fn new(lexer: &'a mut Lexer<'a>) -> Parser<'a> { - | ++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/issues/issue-15094.stderr b/tests/ui/issues/issue-15094.stderr deleted file mode 100644 index 8e0fc8f1770..00000000000 --- a/tests/ui/issues/issue-15094.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0053]: method `call_once` has an incompatible type for trait - --> $DIR/issue-15094.rs:11:5 - | -LL | fn call_once(self, _args: ()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "Rust" fn - | - = note: expected signature `extern "rust-call" fn(Debuger<_>, ())` - found signature `fn(Debuger<_>, ())` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/issues/issue-15167.stderr b/tests/ui/issues/issue-15167.stderr deleted file mode 100644 index 53082ea0ec6..00000000000 --- a/tests/ui/issues/issue-15167.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0425]: cannot find value `n` in this scope - --> $DIR/issue-15167.rs:3:25 - | -LL | macro_rules! f { () => (n) } - | ^ not found in this scope -... -LL | println!("{}", f!()); - | ---- in this macro invocation - | - = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `n` in this scope - --> $DIR/issue-15167.rs:3:25 - | -LL | macro_rules! f { () => (n) } - | ^ not found in this scope -... -LL | println!("{}", f!()); - | ---- in this macro invocation - | - = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `n` in this scope - --> $DIR/issue-15167.rs:3:25 - | -LL | macro_rules! f { () => (n) } - | ^ not found in this scope -... -LL | println!("{}", f!()); - | ---- in this macro invocation - | - = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `n` in this scope - --> $DIR/issue-15167.rs:3:25 - | -LL | macro_rules! f { () => (n) } - | ^ not found in this scope -... -LL | println!("{}", f!()); - | ---- in this macro invocation - | - = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/issues/issue-15207.stderr b/tests/ui/issues/issue-15207.stderr deleted file mode 100644 index a1047e27ba2..00000000000 --- a/tests/ui/issues/issue-15207.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0599]: no method named `push` found for type `!` in the current scope - --> $DIR/issue-15207.rs:3:15 - | -LL | break.push(1) - | ^^^^ method not found in `!` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/issues/issue-15260.stderr b/tests/ui/issues/issue-15260.stderr deleted file mode 100644 index 4a3041122b2..00000000000 --- a/tests/ui/issues/issue-15260.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/issue-15260.rs:8:9 - | -LL | a: _, - | ---- first use of `a` -LL | a: _ - | ^^^^ multiple uses of `a` in pattern - -error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/issue-15260.rs:14:9 - | -LL | a, - | - first use of `a` -LL | a: _ - | ^^^^ multiple uses of `a` in pattern - -error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/issue-15260.rs:20:9 - | -LL | a, - | - first use of `a` -LL | a: _, - | ^^^^ multiple uses of `a` in pattern - -error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/issue-15260.rs:22:9 - | -LL | a, - | - first use of `a` -... -LL | a: x - | ^^^^ multiple uses of `a` in pattern - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0025`. diff --git a/tests/ui/issues/issue-15381.stderr b/tests/ui/issues/issue-15381.stderr deleted file mode 100644 index 03a0100f1bd..00000000000 --- a/tests/ui/issues/issue-15381.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0005]: refutable pattern in `for` loop binding - --> $DIR/issue-15381.rs:4:9 - | -LL | for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) { - | ^^^^^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered - | - = note: the matched value is of type `&[u8]` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/issues/issue-15756.stderr b/tests/ui/issues/issue-15756.stderr deleted file mode 100644 index a487d360bef..00000000000 --- a/tests/ui/issues/issue-15756.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: the size for values of type `[T]` cannot be known at compilation time - --> $DIR/issue-15756.rs:7:10 - | -LL | &mut something - | ^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[T]` - = note: all local variables 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-15783.stderr b/tests/ui/issues/issue-15783.stderr deleted file mode 100644 index c9c9a723a86..00000000000 --- a/tests/ui/issues/issue-15783.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-15783.rs:10:19 - | -LL | let msg = foo(x); - | --- ^ expected `Option<&[&str]>`, found `Option<&[&str; 1]>` - | | - | arguments to this function are incorrect - | - = note: expected enum `Option<&[&str]>` - found enum `Option<&[&str; 1]>` -note: function defined here - --> $DIR/issue-15783.rs:3:8 - | -LL | pub fn foo(params: Option<&[&str]>) -> usize { - | ^^^ ----------------------- - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-15858.stderr b/tests/ui/issues/issue-15858.stderr deleted file mode 100644 index 0c082cc0862..00000000000 --- a/tests/ui/issues/issue-15858.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: method `do_something` is never used - --> $DIR/issue-15858.rs:7:8 - | -LL | trait Bar { - | --- method in this trait -LL | fn do_something(&mut self); - | ^^^^^^^^^^^^ - | - = note: `#[warn(dead_code)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/issues/issue-15896.stderr b/tests/ui/issues/issue-15896.stderr deleted file mode 100644 index 381f6dc2276..00000000000 --- a/tests/ui/issues/issue-15896.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-15896.rs:11:11 - | -LL | let u = match e { - | - this expression has type `E` -LL | E::B( -LL | Tau{t: x}, - | ^^^^^^^^^ expected `R`, found `Tau` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-15965.stderr b/tests/ui/issues/issue-15965.stderr deleted file mode 100644 index 14727e74334..00000000000 --- a/tests/ui/issues/issue-15965.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/issue-15965.rs:3:9 - | -LL | / { return () } -LL | | -LL | | () - | |______^ cannot infer type - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-16048.stderr b/tests/ui/issues/issue-16048.stderr deleted file mode 100644 index f97f13152bc..00000000000 --- a/tests/ui/issues/issue-16048.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0195]: lifetime parameters or bounds on method `get` do not match the trait declaration - --> $DIR/issue-16048.rs:21:11 - | -LL | fn get<'p, T : Test<'p>>(&self) -> T; - | ------------------ lifetimes in impl do not match this method in trait -... -LL | fn get<'p, T: Test<'a> + From>>(&self) -> T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait - -error[E0605]: non-primitive cast: `Foo<'a>` as `T` - --> $DIR/issue-16048.rs:24:16 - | -LL | return *self as T; - | ^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object - | -help: consider using the `From` trait instead - | -LL - return *self as T; -LL + return T::from(*self); - | - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0195, E0605. -For more information about an error, try `rustc --explain E0195`. diff --git a/tests/ui/issues/issue-16149.stderr b/tests/ui/issues/issue-16149.stderr deleted file mode 100644 index 9ffd0e7e645..00000000000 --- a/tests/ui/issues/issue-16149.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0530]: match bindings cannot shadow statics - --> $DIR/issue-16149.rs:7:9 - | -LL | static externalValue: isize; - | ---------------------------- the static `externalValue` is defined here -... -LL | externalValue => true, - | ^^^^^^^^^^^^^ cannot be named the same as a static - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0530`. diff --git a/tests/ui/issues/issue-16256.stderr b/tests/ui/issues/issue-16256.stderr deleted file mode 100644 index 75c3ec1bd1c..00000000000 --- a/tests/ui/issues/issue-16256.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: unused closure that must be used - --> $DIR/issue-16256.rs:5:5 - | -LL | |c: u8| buf.push(c); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: closures are lazy and do nothing unless called - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/issues/issue-16401.stderr b/tests/ui/issues/issue-16401.stderr deleted file mode 100644 index 6af920ca439..00000000000 --- a/tests/ui/issues/issue-16401.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-16401.rs:8:9 - | -LL | match () { - | -- this expression has type `()` -LL | Slice { data: data, len: len } => (), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Slice<_>` - | - = note: expected unit type `()` - found struct `Slice<_>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/iterators/chunk-iterator-mut-pattern.rs b/tests/ui/iterators/chunk-iterator-mut-pattern.rs deleted file mode 100644 index e0861dee61e..00000000000 --- a/tests/ui/iterators/chunk-iterator-mut-pattern.rs +++ /dev/null @@ -1,14 +0,0 @@ -use std::slice::Chunks; -use std::slice::ChunksMut; - -fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: ChunksMut<'a,T>) -{ - for - &mut something - //~^ ERROR the size for values of type - in arg2 - { - } -} - -fn main() {} diff --git a/tests/ui/iterators/explicit-deref-non-deref-type-15756.rs b/tests/ui/iterators/explicit-deref-non-deref-type-15756.rs new file mode 100644 index 00000000000..6d4a3bffcf7 --- /dev/null +++ b/tests/ui/iterators/explicit-deref-non-deref-type-15756.rs @@ -0,0 +1,16 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15756 + +use std::slice::Chunks; +use std::slice::ChunksMut; + +fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: ChunksMut<'a,T>) +{ + for + &mut something + //~^ ERROR the size for values of type + in arg2 + { + } +} + +fn main() {} diff --git a/tests/ui/iterators/explicit-deref-non-deref-type-15756.stderr b/tests/ui/iterators/explicit-deref-non-deref-type-15756.stderr new file mode 100644 index 00000000000..b4f9aab8496 --- /dev/null +++ b/tests/ui/iterators/explicit-deref-non-deref-type-15756.stderr @@ -0,0 +1,12 @@ +error[E0277]: the size for values of type `[T]` cannot be known at compilation time + --> $DIR/explicit-deref-non-deref-type-15756.rs:9:10 + | +LL | &mut something + | ^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[T]` + = note: all local variables 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/iterators/iterator-sum-array-15673.rs b/tests/ui/iterators/iterator-sum-array-15673.rs deleted file mode 100644 index bb61c246276..00000000000 --- a/tests/ui/iterators/iterator-sum-array-15673.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -#![allow(stable_features)] - -#![feature(iter_arith)] - -fn main() { - let x: [u64; 3] = [1, 2, 3]; - assert_eq!(6, (0..3).map(|i| x[i]).sum::()); -} diff --git a/tests/ui/lifetimes/explicit-lifetime-required-15034.rs b/tests/ui/lifetimes/explicit-lifetime-required-15034.rs deleted file mode 100644 index 9ea6ed89ca2..00000000000 --- a/tests/ui/lifetimes/explicit-lifetime-required-15034.rs +++ /dev/null @@ -1,22 +0,0 @@ -pub struct Lexer<'a> { - input: &'a str, -} - -impl<'a> Lexer<'a> { - pub fn new(input: &'a str) -> Lexer<'a> { - Lexer { input: input } - } -} - -struct Parser<'a> { - lexer: &'a mut Lexer<'a>, -} - -impl<'a> Parser<'a> { - pub fn new(lexer: &'a mut Lexer) -> Parser<'a> { - Parser { lexer: lexer } - //~^ ERROR explicit lifetime required in the type of `lexer` [E0621] - } -} - -fn main() {} diff --git a/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.rs b/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.rs new file mode 100644 index 00000000000..e7f9a94231f --- /dev/null +++ b/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.rs @@ -0,0 +1,24 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15034 + +pub struct Lexer<'a> { + input: &'a str, +} + +impl<'a> Lexer<'a> { + pub fn new(input: &'a str) -> Lexer<'a> { + Lexer { input: input } + } +} + +struct Parser<'a> { + lexer: &'a mut Lexer<'a>, +} + +impl<'a> Parser<'a> { + pub fn new(lexer: &'a mut Lexer) -> Parser<'a> { + Parser { lexer: lexer } + //~^ ERROR explicit lifetime required in the type of `lexer` [E0621] + } +} + +fn main() {} diff --git a/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.stderr b/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.stderr new file mode 100644 index 00000000000..0762714d259 --- /dev/null +++ b/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.stderr @@ -0,0 +1,14 @@ +error[E0621]: explicit lifetime required in the type of `lexer` + --> $DIR/nondeterministic-lifetime-errors-15034.rs:19:9 + | +LL | Parser { lexer: lexer } + | ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required + | +help: add explicit lifetime `'a` to the type of `lexer` + | +LL | pub fn new(lexer: &'a mut Lexer<'a>) -> Parser<'a> { + | ++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lifetimes/struct-lifetime-inference-15735.rs b/tests/ui/lifetimes/struct-lifetime-inference-15735.rs index f5b3803f155..39e619648eb 100644 --- a/tests/ui/lifetimes/struct-lifetime-inference-15735.rs +++ b/tests/ui/lifetimes/struct-lifetime-inference-15735.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15735 + //@ check-pass #![allow(dead_code)] struct A<'a> { diff --git a/tests/ui/macros/for-loop-macro-rules-hygiene.rs b/tests/ui/macros/for-loop-macro-rules-hygiene.rs new file mode 100644 index 00000000000..fcebda1b9da --- /dev/null +++ b/tests/ui/macros/for-loop-macro-rules-hygiene.rs @@ -0,0 +1,12 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15189 + +//@ run-pass +macro_rules! third { + ($e:expr) => ({let x = 2; $e[x]}) +} + +fn main() { + let x = vec![10_usize,11_usize,12_usize,13_usize]; + let t = third!(x); + assert_eq!(t,12_usize); +} diff --git a/tests/ui/macros/macro-hygiene-scope-15167.rs b/tests/ui/macros/macro-hygiene-scope-15167.rs index a2653c10ea4..6578f898a5f 100644 --- a/tests/ui/macros/macro-hygiene-scope-15167.rs +++ b/tests/ui/macros/macro-hygiene-scope-15167.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15167 + // macro f should not be able to inject a reference to 'n'. macro_rules! f { () => (n) } diff --git a/tests/ui/macros/macro-hygiene-scope-15167.stderr b/tests/ui/macros/macro-hygiene-scope-15167.stderr new file mode 100644 index 00000000000..58112c52df1 --- /dev/null +++ b/tests/ui/macros/macro-hygiene-scope-15167.stderr @@ -0,0 +1,47 @@ +error[E0425]: cannot find value `n` in this scope + --> $DIR/macro-hygiene-scope-15167.rs:5:25 + | +LL | macro_rules! f { () => (n) } + | ^ not found in this scope +... +LL | println!("{}", f!()); + | ---- in this macro invocation + | + = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0425]: cannot find value `n` in this scope + --> $DIR/macro-hygiene-scope-15167.rs:5:25 + | +LL | macro_rules! f { () => (n) } + | ^ not found in this scope +... +LL | println!("{}", f!()); + | ---- in this macro invocation + | + = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0425]: cannot find value `n` in this scope + --> $DIR/macro-hygiene-scope-15167.rs:5:25 + | +LL | macro_rules! f { () => (n) } + | ^ not found in this scope +... +LL | println!("{}", f!()); + | ---- in this macro invocation + | + = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0425]: cannot find value `n` in this scope + --> $DIR/macro-hygiene-scope-15167.rs:5:25 + | +LL | macro_rules! f { () => (n) } + | ^ not found in this scope +... +LL | println!("{}", f!()); + | ---- in this macro invocation + | + = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/macros/macro-variable-capture-15189.rs b/tests/ui/macros/macro-variable-capture-15189.rs deleted file mode 100644 index 4dbe2179dd9..00000000000 --- a/tests/ui/macros/macro-variable-capture-15189.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -macro_rules! third { - ($e:expr) => ({let x = 2; $e[x]}) -} - -fn main() { - let x = vec![10_usize,11_usize,12_usize,13_usize]; - let t = third!(x); - assert_eq!(t,12_usize); -} diff --git a/tests/ui/match/nested-enum-match-optimization.rs b/tests/ui/match/nested-enum-match-optimization.rs deleted file mode 100644 index af92e9dfa4c..00000000000 --- a/tests/ui/match/nested-enum-match-optimization.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -enum NestedEnum { - First, - Second, - Third -} -enum Enum { - Variant1(bool), - Variant2(NestedEnum) -} - -#[inline(never)] -fn foo(x: Enum) -> isize { - match x { - Enum::Variant1(true) => 1, - Enum::Variant1(false) => 2, - Enum::Variant2(NestedEnum::Second) => 3, - Enum::Variant2(NestedEnum::Third) => 4, - Enum::Variant2(NestedEnum::First) => 5 - } -} - -fn main() { - assert_eq!(foo(Enum::Variant2(NestedEnum::Third)), 4); -} diff --git a/tests/ui/moves/match-move-same-binding-15571.rs b/tests/ui/moves/match-move-same-binding-15571.rs index cf17113a282..f6d79c6d76c 100644 --- a/tests/ui/moves/match-move-same-binding-15571.rs +++ b/tests/ui/moves/match-move-same-binding-15571.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15571 + //@ run-pass fn match_on_local() { diff --git a/tests/ui/never/never-type-method-call-15207.rs b/tests/ui/never/never-type-method-call-15207.rs index 356e55ac912..69cdeeabb7c 100644 --- a/tests/ui/never/never-type-method-call-15207.rs +++ b/tests/ui/never/never-type-method-call-15207.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15207 + fn main() { loop { break.push(1) //~ ERROR no method named `push` found for type `!` diff --git a/tests/ui/never/never-type-method-call-15207.stderr b/tests/ui/never/never-type-method-call-15207.stderr new file mode 100644 index 00000000000..265e7c8611d --- /dev/null +++ b/tests/ui/never/never-type-method-call-15207.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `push` found for type `!` in the current scope + --> $DIR/never-type-method-call-15207.rs:5:15 + | +LL | break.push(1) + | ^^^^ method not found in `!` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/parser/generics-rangle-eq-15043.rs b/tests/ui/parser/generics-rangle-eq-15043.rs new file mode 100644 index 00000000000..1afc334dfd8 --- /dev/null +++ b/tests/ui/parser/generics-rangle-eq-15043.rs @@ -0,0 +1,15 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15043 + +//@ run-pass + +#![allow(warnings)] + +struct S(T); + +static s1: S>=S(S(0)); +static s2: S=S(0); + +fn main() { + let foo: S>=S(S(0)); + let foo: S=S(0); +} diff --git a/tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs new file mode 100644 index 00000000000..9f7c5084c0e --- /dev/null +++ b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs @@ -0,0 +1,17 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15896 + +// Regression test for #15896. It used to ICE rustc. + +fn main() { + enum R { REB(()) } + struct Tau { t: usize } + enum E { B(R, Tau) } + + let e = E::B(R::REB(()), Tau { t: 3 }); + let u = match e { + E::B( + Tau{t: x}, + //~^ ERROR mismatched types + _) => x, + }; +} diff --git a/tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr new file mode 100644 index 00000000000..8dee4c37e2f --- /dev/null +++ b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/enum-struct-pattern-mismatch-15896.rs:13:11 + | +LL | let u = match e { + | - this expression has type `E` +LL | E::B( +LL | Tau{t: x}, + | ^^^^^^^^^ expected `R`, found `Tau` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/enum-struct-pattern-mismatch.rs b/tests/ui/pattern/enum-struct-pattern-mismatch.rs deleted file mode 100644 index d3153b516e6..00000000000 --- a/tests/ui/pattern/enum-struct-pattern-mismatch.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Regression test for #15896. It used to ICE rustc. - -fn main() { - enum R { REB(()) } - struct Tau { t: usize } - enum E { B(R, Tau) } - - let e = E::B(R::REB(()), Tau { t: 3 }); - let u = match e { - E::B( - Tau{t: x}, - //~^ ERROR mismatched types - _) => x, - }; -} diff --git a/tests/ui/pattern/refutable-pattern-for-loop-15381.rs b/tests/ui/pattern/refutable-pattern-for-loop-15381.rs index bd5f62ddc67..3c19612c9cc 100644 --- a/tests/ui/pattern/refutable-pattern-for-loop-15381.rs +++ b/tests/ui/pattern/refutable-pattern-for-loop-15381.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15381 + fn main() { let values: Vec = vec![1,2,3,4,5,6,7,8]; diff --git a/tests/ui/pattern/refutable-pattern-for-loop-15381.stderr b/tests/ui/pattern/refutable-pattern-for-loop-15381.stderr new file mode 100644 index 00000000000..3c1d5fb454c --- /dev/null +++ b/tests/ui/pattern/refutable-pattern-for-loop-15381.stderr @@ -0,0 +1,11 @@ +error[E0005]: refutable pattern in `for` loop binding + --> $DIR/refutable-pattern-for-loop-15381.rs:6:9 + | +LL | for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) { + | ^^^^^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered + | + = note: the matched value is of type `&[u8]` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/pattern/slice-pattern-recursion-15104.rs b/tests/ui/pattern/slice-pattern-recursion-15104.rs index e68c94c370e..24e3fe78de0 100644 --- a/tests/ui/pattern/slice-pattern-recursion-15104.rs +++ b/tests/ui/pattern/slice-pattern-recursion-15104.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15104 + //@ run-pass fn main() { diff --git a/tests/ui/pattern/static-binding-shadow-16149.rs b/tests/ui/pattern/static-binding-shadow-16149.rs index 51b60725c5a..a46f78214c7 100644 --- a/tests/ui/pattern/static-binding-shadow-16149.rs +++ b/tests/ui/pattern/static-binding-shadow-16149.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16149 + extern "C" { static externalValue: isize; } diff --git a/tests/ui/pattern/static-binding-shadow-16149.stderr b/tests/ui/pattern/static-binding-shadow-16149.stderr new file mode 100644 index 00000000000..6d8c7634acd --- /dev/null +++ b/tests/ui/pattern/static-binding-shadow-16149.stderr @@ -0,0 +1,12 @@ +error[E0530]: match bindings cannot shadow statics + --> $DIR/static-binding-shadow-16149.rs:9:9 + | +LL | static externalValue: isize; + | ---------------------------- the static `externalValue` is defined here +... +LL | externalValue => true, + | ^^^^^^^^^^^^^ cannot be named the same as a static + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0530`. diff --git a/tests/ui/pattern/struct-field-duplicate-binding-15260.rs b/tests/ui/pattern/struct-field-duplicate-binding-15260.rs new file mode 100644 index 00000000000..a3617798cdf --- /dev/null +++ b/tests/ui/pattern/struct-field-duplicate-binding-15260.rs @@ -0,0 +1,27 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15260 + +struct Foo { + a: usize, +} + +fn main() { + let Foo { + a: _, + a: _ + //~^ ERROR field `a` bound multiple times in the pattern + } = Foo { a: 29 }; + + let Foo { + a, + a: _ + //~^ ERROR field `a` bound multiple times in the pattern + } = Foo { a: 29 }; + + let Foo { + a, + a: _, + //~^ ERROR field `a` bound multiple times in the pattern + a: x + //~^ ERROR field `a` bound multiple times in the pattern + } = Foo { a: 29 }; +} diff --git a/tests/ui/pattern/struct-field-duplicate-binding-15260.stderr b/tests/ui/pattern/struct-field-duplicate-binding-15260.stderr new file mode 100644 index 00000000000..536904fbcb3 --- /dev/null +++ b/tests/ui/pattern/struct-field-duplicate-binding-15260.stderr @@ -0,0 +1,36 @@ +error[E0025]: field `a` bound multiple times in the pattern + --> $DIR/struct-field-duplicate-binding-15260.rs:10:9 + | +LL | a: _, + | ---- first use of `a` +LL | a: _ + | ^^^^ multiple uses of `a` in pattern + +error[E0025]: field `a` bound multiple times in the pattern + --> $DIR/struct-field-duplicate-binding-15260.rs:16:9 + | +LL | a, + | - first use of `a` +LL | a: _ + | ^^^^ multiple uses of `a` in pattern + +error[E0025]: field `a` bound multiple times in the pattern + --> $DIR/struct-field-duplicate-binding-15260.rs:22:9 + | +LL | a, + | - first use of `a` +LL | a: _, + | ^^^^ multiple uses of `a` in pattern + +error[E0025]: field `a` bound multiple times in the pattern + --> $DIR/struct-field-duplicate-binding-15260.rs:24:9 + | +LL | a, + | - first use of `a` +... +LL | a: x + | ^^^^ multiple uses of `a` in pattern + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0025`. diff --git a/tests/ui/pattern/struct-field-duplicate-binding.rs b/tests/ui/pattern/struct-field-duplicate-binding.rs deleted file mode 100644 index 64fc3df3d23..00000000000 --- a/tests/ui/pattern/struct-field-duplicate-binding.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct Foo { - a: usize, -} - -fn main() { - let Foo { - a: _, - a: _ - //~^ ERROR field `a` bound multiple times in the pattern - } = Foo { a: 29 }; - - let Foo { - a, - a: _ - //~^ ERROR field `a` bound multiple times in the pattern - } = Foo { a: 29 }; - - let Foo { - a, - a: _, - //~^ ERROR field `a` bound multiple times in the pattern - a: x - //~^ ERROR field `a` bound multiple times in the pattern - } = Foo { a: 29 }; -} diff --git a/tests/ui/pattern/tuple-enum-match-15129.rs b/tests/ui/pattern/tuple-enum-match-15129.rs index e2ddb989072..1d6192c4cb3 100644 --- a/tests/ui/pattern/tuple-enum-match-15129.rs +++ b/tests/ui/pattern/tuple-enum-match-15129.rs @@ -1,24 +1,25 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15129 + //@ run-pass pub enum T { T1(()), - T2(()) + T2(()), } pub enum V { V1(isize), - V2(bool) + V2(bool), } fn foo(x: (T, V)) -> String { match x { - (T::T1(()), V::V1(i)) => format!("T1(()), V1({})", i), - (T::T2(()), V::V2(b)) => format!("T2(()), V2({})", b), - _ => String::new() + (T::T1(()), V::V1(i)) => format!("T1(()), V1({})", i), + (T::T2(()), V::V2(b)) => format!("T2(()), V2({})", b), + _ => String::new(), } } - fn main() { assert_eq!(foo((T::T1(()), V::V1(99))), "T1(()), V1(99)".to_string()); assert_eq!(foo((T::T2(()), V::V2(true))), "T2(()), V2(true)".to_string()); diff --git a/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs new file mode 100644 index 00000000000..2eba33e177e --- /dev/null +++ b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs @@ -0,0 +1,17 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16401 + +struct Slice { + data: *const T, + len: usize, +} + +fn main() { + match () { //~ NOTE this expression has type `()` + Slice { data: data, len: len } => (), + //~^ ERROR mismatched types + //~| NOTE expected unit type `()` + //~| NOTE found struct `Slice<_>` + //~| NOTE expected `()`, found `Slice<_>` + _ => unreachable!() + } +} diff --git a/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr new file mode 100644 index 00000000000..22c04e439c4 --- /dev/null +++ b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/unit-type-struct-pattern-mismatch-16401.rs:10:9 + | +LL | match () { + | -- this expression has type `()` +LL | Slice { data: data, len: len } => (), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Slice<_>` + | + = note: expected unit type `()` + found struct `Slice<_>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/unit-type-struct-pattern-mismatch.rs b/tests/ui/pattern/unit-type-struct-pattern-mismatch.rs deleted file mode 100644 index 0985a6806d2..00000000000 --- a/tests/ui/pattern/unit-type-struct-pattern-mismatch.rs +++ /dev/null @@ -1,15 +0,0 @@ -struct Slice { - data: *const T, - len: usize, -} - -fn main() { - match () { //~ NOTE this expression has type `()` - Slice { data: data, len: len } => (), - //~^ ERROR mismatched types - //~| NOTE expected unit type `()` - //~| NOTE found struct `Slice<_>` - //~| NOTE expected `()`, found `Slice<_>` - _ => unreachable!() - } -} diff --git a/tests/ui/statics/conditional-static-declaration-16010.rs b/tests/ui/statics/conditional-static-declaration-16010.rs new file mode 100644 index 00000000000..0bc5b0ee86f --- /dev/null +++ b/tests/ui/statics/conditional-static-declaration-16010.rs @@ -0,0 +1,11 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16010 + +//@ run-pass +#![allow(dead_code)] + +fn main() { + if true { return } + match () { + () => { static MAGIC: usize = 0; } + } +} diff --git a/tests/ui/statics/conditional-static-declaration.rs b/tests/ui/statics/conditional-static-declaration.rs deleted file mode 100644 index 4ab74f09059..00000000000 --- a/tests/ui/statics/conditional-static-declaration.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -fn main() { - if true { return } - match () { - () => { static MAGIC: usize = 0; } - } -} diff --git a/tests/ui/structs/static-struct-init-15043.rs b/tests/ui/structs/static-struct-init-15043.rs deleted file mode 100644 index a9bb46b649b..00000000000 --- a/tests/ui/structs/static-struct-init-15043.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -#![allow(warnings)] - -struct S(T); - -static s1: S>=S(S(0)); -static s2: S=S(0); - -fn main() { - let foo: S>=S(S(0)); - let foo: S=S(0); -} diff --git a/tests/ui/traits/fn-type-trait-impl-15444.rs b/tests/ui/traits/fn-type-trait-impl-15444.rs index 14708c7733c..ab91e88b9cd 100644 --- a/tests/ui/traits/fn-type-trait-impl-15444.rs +++ b/tests/ui/traits/fn-type-trait-impl-15444.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15444 + //@ run-pass trait MyTrait { diff --git a/tests/ui/traits/index-trait-multiple-impls-15734.rs b/tests/ui/traits/index-trait-multiple-impls-15734.rs new file mode 100644 index 00000000000..a2d5d7c87fc --- /dev/null +++ b/tests/ui/traits/index-trait-multiple-impls-15734.rs @@ -0,0 +1,61 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15734 + +//@ run-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +use std::ops::Index; + +struct Mat { data: Vec, cols: usize, } + +impl Mat { + fn new(data: Vec, cols: usize) -> Mat { + Mat { data: data, cols: cols } + } + fn row<'a>(&'a self, row: usize) -> Row<&'a Mat> { + Row { mat: self, row: row, } + } +} + +impl Index<(usize, usize)> for Mat { + type Output = T; + + fn index<'a>(&'a self, (row, col): (usize, usize)) -> &'a T { + &self.data[row * self.cols + col] + } +} + +impl<'a, T> Index<(usize, usize)> for &'a Mat { + type Output = T; + + fn index<'b>(&'b self, index: (usize, usize)) -> &'b T { + (*self).index(index) + } +} + +struct Row { mat: M, row: usize, } + +impl> Index for Row { + type Output = T; + + fn index<'a>(&'a self, col: usize) -> &'a T { + &self.mat[(self.row, col)] + } +} + +fn main() { + let m = Mat::new(vec![1, 2, 3, 4, 5, 6], 3); + let r = m.row(1); + + assert_eq!(r.index(2), &6); + assert_eq!(r[2], 6); + assert_eq!(r[2], 6); + assert_eq!(6, r[2]); + + let e = r[2]; + assert_eq!(e, 6); + + let e: usize = r[2]; + assert_eq!(e, 6); +} diff --git a/tests/ui/traits/index-trait-multiple-impls.rs b/tests/ui/traits/index-trait-multiple-impls.rs deleted file mode 100644 index 26fb7061664..00000000000 --- a/tests/ui/traits/index-trait-multiple-impls.rs +++ /dev/null @@ -1,59 +0,0 @@ -//@ run-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver - -use std::ops::Index; - -struct Mat { data: Vec, cols: usize, } - -impl Mat { - fn new(data: Vec, cols: usize) -> Mat { - Mat { data: data, cols: cols } - } - fn row<'a>(&'a self, row: usize) -> Row<&'a Mat> { - Row { mat: self, row: row, } - } -} - -impl Index<(usize, usize)> for Mat { - type Output = T; - - fn index<'a>(&'a self, (row, col): (usize, usize)) -> &'a T { - &self.data[row * self.cols + col] - } -} - -impl<'a, T> Index<(usize, usize)> for &'a Mat { - type Output = T; - - fn index<'b>(&'b self, index: (usize, usize)) -> &'b T { - (*self).index(index) - } -} - -struct Row { mat: M, row: usize, } - -impl> Index for Row { - type Output = T; - - fn index<'a>(&'a self, col: usize) -> &'a T { - &self.mat[(self.row, col)] - } -} - -fn main() { - let m = Mat::new(vec![1, 2, 3, 4, 5, 6], 3); - let r = m.row(1); - - assert_eq!(r.index(2), &6); - assert_eq!(r[2], 6); - assert_eq!(r[2], 6); - assert_eq!(6, r[2]); - - let e = r[2]; - assert_eq!(e, 6); - - let e: usize = r[2]; - assert_eq!(e, 6); -} diff --git a/tests/ui/traits/lifetime-mismatch-trait-impl-16048.rs b/tests/ui/traits/lifetime-mismatch-trait-impl-16048.rs new file mode 100644 index 00000000000..9c36b231403 --- /dev/null +++ b/tests/ui/traits/lifetime-mismatch-trait-impl-16048.rs @@ -0,0 +1,32 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16048 + +trait NoLifetime { + fn get<'p, T : Test<'p>>(&self) -> T; + //~^ NOTE lifetimes in impl do not match this method in trait +} + +trait Test<'p> { + fn new(buf: &'p mut [u8]) -> Self; +} + +struct Foo<'a> { + buf: &'a mut [u8], +} + +impl<'a> Test<'a> for Foo<'a> { + fn new(buf: &'a mut [u8]) -> Foo<'a> { + Foo { buf: buf } + } +} + +impl<'a> NoLifetime for Foo<'a> { + fn get<'p, T: Test<'a> + From>>(&self) -> T { + //~^ ERROR E0195 + //~| NOTE lifetimes do not match method in trait + return *self as T; + //~^ ERROR non-primitive cast: `Foo<'a>` as `T` + //~| NOTE an `as` expression can only be used to convert between primitive types + } +} + +fn main() {} diff --git a/tests/ui/traits/lifetime-mismatch-trait-impl-16048.stderr b/tests/ui/traits/lifetime-mismatch-trait-impl-16048.stderr new file mode 100644 index 00000000000..08b69184b7f --- /dev/null +++ b/tests/ui/traits/lifetime-mismatch-trait-impl-16048.stderr @@ -0,0 +1,25 @@ +error[E0195]: lifetime parameters or bounds on method `get` do not match the trait declaration + --> $DIR/lifetime-mismatch-trait-impl-16048.rs:23:11 + | +LL | fn get<'p, T : Test<'p>>(&self) -> T; + | ------------------ lifetimes in impl do not match this method in trait +... +LL | fn get<'p, T: Test<'a> + From>>(&self) -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait + +error[E0605]: non-primitive cast: `Foo<'a>` as `T` + --> $DIR/lifetime-mismatch-trait-impl-16048.rs:26:16 + | +LL | return *self as T; + | ^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | +help: consider using the `From` trait instead + | +LL - return *self as T; +LL + return T::from(*self); + | + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0195, E0605. +For more information about an error, try `rustc --explain E0195`. diff --git a/tests/ui/traits/lifetime-mismatch-trait-impl.rs b/tests/ui/traits/lifetime-mismatch-trait-impl.rs deleted file mode 100644 index eaf6acff26b..00000000000 --- a/tests/ui/traits/lifetime-mismatch-trait-impl.rs +++ /dev/null @@ -1,30 +0,0 @@ -trait NoLifetime { - fn get<'p, T : Test<'p>>(&self) -> T; - //~^ NOTE lifetimes in impl do not match this method in trait -} - -trait Test<'p> { - fn new(buf: &'p mut [u8]) -> Self; -} - -struct Foo<'a> { - buf: &'a mut [u8], -} - -impl<'a> Test<'a> for Foo<'a> { - fn new(buf: &'a mut [u8]) -> Foo<'a> { - Foo { buf: buf } - } -} - -impl<'a> NoLifetime for Foo<'a> { - fn get<'p, T: Test<'a> + From>>(&self) -> T { - //~^ ERROR E0195 - //~| NOTE lifetimes do not match method in trait - return *self as T; - //~^ ERROR non-primitive cast: `Foo<'a>` as `T` - //~| NOTE an `as` expression can only be used to convert between primitive types - } -} - -fn main() {} -- cgit 1.4.1-3-g733a5