/src/test/ui/suggestions/unnamable-types.rs

https://gitlab.com/rust-lang/rust · Rust · 39 lines · 11 code · 10 blank · 18 comment · 3 complexity · 68a6cccb9d6a82bab2a59d36c0f641de MD5 · raw file

  1. // Test that we do not suggest to add type annotations for unnamable types.
  2. #![crate_type="lib"]
  3. #![feature(generators)]
  4. const A = 5;
  5. //~^ ERROR: missing type for `const` item
  6. //~| HELP: provide a type for the constant
  7. static B: _ = "abc";
  8. //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static variables
  9. //~| NOTE: not allowed in type signatures
  10. //~| HELP: replace with the correct type
  11. // FIXME: this should also suggest a function pointer, as the closure is non-capturing
  12. const C: _ = || 42;
  13. //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for constants
  14. //~| NOTE: not allowed in type signatures
  15. //~| NOTE: however, the inferred type
  16. struct S<T> { t: T }
  17. const D = S { t: { let i = 0; move || -> i32 { i } } };
  18. //~^ ERROR: missing type for `const` item
  19. //~| NOTE: however, the inferred type
  20. fn foo() -> i32 { 42 }
  21. const E = foo;
  22. //~^ ERROR: missing type for `const` item
  23. //~| HELP: provide a type for the constant
  24. const F = S { t: foo };
  25. //~^ ERROR: missing type for `const` item
  26. //~| HELP: provide a type for the constant
  27. const G = || -> i32 { yield 0; return 1; };
  28. //~^ ERROR: missing type for `const` item
  29. //~| NOTE: however, the inferred type