4

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?

  • I guess it seems like an open issue since it slips from deny(warnings) and also allow(warnings). Here is the open_issue – Websterix Feb 15 '19 at 14:22
2

It is an open issue currently.

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

Reference

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.