diff options
| author | bors <bors@rust-lang.org> | 2020-08-20 05:06:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-08-20 05:06:55 +0000 |
| commit | 1a22a0ff93d63f738151f096434e732466b4a42e (patch) | |
| tree | 6515b17120310b99d340ce4ddda3cd3fc6c61cca /src/test/ui/polymorphization | |
| parent | f6049b60dbbc267a69b5c5f1d335f8f54bac2173 (diff) | |
| parent | 5703b2863e1b4b815007b5a3380734634acd1f37 (diff) | |
| download | rust-1a22a0ff93d63f738151f096434e732466b4a42e.tar.gz rust-1a22a0ff93d63f738151f096434e732466b4a42e.zip | |
Auto merge of #75595 - davidtwco:polymorphization-predicate-simplification-correction, r=eddyb
polymorphize: if any param in a predicate is used, then all are used Addresses [review](https://github.com/rust-lang/rust/pull/75518#discussion_r470907646) [comments](https://github.com/rust-lang/rust/pull/75518#discussion_r470907865) [from](https://github.com/rust-lang/rust/pull/75518#discussion_r470908188) @eddyb in #75518 that I didn't get to resolve before bors merged. This PR modifies polymorphization's handling of predicates so that if any generic parameter is used in a predicate then all parameters in that predicate are used. r? @eddyb
Diffstat (limited to 'src/test/ui/polymorphization')
| -rw-r--r-- | src/test/ui/polymorphization/predicates.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/polymorphization/predicates.rs b/src/test/ui/polymorphization/predicates.rs index 60555dc12dc..97f1ef2c90a 100644 --- a/src/test/ui/polymorphization/predicates.rs +++ b/src/test/ui/polymorphization/predicates.rs @@ -60,6 +60,21 @@ where std::mem::size_of::<C>() } +// Finally, check that `F` is considered used because `G` is used when neither are in the self-ty +// of the predicate. + +trait Foobar<F, G> {} + +impl Foobar<u32, u32> for () {} + +#[rustc_polymorphize_error] +fn foobar<F, G>() -> usize +where + (): Foobar<F, G>, +{ + std::mem::size_of::<G>() +} + fn main() { let x = &[2u32]; foo(x.iter()); @@ -69,4 +84,6 @@ fn main() { let _ = a.next(); let _ = quux::<u8, u16, u32>(); + + let _ = foobar::<u32, u32>(); } |
