Ignore borrow_deref_ref warnings in code from procedural macros.
This commit is contained in:
parent
371120bdbf
commit
394b4c1906
4 changed files with 37 additions and 5 deletions
|
|
@ -1,7 +1,11 @@
|
|||
//@run-rustfix
|
||||
//@aux-build: proc_macros.rs
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::with_span;
|
||||
|
||||
fn main() {}
|
||||
|
||||
mod should_lint {
|
||||
|
|
@ -47,6 +51,17 @@ mod should_not_lint2 {
|
|||
}
|
||||
}
|
||||
|
||||
with_span!(
|
||||
span
|
||||
|
||||
fn just_returning(x: &u32) -> &u32 {
|
||||
x
|
||||
}
|
||||
|
||||
fn dont_lint_proc_macro() {
|
||||
let a = &mut &*just_returning(&12);
|
||||
}
|
||||
);
|
||||
// this mod explains why we should not lint `& &* (&T)`
|
||||
mod false_negative {
|
||||
fn foo() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
//@run-rustfix
|
||||
//@aux-build: proc_macros.rs
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::with_span;
|
||||
|
||||
fn main() {}
|
||||
|
||||
mod should_lint {
|
||||
|
|
@ -47,6 +51,17 @@ mod should_not_lint2 {
|
|||
}
|
||||
}
|
||||
|
||||
with_span!(
|
||||
span
|
||||
|
||||
fn just_returning(x: &u32) -> &u32 {
|
||||
x
|
||||
}
|
||||
|
||||
fn dont_lint_proc_macro() {
|
||||
let a = &mut &*just_returning(&12);
|
||||
}
|
||||
);
|
||||
// this mod explains why we should not lint `& &* (&T)`
|
||||
mod false_negative {
|
||||
fn foo() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: deref on an immutable reference
|
||||
--> $DIR/borrow_deref_ref.rs:10:17
|
||||
--> $DIR/borrow_deref_ref.rs:14:17
|
||||
|
|
||||
LL | let b = &*a;
|
||||
| ^^^ help: if you would like to reborrow, try removing `&*`: `a`
|
||||
|
|
@ -7,13 +7,13 @@ LL | let b = &*a;
|
|||
= note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
|
||||
|
||||
error: deref on an immutable reference
|
||||
--> $DIR/borrow_deref_ref.rs:12:22
|
||||
--> $DIR/borrow_deref_ref.rs:16:22
|
||||
|
|
||||
LL | let b = &mut &*bar(&12);
|
||||
| ^^^^^^^^^^ help: if you would like to reborrow, try removing `&*`: `bar(&12)`
|
||||
|
||||
error: deref on an immutable reference
|
||||
--> $DIR/borrow_deref_ref.rs:55:23
|
||||
--> $DIR/borrow_deref_ref.rs:70:23
|
||||
|
|
||||
LL | let addr_y = &&*x as *const _ as usize; // assert ok
|
||||
| ^^^ help: if you would like to reborrow, try removing `&*`: `x`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue