diff options
| author | bors <bors@rust-lang.org> | 2019-12-11 09:12:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-11 09:12:06 +0000 |
| commit | 033662dfbca088937b9cdfd3d9584015b5e375b2 (patch) | |
| tree | 2ef62b3f6d4746ca251307c5543a7f066ada1fa3 /src/test | |
| parent | ddca1e09c36a6ce21d95fec1619f23ba59b69c8a (diff) | |
| parent | f6ceef546b9b008afd12fafa742783c570a18aa8 (diff) | |
| download | rust-033662dfbca088937b9cdfd3d9584015b5e375b2.tar.gz rust-033662dfbca088937b9cdfd3d9584015b5e375b2.zip | |
Auto merge of #67220 - Centril:rollup-n3u9wd5, r=Centril
Rollup of 6 pull requests Successful merges: - #66881 (Optimize Ord trait implementation for bool) - #67015 (Fix constant propagation for scalar pairs) - #67074 (Add options to --extern flag.) - #67164 (Ensure that panicking in constants eventually errors) - #67174 (Remove `checked_add` in `Layout::repeat`) - #67205 (Make `publish_toolstate.sh` executable) Failed merges: r? @ghost
Diffstat (limited to 'src/test')
23 files changed, 347 insertions, 9 deletions
diff --git a/src/test/codegen/bool-cmp.rs b/src/test/codegen/bool-cmp.rs new file mode 100644 index 00000000000..8769a4cb5e1 --- /dev/null +++ b/src/test/codegen/bool-cmp.rs @@ -0,0 +1,17 @@ +// This is a test for optimal Ord trait implementation for bool. +// See <https://github.com/rust-lang/rust/issues/66780> for more info. + +// compile-flags: -C opt-level=3 + +#![crate_type = "lib"] + +use std::cmp::Ordering; + +// CHECK-LABEL: @cmp_bool +#[no_mangle] +pub fn cmp_bool(a: bool, b: bool) -> Ordering { +// CHECK: zext i1 +// CHECK: zext i1 +// CHECK: sub nsw + a.cmp(&b) +} diff --git a/src/test/mir-opt/const_prop/issue-66971.rs b/src/test/mir-opt/const_prop/issue-66971.rs new file mode 100644 index 00000000000..30c75303b3e --- /dev/null +++ b/src/test/mir-opt/const_prop/issue-66971.rs @@ -0,0 +1,38 @@ +// compile-flags: -Z mir-opt-level=2 + +// Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected +// outputs below, after ConstProp this is how _2 would look like with the bug: +// +// _2 = (const Scalar(0x00) : (), const 0u8); +// +// Which has the wrong type. + +fn encode(this: ((), u8, u8)) { + assert!(this.2 == 0); +} + +fn main() { + encode(((), 0, 0)); +} + +// END RUST SOURCE +// START rustc.main.ConstProp.before.mir +// bb0: { +// ... +// _3 = (); +// _2 = (move _3, const 0u8, const 0u8); +// ... +// _1 = const encode(move _2) -> bb1; +// ... +// } +// END rustc.main.ConstProp.before.mir +// START rustc.main.ConstProp.after.mir +// bb0: { +// ... +// _3 = const Scalar(<ZST>) : (); +// _2 = (move _3, const 0u8, const 0u8); +// ... +// _1 = const encode(move _2) -> bb1; +// ... +// } +// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/issue-67019.rs b/src/test/mir-opt/const_prop/issue-67019.rs new file mode 100644 index 00000000000..c6d753a1209 --- /dev/null +++ b/src/test/mir-opt/const_prop/issue-67019.rs @@ -0,0 +1,34 @@ +// compile-flags: -Z mir-opt-level=2 + +// This used to ICE in const-prop + +fn test(this: ((u8, u8),)) { + assert!((this.0).0 == 1); +} + +fn main() { + test(((1, 2),)); +} + +// Important bit is parameter passing so we only check that below +// END RUST SOURCE +// START rustc.main.ConstProp.before.mir +// bb0: { +// ... +// _3 = (const 1u8, const 2u8); +// _2 = (move _3,); +// ... +// _1 = const test(move _2) -> bb1; +// ... +// } +// END rustc.main.ConstProp.before.mir +// START rustc.main.ConstProp.after.mir +// bb0: { +// ... +// _3 = (const 1u8, const 2u8); +// _2 = (move _3,); +// ... +// _1 = const test(move _2) -> bb1; +// ... +// } +// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/retain-never-const.rs b/src/test/mir-opt/retain-never-const.rs new file mode 100644 index 00000000000..5d59b2f4842 --- /dev/null +++ b/src/test/mir-opt/retain-never-const.rs @@ -0,0 +1,28 @@ +// Regression test for #66975 - ensure that we don't keep unevaluated +// `!`-typed constants until codegen. + +// Force generation of optimized mir for functions that do not reach codegen. +// compile-flags: --emit mir,link + +#![feature(const_panic)] + +struct PrintName<T>(T); + +impl<T> PrintName<T> { + const VOID: ! = panic!(); +} + +fn no_codegen<T>() { + let _ = PrintName::<T>::VOID; +} + +fn main() {} + +// END RUST SOURCE +// START rustc.no_codegen.PreCodegen.after.mir +// bb0: { +// StorageLive(_1); +// _1 = const PrintName::<T>::VOID; +// unreachable; +// } +// END rustc.no_codegen.PreCodegen.after.mir diff --git a/src/test/rustdoc/issue-66159.rs b/src/test/rustdoc/issue-66159.rs index a69ba61a283..003d079a470 100644 --- a/src/test/rustdoc/issue-66159.rs +++ b/src/test/rustdoc/issue-66159.rs @@ -1,6 +1,5 @@ -// aux-build:issue-66159-1.rs +// aux-crate:priv:issue_66159_1=issue-66159-1.rs // compile-flags:-Z unstable-options -// extern-private:issue_66159_1 // The issue was an ICE which meant that we never actually generated the docs // so if we have generated the docs, we're okay. diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs new file mode 100644 index 00000000000..516ca4f3f77 --- /dev/null +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -0,0 +1,18 @@ +// Regression test for #66975 +#![warn(const_err)] + +struct PrintName<T>(T); + +impl<T> PrintName<T> { + const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] }; + //~^ WARN any use of this value will cause an error +} + +fn f<T>() { + let _ = PrintName::<T>::VOID; + //~^ ERROR erroneous constant encountered +} + +pub fn main() { + f::<()>(); +} diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr new file mode 100644 index 00000000000..e2bd8d0cc85 --- /dev/null +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -0,0 +1,22 @@ +warning: any use of this value will cause an error + --> $DIR/index-out-of-bounds-never-type.rs:7:61 + | +LL | const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] }; + | --------------------------------------------------------^^^^^--- + | | + | index out of bounds: the len is 0 but the index is 0 + | +note: lint level defined here + --> $DIR/index-out-of-bounds-never-type.rs:2:9 + | +LL | #![warn(const_err)] + | ^^^^^^^^^ + +error: erroneous constant encountered + --> $DIR/index-out-of-bounds-never-type.rs:12:13 + | +LL | let _ = PrintName::<T>::VOID; + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs new file mode 100644 index 00000000000..b39d9af5546 --- /dev/null +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -0,0 +1,15 @@ +// Regression test for #66975 +#![warn(const_err)] +#![feature(const_panic)] + +struct PrintName; + +impl PrintName { + const VOID: ! = panic!(); + //~^ WARN any use of this value will cause an error +} + +fn main() { + let _ = PrintName::VOID; + //~^ ERROR erroneous constant used +} diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr new file mode 100644 index 00000000000..c07c8c65a2f --- /dev/null +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -0,0 +1,24 @@ +warning: any use of this value will cause an error + --> $DIR/panic-assoc-never-type.rs:8:21 + | +LL | const VOID: ! = panic!(); + | ----------------^^^^^^^^- + | | + | the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:8:21 + | +note: lint level defined here + --> $DIR/panic-assoc-never-type.rs:2:9 + | +LL | #![warn(const_err)] + | ^^^^^^^^^ + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0080]: erroneous constant used + --> $DIR/panic-assoc-never-type.rs:13:13 + | +LL | let _ = PrintName::VOID; + | ^^^^^^^^^^^^^^^ referenced constant has errors + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs new file mode 100644 index 00000000000..42eabbf5847 --- /dev/null +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -0,0 +1,11 @@ +// Regression test for #66975 +#![warn(const_err)] +#![feature(const_panic)] + +const VOID: ! = panic!(); +//~^ WARN any use of this value will cause an error + +fn main() { + let _ = VOID; + //~^ ERROR erroneous constant used +} diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr new file mode 100644 index 00000000000..4fb11a61525 --- /dev/null +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -0,0 +1,24 @@ +warning: any use of this value will cause an error + --> $DIR/panic-never-type.rs:5:17 + | +LL | const VOID: ! = panic!(); + | ----------------^^^^^^^^- + | | + | the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:5:17 + | +note: lint level defined here + --> $DIR/panic-never-type.rs:2:9 + | +LL | #![warn(const_err)] + | ^^^^^^^^^ + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0080]: erroneous constant used + --> $DIR/panic-never-type.rs:9:13 + | +LL | let _ = VOID; + | ^^^^ referenced constant has errors + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/extern-flag/auxiliary/somedep.rs b/src/test/ui/extern-flag/auxiliary/somedep.rs new file mode 100644 index 00000000000..dd2f373f849 --- /dev/null +++ b/src/test/ui/extern-flag/auxiliary/somedep.rs @@ -0,0 +1,3 @@ +pub fn somefun() {} + +pub struct S; diff --git a/src/test/ui/extern-flag/multiple-opts.rs b/src/test/ui/extern-flag/multiple-opts.rs new file mode 100644 index 00000000000..3dc2f1d73f8 --- /dev/null +++ b/src/test/ui/extern-flag/multiple-opts.rs @@ -0,0 +1,20 @@ +// aux-crate:priv,noprelude:somedep=somedep.rs +// compile-flags: -Zunstable-options +// edition:2018 + +// Test for multiple options to --extern. Can't test for errors from both +// options at the same time, so this only checks that noprelude is honored. + +#![warn(exported_private_dependencies)] + +// Module to avoid adding to prelude. +pub mod m { + extern crate somedep; + pub struct PublicType { + pub field: somedep::S, + } +} + +fn main() { + somedep::somefun(); //~ ERROR failed to resolve +} diff --git a/src/test/ui/extern-flag/multiple-opts.stderr b/src/test/ui/extern-flag/multiple-opts.stderr new file mode 100644 index 00000000000..3bf73d11cfd --- /dev/null +++ b/src/test/ui/extern-flag/multiple-opts.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: use of undeclared type or module `somedep` + --> $DIR/multiple-opts.rs:19:5 + | +LL | somedep::somefun(); + | ^^^^^^^ use of undeclared type or module `somedep` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/extern-flag/noprelude-and-prelude.rs b/src/test/ui/extern-flag/noprelude-and-prelude.rs new file mode 100644 index 00000000000..e6a150b9e8b --- /dev/null +++ b/src/test/ui/extern-flag/noprelude-and-prelude.rs @@ -0,0 +1,10 @@ +// check-pass +// aux-crate:noprelude:somedep=somedep.rs +// compile-flags: -Zunstable-options --extern somedep +// edition:2018 + +// Having a flag with `noprelude` and one without, will add to the prelude. + +fn main() { + somedep::somefun(); +} diff --git a/src/test/ui/extern-flag/noprelude-resolves.rs b/src/test/ui/extern-flag/noprelude-resolves.rs new file mode 100644 index 00000000000..f69f552b69d --- /dev/null +++ b/src/test/ui/extern-flag/noprelude-resolves.rs @@ -0,0 +1,11 @@ +// check-pass +// aux-crate:noprelude:somedep=somedep.rs +// compile-flags: -Zunstable-options +// edition:2018 + +// `extern crate` can be used to add to prelude. +extern crate somedep; + +fn main() { + somedep::somefun(); +} diff --git a/src/test/ui/extern-flag/noprelude.rs b/src/test/ui/extern-flag/noprelude.rs new file mode 100644 index 00000000000..cdbf3409100 --- /dev/null +++ b/src/test/ui/extern-flag/noprelude.rs @@ -0,0 +1,7 @@ +// aux-crate:noprelude:somedep=somedep.rs +// compile-flags: -Zunstable-options +// edition:2018 + +fn main() { + somedep::somefun(); //~ ERROR failed to resolve +} diff --git a/src/test/ui/extern-flag/noprelude.stderr b/src/test/ui/extern-flag/noprelude.stderr new file mode 100644 index 00000000000..beb9200ddda --- /dev/null +++ b/src/test/ui/extern-flag/noprelude.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: use of undeclared type or module `somedep` + --> $DIR/noprelude.rs:6:5 + | +LL | somedep::somefun(); + | ^^^^^^^ use of undeclared type or module `somedep` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/extern-flag/public-and-private.rs b/src/test/ui/extern-flag/public-and-private.rs new file mode 100644 index 00000000000..a3a81cbf372 --- /dev/null +++ b/src/test/ui/extern-flag/public-and-private.rs @@ -0,0 +1,13 @@ +// aux-crate:priv:somedep=somedep.rs +// compile-flags: -Zunstable-options --extern somedep +// edition:2018 + +#![deny(exported_private_dependencies)] + +// Having a flag with `priv` and one without, will remain private (it is sticky). + +pub struct PublicType { + pub field: somedep::S, //~ ERROR from private dependency +} + +fn main() {} diff --git a/src/test/ui/extern-flag/public-and-private.stderr b/src/test/ui/extern-flag/public-and-private.stderr new file mode 100644 index 00000000000..72f1bb2d26f --- /dev/null +++ b/src/test/ui/extern-flag/public-and-private.stderr @@ -0,0 +1,14 @@ +error: type `somedep::S` from private dependency 'somedep' in public interface + --> $DIR/public-and-private.rs:10:5 + | +LL | pub field: somedep::S, + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/public-and-private.rs:5:9 + | +LL | #![deny(exported_private_dependencies)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/mir/issue66339.rs b/src/test/ui/mir/issue66339.rs new file mode 100644 index 00000000000..98e178c0551 --- /dev/null +++ b/src/test/ui/mir/issue66339.rs @@ -0,0 +1,13 @@ +// compile-flags: -Z mir-opt-level=2 +// build-pass + +// This used to ICE in const-prop + +fn foo() { + let bar = |_| { }; + let _ = bar("a"); +} + +fn main() { + foo(); +} diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs index 784615354a9..feab72b3efa 100644 --- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs @@ -1,11 +1,10 @@ - // aux-build:priv_dep.rs + // aux-crate:priv:priv_dep=priv_dep.rs // aux-build:pub_dep.rs - // extern-private:priv_dep #![deny(exported_private_dependencies)] // This crate is a private dependency extern crate priv_dep; -// This crate is a public dependenct +// This crate is a public dependency extern crate pub_dep; use priv_dep::{OtherType, OtherTrait}; diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr index b31efdbd781..f21b11f5b32 100644 --- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr @@ -1,23 +1,23 @@ error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:21:5 + --> $DIR/pub-priv1.rs:20:5 | LL | pub field: OtherType, | ^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/pub-priv1.rs:4:9 + --> $DIR/pub-priv1.rs:3:9 | LL | #![deny(exported_private_dependencies)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:28:5 + --> $DIR/pub-priv1.rs:27:5 | LL | pub fn pub_fn(param: OtherType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:34:1 + --> $DIR/pub-priv1.rs:33:1 | LL | / pub trait MyPubTrait { LL | | type Foo: OtherTrait; |
