Rustup to rust-lang/rust#66935
This commit is contained in:
parent
7a943a9dfc
commit
f6a75f17f6
@ -424,7 +424,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
|
||||
};
|
||||
|
||||
if attr.style == AttrStyle::Outer {
|
||||
if attr_item.tokens.is_empty() || !is_present_in_source(cx, attr.span) {
|
||||
if attr_item.args.inner_tokens().is_empty() || !is_present_in_source(cx, attr.span) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,11 @@ declare_lint_pass!(DbgMacro => [DBG_MACRO]);
|
||||
impl EarlyLintPass for DbgMacro {
|
||||
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) {
|
||||
if mac.path == sym!(dbg) {
|
||||
if let Some(sugg) = tts_span(mac.tts.clone()).and_then(|span| snippet_opt(cx, span)) {
|
||||
if let Some(sugg) = tts_span(mac.args.inner_tokens()).and_then(|span| snippet_opt(cx, span)) {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
DBG_MACRO,
|
||||
mac.span,
|
||||
mac.span(),
|
||||
"`dbg!` macro is intended as a debugging tool",
|
||||
"ensure to avoid having uses of it in version control",
|
||||
sugg,
|
||||
@ -46,7 +46,7 @@ impl EarlyLintPass for DbgMacro {
|
||||
span_help_and_lint(
|
||||
cx,
|
||||
DBG_MACRO,
|
||||
mac.span,
|
||||
mac.span(),
|
||||
"`dbg!` macro is intended as a debugging tool",
|
||||
"ensure to avoid having uses of it in version control",
|
||||
);
|
||||
|
@ -189,13 +189,13 @@ declare_lint_pass!(Write => [
|
||||
impl EarlyLintPass for Write {
|
||||
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &Mac) {
|
||||
if mac.path == sym!(println) {
|
||||
span_lint(cx, PRINT_STDOUT, mac.span, "use of `println!`");
|
||||
if let (Some(fmt_str), _) = check_tts(cx, &mac.tts, false) {
|
||||
span_lint(cx, PRINT_STDOUT, mac.span(), "use of `println!`");
|
||||
if let (Some(fmt_str), _) = check_tts(cx, &mac.args.inner_tokens(), false) {
|
||||
if fmt_str.symbol == Symbol::intern("") {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
PRINTLN_EMPTY_STRING,
|
||||
mac.span,
|
||||
mac.span(),
|
||||
"using `println!(\"\")`",
|
||||
"replace it with",
|
||||
"println!()".to_string(),
|
||||
@ -204,13 +204,13 @@ impl EarlyLintPass for Write {
|
||||
}
|
||||
}
|
||||
} else if mac.path == sym!(print) {
|
||||
span_lint(cx, PRINT_STDOUT, mac.span, "use of `print!`");
|
||||
if let (Some(fmt_str), _) = check_tts(cx, &mac.tts, false) {
|
||||
span_lint(cx, PRINT_STDOUT, mac.span(), "use of `print!`");
|
||||
if let (Some(fmt_str), _) = check_tts(cx, &mac.args.inner_tokens(), false) {
|
||||
if check_newlines(&fmt_str) {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
PRINT_WITH_NEWLINE,
|
||||
mac.span,
|
||||
mac.span(),
|
||||
"using `print!()` with a format string that ends in a single newline",
|
||||
|err| {
|
||||
err.multipart_suggestion(
|
||||
@ -226,12 +226,12 @@ impl EarlyLintPass for Write {
|
||||
}
|
||||
}
|
||||
} else if mac.path == sym!(write) {
|
||||
if let (Some(fmt_str), _) = check_tts(cx, &mac.tts, true) {
|
||||
if let (Some(fmt_str), _) = check_tts(cx, &mac.args.inner_tokens(), true) {
|
||||
if check_newlines(&fmt_str) {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
WRITE_WITH_NEWLINE,
|
||||
mac.span,
|
||||
mac.span(),
|
||||
"using `write!()` with a format string that ends in a single newline",
|
||||
|err| {
|
||||
err.multipart_suggestion(
|
||||
@ -247,7 +247,7 @@ impl EarlyLintPass for Write {
|
||||
}
|
||||
}
|
||||
} else if mac.path == sym!(writeln) {
|
||||
if let (Some(fmt_str), expr) = check_tts(cx, &mac.tts, true) {
|
||||
if let (Some(fmt_str), expr) = check_tts(cx, &mac.args.inner_tokens(), true) {
|
||||
if fmt_str.symbol == Symbol::intern("") {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
let suggestion = expr.map_or_else(
|
||||
@ -261,7 +261,7 @@ impl EarlyLintPass for Write {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
WRITELN_EMPTY_STRING,
|
||||
mac.span,
|
||||
mac.span(),
|
||||
format!("using `writeln!({}, \"\")`", suggestion).as_str(),
|
||||
"replace it with",
|
||||
format!("writeln!({})", suggestion),
|
||||
|
Loading…
x
Reference in New Issue
Block a user