diff options
| author | bors <bors@rust-lang.org> | 2020-11-05 10:22:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-05 10:22:20 +0000 |
| commit | f7801d6c7cc19ab22bdebcc8efa894a564c53469 (patch) | |
| tree | a9b21c6a0736b922133b84b770cdbd3f2f8dc962 /src/test/ui | |
| parent | 8c2070121905b66698ebbfb105eab30f3484e602 (diff) | |
| parent | 8416e13d888a576e421763c07b1464bd93c09aee (diff) | |
Auto merge of #78767 - m-ou-se:rollup-eu5wgxl, r=m-ou-se
Rollup of 15 pull requests Successful merges: - #76718 (Move Vec UI tests to unit tests when possible) - #78093 (Clean up docs for 'as' keyword) - #78425 (Move f64::NAN ui tests into `library`) - #78465 (Change as_str → to_string in proc_macro::Ident::span() docs) - #78584 (Add keyboard handling to the theme picker menu) - #78716 (Array trait impl comment/doc fixes) - #78727 ((rustdoc) fix test for trait impl display) - #78733 (fix a couple of clippy warnings:) - #78735 (Simplify the implementation of `get_mut` (no unsafe)) - #78738 (Move range in ui test to ops test in library/core) - #78739 (Fix ICE on type error in async function) - #78742 (make intern_const_alloc_recursive return error) - #78756 (Update cargo) - #78757 (Improve and clean up some intra-doc links) - #78758 (Fixed typo in comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/array-slice-vec/subslice-patterns-pass.rs | 126 | ||||
| -rw-r--r-- | src/test/ui/array-slice-vec/vec-macro-repeat.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/async-await/issues/issue-78654.full.stderr | 19 | ||||
| -rw-r--r-- | src/test/ui/async-await/issues/issue-78654.min.stderr | 19 | ||||
| -rw-r--r-- | src/test/ui/async-await/issues/issue-78654.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/consts/dangling-alloc-id-ice.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/consts/dangling-alloc-id-ice.stderr | 15 | ||||
| -rw-r--r-- | src/test/ui/consts/issue-78655.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/consts/issue-78655.stderr | 30 | ||||
| -rw-r--r-- | src/test/ui/format-nan.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/range.rs | 51 | ||||
| -rw-r--r-- | src/test/ui/swap-2.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/zero-sized/zero-sized-vec-deque-push.rs | 32 | ||||
| -rw-r--r-- | src/test/ui/zero-sized/zero-sized-vec-push.rs | 20 |
14 files changed, 96 insertions, 282 deletions
diff --git a/src/test/ui/array-slice-vec/subslice-patterns-pass.rs b/src/test/ui/array-slice-vec/subslice-patterns-pass.rs deleted file mode 100644 index e05790911f5..00000000000 --- a/src/test/ui/array-slice-vec/subslice-patterns-pass.rs +++ /dev/null @@ -1,126 +0,0 @@ -// This test comprehensively checks the passing static and dynamic semantics -// of subslice patterns `..`, `x @ ..`, `ref x @ ..`, and `ref mut @ ..` -// in slice patterns `[$($pat), $(,)?]` . - -// run-pass - -#![allow(unreachable_patterns)] - -use std::convert::identity; - -#[derive(PartialEq, Debug, Clone)] -struct N(u8); - -macro_rules! n { - ($($e:expr),* $(,)?) => { - [$(N($e)),*] - } -} - -macro_rules! c { - ($inp:expr, $typ:ty, $out:expr $(,)?) => { - assert_eq!($out, identity::<$typ>($inp)); - } -} - -macro_rules! m { - ($e:expr, $p:pat => $b:expr) => { - match $e { - $p => $b, - _ => panic!(), - } - } -} - -fn main() { - slices(); - arrays(); -} - -fn slices() { - // Matching slices using `ref` patterns: - let mut v = vec![N(0), N(1), N(2), N(3), N(4)]; - let mut vc = (0..=4).collect::<Vec<u8>>(); - - let [..] = v[..]; // Always matches. - m!(v[..], [N(0), ref sub @ .., N(4)] => c!(sub, &[N], n![1, 2, 3])); - m!(v[..], [N(0), ref sub @ ..] => c!(sub, &[N], n![1, 2, 3, 4])); - m!(v[..], [ref sub @ .., N(4)] => c!(sub, &[N], n![0, 1, 2, 3])); - m!(v[..], [ref sub @ .., _, _, _, _, _] => c!(sub, &[N], &n![] as &[N])); - m!(v[..], [_, _, _, _, _, ref sub @ ..] => c!(sub, &[N], &n![] as &[N])); - m!(vc[..], [x, .., y] => c!((x, y), (u8, u8), (0, 4))); - - // Matching slices using `ref mut` patterns: - let [..] = v[..]; // Always matches. - m!(v[..], [N(0), ref mut sub @ .., N(4)] => c!(sub, &mut [N], n![1, 2, 3])); - m!(v[..], [N(0), ref mut sub @ ..] => c!(sub, &mut [N], n![1, 2, 3, 4])); - m!(v[..], [ref mut sub @ .., N(4)] => c!(sub, &mut [N], n![0, 1, 2, 3])); - m!(v[..], [ref mut sub @ .., _, _, _, _, _] => c!(sub, &mut [N], &mut n![] as &mut [N])); - m!(v[..], [_, _, _, _, _, ref mut sub @ ..] => c!(sub, &mut [N], &mut n![] as &mut [N])); - m!(vc[..], [x, .., y] => c!((x, y), (u8, u8), (0, 4))); - - // Matching slices using default binding modes (&): - let [..] = &v[..]; // Always matches. - m!(&v[..], [N(0), sub @ .., N(4)] => c!(sub, &[N], n![1, 2, 3])); - m!(&v[..], [N(0), sub @ ..] => c!(sub, &[N], n![1, 2, 3, 4])); - m!(&v[..], [sub @ .., N(4)] => c!(sub, &[N], n![0, 1, 2, 3])); - m!(&v[..], [sub @ .., _, _, _, _, _] => c!(sub, &[N], &n![] as &[N])); - m!(&v[..], [_, _, _, _, _, sub @ ..] => c!(sub, &[N], &n![] as &[N])); - m!(&vc[..], [x, .., y] => c!((x, y), (&u8, &u8), (&0, &4))); - - // Matching slices using default binding modes (&mut): - let [..] = &mut v[..]; // Always matches. - m!(&mut v[..], [N(0), sub @ .., N(4)] => c!(sub, &mut [N], n![1, 2, 3])); - m!(&mut v[..], [N(0), sub @ ..] => c!(sub, &mut [N], n![1, 2, 3, 4])); - m!(&mut v[..], [sub @ .., N(4)] => c!(sub, &mut [N], n![0, 1, 2, 3])); - m!(&mut v[..], [sub @ .., _, _, _, _, _] => c!(sub, &mut [N], &mut n![] as &mut [N])); - m!(&mut v[..], [_, _, _, _, _, sub @ ..] => c!(sub, &mut [N], &mut n![] as &mut [N])); - m!(&mut vc[..], [x, .., y] => c!((x, y), (&mut u8, &mut u8), (&mut 0, &mut 4))); -} - -fn arrays() { - let mut v = n![0, 1, 2, 3, 4]; - let vc = [0, 1, 2, 3, 4]; - - // Matching arrays by value: - m!(v.clone(), [N(0), sub @ .., N(4)] => c!(sub, [N; 3], n![1, 2, 3])); - m!(v.clone(), [N(0), sub @ ..] => c!(sub, [N; 4], n![1, 2, 3, 4])); - m!(v.clone(), [sub @ .., N(4)] => c!(sub, [N; 4], n![0, 1, 2, 3])); - m!(v.clone(), [sub @ .., _, _, _, _, _] => c!(sub, [N; 0], n![] as [N; 0])); - m!(v.clone(), [_, _, _, _, _, sub @ ..] => c!(sub, [N; 0], n![] as [N; 0])); - m!(v.clone(), [x, .., y] => c!((x, y), (N, N), (N(0), N(4)))); - m!(v.clone(), [..] => ()); - - // Matching arrays by ref patterns: - m!(v, [N(0), ref sub @ .., N(4)] => c!(sub, &[N; 3], &n![1, 2, 3])); - m!(v, [N(0), ref sub @ ..] => c!(sub, &[N; 4], &n![1, 2, 3, 4])); - m!(v, [ref sub @ .., N(4)] => c!(sub, &[N; 4], &n![0, 1, 2, 3])); - m!(v, [ref sub @ .., _, _, _, _, _] => c!(sub, &[N; 0], &n![] as &[N; 0])); - m!(v, [_, _, _, _, _, ref sub @ ..] => c!(sub, &[N; 0], &n![] as &[N; 0])); - m!(vc, [x, .., y] => c!((x, y), (u8, u8), (0, 4))); - - // Matching arrays by ref mut patterns: - m!(v, [N(0), ref mut sub @ .., N(4)] => c!(sub, &mut [N; 3], &mut n![1, 2, 3])); - m!(v, [N(0), ref mut sub @ ..] => c!(sub, &mut [N; 4], &mut n![1, 2, 3, 4])); - m!(v, [ref mut sub @ .., N(4)] => c!(sub, &mut [N; 4], &mut n![0, 1, 2, 3])); - m!(v, [ref mut sub @ .., _, _, _, _, _] => c!(sub, &mut [N; 0], &mut n![] as &mut [N; 0])); - m!(v, [_, _, _, _, _, ref mut sub @ ..] => c!(sub, &mut [N; 0], &mut n![] as &mut [N; 0])); - - // Matching arrays by default binding modes (&): - m!(&v, [N(0), sub @ .., N(4)] => c!(sub, &[N; 3], &n![1, 2, 3])); - m!(&v, [N(0), sub @ ..] => c!(sub, &[N; 4], &n![1, 2, 3, 4])); - m!(&v, [sub @ .., N(4)] => c!(sub, &[N; 4], &n![0, 1, 2, 3])); - m!(&v, [sub @ .., _, _, _, _, _] => c!(sub, &[N; 0], &n![] as &[N; 0])); - m!(&v, [_, _, _, _, _, sub @ ..] => c!(sub, &[N; 0], &n![] as &[N; 0])); - m!(&v, [..] => ()); - m!(&v, [x, .., y] => c!((x, y), (&N, &N), (&N(0), &N(4)))); - - // Matching arrays by default binding modes (&mut): - m!(&mut v, [N(0), sub @ .., N(4)] => c!(sub, &mut [N; 3], &mut n![1, 2, 3])); - m!(&mut v, [N(0), sub @ ..] => c!(sub, &mut [N; 4], &mut n![1, 2, 3, 4])); - m!(&mut v, [sub @ .., N(4)] => c!(sub, &mut [N; 4], &mut n![0, 1, 2, 3])); - m!(&mut v, [sub @ .., _, _, _, _, _] => c!(sub, &mut [N; 0], &mut n![] as &[N; 0])); - m!(&mut v, [_, _, _, _, _, sub @ ..] => c!(sub, &mut [N; 0], &mut n![] as &[N; 0])); - m!(&mut v, [..] => ()); - m!(&mut v, [x, .., y] => c!((x, y), (&mut N, &mut N), (&mut N(0), &mut N(4)))); -} diff --git a/src/test/ui/array-slice-vec/vec-macro-repeat.rs b/src/test/ui/array-slice-vec/vec-macro-repeat.rs deleted file mode 100644 index 7be8dadbe17..00000000000 --- a/src/test/ui/array-slice-vec/vec-macro-repeat.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass - - - -pub fn main() { - assert_eq!(vec![1; 3], vec![1, 1, 1]); - assert_eq!(vec![1; 2], vec![1, 1]); - assert_eq!(vec![1; 1], vec![1]); - assert_eq!(vec![1; 0], vec![]); - - // from_elem syntax (see RFC 832) - let el = Box::new(1); - let n = 3; - assert_eq!(vec![el; n], vec![Box::new(1), Box::new(1), Box::new(1)]); -} diff --git a/src/test/ui/async-await/issues/issue-78654.full.stderr b/src/test/ui/async-await/issues/issue-78654.full.stderr new file mode 100644 index 00000000000..ff0260523db --- /dev/null +++ b/src/test/ui/async-await/issues/issue-78654.full.stderr @@ -0,0 +1,19 @@ +error[E0573]: expected type, found built-in attribute `feature` + --> $DIR/issue-78654.rs:10:15 + | +LL | impl<const H: feature> Foo { + | ^^^^^^^ not a type + +error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates + --> $DIR/issue-78654.rs:10:12 + | +LL | impl<const H: feature> Foo { + | ^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0207, E0573. +For more information about an error, try `rustc --explain E0207`. diff --git a/src/test/ui/async-await/issues/issue-78654.min.stderr b/src/test/ui/async-await/issues/issue-78654.min.stderr new file mode 100644 index 00000000000..ff0260523db --- /dev/null +++ b/src/test/ui/async-await/issues/issue-78654.min.stderr @@ -0,0 +1,19 @@ +error[E0573]: expected type, found built-in attribute `feature` + --> $DIR/issue-78654.rs:10:15 + | +LL | impl<const H: feature> Foo { + | ^^^^^^^ not a type + +error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates + --> $DIR/issue-78654.rs:10:12 + | +LL | impl<const H: feature> Foo { + | ^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0207, E0573. +For more information about an error, try `rustc --explain E0207`. diff --git a/src/test/ui/async-await/issues/issue-78654.rs b/src/test/ui/async-await/issues/issue-78654.rs new file mode 100644 index 00000000000..b57ed35f8e3 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-78654.rs @@ -0,0 +1,16 @@ +// edition:2018 +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] + +struct Foo; + +impl<const H: feature> Foo { +//~^ ERROR: expected type, found built-in attribute `feature` +//~^^ ERROR: the const parameter `H` is not constrained by the impl trait, self type, or predicates + async fn biz() {} +} + +fn main() {} diff --git a/src/test/ui/consts/dangling-alloc-id-ice.rs b/src/test/ui/consts/dangling-alloc-id-ice.rs index 3b7f1de5b9b..95acacdb787 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.rs +++ b/src/test/ui/consts/dangling-alloc-id-ice.rs @@ -6,7 +6,7 @@ union Foo<'a> { long_live_the_unit: &'static (), } -const FOO: &() = { //~ ERROR it is undefined behavior to use this value +const FOO: &() = { //~^ ERROR encountered dangling pointer in final constant let y = (); unsafe { Foo { y: &y }.long_live_the_unit } diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr index 14a49810b9d..24f57449872 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.stderr +++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr @@ -8,18 +8,5 @@ LL | | unsafe { Foo { y: &y }.long_live_the_unit } LL | | }; | |__^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/dangling-alloc-id-ice.rs:9:1 - | -LL | / const FOO: &() = { -LL | | -LL | | let y = (); -LL | | unsafe { Foo { y: &y }.long_live_the_unit } -LL | | }; - | |__^ type validation failed: encountered a dangling reference (use-after-free) - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/issue-78655.rs b/src/test/ui/consts/issue-78655.rs new file mode 100644 index 00000000000..066764bc46f --- /dev/null +++ b/src/test/ui/consts/issue-78655.rs @@ -0,0 +1,10 @@ +const FOO: *const u32 = { //~ ERROR encountered dangling pointer in final constant + let x; + &x //~ ERROR borrow of possibly-uninitialized variable: `x` +}; + +fn main() { + let FOO = FOO; + //~^ ERROR could not evaluate constant pattern + //~| ERROR could not evaluate constant pattern +} diff --git a/src/test/ui/consts/issue-78655.stderr b/src/test/ui/consts/issue-78655.stderr new file mode 100644 index 00000000000..cf3fe18f802 --- /dev/null +++ b/src/test/ui/consts/issue-78655.stderr @@ -0,0 +1,30 @@ +error[E0381]: borrow of possibly-uninitialized variable: `x` + --> $DIR/issue-78655.rs:3:5 + | +LL | &x + | ^^ use of possibly-uninitialized `x` + +error: encountered dangling pointer in final constant + --> $DIR/issue-78655.rs:1:1 + | +LL | / const FOO: *const u32 = { +LL | | let x; +LL | | &x +LL | | }; + | |__^ + +error: could not evaluate constant pattern + --> $DIR/issue-78655.rs:7:9 + | +LL | let FOO = FOO; + | ^^^ + +error: could not evaluate constant pattern + --> $DIR/issue-78655.rs:7:9 + | +LL | let FOO = FOO; + | ^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/format-nan.rs b/src/test/ui/format-nan.rs deleted file mode 100644 index e4a134fa2fb..00000000000 --- a/src/test/ui/format-nan.rs +++ /dev/null @@ -1,9 +0,0 @@ -// run-pass - -pub fn main() { - use std::f64; - let x = "NaN".to_string(); - assert_eq!(format!("{}", f64::NAN), x); - assert_eq!(format!("{:e}", f64::NAN), x); - assert_eq!(format!("{:E}", f64::NAN), x); -} diff --git a/src/test/ui/range.rs b/src/test/ui/range.rs deleted file mode 100644 index f3f7508d124..00000000000 --- a/src/test/ui/range.rs +++ /dev/null @@ -1,51 +0,0 @@ -// run-pass -#![allow(unused_braces)] -#![allow(unused_comparisons)] -#![allow(dead_code)] -#![allow(unused_mut)] -// Test range syntax. - - -fn foo() -> isize { 42 } - -// Test that range syntax works in return statements -fn return_range_to() -> ::std::ops::RangeTo<i32> { return ..1; } -fn return_full_range() -> ::std::ops::RangeFull { return ..; } - -pub fn main() { - let mut count = 0; - for i in 0_usize..10 { - assert!(i >= 0 && i < 10); - count += i; - } - assert_eq!(count, 45); - - let mut count = 0; - let mut range = 0_usize..10; - for i in range { - assert!(i >= 0 && i < 10); - count += i; - } - assert_eq!(count, 45); - - let mut count = 0; - let mut rf = 3_usize..; - for i in rf.take(10) { - assert!(i >= 3 && i < 13); - count += i; - } - assert_eq!(count, 75); - - let _ = 0_usize..4+4-3; - let _ = 0..foo(); - - let _ = { &42..&100 }; // references to literals are OK - let _ = ..42_usize; - - // Test we can use two different types with a common supertype. - let x = &42; - { - let y = 42; - let _ = x..&y; - } -} diff --git a/src/test/ui/swap-2.rs b/src/test/ui/swap-2.rs deleted file mode 100644 index c8f298ec0e5..00000000000 --- a/src/test/ui/swap-2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -use std::mem::swap; - -pub fn main() { - let mut a: Vec<isize> = vec![0, 1, 2, 3, 4, 5, 6]; - a.swap(2, 4); - assert_eq!(a[2], 4); - assert_eq!(a[4], 2); - let mut n = 42; - swap(&mut n, &mut a[0]); - assert_eq!(a[0], 42); - assert_eq!(n, 0); -} diff --git a/src/test/ui/zero-sized/zero-sized-vec-deque-push.rs b/src/test/ui/zero-sized/zero-sized-vec-deque-push.rs deleted file mode 100644 index c541208703b..00000000000 --- a/src/test/ui/zero-sized/zero-sized-vec-deque-push.rs +++ /dev/null @@ -1,32 +0,0 @@ -// run-pass -use std::collections::VecDeque; -use std::iter::Iterator; - -fn main() { - const N: usize = 8; - - // Zero sized type - struct Zst; - - // Test that for all possible sequences of push_front / push_back, - // we end up with a deque of the correct size - - for len in 0..N { - let mut tester = VecDeque::with_capacity(len); - assert_eq!(tester.len(), 0); - assert!(tester.capacity() >= len); - for case in 0..(1 << len) { - assert_eq!(tester.len(), 0); - for bit in 0..len { - if case & (1 << bit) != 0 { - tester.push_front(Zst); - } else { - tester.push_back(Zst); - } - } - assert_eq!(tester.len(), len); - assert_eq!(tester.iter().count(), len); - tester.clear(); - } - } -} diff --git a/src/test/ui/zero-sized/zero-sized-vec-push.rs b/src/test/ui/zero-sized/zero-sized-vec-push.rs deleted file mode 100644 index 9e9fbc972d5..00000000000 --- a/src/test/ui/zero-sized/zero-sized-vec-push.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-pass -#![allow(unused_variables)] -use std::iter::Iterator; -use std::vec::Vec; - -fn main() { - const N: usize = 8; - - for len in 0..N { - let mut tester = Vec::with_capacity(len); - assert_eq!(tester.len(), 0); - assert!(tester.capacity() >= len); - for bit in 0..len { - tester.push(()); - } - assert_eq!(tester.len(), len); - assert_eq!(tester.iter().count(), len); - tester.clear(); - } -} |
