Auto merge of #110852 - matthiaskrgr:rollup-jz3eosr, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #108760 (Add lint to deny diagnostics composed of static strings) - #109444 (Change tidy error message for TODOs) - #110419 (Spelling library) - #110550 (Suggest deref on comparison binop RHS even if type is not Copy) - #110641 (Add new rustdoc book chapter to describe in-doc settings) - #110798 (pass `unused_extern_crates` in `librustdoc::doctest::make_test`) - #110819 (simplify TrustedLen impls) - #110825 (diagnostics: add test case for already-solved issue) - #110835 (Make some region folders a little stricter.) - #110847 (rustdoc-json: Time serialization.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
1c42cb4ef0
85 changed files with 833 additions and 329 deletions
|
@ -14,6 +14,7 @@ use rustc_span::symbol::Ident;
|
|||
use rustc_span::{sym, Span};
|
||||
use rustc_target::spec::{abi, SanitizerSet};
|
||||
|
||||
use crate::errors;
|
||||
use crate::target_features::from_target_feature;
|
||||
use crate::{errors::ExpectedUsedSymbol, target_features::check_target_feature_trait_unsafe};
|
||||
|
||||
|
@ -334,10 +335,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
|||
codegen_fn_attrs.no_sanitize |= SanitizerSet::HWADDRESS
|
||||
}
|
||||
_ => {
|
||||
tcx.sess
|
||||
.struct_span_err(item.span(), "invalid argument for `no_sanitize`")
|
||||
.note("expected one of: `address`, `cfi`, `hwaddress`, `kcfi`, `memory`, `memtag`, `shadow-call-stack`, or `thread`")
|
||||
.emit();
|
||||
tcx.sess.emit_err(errors::InvalidNoSanitize { span: item.span() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -608,10 +606,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
|||
let sole_meta_list = match meta_item_list {
|
||||
Some([item]) => item.lit(),
|
||||
Some(_) => {
|
||||
tcx.sess
|
||||
.struct_span_err(attr.span, "incorrect number of arguments to `#[link_ordinal]`")
|
||||
.note("the attribute requires exactly one argument")
|
||||
.emit();
|
||||
tcx.sess.emit_err(errors::InvalidLinkOrdinalNargs { span: attr.span });
|
||||
return None;
|
||||
}
|
||||
_ => None,
|
||||
|
@ -642,10 +637,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
|||
None
|
||||
}
|
||||
} else {
|
||||
tcx.sess
|
||||
.struct_span_err(attr.span, "illegal ordinal format in `link_ordinal`")
|
||||
.note("an unsuffixed integer value, e.g., `1`, is expected")
|
||||
.emit();
|
||||
tcx.sess.emit_err(errors::InvalidLinkOrdinalFormat { span: attr.span });
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -981,3 +981,37 @@ impl IntoDiagnosticArg for ExpectedPointerMutability {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_invalid_no_sanitize)]
|
||||
#[note]
|
||||
pub struct InvalidNoSanitize {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_invalid_link_ordinal_nargs)]
|
||||
#[note]
|
||||
pub struct InvalidLinkOrdinalNargs {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_illegal_link_ordinal_format)]
|
||||
#[note]
|
||||
pub struct InvalidLinkOrdinalFormat {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_target_feature_safe_trait)]
|
||||
pub struct TargetFeatureSafeTrait {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
#[label(codegen_ssa_label_def)]
|
||||
pub def: Span,
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::errors;
|
||||
use rustc_ast::ast;
|
||||
use rustc_attr::InstructionSetAttr;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
|
@ -443,14 +444,10 @@ pub fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_s
|
|||
if let DefKind::AssocFn = tcx.def_kind(id) {
|
||||
let parent_id = tcx.local_parent(id);
|
||||
if let DefKind::Trait | DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) {
|
||||
tcx.sess
|
||||
.struct_span_err(
|
||||
attr_span,
|
||||
"`#[target_feature(..)]` cannot be applied to safe trait method",
|
||||
)
|
||||
.span_label(attr_span, "cannot be applied to safe trait method")
|
||||
.span_label(tcx.def_span(id), "not an `unsafe` function")
|
||||
.emit();
|
||||
tcx.sess.emit_err(errors::TargetFeatureSafeTrait {
|
||||
span: attr_span,
|
||||
def: tcx.def_span(id),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue