Skip to content

Commit 764dfe5

Browse files
committed
Skip rustfmt as it is wanted for this test
1 parent ce98468 commit 764dfe5

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

clippy_lints/src/reference.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::{in_macro, snippet_opt, snippet_with_applicability, span_lint_and_sugg};
22
use if_chain::if_chain;
3-
use rustc_ast::ast::{Expr, ExprKind, UnOp, Mutability};
3+
use rustc_ast::ast::{Expr, ExprKind, Mutability, UnOp};
44
use rustc_errors::Applicability;
55
use rustc_lint::{EarlyContext, EarlyLintPass};
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -53,22 +53,20 @@ impl EarlyLintPass for DerefAddrOf {
5353
// Remove leading whitespace from the given span
5454
// e.g: ` $visitor` turns into `$visitor`
5555
let trim_leading_whitespaces = |span| {
56-
if let Some(start_no_whitespace) = snippet_opt(cx, span).and_then(|snip| {
56+
snippet_opt(cx, span).and_then(|snip| {
57+
#[allow(clippy::cast_possible_truncation)]
5758
snip.find(|c: char| !c.is_whitespace()).map(|pos| {
5859
span.lo() + BytePos(pos as u32)
5960
})
60-
}) {
61-
e.span.with_lo(start_no_whitespace)
62-
} else {
63-
span
64-
}
61+
}).map_or(span, |start_no_whitespace| e.span.with_lo(start_no_whitespace))
6562
};
6663

6764
let rpos = if *mutability == Mutability::Mut {
6865
macro_source.rfind("mut").expect("already checked this is a mutable reference") + "mut".len()
6966
} else {
70-
macro_source.rfind("&").expect("already checked this is a reference") + "&".len()
67+
macro_source.rfind('&').expect("already checked this is a reference") + "&".len()
7168
};
69+
#[allow(clippy::cast_possible_truncation)]
7270
let span_after_ref = e.span.with_lo(BytePos(e.span.lo().0 + rpos as u32));
7371
let span = trim_leading_whitespaces(span_after_ref);
7472
snippet_with_applicability(cx, span, "_", &mut applicability).to_string()

clippy_lints/src/try_err.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,16 @@ impl<'tcx> LateLintPass<'tcx> for TryErr {
9191
};
9292

9393
let expr_err_ty = cx.typeck_results().expr_ty(err_arg);
94-
95-
// println!("\n\n{:?}", in_macro(expr.span));
96-
// println!("{:#?}", snippet(cx, err_arg.span, "_"));
9794
let origin_snippet = if err_arg.span.from_expansion() && !in_macro(expr.span) {
98-
// println!("from expansion");
9995
snippet_with_macro_callsite(cx, err_arg.span, "_")
10096
} else {
101-
// println!("just a snippet");
10297
snippet(cx, err_arg.span, "_")
10398
};
10499
let suggestion = if err_ty == expr_err_ty {
105100
format!("return {}{}{}", prefix, origin_snippet, suffix)
106101
} else {
107102
format!("return {}{}.into(){}", prefix, origin_snippet, suffix)
108103
};
109-
// println!("origin_snippet: {:#?}", origin_snippet);
110-
// println!("suggestion: {:#?}", suggestion);
111104

112105
span_lint_and_sugg(
113106
cx,

tests/ui/deref_addrof.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fn main() {
3838
let b = *aref;
3939
}
4040

41+
#[rustfmt::skip]
4142
macro_rules! m {
4243
($visitor: expr) => {
4344
$visitor

tests/ui/deref_addrof.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fn main() {
3838
let b = **&aref;
3939
}
4040

41+
#[rustfmt::skip]
4142
macro_rules! m {
4243
($visitor: expr) => {
4344
*& $visitor

tests/ui/deref_addrof.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ LL | let b = **&aref;
4949
| ^^^^^^ help: try this: `aref`
5050

5151
error: immediately dereferencing a reference
52-
--> $DIR/deref_addrof.rs:43:9
52+
--> $DIR/deref_addrof.rs:44:9
5353
|
5454
LL | *& $visitor
5555
| ^^^^^^^^^^^ help: try this: `$visitor`
@@ -60,7 +60,7 @@ LL | m!(self)
6060
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
6161

6262
error: immediately dereferencing a reference
63-
--> $DIR/deref_addrof.rs:50:9
63+
--> $DIR/deref_addrof.rs:51:9
6464
|
6565
LL | *& mut $visitor
6666
| ^^^^^^^^^^^^^^^ help: try this: `$visitor`

0 commit comments

Comments
 (0)