From 5ba1895d3ffec561095af747095f0bec7a22d407 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 10 May 2019 20:53:21 +0100 Subject: [PATCH 1/6] Make const parent errors delay_span_bugs --- src/librustc_typeck/collect.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 0cd7fe9159493..00544e734a12a 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1403,7 +1403,13 @@ pub fn checked_type_of<'a, 'tcx>( if !fail { return None; } - bug!("unexpected const parent path def {:?}", x); + tcx.sess.delay_span_bug( + DUMMY_SP, + &format!( + "unexpected const parent path def {:?}", x + ), + ); + tcx.types.err } } } @@ -1411,7 +1417,13 @@ pub fn checked_type_of<'a, 'tcx>( if !fail { return None; } - bug!("unexpected const parent path {:?}", x); + tcx.sess.delay_span_bug( + DUMMY_SP, + &format!( + "unexpected const parent path {:?}", x + ), + ); + tcx.types.err } } } @@ -1420,7 +1432,13 @@ pub fn checked_type_of<'a, 'tcx>( if !fail { return None; } - bug!("unexpected const parent in type_of_def_id(): {:?}", x); + tcx.sess.delay_span_bug( + DUMMY_SP, + &format!( + "unexpected const parent in type_of_def_id(): {:?}", x + ), + ); + tcx.types.err } } } From ce90a9e5ee7206b65cedc5afb5e723a6aeb12f33 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 10 May 2019 20:53:35 +0100 Subject: [PATCH 2/6] Add a test for invalid const arguments --- .../invalid-const-arg-for-type-param.rs | 9 +++++++ .../invalid-const-arg-for-type-param.stderr | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/test/ui/const-generics/invalid-const-arg-for-type-param.rs create mode 100644 src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr 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 0000000000000..b069cd89680c1 --- /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 0000000000000..8f3f91651edfb --- /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 have detailed explanations: E0107, E0599. +For more information about an error, try `rustc --explain E0107`. From 1479f930fa695478e1113fb99435ac9cb58085d4 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 10 May 2019 20:53:46 +0100 Subject: [PATCH 3/6] Add a test for failed inference of const types --- .../cannot-infer-type-for-const-param.rs | 11 +++++++++++ .../cannot-infer-type-for-const-param.stderr | 15 +++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/test/ui/const-generics/cannot-infer-type-for-const-param.rs create mode 100644 src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr 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 0000000000000..c3f5e360fe280 --- /dev/null +++ b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs @@ -0,0 +1,11 @@ +#![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(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 0000000000000..a0641bd2fdc96 --- /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`. From 74f8f352c5c08560802db6cf216cd70f991c2c45 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 20 May 2019 11:54:02 +0200 Subject: [PATCH 4/6] disable the ui/const-generics/cannot-infer-type-for-const-param.rs test 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 --- .../ui/const-generics/cannot-infer-type-for-const-param.rs | 6 ++++++ 1 file changed, 6 insertions(+) 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 index c3f5e360fe280..7d546827c9d73 100644 --- 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 @@ -1,3 +1,9 @@ +// 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 From d097156df60bc699ac3737d4da1ab1acb2f134dc Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 20 May 2019 12:10:51 +0200 Subject: [PATCH 5/6] bless test output --- .../ui/const-generics/invalid-const-arg-for-type-param.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 8f3f91651edfb..1bd9865369371 100644 --- 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 @@ -21,5 +21,5 @@ LL | S::<0>; error: aborting due to 3 previous errors -Some errors have detailed explanations: E0107, E0599. +Some errors occurred: E0107, E0599. For more information about an error, try `rustc --explain E0107`. From d53e43528381da5102776648fa8c930bc492c4b9 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 20 May 2019 14:03:13 +0200 Subject: [PATCH 6/6] release rust 1.35.0 --- src/ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/run.sh b/src/ci/run.sh index 07e01b7e1e0fa..3606f54720832 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -43,7 +43,7 @@ fi # # FIXME: need a scheme for changing this `nightly` value to `beta` and `stable` # either automatically or manually. -export RUST_RELEASE_CHANNEL=beta +export RUST_RELEASE_CHANNEL=stable if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"