5

I am generating code with a macro, which contains fully qualified type paths like this:

let vec: Vec::<String>;

Note the extra :: before <String>. This is necessary so that the same input token can be also be used for the constructor, by appending ::new():

Vec::<String>::new()

However, this produces warnings:

warning: unnecessary path disambiguator
 --> src/main.rs:4:17
  |
4 |     let vec: Vec::<String>;
  |                 ^^ try removing `::`

I can't remove the :: because then I get an error:

error: chained comparison operators require parentheses
 --> src/main.rs:6:14
  |
6 |     vec = Vec<String>::new();
  |              ^^^^^^^^^^
  |
  = help: use `::<...>` instead of `<...>` if you meant to specify type arguments
  = help: or use `(...)` if you meant to specify fn arguments

error[E0423]: expected value, found struct `Vec`
 --> src/main.rs:6:11
  |
6 |     vec = Vec<String>::new();
  |           ^^^
  |           |
  |           did you mean `vec`?
  |           did you mean `Vec { /* fields */ }`?

How can I disable the warning just for this one line?

Peter Hall
  • 53,120
  • 14
  • 139
  • 204
  • I guess it seems like an open issue since it slips from `deny(warnings)` and also `allow(warnings)`. Here is the [open_issue](https://github.com/rust-lang/rust/issues/58055) – Akiner Alkan Feb 15 '19 at 14:22

1 Answers1

3

It is an open issue currently.

This lint is currently slipping these attributes like #![allow(warnings)]

Reference

Akiner Alkan
  • 6,145
  • 3
  • 32
  • 68