-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
212 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// edition:2018 | ||
// FIXME: run-rustfix waiting on multi-span suggestions | ||
|
||
#![warn(clippy::ref_binding_to_reference)] | ||
#![allow(clippy::needless_borrowed_reference)] | ||
|
||
fn f1(_: &str) {} | ||
macro_rules! m2 { | ||
($e:expr) => { | ||
f1(*$e); | ||
}; | ||
} | ||
macro_rules! m3 { | ||
($i:ident) => { | ||
Some(ref $i) | ||
}; | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn main() { | ||
let x = String::new(); | ||
|
||
// Ok, the pattern is in a different context than the match arm | ||
let _: &&String = match Some(&x) { | ||
m3!(x) => x, | ||
None => return, | ||
}; | ||
|
||
// Err, reference to a &String | ||
let _: &&String = match Some(&x) { | ||
Some(ref x) => x, | ||
None => return, | ||
}; | ||
|
||
// Err, reference to a &String | ||
let _: &&String = match Some(&x) { | ||
Some(ref x) => { | ||
f1(x); | ||
f1(*x); | ||
x | ||
}, | ||
None => return, | ||
}; | ||
|
||
// Err, reference to a &String | ||
match Some(&x) { | ||
Some(ref x) => m2!(x), | ||
None => return, | ||
} | ||
|
||
// Err, reference to a &String | ||
let _ = |&ref x: &&String| { | ||
let _: &&String = x; | ||
}; | ||
} | ||
|
||
// Err, reference to a &String | ||
fn f2<'a>(&ref x: &&'a String) -> &'a String { | ||
let _: &&String = x; | ||
*x | ||
} | ||
|
||
trait T1 { | ||
// Err, reference to a &String | ||
fn f(&ref x: &&String) { | ||
let _: &&String = x; | ||
} | ||
} | ||
|
||
struct S; | ||
impl T1 for S { | ||
// Err, reference to a &String | ||
fn f(&ref x: &&String) { | ||
let _: &&String = x; | ||
} | ||
} |
Oops, something went wrong.