Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
commit suggestion of not always pretty printing

Co-authored-by: Urgau <[email protected]>
  • Loading branch information
sassman and Urgau committed Dec 9, 2024
1 parent 1696f53 commit 7951d19
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
mixed_export_name_no_mangle_lint_state.track_no_mangle(
attr.span,
tcx.local_def_id_to_hir_id(did),
rustc_ast_pretty::pprust::attribute_to_string(attr),
attr,
);
} else {
tcx.dcx()
Expand Down Expand Up @@ -788,22 +788,22 @@ fn check_link_name_xor_ordinal(
}

#[derive(Default)]
struct MixedExportNameAndNoMangleState {
struct MixedExportNameAndNoMangleState<'a> {
export_name: Option<Span>,
hir_id: Option<HirId>,
no_mangle: Option<Span>,
no_mangle_attr_name: Option<String>,
no_mangle_attr: Option<&'a ast::Attribute>,
}

impl MixedExportNameAndNoMangleState {
impl<'a> MixedExportNameAndNoMangleState<'a> {
fn track_export_name(&mut self, span: Span) {
self.export_name = Some(span);
}

fn track_no_mangle(&mut self, span: Span, hir_id: HirId, attr_name: String) {
fn track_no_mangle(&mut self, span: Span, hir_id: HirId, attr_name: &'a ast::Attribute) {
self.no_mangle = Some(span);
self.hir_id = Some(hir_id);
self.no_mangle_attr_name = Some(attr_name);
self.no_mangle_attr = Some(attr_name);
}

/// Emit diagnostics if the lint condition is met.
Expand All @@ -812,7 +812,7 @@ impl MixedExportNameAndNoMangleState {
export_name: Some(export_name),
no_mangle: Some(no_mangle),
hir_id: Some(hir_id),
no_mangle_attr_name: Some(no_mangle_attr_name),
no_mangle_attr: Some(no_mangle_attr),
} = self
{
tcx.emit_node_span_lint(
Expand All @@ -821,7 +821,7 @@ impl MixedExportNameAndNoMangleState {
no_mangle,
errors::MixedExportNameAndNoMangle {
no_mangle,
no_mangle_attr: no_mangle_attr_name,
no_mangle_attr: rustc_ast_pretty::pprust::attribute_to_string(no_mangle_attr),
export_name,
removal_span: no_mangle,
},
Expand Down

0 comments on commit 7951d19

Please sign in to comment.