Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bc0170a
Add a workaround for parallel rustc crashing when there are delayed bugs
bjorn3 Jan 24, 2025
6bdc877
Add a suggestion to cast target_feature fn items to fn pointers.
veluca93 Jan 25, 2025
d36e2b8
Incorporate `iter_nodes` into `graph::DirectedGraph`
Zalathar Jan 26, 2025
b3a5d0a
Implement phantom variance markers
jhpratt Jan 21, 2025
6f543d5
Add regression test
bjorn3 Jan 24, 2025
ebf5363
Mark all NuttX targets as tier 3 target and support the standard library
no1wudi Jan 25, 2025
ac1c6c5
Use identifiers in diagnostics more often
compiler-errors Jan 27, 2025
c08624d
Remove redundant to_ident_string calls
compiler-errors Jan 27, 2025
0b18b4f
Remove all dead files inside tests/ui/
fmease Jan 27, 2025
c38951b
Make a previously unreachable UI test reachable
fmease Jan 26, 2025
0536423
fix doc for std::sync::mpmc
usamoi Jan 22, 2025
b24f674
Change `collect_and_partition_mono_items` tuple return type to a struct
oli-obk Jan 27, 2025
f630f7f
Clarify WindowsMut (Lending)Iterator
hkBst Jan 20, 2025
b7476f1
Rollup merge of #135773 - hkBst:patch-10, r=tgross35
GuillaumeGomez Jan 27, 2025
314a695
Rollup merge of #135807 - jhpratt:phantom-variance, r=Amanieu
GuillaumeGomez Jan 27, 2025
4d5c8bd
Rollup merge of #135876 - usamoi:mpmc-doc, r=tgross35
GuillaumeGomez Jan 27, 2025
a02e788
Rollup merge of #135988 - bjorn3:workaround_parallel_rustc_crash, r=lqd
GuillaumeGomez Jan 27, 2025
2a2e5e8
Rollup merge of #136037 - no1wudi:doc, r=jieyouxu
GuillaumeGomez Jan 27, 2025
06df5cd
Rollup merge of #136064 - veluca93:tf11-fntrait-note, r=oli-obk
GuillaumeGomez Jan 27, 2025
f29979a
Rollup merge of #136082 - Zalathar:iter-nodes, r=oli-obk
GuillaumeGomez Jan 27, 2025
f4a5cbd
Rollup merge of #136112 - fmease:clean-up-all-dead-files-in-ui-tests,…
GuillaumeGomez Jan 27, 2025
03fdcff
Rollup merge of #136114 - compiler-errors:more-idents, r=jieyouxu
GuillaumeGomez Jan 27, 2025
3d02ce7
Rollup merge of #136118 - oli-obk:push-qsslxsopnrmr, r=Zalathar
GuillaumeGomez Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use identifiers in diagnostics more often
  • Loading branch information
compiler-errors committed Jan 27, 2025
commit ac1c6c50f4a82a34002231d2c1a2a5a007af959f
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ fn try_report_async_mismatch<'tcx>(
// the right span is a bit difficult.
return Err(tcx.sess.dcx().emit_err(MethodShouldReturnFuture {
span: tcx.def_span(impl_m.def_id),
method_name: trait_m.name,
method_name: tcx.item_ident(impl_m.def_id),
trait_item_span: tcx.hir().span_if_local(trait_m.def_id),
}));
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {

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

let err = match tcx.span_of_impl(parent_impl) {
Ok(sp) => errors::ImplNotMarkedDefault::Ok { span, ident, ok_label: sp },
Expand Down Expand Up @@ -297,7 +297,7 @@ fn default_body_is_unstable(
reason: Option<Symbol>,
issue: Option<NonZero<u32>>,
) {
let missing_item_name = tcx.associated_item(item_did).name;
let missing_item_name = tcx.item_ident(item_did);
let (mut some_note, mut none_note, mut reason_str) = (false, false, String::new());
match reason {
Some(r) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()

res = Err(tcx.dcx().emit_err(errors::DispatchFromDynZST {
span,
name: field.name,
name: field.ident(tcx),
ty: ty_a,
}));

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ fn emit_orphan_check_error<'tcx>(
traits::OrphanCheckErr::UncoveredTyParams(UncoveredTyParams { uncovered, local_ty }) => {
let mut reported = None;
for param_def_id in uncovered {
let span = tcx.def_ident_span(param_def_id).unwrap();
let name = tcx.item_name(param_def_id);
let name = tcx.item_ident(param_def_id);
let span = name.span;

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

for param_def_id in uncovered {
let span = tcx.def_ident_span(param_def_id).unwrap();
let name = tcx.item_name(param_def_id);
let name = tcx.item_ident(param_def_id);

match local_ty {
Some(local_type) => tcx.emit_node_span_lint(
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ fn lower_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) {
tcx.dcx().emit_err(errors::EnumDiscriminantOverflowed {
span,
discr: prev_discr.unwrap().to_string(),
item_name: tcx.item_name(variant.def_id),
item_name: tcx.item_ident(variant.def_id),
wrapped_discr: wrapped_discr.to_string(),
});
None
Expand Down Expand Up @@ -990,11 +990,10 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
}

/// Check if a given field `ident` declared at `field_decl` has been declared elsewhere before.
fn check_field_decl(&mut self, ident: Ident, field_decl: FieldDeclSpan) {
fn check_field_decl(&mut self, field_name: Ident, field_decl: FieldDeclSpan) {
use FieldDeclSpan::*;
let field_name = ident.name;
let ident = ident.normalize_to_macros_2_0();
match (field_decl, self.seen_fields.get(&ident).copied()) {
let field_name = field_name.normalize_to_macros_2_0();
match (field_decl, self.seen_fields.get(&field_name).copied()) {
(NotNested(span), Some(NotNested(prev_span))) => {
self.tcx.dcx().emit_err(errors::FieldAlreadyDeclared::NotNested {
field_name,
Expand Down Expand Up @@ -1035,7 +1034,7 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
});
}
(field_decl, None) => {
self.seen_fields.insert(ident, field_decl);
self.seen_fields.insert(field_name, field_decl);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub(super) fn find_opaque_ty_constraints_for_impl_trait_in_assoc_type(
} else {
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
span: tcx.def_span(def_id),
name: tcx.item_name(parent_def_id.to_def_id()),
name: tcx.item_ident(parent_def_id.to_def_id()),
what: "impl",
});
Ty::new_error(tcx, reported)
Expand Down Expand Up @@ -136,7 +136,7 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
}
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
span: tcx.def_span(def_id),
name: tcx.item_name(parent_def_id.to_def_id()),
name: tcx.item_ident(parent_def_id.to_def_id()),
what: match tcx.hir_node(scope) {
_ if scope == hir::CRATE_HIR_ID => "module",
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",
Expand Down
32 changes: 16 additions & 16 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub(crate) struct DropImplOnWrongItem {
pub(crate) enum FieldAlreadyDeclared {
#[diag(hir_analysis_field_already_declared, code = E0124)]
NotNested {
field_name: Symbol,
field_name: Ident,
#[primary_span]
#[label]
span: Span,
Expand All @@ -226,7 +226,7 @@ pub(crate) enum FieldAlreadyDeclared {
},
#[diag(hir_analysis_field_already_declared_current_nested)]
CurrentNested {
field_name: Symbol,
field_name: Ident,
#[primary_span]
#[label]
span: Span,
Expand All @@ -239,7 +239,7 @@ pub(crate) enum FieldAlreadyDeclared {
},
#[diag(hir_analysis_field_already_declared_previous_nested)]
PreviousNested {
field_name: Symbol,
field_name: Ident,
#[primary_span]
#[label]
span: Span,
Expand All @@ -252,7 +252,7 @@ pub(crate) enum FieldAlreadyDeclared {
},
#[diag(hir_analysis_field_already_declared_both_nested)]
BothNested {
field_name: Symbol,
field_name: Ident,
#[primary_span]
#[label]
span: Span,
Expand Down Expand Up @@ -418,7 +418,7 @@ pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
pub(crate) struct UnconstrainedOpaqueType {
#[primary_span]
pub span: Span,
pub name: Symbol,
pub name: Ident,
pub what: &'static str,
}

Expand Down Expand Up @@ -802,7 +802,7 @@ pub(crate) struct EnumDiscriminantOverflowed {
#[label]
pub span: Span,
pub discr: String,
pub item_name: Symbol,
pub item_name: Ident,
pub wrapped_discr: String,
}

Expand Down Expand Up @@ -893,15 +893,15 @@ pub(crate) enum ImplNotMarkedDefault {
span: Span,
#[label(hir_analysis_ok_label)]
ok_label: Span,
ident: Symbol,
ident: Ident,
},
#[diag(hir_analysis_impl_not_marked_default_err, code = E0520)]
#[note]
Err {
#[primary_span]
span: Span,
cname: Symbol,
ident: Symbol,
ident: Ident,
},
}

Expand Down Expand Up @@ -977,7 +977,7 @@ pub(crate) struct MissingTraitItemUnstable {
pub some_note: bool,
#[note(hir_analysis_none_note)]
pub none_note: bool,
pub missing_item_name: Symbol,
pub missing_item_name: Ident,
pub feature: Symbol,
pub reason: String,
}
Expand Down Expand Up @@ -1249,7 +1249,7 @@ pub(crate) struct InherentNominal {
pub(crate) struct DispatchFromDynZST<'a> {
#[primary_span]
pub span: Span,
pub name: Symbol,
pub name: Ident,
pub ty: Ty<'a>,
}

Expand Down Expand Up @@ -1389,7 +1389,7 @@ pub(crate) struct TyParamFirstLocal<'tcx> {
pub span: Span,
#[note(hir_analysis_case_note)]
pub note: (),
pub param: Symbol,
pub param: Ident,
pub local_type: Ty<'tcx>,
}

Expand All @@ -1401,7 +1401,7 @@ pub(crate) struct TyParamFirstLocalLint<'tcx> {
pub span: Span,
#[note(hir_analysis_case_note)]
pub note: (),
pub param: Symbol,
pub param: Ident,
pub local_type: Ty<'tcx>,
}

Expand All @@ -1414,7 +1414,7 @@ pub(crate) struct TyParamSome {
pub span: Span,
#[note(hir_analysis_only_note)]
pub note: (),
pub param: Symbol,
pub param: Ident,
}

#[derive(LintDiagnostic)]
Expand All @@ -1425,7 +1425,7 @@ pub(crate) struct TyParamSomeLint {
pub span: Span,
#[note(hir_analysis_only_note)]
pub note: (),
pub param: Symbol,
pub param: Ident,
}

#[derive(Diagnostic)]
Expand Down Expand Up @@ -1533,7 +1533,7 @@ pub(crate) struct UnsupportedDelegation<'a> {
pub(crate) struct MethodShouldReturnFuture {
#[primary_span]
pub span: Span,
pub method_name: Symbol,
pub method_name: Ident,
#[note]
pub trait_item_span: Option<Span>,
}
Expand Down Expand Up @@ -1585,7 +1585,7 @@ pub(crate) struct UnconstrainedGenericParameter {
#[primary_span]
#[label]
pub span: Span,
pub param_name: Symbol,
pub param_name: Ident,
pub param_def_kind: &'static str,
#[note(hir_analysis_const_param_note)]
pub const_param_note: bool,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/impl_wf_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
{
let mut diag = tcx.dcx().create_err(UnconstrainedGenericParameter {
span: tcx.def_span(param.def_id),
param_name: param.name,
param_name: tcx.item_ident(param.def_id),
param_def_kind: tcx.def_descr(param.def_id),
const_param_note: false,
const_param_note2: false,
Expand Down Expand Up @@ -223,7 +223,7 @@ pub(crate) fn enforce_impl_non_lifetime_params_are_constrained(
let const_param_note = matches!(param.kind, ty::GenericParamDefKind::Const { .. });
let mut diag = tcx.dcx().create_err(UnconstrainedGenericParameter {
span: tcx.def_span(param.def_id),
param_name: param.name,
param_name: tcx.item_ident(param.def_id),
param_def_kind: tcx.def_descr(param.def_id),
const_param_note,
const_param_note2: const_param_note,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/dangling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn lint_expr(cx: &LateContext<'_>, expr: &Expr<'_>) {
expr.hir_id,
method.ident.span,
DanglingPointersFromTemporaries {
callee: method.ident.name,
callee: method.ident,
ty,
ptr_span: method.ident.span,
temporary_span: receiver.span,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ pub(crate) struct IgnoredUnlessCrateSpecified<'a> {
#[help(lint_help_visit)]
// FIXME: put #[primary_span] on `ptr_span` once it does not cause conflicts
pub(crate) struct DanglingPointersFromTemporaries<'tcx> {
pub callee: Symbol,
pub callee: Ident,
pub ty: Ty<'tcx>,
#[label(lint_label_ptr)]
pub ptr_span: Span,
Expand Down Expand Up @@ -1333,7 +1333,7 @@ pub(crate) enum NonUpperCaseGlobalSub {
#[diag(lint_noop_method_call)]
#[note]
pub(crate) struct NoopMethodCallDiag<'a> {
pub method: Symbol,
pub method: Ident,
pub orig_ty: Ty<'a>,
pub trait_: Symbol,
#[suggestion(code = "", applicability = "machine-applicable")]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/noop_method_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
_ => None,
};
cx.emit_span_lint(NOOP_METHOD_CALL, span, NoopMethodCallDiag {
method: call.ident.name,
method: call.ident,
orig_ty,
trait_,
label: span,
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,15 @@ impl<'tcx> TyCtxt<'tcx> {
Some(Ident::new(def, span))
}

/// Look up the name and span of a definition.
///
/// See [`item_name`][Self::item_name] for more information.
pub fn item_ident(self, def_id: DefId) -> Ident {
self.opt_item_ident(def_id).unwrap_or_else(|| {
bug!("item_ident: no name for {:?}", self.def_path(def_id));
})
}

pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
Some(self.associated_item(def_id))
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{self, Ty};
use rustc_pattern_analysis::errors::Uncovered;
use rustc_pattern_analysis::rustc::RustcPatCtxt;
use rustc_span::{Span, Symbol};
use rustc_span::{Ident, Span, Symbol};

use crate::fluent_generated as fluent;

Expand Down Expand Up @@ -753,7 +753,7 @@ pub(crate) struct BindingsWithVariantName {
#[suggestion(code = "{ty_path}::{name}", applicability = "machine-applicable")]
pub(crate) suggestion: Option<Span>,
pub(crate) ty_path: String,
pub(crate) name: Symbol,
pub(crate) name: Ident,
}

#[derive(LintDiagnostic)]
Expand Down Expand Up @@ -797,7 +797,7 @@ pub(crate) struct BorrowOfMovedValue {
pub(crate) binding_span: Span,
#[label(mir_build_value_borrowed_label)]
pub(crate) conflicts_ref: Vec<Span>,
pub(crate) name: Symbol,
pub(crate) name: Ident,
pub(crate) ty: String,
#[suggestion(code = "ref ", applicability = "machine-applicable")]
pub(crate) suggest_borrowing: Option<Span>,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use rustc_session::lint::builtin::{
};
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::hygiene::DesugaringKind;
use rustc_span::{Span, sym};
use rustc_span::{Ident, Span, sym};
use rustc_trait_selection::infer::InferCtxtExt;
use tracing::instrument;

Expand Down Expand Up @@ -800,7 +800,7 @@ fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, 'tcx>, pat:
sess.dcx().emit_err(BorrowOfMovedValue {
binding_span: pat.span,
conflicts_ref,
name,
name: Ident::new(name, pat.span),
ty,
suggest_borrowing: Some(pat.span.shrink_to_lo()),
has_path: path.is_some(),
Expand Down Expand Up @@ -908,7 +908,7 @@ fn check_for_bindings_named_same_as_variants(
None
},
ty_path,
name,
name: Ident::new(name, pat.span),
},
)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3233,7 +3233,7 @@ pub(crate) struct MalformedCfgAttr {
pub(crate) struct UnknownBuiltinConstruct {
#[primary_span]
pub span: Span,
pub name: Symbol,
pub name: Ident,
}

#[derive(Diagnostic)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ impl<'a> Parser<'a> {
} else {
let err = self.dcx().create_err(errors::UnknownBuiltinConstruct {
span: lo.to(ident.span),
name: ident.name,
name: ident,
});
return Err(err);
};
Expand Down
Loading