Skip to content

Commit

Permalink
Auto merge of rust-lang#6667 - Manishearth:rustup, r=Manishearth
Browse files Browse the repository at this point in the history
Rustup

Pulling in AST changes

changelog: none
  • Loading branch information
bors committed Feb 3, 2021
2 parents 11edf92 + 741259b commit 3e41797
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ indent_style = space
indent_size = 4

[*.md]
# double whitespace at end of line
# denotes a line break in Markdown
trim_trailing_whitespace = false

[*.yml]
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::utils::{
};
use if_chain::if_chain;
use itertools::Itertools;
use rustc_ast::ast::{Async, AttrKind, Attribute, FnRetTy, ItemKind};
use rustc_ast::ast::{Async, AttrKind, Attribute, FnKind, FnRetTy, ItemKind};
use rustc_ast::token::CommentKind;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
Expand Down Expand Up @@ -563,7 +563,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
| ItemKind::ExternCrate(..)
| ItemKind::ForeignMod(..) => return false,
// We found a main function ...
ItemKind::Fn(_, sig, _, Some(block)) if item.ident.name == sym::main => {
ItemKind::Fn(box FnKind(_, sig, _, Some(block))) if item.ident.name == sym::main => {
let is_async = matches!(sig.header.asyncness, Async::Yes { .. });
let returns_nothing = match &sig.decl.output {
FnRetTy::Default(..) => true,
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/excessive_bools.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::utils::{attr_by_name, in_macro, match_path_ast, span_lint_and_help};
use rustc_ast::ast::{AssocItemKind, Extern, FnSig, Item, ItemKind, Ty, TyKind};
use rustc_ast::ast::{AssocItemKind, Extern, FnKind, FnSig, ImplKind, Item, ItemKind, TraitKind, Ty, TyKind};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::Span;
Expand Down Expand Up @@ -159,17 +159,17 @@ impl EarlyLintPass for ExcessiveBools {
);
}
},
ItemKind::Impl {
ItemKind::Impl(box ImplKind {
of_trait: None, items, ..
}
| ItemKind::Trait(_, _, _, _, items) => {
})
| ItemKind::Trait(box TraitKind(.., items)) => {
for item in items {
if let AssocItemKind::Fn(_, fn_sig, _, _) = &item.kind {
if let AssocItemKind::Fn(box FnKind(_, fn_sig, _, _)) = &item.kind {
self.check_fn_sig(cx, fn_sig, item.span);
}
}
},
ItemKind::Fn(_, fn_sig, _, _) => self.check_fn_sig(cx, fn_sig, item.span),
ItemKind::Fn(box FnKind(_, fn_sig, _, _)) => self.check_fn_sig(cx, fn_sig, item.span),
_ => (),
}
}
Expand Down
8 changes: 5 additions & 3 deletions clippy_lints/src/non_expressive_names.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::utils::{span_lint, span_lint_and_then};
use rustc_ast::ast::{Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Item, ItemKind, Local, Pat, PatKind};
use rustc_ast::ast::{
Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, FnKind, Item, ItemKind, Local, Pat, PatKind,
};
use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_middle::lint::in_external_macro;
Expand Down Expand Up @@ -364,7 +366,7 @@ impl EarlyLintPass for NonExpressiveNames {
return;
}

if let ItemKind::Fn(_, ref sig, _, Some(ref blk)) = item.kind {
if let ItemKind::Fn(box FnKind(_, ref sig, _, Some(ref blk))) = item.kind {
do_check(self, cx, &item.attrs, &sig.decl, blk);
}
}
Expand All @@ -374,7 +376,7 @@ impl EarlyLintPass for NonExpressiveNames {
return;
}

if let AssocItemKind::Fn(_, ref sig, _, Some(ref blk)) = item.kind {
if let AssocItemKind::Fn(box FnKind(_, ref sig, _, Some(ref blk))) = item.kind {
do_check(self, cx, &item.attrs, &sig.decl, blk);
}
}
Expand Down
22 changes: 11 additions & 11 deletions clippy_lints/src/utils/ast_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
(Use(l), Use(r)) => eq_use_tree(l, r),
(Static(lt, lm, le), Static(rt, rm, re)) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re),
(Const(ld, lt, le), Const(rd, rt, re)) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re),
(Fn(ld, lf, lg, lb), Fn(rd, rf, rg, rb)) => {
(Fn(box FnKind(ld, lf, lg, lb)), Fn(box FnKind(rd, rf, rg, rb))) => {
eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r))
},
(Mod(l), Mod(r)) => l.inline == r.inline && over(&l.items, &r.items, |l, r| eq_item(l, r, eq_item_kind)),
(ForeignMod(l), ForeignMod(r)) => {
both(&l.abi, &r.abi, |l, r| eq_str_lit(l, r))
&& over(&l.items, &r.items, |l, r| eq_item(l, r, eq_foreign_item_kind))
},
(TyAlias(ld, lg, lb, lt), TyAlias(rd, rg, rb, rt)) => {
(TyAlias(box TyAliasKind(ld, lg, lb, lt)), TyAlias(box TyAliasKind(rd, rg, rb, rt))) => {
eq_defaultness(*ld, *rd)
&& eq_generics(lg, rg)
&& over(lb, rb, |l, r| eq_generic_bound(l, r))
Expand All @@ -251,7 +251,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
(Struct(lv, lg), Struct(rv, rg)) | (Union(lv, lg), Union(rv, rg)) => {
eq_variant_data(lv, rv) && eq_generics(lg, rg)
},
(Trait(la, lu, lg, lb, li), Trait(ra, ru, rg, rb, ri)) => {
(Trait(box TraitKind(la, lu, lg, lb, li)), Trait(box TraitKind(ra, ru, rg, rb, ri))) => {
la == ra
&& matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No)
&& eq_generics(lg, rg)
Expand All @@ -260,7 +260,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
},
(TraitAlias(lg, lb), TraitAlias(rg, rb)) => eq_generics(lg, rg) && over(lb, rb, |l, r| eq_generic_bound(l, r)),
(
Impl {
Impl(box ImplKind {
unsafety: lu,
polarity: lp,
defaultness: ld,
Expand All @@ -269,8 +269,8 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
of_trait: lot,
self_ty: lst,
items: li,
},
Impl {
}),
Impl(box ImplKind {
unsafety: ru,
polarity: rp,
defaultness: rd,
Expand All @@ -279,7 +279,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
of_trait: rot,
self_ty: rst,
items: ri,
},
}),
) => {
matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No)
&& matches!(lp, ImplPolarity::Positive) == matches!(rp, ImplPolarity::Positive)
Expand All @@ -300,10 +300,10 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
use ForeignItemKind::*;
match (l, r) {
(Static(lt, lm, le), Static(rt, rm, re)) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re),
(Fn(ld, lf, lg, lb), Fn(rd, rf, rg, rb)) => {
(Fn(box FnKind(ld, lf, lg, lb)), Fn(box FnKind(rd, rf, rg, rb))) => {
eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r))
},
(TyAlias(ld, lg, lb, lt), TyAlias(rd, rg, rb, rt)) => {
(TyAlias(box TyAliasKind(ld, lg, lb, lt)), TyAlias(box TyAliasKind(rd, rg, rb, rt))) => {
eq_defaultness(*ld, *rd)
&& eq_generics(lg, rg)
&& over(lb, rb, |l, r| eq_generic_bound(l, r))
Expand All @@ -318,10 +318,10 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
use AssocItemKind::*;
match (l, r) {
(Const(ld, lt, le), Const(rd, rt, re)) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re),
(Fn(ld, lf, lg, lb), Fn(rd, rf, rg, rb)) => {
(Fn(box FnKind(ld, lf, lg, lb)), Fn(box FnKind(rd, rf, rg, rb))) => {
eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r))
},
(TyAlias(ld, lg, lb, lt), TyAlias(rd, rg, rb, rt)) => {
(TyAlias(box TyAliasKind(ld, lg, lb, lt)), TyAlias(box TyAliasKind(rd, rg, rb, rt))) => {
eq_defaultness(*ld, *rd)
&& eq_generics(lg, rg)
&& over(lb, rb, |l, r| eq_generic_bound(l, r))
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::Range;

use crate::utils::{snippet_with_applicability, span_lint, span_lint_and_sugg, span_lint_and_then};
use if_chain::if_chain;
use rustc_ast::ast::{Expr, ExprKind, Item, ItemKind, LitKind, MacCall, StrLit, StrStyle};
use rustc_ast::ast::{Expr, ExprKind, ImplKind, Item, ItemKind, LitKind, MacCall, StrLit, StrStyle};
use rustc_ast::token;
use rustc_ast::tokenstream::TokenStream;
use rustc_errors::Applicability;
Expand Down Expand Up @@ -231,10 +231,10 @@ impl_lint_pass!(Write => [

impl EarlyLintPass for Write {
fn check_item(&mut self, _: &EarlyContext<'_>, item: &Item) {
if let ItemKind::Impl {
if let ItemKind::Impl(box ImplKind {
of_trait: Some(trait_ref),
..
} = &item.kind
}) = &item.kind
{
let trait_name = trait_ref
.path
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-01-30"
channel = "nightly-2021-02-03"
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]
23 changes: 19 additions & 4 deletions tests/ui/panicking_macros.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ error: `panic` should not be present in production code
|
LL | panic!("message");
| ^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `panic` should not be present in production code
--> $DIR/panicking_macros.rs:10:5
|
LL | panic!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `todo` should not be present in production code
--> $DIR/panicking_macros.rs:16:5
Expand All @@ -29,18 +25,23 @@ LL | todo!();
| ^^^^^^^^
|
= note: `-D clippy::todo` implied by `-D warnings`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `todo` should not be present in production code
--> $DIR/panicking_macros.rs:17:5
|
LL | todo!("message");
| ^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `todo` should not be present in production code
--> $DIR/panicking_macros.rs:18:5
|
LL | todo!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `unimplemented` should not be present in production code
--> $DIR/panicking_macros.rs:24:5
Expand All @@ -49,18 +50,23 @@ LL | unimplemented!();
| ^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::unimplemented` implied by `-D warnings`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `unimplemented` should not be present in production code
--> $DIR/panicking_macros.rs:25:5
|
LL | unimplemented!("message");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `unimplemented` should not be present in production code
--> $DIR/panicking_macros.rs:26:5
|
LL | unimplemented!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: usage of the `unreachable!` macro
--> $DIR/panicking_macros.rs:32:5
Expand All @@ -69,6 +75,7 @@ LL | unreachable!();
| ^^^^^^^^^^^^^^^
|
= note: `-D clippy::unreachable` implied by `-D warnings`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: usage of the `unreachable!` macro
--> $DIR/panicking_macros.rs:33:5
Expand All @@ -83,6 +90,8 @@ error: usage of the `unreachable!` macro
|
LL | unreachable!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `panic` should not be present in production code
--> $DIR/panicking_macros.rs:40:5
Expand All @@ -95,18 +104,24 @@ error: `todo` should not be present in production code
|
LL | todo!();
| ^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `unimplemented` should not be present in production code
--> $DIR/panicking_macros.rs:42:5
|
LL | unimplemented!();
| ^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: usage of the `unreachable!` macro
--> $DIR/panicking_macros.rs:43:5
|
LL | unreachable!();
| ^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 16 previous errors

0 comments on commit 3e41797

Please sign in to comment.