Skip to content

Commit b20a9cd

Browse files
committed
Auto merge of rust-lang#5587 - flip1995:rustup, r=phansch
Rustup Done with ```bash git subtree push -P src/tools/clippy [email protected]:flip1995/rust-clippy rustup ``` from https://github.com/flip1995/rust/tree/clippyup A rebase was required to get rid of empty merge commits, that somehow were not empty? 🤔 changelog: none
2 parents 43a1777 + eec17d2 commit b20a9cd

14 files changed

+36
-36
lines changed

clippy_lints/src/bytecount.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ use crate::utils::{
33
span_lint_and_sugg, walk_ptrs_ty,
44
};
55
use if_chain::if_chain;
6-
use rustc_ast::ast::{Name, UintTy};
6+
use rustc_ast::ast::UintTy;
77
use rustc_errors::Applicability;
88
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp};
99
use rustc_lint::{LateContext, LateLintPass};
1010
use rustc_middle::ty;
1111
use rustc_session::{declare_lint_pass, declare_tool_lint};
12+
use rustc_span::Symbol;
1213

1314
declare_clippy_lint! {
1415
/// **What it does:** Checks for naive byte counts
@@ -95,11 +96,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
9596
}
9697
}
9798

98-
fn check_arg(name: Name, arg: Name, needle: &Expr<'_>) -> bool {
99+
fn check_arg(name: Symbol, arg: Symbol, needle: &Expr<'_>) -> bool {
99100
name == arg && !contains_name(name, needle)
100101
}
101102

102-
fn get_path_name(expr: &Expr<'_>) -> Option<Name> {
103+
fn get_path_name(expr: &Expr<'_>) -> Option<Symbol> {
103104
match expr.kind {
104105
ExprKind::Box(ref e) | ExprKind::AddrOf(BorrowKind::Ref, _, ref e) | ExprKind::Unary(UnOp::UnDeref, ref e) => {
105106
get_path_name(e)

clippy_lints/src/inline_fn_without_body.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
33
use crate::utils::span_lint_and_then;
44
use crate::utils::sugg::DiagnosticBuilderExt;
5-
use rustc_ast::ast::{Attribute, Name};
5+
use rustc_ast::ast::Attribute;
66
use rustc_errors::Applicability;
77
use rustc_hir::{TraitFn, TraitItem, TraitItemKind};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
10+
use rustc_span::Symbol;
1011

1112
declare_clippy_lint! {
1213
/// **What it does:** Checks for `#[inline]` on trait methods without bodies
@@ -38,7 +39,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InlineFnWithoutBody {
3839
}
3940
}
4041

41-
fn check_attrs(cx: &LateContext<'_, '_>, name: Name, attrs: &[Attribute]) {
42+
fn check_attrs(cx: &LateContext<'_, '_>, name: Symbol, attrs: &[Attribute]) {
4243
for attr in attrs {
4344
if !attr.check_name(sym!(inline)) {
4445
continue;

clippy_lints/src/len_zero.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::utils::{get_item_name, snippet_with_applicability, span_lint, span_lint_and_sugg, walk_ptrs_ty};
2-
use rustc_ast::ast::{LitKind, Name};
2+
use rustc_ast::ast::LitKind;
33
use rustc_data_structures::fx::FxHashSet;
44
use rustc_errors::Applicability;
55
use rustc_hir::def_id::DefId;
66
use rustc_hir::{AssocItemKind, BinOpKind, Expr, ExprKind, ImplItemRef, Item, ItemKind, TraitItemRef};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_middle::ty;
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
10-
use rustc_span::source_map::{Span, Spanned};
10+
use rustc_span::source_map::{Span, Spanned, Symbol};
1111

1212
declare_clippy_lint! {
1313
/// **What it does:** Checks for getting the length of something via `.len()`
@@ -226,7 +226,7 @@ fn check_cmp(cx: &LateContext<'_, '_>, span: Span, method: &Expr<'_>, lit: &Expr
226226
fn check_len(
227227
cx: &LateContext<'_, '_>,
228228
span: Span,
229-
method_name: Name,
229+
method_name: Symbol,
230230
args: &[Expr<'_>],
231231
lit: &LitKind,
232232
op: &str,

clippy_lints/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ mod zero_div_zero;
335335
pub use crate::utils::conf::Conf;
336336

337337
mod reexport {
338-
pub use rustc_ast::ast::Name;
338+
pub use rustc_span::Symbol as Name;
339339
}
340340

341341
/// Register all pre expansion lints

clippy_lints/src/map_clone.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use crate::utils::{
33
is_copy, is_type_diagnostic_item, match_trait_method, remove_blocks, snippet_with_applicability, span_lint_and_sugg,
44
};
55
use if_chain::if_chain;
6-
use rustc_ast::ast::Ident;
76
use rustc_errors::Applicability;
87
use rustc_hir as hir;
98
use rustc_lint::{LateContext, LateLintPass};
109
use rustc_middle::mir::Mutability;
1110
use rustc_middle::ty;
1211
use rustc_session::{declare_lint_pass, declare_tool_lint};
13-
use rustc_span::source_map::Span;
12+
use rustc_span::symbol::Ident;
13+
use rustc_span::Span;
1414

1515
declare_clippy_lint! {
1616
/// **What it does:** Checks for usage of `iterator.map(|x| x.clone())` and suggests

clippy_lints/src/non_expressive_names.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::utils::{span_lint, span_lint_and_then};
22
use rustc_ast::ast::{
3-
Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Ident, Item, ItemKind, Local, MacCall, Pat, PatKind,
3+
Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Item, ItemKind, Local, MacCall, Pat, PatKind,
44
};
55
use rustc_ast::attr;
66
use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor};
77
use rustc_lint::{EarlyContext, EarlyLintPass};
88
use rustc_session::{declare_tool_lint, impl_lint_pass};
99
use rustc_span::source_map::Span;
10-
use rustc_span::symbol::SymbolStr;
10+
use rustc_span::symbol::{Ident, SymbolStr};
1111
use std::cmp::Ordering;
1212

1313
declare_clippy_lint! {

clippy_lints/src/unsafe_removed_from_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::utils::span_lint;
2-
use rustc_ast::ast::{Ident, Item, ItemKind, UseTree, UseTreeKind};
2+
use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind};
33
use rustc_lint::{EarlyContext, EarlyLintPass};
44
use rustc_session::{declare_lint_pass, declare_tool_lint};
55
use rustc_span::source_map::Span;
6-
use rustc_span::symbol::SymbolStr;
6+
use rustc_span::symbol::{Ident, SymbolStr};
77

88
declare_clippy_lint! {
99
/// **What it does:** Checks for imports that remove "unsafe" from an item's

clippy_lints/src/utils/hir_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::consts::{constant_context, constant_simple};
22
use crate::utils::differing_macro_contexts;
3-
use rustc_ast::ast::Name;
43
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
54
use rustc_hir::{
65
BinOpKind, Block, BlockCheckMode, BodyId, BorrowKind, CaptureBy, Expr, ExprKind, Field, FnRetTy, GenericArg,
@@ -10,6 +9,7 @@ use rustc_hir::{
109
use rustc_lint::LateContext;
1110
use rustc_middle::ich::StableHashingContextProvider;
1211
use rustc_middle::ty::TypeckTables;
12+
use rustc_span::Symbol;
1313
use std::hash::Hash;
1414

1515
/// Type used to check whether two ast are the same. This is different from the
@@ -544,7 +544,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
544544
}
545545
}
546546

547-
pub fn hash_name(&mut self, n: Name) {
547+
pub fn hash_name(&mut self, n: Symbol) {
548548
n.as_str().hash(&mut self.s);
549549
}
550550

clippy_lints/src/utils/internal_lints.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::utils::{
44
span_lint_and_help, span_lint_and_sugg, walk_ptrs_ty,
55
};
66
use if_chain::if_chain;
7-
use rustc_ast::ast::{Crate as AstCrate, ItemKind, LitKind, Name, NodeId};
7+
use rustc_ast::ast::{Crate as AstCrate, ItemKind, LitKind, NodeId};
88
use rustc_ast::visit::FnKind;
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1010
use rustc_errors::Applicability;
@@ -17,7 +17,7 @@ use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
1717
use rustc_middle::hir::map::Map;
1818
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
1919
use rustc_span::source_map::{Span, Spanned};
20-
use rustc_span::symbol::SymbolStr;
20+
use rustc_span::symbol::{Symbol, SymbolStr};
2121

2222
use std::borrow::{Borrow, Cow};
2323

@@ -245,8 +245,8 @@ impl EarlyLintPass for ClippyLintsInternal {
245245

246246
#[derive(Clone, Debug, Default)]
247247
pub struct LintWithoutLintPass {
248-
declared_lints: FxHashMap<Name, Span>,
249-
registered_lints: FxHashSet<Name>,
248+
declared_lints: FxHashMap<Symbol, Span>,
249+
registered_lints: FxHashSet<Symbol>,
250250
}
251251

252252
impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS]);
@@ -357,7 +357,7 @@ fn is_lint_ref_type<'tcx>(cx: &LateContext<'_, 'tcx>, ty: &Ty<'_>) -> bool {
357357
}
358358

359359
struct LintCollector<'a, 'tcx> {
360-
output: &'a mut FxHashSet<Name>,
360+
output: &'a mut FxHashSet<Symbol>,
361361
cx: &'a LateContext<'a, 'tcx>,
362362
}
363363

clippy_lints/src/utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ pub fn is_allowed(cx: &LateContext<'_, '_>, lint: &'static Lint, id: HirId) -> b
10771077
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
10781078
}
10791079

1080-
pub fn get_arg_name(pat: &Pat<'_>) -> Option<ast::Name> {
1080+
pub fn get_arg_name(pat: &Pat<'_>) -> Option<Name> {
10811081
match pat.kind {
10821082
PatKind::Binding(.., ident, None) => Some(ident.name),
10831083
PatKind::Ref(ref subpat, _) => get_arg_name(subpat),

clippy_lints/src/utils/ptr.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use crate::utils::{get_pat_name, match_var, snippet};
2-
use rustc_ast::ast::Name;
32
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
43
use rustc_hir::{Body, BodyId, Expr, ExprKind, Param};
54
use rustc_lint::LateContext;
65
use rustc_middle::hir::map::Map;
7-
use rustc_span::source_map::Span;
6+
use rustc_span::{Span, Symbol};
87
use std::borrow::Cow;
98

109
pub fn get_spans(
@@ -25,7 +24,7 @@ pub fn get_spans(
2524

2625
fn extract_clone_suggestions<'a, 'tcx>(
2726
cx: &LateContext<'a, 'tcx>,
28-
name: Name,
27+
name: Symbol,
2928
replace: &[(&'static str, &'static str)],
3029
body: &'tcx Body<'_>,
3130
) -> Option<Vec<(Span, Cow<'static, str>)>> {
@@ -46,7 +45,7 @@ fn extract_clone_suggestions<'a, 'tcx>(
4645

4746
struct PtrCloneVisitor<'a, 'tcx> {
4847
cx: &'a LateContext<'a, 'tcx>,
49-
name: Name,
48+
name: Symbol,
5049
replace: &'a [(&'static str, &'static str)],
5150
spans: Vec<(Span, Cow<'static, str>)>,
5251
abort: bool,
@@ -83,6 +82,6 @@ impl<'a, 'tcx> Visitor<'tcx> for PtrCloneVisitor<'a, 'tcx> {
8382
}
8483
}
8584

86-
fn get_binding_name(arg: &Param<'_>) -> Option<Name> {
85+
fn get_binding_name(arg: &Param<'_>) -> Option<Symbol> {
8786
get_pat_name(&arg.pat)
8887
}

clippy_lints/src/utils/usage.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::utils::match_var;
2-
use rustc_ast::ast;
32
use rustc_data_structures::fx::FxHashSet;
43
use rustc_hir::def::Res;
54
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
@@ -8,7 +7,7 @@ use rustc_infer::infer::TyCtxtInferExt;
87
use rustc_lint::LateContext;
98
use rustc_middle::hir::map::Map;
109
use rustc_middle::ty;
11-
use rustc_span::symbol::Ident;
10+
use rustc_span::symbol::{Ident, Symbol};
1211
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase};
1312

1413
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
@@ -78,8 +77,8 @@ impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
7877
}
7978

8079
pub struct UsedVisitor {
81-
pub var: ast::Name, // var to look for
82-
pub used: bool, // has the var been used otherwise?
80+
pub var: Symbol, // var to look for
81+
pub used: bool, // has the var been used otherwise?
8382
}
8483

8584
impl<'tcx> Visitor<'tcx> for UsedVisitor {

tests/ui/implicit_saturating_sub.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ fn main() {
2929
// Lint
3030
u_16 = u_16.saturating_sub(1);
3131

32-
let mut end_32: u32 = 7000;
33-
let mut start_32: u32 = 7010;
32+
let mut end_32: u32 = 7010;
33+
let mut start_32: u32 = 7000;
3434

3535
let mut u_32: u32 = end_32 - start_32;
3636

tests/ui/implicit_saturating_sub.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ fn main() {
3535
u_16 -= 1;
3636
}
3737

38-
let mut end_32: u32 = 7000;
39-
let mut start_32: u32 = 7010;
38+
let mut end_32: u32 = 7010;
39+
let mut start_32: u32 = 7000;
4040

4141
let mut u_32: u32 = end_32 - start_32;
4242

0 commit comments

Comments
 (0)