Skip to content

Commit

Permalink
Auto merge of #4878 - flip1995:rustup, r=flip1995
Browse files Browse the repository at this point in the history
Rustup

Included rustups:

- rust-lang/rust#66935 (syntax: Unify macro and attribute arguments in AST)
- rust-lang/rust#66941 (Remove `ord` lang item)

Fixes? #2597

changelog: none
  • Loading branch information
bors committed Dec 3, 2019
2 parents 7a943a9 + 7162393 commit f0fc18a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/dbg_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
);
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/eq_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
BinOpKind::Shr => (cx.tcx.lang_items().shr_trait(), false),
BinOpKind::Ne | BinOpKind::Eq => (cx.tcx.lang_items().eq_trait(), true),
BinOpKind::Lt | BinOpKind::Le | BinOpKind::Ge | BinOpKind::Gt => {
(cx.tcx.lang_items().ord_trait(), true)
(cx.tcx.lang_items().partial_ord_trait(), true)
},
};
if let Some(trait_id) = trait_id {
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
left.span,
"use the left value directly",
lsnip,
Applicability::MachineApplicable, // snippet
Applicability::MaybeIncorrect, // FIXME #2597
);
})
}
Expand All @@ -173,7 +173,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
right.span,
"use the right value directly",
rsnip,
Applicability::MachineApplicable, // snippet
Applicability::MaybeIncorrect, // FIXME #2597
);
})
}
Expand Down
20 changes: 10 additions & 10 deletions clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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),
Expand Down
10 changes: 1 addition & 9 deletions tests/ui/op_ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ help: use the values directly
LL | let foo = 5 - 6;
| ^ ^

error: taken reference of right operand
--> $DIR/op_ref.rs:20:8
|
LL | if b < &a {
| ^^^^--
| |
| help: use the right value directly: `a`

error: taken reference of right operand
--> $DIR/op_ref.rs:57:13
|
Expand All @@ -26,5 +18,5 @@ LL | let z = x & &y;
| |
| help: use the right value directly: `y`

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

0 comments on commit f0fc18a

Please sign in to comment.