diff options
| author | bors <bors@rust-lang.org> | 2020-08-08 15:57:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-08-08 15:57:12 +0000 |
| commit | 3f091baba4fa656adb4c1a57b64aa831002d801d (patch) | |
| tree | c2ada61f21cdbd927ef33d71d7608e40074e7e2a /src/test/ui/polymorphization | |
| parent | 2bac92bba14f3b260b337d2a51c77c0780456e65 (diff) | |
| parent | d97f89b1a6add41b6ac3c0d69cbe82d15483a0d6 (diff) | |
| download | rust-3f091baba4fa656adb4c1a57b64aa831002d801d.tar.gz rust-3f091baba4fa656adb4c1a57b64aa831002d801d.zip | |
Auto merge of #75260 - davidtwco:polymorphization-promoted-substs, r=lcnr
polymorphize: unevaluated constants This PR makes polymorphization visit the promoted MIR of unevaluated constants with available promoted MIR instead of visiting the substitutions of that constant - which will mark all of the generic parameters as used; in addition polymorphization will now visit non-promoted unevaluated constants rather than visit their substs. r? @lcnr
Diffstat (limited to 'src/test/ui/polymorphization')
7 files changed, 72 insertions, 2 deletions
diff --git a/src/test/ui/polymorphization/promoted-function-1.rs b/src/test/ui/polymorphization/promoted-function-1.rs new file mode 100644 index 00000000000..2cd02673442 --- /dev/null +++ b/src/test/ui/polymorphization/promoted-function-1.rs @@ -0,0 +1,12 @@ +// build-fail +// compile-flags: -Zpolymorphize=on +#![crate_type = "lib"] +#![feature(rustc_attrs)] + +fn foo<'a>(_: &'a ()) {} + +#[rustc_polymorphize_error] +pub fn test<T>() { + //~^ ERROR item has unused generic parameters + foo(&()); +} diff --git a/src/test/ui/polymorphization/promoted-function-1.stderr b/src/test/ui/polymorphization/promoted-function-1.stderr new file mode 100644 index 00000000000..fcbb8694923 --- /dev/null +++ b/src/test/ui/polymorphization/promoted-function-1.stderr @@ -0,0 +1,8 @@ +error: item has unused generic parameters + --> $DIR/promoted-function-1.rs:9:8 + | +LL | pub fn test<T>() { + | ^^^^ - generic parameter `T` is unused + +error: aborting due to previous error + diff --git a/src/test/ui/polymorphization/promoted-function-2.rs b/src/test/ui/polymorphization/promoted-function-2.rs new file mode 100644 index 00000000000..2831f861f55 --- /dev/null +++ b/src/test/ui/polymorphization/promoted-function-2.rs @@ -0,0 +1,16 @@ +// build-fail +// compile-flags:-Zpolymorphize=on +#![crate_type = "lib"] +#![feature(lazy_normalization_consts, rustc_attrs)] +//~^ WARN the feature `lazy_normalization_consts` is incomplete + +#[rustc_polymorphize_error] +fn test<T>() { + //~^ ERROR item has unused generic parameters + let x = [0; 3 + 4]; +} + +pub fn caller() { + test::<String>(); + test::<Vec<String>>(); +} diff --git a/src/test/ui/polymorphization/promoted-function-2.stderr b/src/test/ui/polymorphization/promoted-function-2.stderr new file mode 100644 index 00000000000..38d4808c48c --- /dev/null +++ b/src/test/ui/polymorphization/promoted-function-2.stderr @@ -0,0 +1,17 @@ +warning: the feature `lazy_normalization_consts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/promoted-function-2.rs:4:12 + | +LL | #![feature(lazy_normalization_consts, rustc_attrs)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #72219 <https://github.com/rust-lang/rust/issues/72219> for more information + +error: item has unused generic parameters + --> $DIR/promoted-function-2.rs:8:4 + | +LL | fn test<T>() { + | ^^^^ - generic parameter `T` is unused + +error: aborting due to previous error; 1 warning emitted + diff --git a/src/test/ui/polymorphization/promoted-function.rs b/src/test/ui/polymorphization/promoted-function.rs index 0d3af7a89c2..a56a8e70e4c 100644 --- a/src/test/ui/polymorphization/promoted-function.rs +++ b/src/test/ui/polymorphization/promoted-function.rs @@ -1,4 +1,6 @@ // run-pass +// compile-flags:-Zpolymorphize=on + fn fop<T>() {} fn bar<T>() -> &'static fn() { diff --git a/src/test/ui/polymorphization/unsized_cast.rs b/src/test/ui/polymorphization/unsized_cast.rs index b8facc16070..b803fec2ccf 100644 --- a/src/test/ui/polymorphization/unsized_cast.rs +++ b/src/test/ui/polymorphization/unsized_cast.rs @@ -17,6 +17,7 @@ fn foo<T: Default>() { fn foo2<T: Default>() { let _: T = Default::default(); (|| { + //~^ ERROR item has unused generic parameters let call: extern "rust-call" fn(_, _) = Fn::call; call(&|| {}, ()); //~^ ERROR item has unused generic parameters diff --git a/src/test/ui/polymorphization/unsized_cast.stderr b/src/test/ui/polymorphization/unsized_cast.stderr index d4727acca9a..b51cc5c719f 100644 --- a/src/test/ui/polymorphization/unsized_cast.stderr +++ b/src/test/ui/polymorphization/unsized_cast.stderr @@ -17,7 +17,7 @@ LL | (|| Box::new(|| {}) as Box<dyn Fn()>)(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: item has unused generic parameters - --> $DIR/unsized_cast.rs:21:15 + --> $DIR/unsized_cast.rs:22:15 | LL | fn foo2<T: Default>() { | - generic parameter `T` is unused @@ -25,5 +25,19 @@ LL | fn foo2<T: Default>() { LL | call(&|| {}, ()); | ^^^^^ -error: aborting due to 3 previous errors +error: item has unused generic parameters + --> $DIR/unsized_cast.rs:19:5 + | +LL | fn foo2<T: Default>() { + | - generic parameter `T` is unused +LL | let _: T = Default::default(); +LL | / (|| { +LL | | +LL | | let call: extern "rust-call" fn(_, _) = Fn::call; +LL | | call(&|| {}, ()); +LL | | +LL | | })(); + | |______^ + +error: aborting due to 4 previous errors |
