Auto merge of #11094 - y21:issue11084, r=Alexendoo
[`useless_vec`]: add more tests and don't lint inside of macros Closes #11084. I realized that the fix I added in #11081 itself also causes an error in a suggestion when inside of a macro. Example: ```rs macro_rules! x { () => { for _ in vec![1, 2] {} } } x!(); ``` Here it would suggest replacing `vec![1, 2]` with `[x!()]`, because that's what the source callsite is (reminder: it does this to get the correct span of `x!()` for code like `for _ in vec![x!()]`), but that's wrong when *inside* macros, so I decided to make it not lint if the whole loop construct is inside a macro to avoid this issue. changelog: [`useless_vec`]: add more tests and don't lint inside of macros r? `@Alexendoo` since these were your tests, I figured it makes most sense to assign you
This commit is contained in:
commit
3f4e5999b2
4 changed files with 77 additions and 3 deletions
|
|
@ -154,6 +154,10 @@ impl UselessVec {
|
|||
span: Span,
|
||||
suggest_slice: SuggestedType,
|
||||
) {
|
||||
if span.from_expansion() {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
|
||||
let snippet = match *vec_args {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue