Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 03fdcff

Browse files
Rollup merge of #136114 - compiler-errors:more-idents, r=jieyouxu
Use identifiers more in diagnostics code This should make the diagnostics code slightly more correct when rendering idents in mixed crate edition situations. Kinda a no-op, but a cleanup regardless. r? oli-obk or reassign
2 parents f4a5cbd + c08624d commit 03fdcff

File tree

31 files changed

+97
-90
lines changed

31 files changed

+97
-90
lines changed

‎compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub(crate) fn expand_deriving_coerce_pointee(
157157
{
158158
cx.dcx().emit_err(RequiresMaybeSized {
159159
span: pointee_ty_ident.span,
160-
name: pointee_ty_ident.name.to_ident_string(),
160+
name: pointee_ty_ident,
161161
});
162162
return;
163163
}
@@ -471,5 +471,5 @@ struct TooManyPointees {
471471
struct RequiresMaybeSized {
472472
#[primary_span]
473473
span: Span,
474-
name: String,
474+
name: Ident,
475475
}

‎compiler/rustc_hir_analysis/src/check/compare_impl_item.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ fn try_report_async_mismatch<'tcx>(
23622362
// the right span is a bit difficult.
23632363
return Err(tcx.sess.dcx().emit_err(MethodShouldReturnFuture {
23642364
span: tcx.def_span(impl_m.def_id),
2365-
method_name: trait_m.name,
2365+
method_name: tcx.item_ident(impl_m.def_id),
23662366
trait_item_span: tcx.hir().span_if_local(trait_m.def_id),
23672367
}));
23682368
}

‎compiler/rustc_hir_analysis/src/check/mod.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
197197

198198
fn report_forbidden_specialization(tcx: TyCtxt<'_>, impl_item: DefId, parent_impl: DefId) {
199199
let span = tcx.def_span(impl_item);
200-
let ident = tcx.item_name(impl_item);
200+
let ident = tcx.item_ident(impl_item);
201201

202202
let err = match tcx.span_of_impl(parent_impl) {
203203
Ok(sp) => errors::ImplNotMarkedDefault::Ok { span, ident, ok_label: sp },
@@ -297,7 +297,7 @@ fn default_body_is_unstable(
297297
reason: Option<Symbol>,
298298
issue: Option<NonZero<u32>>,
299299
) {
300-
let missing_item_name = tcx.associated_item(item_did).name;
300+
let missing_item_name = tcx.item_ident(item_did);
301301
let (mut some_note, mut none_note, mut reason_str) = (false, false, String::new());
302302
match reason {
303303
Some(r) => {

‎compiler/rustc_hir_analysis/src/coherence/builtin.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
292292

293293
res = Err(tcx.dcx().emit_err(errors::DispatchFromDynZST {
294294
span,
295-
name: field.name,
295+
name: field.ident(tcx),
296296
ty: ty_a,
297297
}));
298298

‎compiler/rustc_hir_analysis/src/coherence/orphan.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ fn emit_orphan_check_error<'tcx>(
465465
traits::OrphanCheckErr::UncoveredTyParams(UncoveredTyParams { uncovered, local_ty }) => {
466466
let mut reported = None;
467467
for param_def_id in uncovered {
468-
let span = tcx.def_ident_span(param_def_id).unwrap();
469-
let name = tcx.item_name(param_def_id);
468+
let name = tcx.item_ident(param_def_id);
469+
let span = name.span;
470470

471471
reported.get_or_insert(match local_ty {
472472
Some(local_type) => tcx.dcx().emit_err(errors::TyParamFirstLocal {
@@ -492,7 +492,7 @@ fn lint_uncovered_ty_params<'tcx>(
492492

493493
for param_def_id in uncovered {
494494
let span = tcx.def_ident_span(param_def_id).unwrap();
495-
let name = tcx.item_name(param_def_id);
495+
let name = tcx.item_ident(param_def_id);
496496

497497
match local_ty {
498498
Some(local_type) => tcx.emit_node_span_lint(

‎compiler/rustc_hir_analysis/src/collect.rs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ fn lower_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) {
928928
tcx.dcx().emit_err(errors::EnumDiscriminantOverflowed {
929929
span,
930930
discr: prev_discr.unwrap().to_string(),
931-
item_name: tcx.item_name(variant.def_id),
931+
item_name: tcx.item_ident(variant.def_id),
932932
wrapped_discr: wrapped_discr.to_string(),
933933
});
934934
None
@@ -990,11 +990,10 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
990990
}
991991

992992
/// Check if a given field `ident` declared at `field_decl` has been declared elsewhere before.
993-
fn check_field_decl(&mut self, ident: Ident, field_decl: FieldDeclSpan) {
993+
fn check_field_decl(&mut self, field_name: Ident, field_decl: FieldDeclSpan) {
994994
use FieldDeclSpan::*;
995-
let field_name = ident.name;
996-
let ident = ident.normalize_to_macros_2_0();
997-
match (field_decl, self.seen_fields.get(&ident).copied()) {
995+
let field_name = field_name.normalize_to_macros_2_0();
996+
match (field_decl, self.seen_fields.get(&field_name).copied()) {
998997
(NotNested(span), Some(NotNested(prev_span))) => {
999998
self.tcx.dcx().emit_err(errors::FieldAlreadyDeclared::NotNested {
1000999
field_name,
@@ -1035,7 +1034,7 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
10351034
});
10361035
}
10371036
(field_decl, None) => {
1038-
self.seen_fields.insert(ident, field_decl);
1037+
self.seen_fields.insert(field_name, field_decl);
10391038
}
10401039
}
10411040
}

‎compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(super) fn find_opaque_ty_constraints_for_impl_trait_in_assoc_type(
5555
} else {
5656
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
5757
span: tcx.def_span(def_id),
58-
name: tcx.item_name(parent_def_id.to_def_id()),
58+
name: tcx.item_ident(parent_def_id.to_def_id()),
5959
what: "impl",
6060
});
6161
Ty::new_error(tcx, reported)
@@ -136,7 +136,7 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
136136
}
137137
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
138138
span: tcx.def_span(def_id),
139-
name: tcx.item_name(parent_def_id.to_def_id()),
139+
name: tcx.item_ident(parent_def_id.to_def_id()),
140140
what: match tcx.hir_node(scope) {
141141
_ if scope == hir::CRATE_HIR_ID => "module",
142142
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",

‎compiler/rustc_hir_analysis/src/errors.rs‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub(crate) struct DropImplOnWrongItem {
217217
pub(crate) enum FieldAlreadyDeclared {
218218
#[diag(hir_analysis_field_already_declared, code = E0124)]
219219
NotNested {
220-
field_name: Symbol,
220+
field_name: Ident,
221221
#[primary_span]
222222
#[label]
223223
span: Span,
@@ -226,7 +226,7 @@ pub(crate) enum FieldAlreadyDeclared {
226226
},
227227
#[diag(hir_analysis_field_already_declared_current_nested)]
228228
CurrentNested {
229-
field_name: Symbol,
229+
field_name: Ident,
230230
#[primary_span]
231231
#[label]
232232
span: Span,
@@ -239,7 +239,7 @@ pub(crate) enum FieldAlreadyDeclared {
239239
},
240240
#[diag(hir_analysis_field_already_declared_previous_nested)]
241241
PreviousNested {
242-
field_name: Symbol,
242+
field_name: Ident,
243243
#[primary_span]
244244
#[label]
245245
span: Span,
@@ -252,7 +252,7 @@ pub(crate) enum FieldAlreadyDeclared {
252252
},
253253
#[diag(hir_analysis_field_already_declared_both_nested)]
254254
BothNested {
255-
field_name: Symbol,
255+
field_name: Ident,
256256
#[primary_span]
257257
#[label]
258258
span: Span,
@@ -418,7 +418,7 @@ pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
418418
pub(crate) struct UnconstrainedOpaqueType {
419419
#[primary_span]
420420
pub span: Span,
421-
pub name: Symbol,
421+
pub name: Ident,
422422
pub what: &'static str,
423423
}
424424

@@ -802,7 +802,7 @@ pub(crate) struct EnumDiscriminantOverflowed {
802802
#[label]
803803
pub span: Span,
804804
pub discr: String,
805-
pub item_name: Symbol,
805+
pub item_name: Ident,
806806
pub wrapped_discr: String,
807807
}
808808

@@ -893,15 +893,15 @@ pub(crate) enum ImplNotMarkedDefault {
893893
span: Span,
894894
#[label(hir_analysis_ok_label)]
895895
ok_label: Span,
896-
ident: Symbol,
896+
ident: Ident,
897897
},
898898
#[diag(hir_analysis_impl_not_marked_default_err, code = E0520)]
899899
#[note]
900900
Err {
901901
#[primary_span]
902902
span: Span,
903903
cname: Symbol,
904-
ident: Symbol,
904+
ident: Ident,
905905
},
906906
}
907907

@@ -977,7 +977,7 @@ pub(crate) struct MissingTraitItemUnstable {
977977
pub some_note: bool,
978978
#[note(hir_analysis_none_note)]
979979
pub none_note: bool,
980-
pub missing_item_name: Symbol,
980+
pub missing_item_name: Ident,
981981
pub feature: Symbol,
982982
pub reason: String,
983983
}
@@ -1249,7 +1249,7 @@ pub(crate) struct InherentNominal {
12491249
pub(crate) struct DispatchFromDynZST<'a> {
12501250
#[primary_span]
12511251
pub span: Span,
1252-
pub name: Symbol,
1252+
pub name: Ident,
12531253
pub ty: Ty<'a>,
12541254
}
12551255

@@ -1389,7 +1389,7 @@ pub(crate) struct TyParamFirstLocal<'tcx> {
13891389
pub span: Span,
13901390
#[note(hir_analysis_case_note)]
13911391
pub note: (),
1392-
pub param: Symbol,
1392+
pub param: Ident,
13931393
pub local_type: Ty<'tcx>,
13941394
}
13951395

@@ -1401,7 +1401,7 @@ pub(crate) struct TyParamFirstLocalLint<'tcx> {
14011401
pub span: Span,
14021402
#[note(hir_analysis_case_note)]
14031403
pub note: (),
1404-
pub param: Symbol,
1404+
pub param: Ident,
14051405
pub local_type: Ty<'tcx>,
14061406
}
14071407

@@ -1414,7 +1414,7 @@ pub(crate) struct TyParamSome {
14141414
pub span: Span,
14151415
#[note(hir_analysis_only_note)]
14161416
pub note: (),
1417-
pub param: Symbol,
1417+
pub param: Ident,
14181418
}
14191419

14201420
#[derive(LintDiagnostic)]
@@ -1425,7 +1425,7 @@ pub(crate) struct TyParamSomeLint {
14251425
pub span: Span,
14261426
#[note(hir_analysis_only_note)]
14271427
pub note: (),
1428-
pub param: Symbol,
1428+
pub param: Ident,
14291429
}
14301430

14311431
#[derive(Diagnostic)]
@@ -1533,7 +1533,7 @@ pub(crate) struct UnsupportedDelegation<'a> {
15331533
pub(crate) struct MethodShouldReturnFuture {
15341534
#[primary_span]
15351535
pub span: Span,
1536-
pub method_name: Symbol,
1536+
pub method_name: Ident,
15371537
#[note]
15381538
pub trait_item_span: Option<Span>,
15391539
}
@@ -1585,7 +1585,7 @@ pub(crate) struct UnconstrainedGenericParameter {
15851585
#[primary_span]
15861586
#[label]
15871587
pub span: Span,
1588-
pub param_name: Symbol,
1588+
pub param_name: Ident,
15891589
pub param_def_kind: &'static str,
15901590
#[note(hir_analysis_const_param_note)]
15911591
pub const_param_note: bool,

‎compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
495495
.iter()
496496
.any(|constraint| constraint.ident.name == item.name)
497497
})
498-
.map(|item| item.name.to_ident_string())
498+
.map(|item| self.tcx.item_ident(item.def_id).to_string())
499499
.collect()
500500
} else {
501501
Vec::default()

‎compiler/rustc_hir_analysis/src/impl_wf_check.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
152152
{
153153
let mut diag = tcx.dcx().create_err(UnconstrainedGenericParameter {
154154
span: tcx.def_span(param.def_id),
155-
param_name: param.name,
155+
param_name: tcx.item_ident(param.def_id),
156156
param_def_kind: tcx.def_descr(param.def_id),
157157
const_param_note: false,
158158
const_param_note2: false,
@@ -223,7 +223,7 @@ pub(crate) fn enforce_impl_non_lifetime_params_are_constrained(
223223
let const_param_note = matches!(param.kind, ty::GenericParamDefKind::Const { .. });
224224
let mut diag = tcx.dcx().create_err(UnconstrainedGenericParameter {
225225
span: tcx.def_span(param.def_id),
226-
param_name: param.name,
226+
param_name: tcx.item_ident(param.def_id),
227227
param_def_kind: tcx.def_descr(param.def_id),
228228
const_param_note,
229229
const_param_note2: const_param_note,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /