From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/generics/wrong-number-of-args.rs | 358 +++++++++++++++++++++++++++ 1 file changed, 358 insertions(+) create mode 100644 src/test/ui/generics/wrong-number-of-args.rs (limited to 'src/test/ui/generics/wrong-number-of-args.rs') diff --git a/src/test/ui/generics/wrong-number-of-args.rs b/src/test/ui/generics/wrong-number-of-args.rs new file mode 100644 index 000000000..cd2f96a18 --- /dev/null +++ b/src/test/ui/generics/wrong-number-of-args.rs @@ -0,0 +1,358 @@ +mod no_generics { + struct Ty; + + type A = Ty; + + type B = Ty<'static>; + //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument + //~| HELP remove these generics + + type C = Ty<'static, usize>; + //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument + //~| ERROR this struct takes 0 generic arguments but 1 generic argument + //~| HELP remove this lifetime argument + //~| HELP remove this generic argument + + type D = Ty<'static, usize, { 0 }>; + //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument + //~| ERROR this struct takes 0 generic arguments but 2 generic arguments + //~| HELP remove this lifetime argument + //~| HELP remove these generic arguments +} + +mod type_and_type { + struct Ty; + + type A = Ty; + //~^ ERROR missing generics for struct `type_and_type::Ty` + //~| HELP add missing + + type B = Ty; + //~^ ERROR this struct takes 2 generic arguments but 1 generic argument + //~| HELP add missing + + type C = Ty; + + 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 { + struct Ty<'a, T>; + + type A = Ty; + //~^ ERROR missing generics for struct + //~| ERROR missing lifetime specifier + //~| HELP add missing + //~| HELP consider introducing + + type B = Ty<'static>; + //~^ ERROR this struct takes 1 generic argument but 0 generic arguments + //~| HELP add missing + + type C = Ty; + //~^ ERROR missing lifetime specifier + //~| 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 + + type F = Ty<'static, usize, 'static, usize>; + //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments + //~| ERROR this struct takes 1 generic argument but 2 generic arguments + //~| HELP remove this lifetime argument + //~| HELP remove this generic argument +} + +mod type_and_type_and_type { + struct Ty; + + type A = Ty; + //~^ ERROR missing generics for struct `type_and_type_and_type::Ty` + //~| HELP add missing + + type B = Ty; + //~^ ERROR this struct takes at least 2 + //~| HELP add missing + + type C = Ty; + + type D = Ty; + + 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 +// somewhere in the message +mod r#trait { + trait NonGeneric { + // + } + + trait GenericLifetime<'a> { + // + } + + trait GenericType { + // + } + + type A = Box>; + //~^ ERROR this trait takes 0 generic arguments but 1 generic argument + //~| HELP remove + + type B = Box; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic + + type C = Box>; + //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied + //~| HELP remove + + type D = Box; + //~^ ERROR missing generics for trait `GenericType` + //~| HELP add missing + + 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 + //~| HELP consider making the bound lifetime-generic + + 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 + //~| HELP consider making the bound lifetime-generic + + 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 + //~| HELP consider making the bound lifetime-generic + //~| 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 + //~| HELP consider making the bound lifetime-generic + + 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 + //~| HELP consider making the bound lifetime-generic + + type E = Box>; + //~^ ERROR missing lifetime specifier + //~| HELP consider introducing + //~| HELP consider making the bound lifetime-generic + //~| 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 + //~| HELP consider making the bound lifetime-generic + + 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 + //~| HELP consider making the bound lifetime-generic + //~| 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 { + mod hash_map { + use std::collections::HashMap; + + type A = HashMap; + //~^ ERROR missing generics for struct `HashMap` + //~| HELP add missing + + type B = HashMap; + //~^ ERROR this struct takes at least + //~| HELP add missing + + type C = HashMap<'static>; + //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument + //~| HELP remove these generics + //~| ERROR this struct takes at least 2 + //~| HELP add missing + + 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 { + type A = Result; + //~^ ERROR missing generics for enum `Result` + //~| HELP add missing + + type B = Result; + //~^ ERROR this enum takes 2 generic arguments but 1 generic argument + //~| HELP add missing + + type C = Result<'static>; + //~^ ERROR this enum takes 0 lifetime arguments but 1 lifetime argument + //~| HELP remove these generics + //~| ERROR this enum takes 2 generic arguments but 0 generic arguments + //~| HELP add missing + + 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 + } +} + +fn main() { } -- cgit v1.2.3