diff options
| author | bors <bors@rust-lang.org> | 2021-03-19 23:53:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-19 23:53:02 +0000 |
| commit | 6bfbf0c33a86707cedd02ca985285191282a80b3 (patch) | |
| tree | 3379b7c53a90fdbb23ef8c041ae4a8eb0b1955fe /src/test | |
| parent | f5f33ec0e0455eefa72fc5567eb1280a4d5ee206 (diff) | |
| parent | 51a29cbb23d2146322350fbfde53fe9523e554fb (diff) | |
| download | rust-6bfbf0c33a86707cedd02ca985285191282a80b3.tar.gz rust-6bfbf0c33a86707cedd02ca985285191282a80b3.zip | |
Auto merge of #83308 - Dylan-DPC:rollup-p2j6sy8, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #79986 (Only build help popup when it's really needed) - #82570 (Add `as_str` method for split whitespace str iterators) - #83244 (Fix overflowing length in Vec<ZST> to VecDeque) - #83254 (Include output stream in `panic!()` documentation) - #83269 (Revert the second deprecation of collections::Bound) - #83277 (Mark early otherwise optimization unsound) - #83285 (Update LLVM to bring in SIMD updates for WebAssembly) - #83297 (Do not ICE on ty::Error as an error must already have been reported) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/mir-opt/early_otherwise_branch.rs | 2 | ||||
| -rw-r--r-- | src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/const-generics/type_mismatch.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/const-generics/type_mismatch.stderr | 23 | ||||
| -rw-r--r-- | src/test/ui/const-generics/type_not_in_scope.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/const-generics/type_not_in_scope.stderr | 24 |
6 files changed, 69 insertions, 2 deletions
diff --git a/src/test/mir-opt/early_otherwise_branch.rs b/src/test/mir-opt/early_otherwise_branch.rs index 548213ab83c..b2caf7d7b8f 100644 --- a/src/test/mir-opt/early_otherwise_branch.rs +++ b/src/test/mir-opt/early_otherwise_branch.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=4 +// compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts // EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff fn opt1(x: Option<u32>, y: Option<u32>) -> u32 { match (x, y) { diff --git a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs index aa304f747f7..8527c01d756 100644 --- a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs +++ b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=4 +// compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts // EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff fn opt1(x: Option<u32>, y: Option<u32>, z: Option<u32>) -> u32 { diff --git a/src/test/ui/const-generics/type_mismatch.rs b/src/test/ui/const-generics/type_mismatch.rs new file mode 100644 index 00000000000..4a7534e3713 --- /dev/null +++ b/src/test/ui/const-generics/type_mismatch.rs @@ -0,0 +1,9 @@ +fn foo<const N: usize>() -> [u8; N] { + bar::<N>() //~ ERROR mismatched types +} + +fn bar<const N: u8>() -> [u8; N] {} +//~^ ERROR mismatched types +//~| ERROR mismatched types + +fn main() {} diff --git a/src/test/ui/const-generics/type_mismatch.stderr b/src/test/ui/const-generics/type_mismatch.stderr new file mode 100644 index 00000000000..f5053e4c8c8 --- /dev/null +++ b/src/test/ui/const-generics/type_mismatch.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/type_mismatch.rs:2:11 + | +LL | bar::<N>() + | ^ expected `u8`, found `usize` + +error[E0308]: mismatched types + --> $DIR/type_mismatch.rs:5:31 + | +LL | fn bar<const N: u8>() -> [u8; N] {} + | ^ expected `usize`, found `u8` + +error[E0308]: mismatched types + --> $DIR/type_mismatch.rs:5:26 + | +LL | fn bar<const N: u8>() -> [u8; N] {} + | --- ^^^^^^^ expected array `[u8; N]`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/type_not_in_scope.rs b/src/test/ui/const-generics/type_not_in_scope.rs new file mode 100644 index 00000000000..5933701808b --- /dev/null +++ b/src/test/ui/const-generics/type_not_in_scope.rs @@ -0,0 +1,11 @@ +impl X { + //~^ ERROR cannot find type + fn getn<const N: usize>() -> [u8; N] { + getn::<N>() + } +} +fn getn<const N: cfg_attr>() -> [u8; N] {} +//~^ ERROR expected type, found built-in attribute `cfg_attr` +//~| ERROR mismatched types + +fn main() {} diff --git a/src/test/ui/const-generics/type_not_in_scope.stderr b/src/test/ui/const-generics/type_not_in_scope.stderr new file mode 100644 index 00000000000..16796acb3d2 --- /dev/null +++ b/src/test/ui/const-generics/type_not_in_scope.stderr @@ -0,0 +1,24 @@ +error[E0412]: cannot find type `X` in this scope + --> $DIR/type_not_in_scope.rs:1:6 + | +LL | impl X { + | ^ not found in this scope + +error[E0573]: expected type, found built-in attribute `cfg_attr` + --> $DIR/type_not_in_scope.rs:7:18 + | +LL | fn getn<const N: cfg_attr>() -> [u8; N] {} + | ^^^^^^^^ not a type + +error[E0308]: mismatched types + --> $DIR/type_not_in_scope.rs:7:33 + | +LL | fn getn<const N: cfg_attr>() -> [u8; N] {} + | ---- ^^^^^^^ expected array `[u8; N]`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0308, E0412, E0573. +For more information about an error, try `rustc --explain E0308`. |
