diff options
| author | bors <bors@rust-lang.org> | 2019-05-20 12:09:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-05-20 12:09:08 +0000 |
| commit | 3c235d5600393dfe6c36eeed34042efad8d4f26e (patch) | |
| tree | a00b084edd8ce8febb9b5906d031223e7b60c42d /src/test/ui | |
| parent | 02b0ca3adb6078217b34494bd94c6e35af988b5e (diff) | |
| parent | d53e43528381da5102776648fa8c930bc492c4b9 (diff) | |
| download | rust-1.35.0.tar.gz rust-1.35.0.zip | |
Auto merge of #60974 - pietroalbini:stable-next, r=pietroalbini 1.35.0
[stable] Rust 1.35.0 stable release This also cherry-picks this beta backport: * #60710: Use `delay_span_bug` for error cases when checking `AnonConst` parent r? @ghost cc @Mark-Simulacrum @rust-lang/release
Diffstat (limited to 'src/test/ui')
4 files changed, 66 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs new file mode 100644 index 00000000000..7d546827c9d --- /dev/null +++ b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs @@ -0,0 +1,17 @@ +// The test is failing on 1.35.0 stable but that's not important since the ICE happens only with +// the feature gate enabled, thus it doesn't affect stable. +// https://github.com/rust-lang/rust/pull/60710#issuecomment-493662676 +// +// ignore-test + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +// We should probably be able to infer the types here. However, this test is checking that we don't +// get an ICE in this case. It may be modified later to not be an error. + +struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]); + +fn main() { + let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed +} diff --git a/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr b/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr new file mode 100644 index 00000000000..a0641bd2fdc --- /dev/null +++ b/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr @@ -0,0 +1,15 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/cannot-infer-type-for-const-param.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + +error[E0282]: type annotations needed + --> $DIR/cannot-infer-type-for-const-param.rs:10:19 + | +LL | let _ = Foo::<3>([1, 2, 3]); + | ^ cannot infer type for `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/const-generics/invalid-const-arg-for-type-param.rs b/src/test/ui/const-generics/invalid-const-arg-for-type-param.rs new file mode 100644 index 00000000000..b069cd89680 --- /dev/null +++ b/src/test/ui/const-generics/invalid-const-arg-for-type-param.rs @@ -0,0 +1,9 @@ +use std::convert::TryInto; + +struct S; + +fn main() { + let _: u32 = 5i32.try_into::<32>().unwrap(); //~ ERROR wrong number of const arguments + S.f::<0>(); //~ ERROR no method named `f` + S::<0>; //~ ERROR wrong number of const arguments +} diff --git a/src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr b/src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr new file mode 100644 index 00000000000..1bd98653693 --- /dev/null +++ b/src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr @@ -0,0 +1,25 @@ +error[E0107]: wrong number of const arguments: expected 0, found 1 + --> $DIR/invalid-const-arg-for-type-param.rs:6:34 + | +LL | let _: u32 = 5i32.try_into::<32>().unwrap(); + | ^^ unexpected const argument + +error[E0599]: no method named `f` found for type `S` in the current scope + --> $DIR/invalid-const-arg-for-type-param.rs:7:7 + | +LL | struct S; + | --------- method `f` not found for this +... +LL | S.f::<0>(); + | ^ + +error[E0107]: wrong number of const arguments: expected 0, found 1 + --> $DIR/invalid-const-arg-for-type-param.rs:8:9 + | +LL | S::<0>; + | ^ unexpected const argument + +error: aborting due to 3 previous errors + +Some errors occurred: E0107, E0599. +For more information about an error, try `rustc --explain E0107`. |
