/src/test/ui/const-generics/generic_arg_infer/in-signature.rs

https://gitlab.com/rust-lang/rust · Rust · 61 lines · 40 code · 6 blank · 15 comment · 3 complexity · e3cfe4dc8c14676a906b93bfa85f46fd MD5 · raw file

  1. #![crate_type = "rlib"]
  2. #![feature(generic_arg_infer)]
  3. struct Foo<const N: usize>;
  4. struct Bar<T, const N: usize>(T);
  5. fn arr_fn() -> [u8; _] {
  6. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
  7. [0; 3]
  8. }
  9. fn ty_fn() -> Bar<i32, _> {
  10. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
  11. Bar::<i32, 3>(0)
  12. }
  13. fn ty_fn_mixed() -> Bar<_, _> {
  14. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
  15. Bar::<i32, 3>(0)
  16. }
  17. const ARR_CT: [u8; _] = [0; 3];
  18. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
  19. static ARR_STATIC: [u8; _] = [0; 3];
  20. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
  21. const TY_CT: Bar<i32, _> = Bar::<i32, 3>(0);
  22. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
  23. static TY_STATIC: Bar<i32, _> = Bar::<i32, 3>(0);
  24. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
  25. const TY_CT_MIXED: Bar<_, _> = Bar::<i32, 3>(0);
  26. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
  27. static TY_STATIC_MIXED: Bar<_, _> = Bar::<i32, 3>(0);
  28. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
  29. trait ArrAssocConst {
  30. const ARR: [u8; _];
  31. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
  32. }
  33. trait TyAssocConst {
  34. const ARR: Bar<i32, _>;
  35. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
  36. }
  37. trait TyAssocConstMixed {
  38. const ARR: Bar<_, _>;
  39. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
  40. }
  41. trait AssocTy {
  42. type Assoc;
  43. }
  44. impl AssocTy for i8 {
  45. type Assoc = [u8; _];
  46. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
  47. }
  48. impl AssocTy for i16 {
  49. type Assoc = Bar<i32, _>;
  50. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
  51. }
  52. impl AssocTy for i32 {
  53. type Assoc = Bar<_, _>;
  54. //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
  55. }