Skip to content

Commit a3eafc3

Browse files
committed
XXX: underscore
1 parent e6b6ba9 commit a3eafc3

File tree

39 files changed

+88
-98
lines changed

39 files changed

+88
-98
lines changed

compiler/rustc_ast/src/token.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
326326

327327
!ident_token.is_reserved_ident()
328328
|| ident_token.is_path_segment_keyword()
329-
|| [kw::Underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Typeof, kw::Dyn]
329+
|| [sym::underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Typeof, kw::Dyn]
330330
.contains(&name)
331331
}
332332

@@ -917,8 +917,7 @@ impl Token {
917917
self.is_non_raw_ident_where(Ident::is_path_segment_keyword)
918918
}
919919

920-
/// Returns true for reserved identifiers used internally for elided lifetimes,
921-
/// unnamed method parameters, error recovery etc.
920+
/// Returns true for reserved identifiers.
922921
pub fn is_special_ident(&self) -> bool {
923922
self.is_non_raw_ident_where(Ident::is_special)
924923
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11731173
// This lets rustdoc render it correctly in documentation.
11741174
hir::PatKind::Binding(_, _, ident, _) => (ident, false),
11751175
hir::PatKind::Wild => {
1176-
(Ident::with_dummy_span(rustc_span::symbol::kw::Underscore), false)
1176+
(Ident::with_dummy_span(rustc_span::symbol::sym::underscore), false)
11771177
}
11781178
_ => {
11791179
// Replace the ident for bindings that aren't simple.

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use rustc_session::lint::builtin::{
3535
};
3636
use rustc_session::lint::{BuiltinLintDiag, LintBuffer};
3737
use rustc_span::Span;
38-
use rustc_span::symbol::{Ident, kw, sym};
38+
use rustc_span::symbol::{Ident, sym};
3939
use rustc_target::spec::abi;
4040
use thin_vec::thin_vec;
4141

@@ -209,7 +209,7 @@ impl<'a> AstValidator<'a> {
209209

210210
fn visit_struct_field_def(&mut self, field: &'a FieldDef) {
211211
if let Some(ref ident) = field.ident
212-
&& ident.name == kw::Underscore
212+
&& ident.name == sym::underscore
213213
{
214214
self.visit_vis(&field.vis);
215215
self.visit_ident(ident);
@@ -563,7 +563,7 @@ impl<'a> AstValidator<'a> {
563563
}
564564

565565
fn check_item_named(&self, ident: Ident, kind: &str) {
566-
if ident.name != kw::Underscore {
566+
if ident.name != sym::underscore {
567567
return;
568568
}
569569
self.dcx().emit_err(errors::ItemUnderscore { span: ident.span, kind });

compiler/rustc_builtin_macros/src/alloc_error_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_ast::{
44
};
55
use rustc_expand::base::{Annotatable, ExtCtxt};
66
use rustc_span::Span;
7-
use rustc_span::symbol::{Ident, kw, sym};
7+
use rustc_span::symbol::{Ident, sym};
88
use thin_vec::{ThinVec, thin_vec};
99

1010
use crate::errors;
@@ -45,7 +45,7 @@ pub(crate) fn expand(
4545
// Generate anonymous constant serving as container for the allocator methods.
4646
let const_ty = ecx.ty(sig_span, TyKind::Tup(ThinVec::new()));
4747
let const_body = ecx.expr_block(ecx.block(span, stmts));
48-
let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body);
48+
let const_item = ecx.item_const(span, Ident::new(sym::underscore, span), const_ty, const_body);
4949
let const_item = if is_stmt {
5050
Annotatable::Stmt(P(ecx.stmt_item(span, const_item)))
5151
} else {

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,44 +139,44 @@ pub fn parse_asm_args<'a>(
139139
let mut explicit_reg = false;
140140
let op = if eat_operand_keyword(p, kw::In, asm_macro)? {
141141
let reg = parse_reg(p, &mut explicit_reg)?;
142-
if p.eat_keyword(kw::Underscore) {
142+
if p.eat_keyword(sym::underscore) {
143143
let err = dcx.create_err(errors::AsmUnderscoreInput { span: p.token.span });
144144
return Err(err);
145145
}
146146
let expr = p.parse_expr()?;
147147
ast::InlineAsmOperand::In { reg, expr }
148148
} else if eat_operand_keyword(p, sym::out, asm_macro)? {
149149
let reg = parse_reg(p, &mut explicit_reg)?;
150-
let expr = if p.eat_keyword(kw::Underscore) { None } else { Some(p.parse_expr()?) };
150+
let expr = if p.eat_keyword(sym::underscore) { None } else { Some(p.parse_expr()?) };
151151
ast::InlineAsmOperand::Out { reg, expr, late: false }
152152
} else if eat_operand_keyword(p, sym::lateout, asm_macro)? {
153153
let reg = parse_reg(p, &mut explicit_reg)?;
154-
let expr = if p.eat_keyword(kw::Underscore) { None } else { Some(p.parse_expr()?) };
154+
let expr = if p.eat_keyword(sym::underscore) { None } else { Some(p.parse_expr()?) };
155155
ast::InlineAsmOperand::Out { reg, expr, late: true }
156156
} else if eat_operand_keyword(p, sym::inout, asm_macro)? {
157157
let reg = parse_reg(p, &mut explicit_reg)?;
158-
if p.eat_keyword(kw::Underscore) {
158+
if p.eat_keyword(sym::underscore) {
159159
let err = dcx.create_err(errors::AsmUnderscoreInput { span: p.token.span });
160160
return Err(err);
161161
}
162162
let expr = p.parse_expr()?;
163163
if p.eat(&token::FatArrow) {
164164
let out_expr =
165-
if p.eat_keyword(kw::Underscore) { None } else { Some(p.parse_expr()?) };
165+
if p.eat_keyword(sym::underscore) { None } else { Some(p.parse_expr()?) };
166166
ast::InlineAsmOperand::SplitInOut { reg, in_expr: expr, out_expr, late: false }
167167
} else {
168168
ast::InlineAsmOperand::InOut { reg, expr, late: false }
169169
}
170170
} else if eat_operand_keyword(p, sym::inlateout, asm_macro)? {
171171
let reg = parse_reg(p, &mut explicit_reg)?;
172-
if p.eat_keyword(kw::Underscore) {
172+
if p.eat_keyword(sym::underscore) {
173173
let err = dcx.create_err(errors::AsmUnderscoreInput { span: p.token.span });
174174
return Err(err);
175175
}
176176
let expr = p.parse_expr()?;
177177
if p.eat(&token::FatArrow) {
178178
let out_expr =
179-
if p.eat_keyword(kw::Underscore) { None } else { Some(p.parse_expr()?) };
179+
if p.eat_keyword(sym::underscore) { None } else { Some(p.parse_expr()?) };
180180
ast::InlineAsmOperand::SplitInOut { reg, in_expr: expr, out_expr, late: true }
181181
} else {
182182
ast::InlineAsmOperand::InOut { reg, expr, late: true }

compiler/rustc_builtin_macros/src/global_allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_ast::{
88
};
99
use rustc_expand::base::{Annotatable, ExtCtxt};
1010
use rustc_span::Span;
11-
use rustc_span::symbol::{Ident, Symbol, kw, sym};
11+
use rustc_span::symbol::{Ident, Symbol, sym};
1212
use thin_vec::{ThinVec, thin_vec};
1313

1414
use crate::errors;
@@ -50,7 +50,7 @@ pub(crate) fn expand(
5050
// Generate anonymous constant serving as container for the allocator methods.
5151
let const_ty = ecx.ty(ty_span, TyKind::Tup(ThinVec::new()));
5252
let const_body = ecx.expr_block(ecx.block(span, stmts));
53-
let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body);
53+
let const_item = ecx.item_const(span, Ident::new(sym::underscore, span), const_ty, const_body);
5454
let const_item = if is_stmt {
5555
Annotatable::Stmt(P(ecx.stmt_item(span, const_item)))
5656
} else {

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_feature::Features;
1111
use rustc_session::Session;
1212
use rustc_span::hygiene::AstPass;
1313
use rustc_span::source_map::SourceMap;
14-
use rustc_span::symbol::{Ident, Symbol, kw, sym};
14+
use rustc_span::symbol::{Ident, Symbol, sym};
1515
use rustc_span::{DUMMY_SP, Span};
1616
use smallvec::smallvec;
1717
use thin_vec::{ThinVec, thin_vec};
@@ -384,7 +384,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
384384

385385
let anon_constant = cx.item_const(
386386
span,
387-
Ident::new(kw::Underscore, span),
387+
Ident::new(sym::underscore, span),
388388
cx.ty(span, ast::TyKind::Tup(ThinVec::new())),
389389
block,
390390
);

compiler/rustc_builtin_macros/src/standard_library_imports.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_session::Session;
66
use rustc_span::DUMMY_SP;
77
use rustc_span::edition::Edition::*;
88
use rustc_span::hygiene::AstPass;
9-
use rustc_span::symbol::{Ident, Symbol, kw, sym};
9+
use rustc_span::symbol::{Ident, Symbol, sym};
1010
use thin_vec::thin_vec;
1111

1212
pub fn inject(
@@ -56,7 +56,7 @@ pub fn inject(
5656
// we do for the panic runtime, profiler runtime, etc.
5757
cx.item(
5858
span,
59-
Ident::new(kw::Underscore, ident_span),
59+
Ident::new(sym::underscore, ident_span),
6060
thin_vec![],
6161
ast::ItemKind::ExternCrate(Some(name)),
6262
)

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub(crate) fn placeholder_type_error_diag<'cx, 'tcx>(
202202

203203
if let Some(generics) = generics {
204204
if let Some(arg) = params.iter().find(|arg| {
205-
matches!(arg.name, hir::ParamName::Plain(Ident { name: kw::Underscore, .. }))
205+
matches!(arg.name, hir::ParamName::Plain(Ident { name: sym::underscore, .. }))
206206
}) {
207207
// Account for `_` already present in cases like `struct S<_>(_);` and suggest
208208
// `struct S<T>(T);` instead of `struct S<_, T>(T);`.

compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_middle::span_bug;
99
use rustc_middle::ty::{self, Ty};
1010
use rustc_session::lint::builtin::{RUST_2021_PRELUDE_COLLISIONS, RUST_2024_PRELUDE_COLLISIONS};
1111
use rustc_span::Span;
12-
use rustc_span::symbol::kw::Underscore;
1312
use rustc_span::symbol::{Ident, sym};
1413
use rustc_trait_selection::infer::InferCtxtExt;
1514
use tracing::debug;
@@ -369,9 +368,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
369368
.collect();
370369

371370
// Find an identifier with which this trait was imported (note that `_` doesn't count).
372-
let any_id = import_items
373-
.iter()
374-
.find_map(|item| if item.ident.name != Underscore { Some(item.ident) } else { None });
371+
let any_id = import_items.iter().find_map(|item| {
372+
if item.ident.name != sym::underscore { Some(item.ident) } else { None }
373+
});
375374
if let Some(any_id) = any_id {
376375
if any_id.name == sym::empty {
377376
// Glob import, so just use its name.

0 commit comments

Comments
 (0)