Skip to content

Commit fb7ad95

Browse files
authored
Rollup merge of #5856 - phansch:remove-symbol-reexport, r=flip1995
Remove old Symbol reexport I couldn't really tell what it was meant to improve. It seems more clear without the renaming to `Name`? changelog: none
2 parents 84455b2 + bb6e857 commit fb7ad95

File tree

6 files changed

+28
-36
lines changed

6 files changed

+28
-36
lines changed

clippy_lints/src/attrs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! checks for attributes
22
3-
use crate::reexport::Name;
43
use crate::utils::{
54
first_line_of_span, is_present_in_source, match_def_path, paths, snippet_opt, span_lint, span_lint_and_help,
65
span_lint_and_sugg, span_lint_and_then, without_block_comments,
@@ -517,7 +516,7 @@ fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>
517516
}
518517
}
519518

520-
fn check_attrs(cx: &LateContext<'_>, span: Span, name: Name, attrs: &[Attribute]) {
519+
fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribute]) {
521520
if span.from_expansion() {
522521
return;
523522
}

clippy_lints/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,6 @@ mod zero_div_zero;
322322

323323
pub use crate::utils::conf::Conf;
324324

325-
mod reexport {
326-
pub use rustc_span::Symbol as Name;
327-
}
328-
329325
/// Register all pre expansion lints
330326
///
331327
/// Pre-expansion lints run before any macro expansion has happened.

clippy_lints/src/lifetimes.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ use rustc_lint::{LateContext, LateLintPass};
1313
use rustc_middle::hir::map::Map;
1414
use rustc_session::{declare_lint_pass, declare_tool_lint};
1515
use rustc_span::source_map::Span;
16-
use rustc_span::symbol::kw;
16+
use rustc_span::symbol::{kw, Symbol};
1717

18-
use crate::reexport::Name;
1918
use crate::utils::{in_macro, last_path_segment, span_lint, trait_ref_of_method};
2019

2120
declare_clippy_lint! {
@@ -113,7 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for Lifetimes {
113112
enum RefLt {
114113
Unnamed,
115114
Static,
116-
Named(Name),
115+
Named(Symbol),
117116
}
118117

119118
fn check_fn_inner<'tcx>(
@@ -456,7 +455,7 @@ fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, where_clause: &'tcx WhereCl
456455
}
457456

458457
struct LifetimeChecker {
459-
map: FxHashMap<Name, Span>,
458+
map: FxHashMap<Symbol, Span>,
460459
}
461460

462461
impl<'tcx> Visitor<'tcx> for LifetimeChecker {

clippy_lints/src/loops.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::consts::constant;
2-
use crate::reexport::Name;
32
use crate::utils::paths;
43
use crate::utils::sugg::Sugg;
54
use crate::utils::usage::{is_unused, mutated_variables};
@@ -1184,7 +1183,7 @@ fn check_for_loop_range<'tcx>(
11841183
}
11851184
}
11861185

1187-
fn is_len_call(expr: &Expr<'_>, var: Name) -> bool {
1186+
fn is_len_call(expr: &Expr<'_>, var: Symbol) -> bool {
11881187
if_chain! {
11891188
if let ExprKind::MethodCall(ref method, _, ref len_args, _) = expr.kind;
11901189
if len_args.len() == 1;
@@ -1640,15 +1639,15 @@ struct VarVisitor<'a, 'tcx> {
16401639
/// var name to look for as index
16411640
var: HirId,
16421641
/// indexed variables that are used mutably
1643-
indexed_mut: FxHashSet<Name>,
1642+
indexed_mut: FxHashSet<Symbol>,
16441643
/// indirectly indexed variables (`v[(i + 4) % N]`), the extend is `None` for global
1645-
indexed_indirectly: FxHashMap<Name, Option<region::Scope>>,
1644+
indexed_indirectly: FxHashMap<Symbol, Option<region::Scope>>,
16461645
/// subset of `indexed` of vars that are indexed directly: `v[i]`
16471646
/// this will not contain cases like `v[calc_index(i)]` or `v[(i + 4) % N]`
1648-
indexed_directly: FxHashMap<Name, (Option<region::Scope>, Ty<'tcx>)>,
1647+
indexed_directly: FxHashMap<Symbol, (Option<region::Scope>, Ty<'tcx>)>,
16491648
/// Any names that are used outside an index operation.
16501649
/// Used to detect things like `&mut vec` used together with `vec[i]`
1651-
referenced: FxHashSet<Name>,
1650+
referenced: FxHashSet<Symbol>,
16521651
/// has the loop variable been used in expressions other than the index of
16531652
/// an index op?
16541653
nonindex: bool,
@@ -2004,7 +2003,7 @@ struct InitializeVisitor<'a, 'tcx> {
20042003
end_expr: &'tcx Expr<'tcx>, // the for loop. Stop scanning here.
20052004
var_id: HirId,
20062005
state: VarState,
2007-
name: Option<Name>,
2006+
name: Option<Symbol>,
20082007
depth: u32, // depth of conditional expressions
20092008
past_loop: bool,
20102009
}
@@ -2167,7 +2166,7 @@ use self::Nesting::{LookFurther, RuledOut, Unknown};
21672166

21682167
struct LoopNestVisitor {
21692168
hir_id: HirId,
2170-
iterator: Name,
2169+
iterator: Symbol,
21712170
nesting: Nesting,
21722171
}
21732172

@@ -2218,7 +2217,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor {
22182217
}
22192218
}
22202219

2221-
fn path_name(e: &Expr<'_>) -> Option<Name> {
2220+
fn path_name(e: &Expr<'_>) -> Option<Symbol> {
22222221
if let ExprKind::Path(QPath::Resolved(_, ref path)) = e.kind {
22232222
let segments = &path.segments;
22242223
if segments.len() == 1 {

clippy_lints/src/shadow.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::reexport::Name;
21
use crate::utils::{contains_name, higher, iter_input_pats, snippet, span_lint_and_then};
32
use rustc_hir::intravisit::FnKind;
43
use rustc_hir::{
@@ -10,6 +9,7 @@ use rustc_middle::lint::in_external_macro;
109
use rustc_middle::ty;
1110
use rustc_session::{declare_lint_pass, declare_tool_lint};
1211
use rustc_span::source_map::Span;
12+
use rustc_span::symbol::Symbol;
1313

1414
declare_clippy_lint! {
1515
/// **What it does:** Checks for bindings that shadow other bindings already in
@@ -123,7 +123,7 @@ fn check_fn<'tcx>(cx: &LateContext<'tcx>, decl: &'tcx FnDecl<'_>, body: &'tcx Bo
123123
check_expr(cx, &body.value, &mut bindings);
124124
}
125125

126-
fn check_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'_>, bindings: &mut Vec<(Name, Span)>) {
126+
fn check_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'_>, bindings: &mut Vec<(Symbol, Span)>) {
127127
let len = bindings.len();
128128
for stmt in block.stmts {
129129
match stmt.kind {
@@ -138,7 +138,7 @@ fn check_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'_>, bindings: &
138138
bindings.truncate(len);
139139
}
140140

141-
fn check_local<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>, bindings: &mut Vec<(Name, Span)>) {
141+
fn check_local<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>, bindings: &mut Vec<(Symbol, Span)>) {
142142
if in_external_macro(cx.sess(), local.span) {
143143
return;
144144
}
@@ -173,7 +173,7 @@ fn check_pat<'tcx>(
173173
pat: &'tcx Pat<'_>,
174174
init: Option<&'tcx Expr<'_>>,
175175
span: Span,
176-
bindings: &mut Vec<(Name, Span)>,
176+
bindings: &mut Vec<(Symbol, Span)>,
177177
) {
178178
// TODO: match more stuff / destructuring
179179
match pat.kind {
@@ -254,7 +254,7 @@ fn check_pat<'tcx>(
254254

255255
fn lint_shadow<'tcx>(
256256
cx: &LateContext<'tcx>,
257-
name: Name,
257+
name: Symbol,
258258
span: Span,
259259
pattern_span: Span,
260260
init: Option<&'tcx Expr<'_>>,
@@ -315,7 +315,7 @@ fn lint_shadow<'tcx>(
315315
}
316316
}
317317

318-
fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut Vec<(Name, Span)>) {
318+
fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut Vec<(Symbol, Span)>) {
319319
if in_external_macro(cx.sess(), expr.span) {
320320
return;
321321
}
@@ -351,7 +351,7 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut
351351
}
352352
}
353353

354-
fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(Name, Span)>) {
354+
fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(Symbol, Span)>) {
355355
match ty.kind {
356356
TyKind::Slice(ref sty) => check_ty(cx, sty, bindings),
357357
TyKind::Array(ref fty, ref anon_const) => {
@@ -371,7 +371,7 @@ fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(
371371
}
372372
}
373373

374-
fn is_self_shadow(name: Name, expr: &Expr<'_>) -> bool {
374+
fn is_self_shadow(name: Symbol, expr: &Expr<'_>) -> bool {
375375
match expr.kind {
376376
ExprKind::Box(ref inner) | ExprKind::AddrOf(_, _, ref inner) => is_self_shadow(name, inner),
377377
ExprKind::Block(ref block, _) => {
@@ -383,6 +383,6 @@ fn is_self_shadow(name: Name, expr: &Expr<'_>) -> bool {
383383
}
384384
}
385385

386-
fn path_eq_name(name: Name, path: &Path<'_>) -> bool {
386+
fn path_eq_name(name: Symbol, path: &Path<'_>) -> bool {
387387
!path.is_global() && path.segments.len() == 1 && path.segments[0].ident.as_str() == name.as_str()
388388
}

clippy_lints/src/utils/mod.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ use rustc_trait_selection::traits::query::normalize::AtExt;
5252
use smallvec::SmallVec;
5353

5454
use crate::consts::{constant, Constant};
55-
use crate::reexport::Name;
5655

5756
/// Returns `true` if the two spans come from differing expansions (i.e., one is
5857
/// from a macro and one isn't).
@@ -150,7 +149,7 @@ pub fn match_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, path: &[&str])
150149
}
151150

152151
/// Checks if an expression references a variable of the given name.
153-
pub fn match_var(expr: &Expr<'_>, var: Name) -> bool {
152+
pub fn match_var(expr: &Expr<'_>, var: Symbol) -> bool {
154153
if let ExprKind::Path(QPath::Resolved(None, ref path)) = expr.kind {
155154
if let [p] = path.segments {
156155
return p.ident.name == var;
@@ -420,7 +419,7 @@ pub fn is_entrypoint_fn(cx: &LateContext<'_>, def_id: DefId) -> bool {
420419
}
421420

422421
/// Gets the name of the item the expression is in, if available.
423-
pub fn get_item_name(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Name> {
422+
pub fn get_item_name(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Symbol> {
424423
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
425424
match cx.tcx.hir().find(parent_id) {
426425
Some(
@@ -433,7 +432,7 @@ pub fn get_item_name(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Name> {
433432
}
434433

435434
/// Gets the name of a `Pat`, if any.
436-
pub fn get_pat_name(pat: &Pat<'_>) -> Option<Name> {
435+
pub fn get_pat_name(pat: &Pat<'_>) -> Option<Symbol> {
437436
match pat.kind {
438437
PatKind::Binding(.., ref spname, _) => Some(spname.name),
439438
PatKind::Path(ref qpath) => single_segment_path(qpath).map(|ps| ps.ident.name),
@@ -443,14 +442,14 @@ pub fn get_pat_name(pat: &Pat<'_>) -> Option<Name> {
443442
}
444443

445444
struct ContainsName {
446-
name: Name,
445+
name: Symbol,
447446
result: bool,
448447
}
449448

450449
impl<'tcx> Visitor<'tcx> for ContainsName {
451450
type Map = Map<'tcx>;
452451

453-
fn visit_name(&mut self, _: Span, name: Name) {
452+
fn visit_name(&mut self, _: Span, name: Symbol) {
454453
if self.name == name {
455454
self.result = true;
456455
}
@@ -461,7 +460,7 @@ impl<'tcx> Visitor<'tcx> for ContainsName {
461460
}
462461

463462
/// Checks if an `Expr` contains a certain name.
464-
pub fn contains_name(name: Name, expr: &Expr<'_>) -> bool {
463+
pub fn contains_name(name: Symbol, expr: &Expr<'_>) -> bool {
465464
let mut cn = ContainsName { name, result: false };
466465
cn.visit_expr(expr);
467466
cn.result
@@ -1027,7 +1026,7 @@ pub fn is_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool
10271026
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
10281027
}
10291028

1030-
pub fn get_arg_name(pat: &Pat<'_>) -> Option<Name> {
1029+
pub fn get_arg_name(pat: &Pat<'_>) -> Option<Symbol> {
10311030
match pat.kind {
10321031
PatKind::Binding(.., ident, None) => Some(ident.name),
10331032
PatKind::Ref(ref subpat, _) => get_arg_name(subpat),

0 commit comments

Comments
 (0)