From 5703b2863e1b4b815007b5a3380734634acd1f37 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 16 Aug 2020 16:35:38 +0100 Subject: polymorphize: ∃ used param ∈ predicate → all used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit 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. Signed-off-by: David Wood --- src/test/ui/polymorphization/predicates.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/test/ui/polymorphization') 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::() } +// Finally, check that `F` is considered used because `G` is used when neither are in the self-ty +// of the predicate. + +trait Foobar {} + +impl Foobar for () {} + +#[rustc_polymorphize_error] +fn foobar() -> usize +where + (): Foobar, +{ + std::mem::size_of::() +} + fn main() { let x = &[2u32]; foo(x.iter()); @@ -69,4 +84,6 @@ fn main() { let _ = a.next(); let _ = quux::(); + + let _ = foobar::(); } -- cgit 1.4.1-3-g733a5