Skip to content

Commit 67f77f5

Browse files
authored
Rollup merge of #100709 - JhonnyBillM:port-expected-used-symbol-diagnostic, r=compiler-errors
Migrate typeck's `used` expected symbol diagnostic to `SessionDiagnostic` r? ``@davidtwco``
2 parents eacbe54 + af4f66e commit 67f77f5

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

compiler/rustc_error_messages/locales/en-US/typeck.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ typeck_unused_extern_crate =
131131
typeck_extern_crate_not_idiomatic =
132132
`extern crate` is not idiomatic in the new edition
133133
.suggestion = convert it to a `{$msg_code}`
134+
135+
typeck_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`

compiler/rustc_typeck/src/collect.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -2836,12 +2836,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
28362836
codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED;
28372837
}
28382838
Some(_) => {
2839-
tcx.sess
2840-
.struct_span_err(
2841-
attr.span,
2842-
"expected `used`, `used(compiler)` or `used(linker)`",
2843-
)
2844-
.emit();
2839+
tcx.sess.emit_err(errors::ExpectedUsedSymbol { span: attr.span });
28452840
}
28462841
None => {
28472842
// Unfortunately, unconditionally using `llvm.used` causes

compiler/rustc_typeck/src/errors.rs

+7
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,10 @@ pub struct ExternCrateNotIdiomatic {
340340
pub msg_code: String,
341341
pub suggestion_code: String,
342342
}
343+
344+
#[derive(SessionDiagnostic)]
345+
#[error(typeck::expected_used_symbol)]
346+
pub struct ExpectedUsedSymbol {
347+
#[primary_span]
348+
pub span: Span,
349+
}

0 commit comments

Comments
 (0)