From 566012ebf2a0a3af5edd2fe5faaec54c8d197c59 Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Wed, 12 May 2021 11:45:23 +0200 Subject: [PATCH] Update wrong-number-of-args test to cover more edge cases --- src/test/ui/generics/wrong-number-of-args.rs | 182 +++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/src/test/ui/generics/wrong-number-of-args.rs b/src/test/ui/generics/wrong-number-of-args.rs index f061c581459..ec2ed9926e2 100644 --- a/src/test/ui/generics/wrong-number-of-args.rs +++ b/src/test/ui/generics/wrong-number-of-args.rs @@ -36,6 +36,10 @@ mod type_and_type { type D = Ty; //~^ ERROR this struct takes 2 generic arguments but 3 generic arguments //~| HELP remove this + + type E = Ty<>; + //~^ ERROR this struct takes 2 generic arguments but 0 generic arguments were supplied + //~| HELP add missing } mod lifetime_and_type { @@ -56,6 +60,12 @@ mod lifetime_and_type { //~| HELP consider introducing type D = Ty<'static, usize>; + + type E = Ty<>; + //~^ ERROR this struct takes 1 generic argument but 0 generic arguments + //~| ERROR missing lifetime specifier + //~| HELP consider introducing + //~| HELP add missing } mod type_and_type_and_type { @@ -76,6 +86,10 @@ mod type_and_type_and_type { type E = Ty; //~^ ERROR this struct takes at most 3 //~| HELP remove + + type F = Ty<>; + //~^ ERROR this struct takes at least 2 generic arguments but 0 generic arguments + //~| HELP add missing } // Traits have an implicit `Self` type - these tests ensure we don't accidentally return it @@ -112,6 +126,166 @@ mod r#trait { type E = Box>; //~^ ERROR this trait takes 1 generic argument but 2 generic arguments //~| HELP remove + + type F = Box>; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + + type G = Box>; + //~^ ERROR this trait takes 1 generic argument but 0 generic arguments + //~| HELP add missing +} + +mod associated_item { + mod non_generic { + trait NonGenericAT { + type AssocTy; + } + + type A = Box>; + //~^ ERROR this trait takes 0 generic arguments but 1 generic argument + //~| HELP remove + } + + mod lifetime { + trait GenericLifetimeAT<'a> { + type AssocTy; + } + + type A = Box>; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + + type B = Box>; + //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied + //~| HELP remove + + type C = Box>; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + //~| ERROR this trait takes 0 generic arguments but 1 generic argument + //~| HELP remove + } + + mod r#type { + trait GenericTypeAT { + type AssocTy; + } + + type A = Box>; + //~^ ERROR this trait takes 1 generic argument but 0 generic arguments + //~| HELP add missing + + type B = Box>; + //~^ ERROR this trait takes 1 generic argument but 2 generic arguments + //~| HELP remove + + type C = Box>; + //~^ ERROR this trait takes 1 generic argument but 0 generic arguments + //~| HELP add missing + //~| ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied + //~| HELP remove + } + + mod lifetime_and_type { + trait GenericLifetimeTypeAT<'a, A> { + type AssocTy; + } + + type A = Box>; + //~^ ERROR this trait takes 1 generic argument but 0 generic arguments + //~| HELP add missing + //~| ERROR missing lifetime specifier + //~| HELP consider introducing + + type B = Box>; + //~^ ERROR this trait takes 1 generic argument but 0 generic arguments were supplied + //~| HELP add missing + + type C = Box>; + //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied + //~| HELP remove + //~| ERROR this trait takes 1 generic argument but 0 generic arguments + //~| HELP add missing + + type D = Box>; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + + type E = Box>; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + //~| ERROR this trait takes 1 generic argument but 2 generic arguments + //~| HELP remove + + type F = Box>; + //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied + //~| HELP remove + + type G = Box>; + //~^ ERROR this trait takes 1 generic argument but 2 generic arguments + //~| HELP remove + + type H = Box>; + //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied + //~| HELP remove + //~| ERROR this trait takes 1 generic argument but 2 generic arguments + //~| HELP remove + } + + mod type_and_type { + trait GenericTypeTypeAT { + type AssocTy; + } + + type A = Box>; + //~^ ERROR this trait takes 2 generic arguments but 0 generic arguments + //~| HELP add missing + + type B = Box>; + //~^ ERROR this trait takes 2 generic arguments but 1 generic argument + //~| HELP add missing + + type C = Box>; + //~^ ERROR this trait takes 2 generic arguments but 3 generic arguments + //~| HELP remove + } + + mod lifetime_and_lifetime { + trait GenericLifetimeLifetimeAT<'a, 'b> { + type AssocTy; + } + + type A = Box>; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + + type B = Box>; + //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied + //~| HELP add missing lifetime argument + } + + mod lifetime_and_lifetime_and_type { + trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> { + type AssocTy; + } + + type A = Box>; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + //~| ERROR this trait takes 1 generic argument but 0 generic arguments + //~| HELP add missing + + type B = Box>; + //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied + //~| HELP add missing lifetime argument + //~| ERROR this trait takes 1 generic argument but 0 generic arguments + //~| HELP add missing + + type C = Box>; + //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied + //~| HELP add missing lifetime argument + } } mod stdlib { @@ -135,6 +309,10 @@ mod stdlib { type D = HashMap; //~^ ERROR this struct takes at most 3 //~| HELP remove this + + type E = HashMap<>; + //~^ ERROR this struct takes at least 2 generic arguments but 0 generic arguments + //~| HELP add missing } mod result { @@ -155,6 +333,10 @@ mod stdlib { type D = Result; //~^ ERROR this enum takes 2 generic arguments but 3 generic arguments //~| HELP remove + + type E = Result<>; + //~^ ERROR this enum takes 2 generic arguments but 0 generic arguments + //~| HELP add missing } }