diff --git a/Cargo.lock b/Cargo.lock
index a3f7b3a4367db..f035068a600d9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6070,6 +6070,7 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
name = "unicode-table-generator"
version = "0.1.0"
dependencies = [
+ "rustc-hash 2.1.1",
"ucd-parse",
]
diff --git a/RELEASES.md b/RELEASES.md
index 3ef074340de46..9dfb5c86e3cae 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -77,6 +77,7 @@ Compatibility Notes
- [For `export_name`, `link_name`, and `link_section` attributes, if multiple of the same attribute is present, the first one now takes precedence.](https://github.com/rust-lang/rust/pull/153041)
- [Update the minimum external LLVM to 21](https://github.com/rust-lang/rust/pull/153684)
- On `avr` targets, C's `double` type is 32-bit by default, so [change `c_double` to `f32` on `avr` targets to match](https://github.com/rust-lang/rust/pull/154647). This is a breaking change, but necessary to make `c_double` match C's double.
+- [`BTreeMap::append()` was optimized, which may now cause panics for types with incorrect `Ord` impls](https://github.com/rust-lang/rust/pull/153107)
diff --git a/compiler/rustc_abi/src/canon_abi.rs b/compiler/rustc_abi/src/canon_abi.rs
index 316cb05ec1806..6b4963ae92461 100644
--- a/compiler/rustc_abi/src/canon_abi.rs
+++ b/compiler/rustc_abi/src/canon_abi.rs
@@ -28,6 +28,7 @@ pub enum CanonAbi {
Rust,
RustCold,
RustPreserveNone,
+ RustTail,
/// An ABI that rustc does not know how to call or define.
Custom,
@@ -59,7 +60,10 @@ pub enum CanonAbi {
impl CanonAbi {
pub fn is_rustic_abi(self) -> bool {
match self {
- CanonAbi::Rust | CanonAbi::RustCold | CanonAbi::RustPreserveNone => true,
+ CanonAbi::Rust
+ | CanonAbi::RustCold
+ | CanonAbi::RustPreserveNone
+ | CanonAbi::RustTail => true,
CanonAbi::C
| CanonAbi::Custom
| CanonAbi::Swift
@@ -81,6 +85,7 @@ impl fmt::Display for CanonAbi {
CanonAbi::Rust => ExternAbi::Rust,
CanonAbi::RustCold => ExternAbi::RustCold,
CanonAbi::RustPreserveNone => ExternAbi::RustPreserveNone,
+ CanonAbi::RustTail => ExternAbi::RustTail,
CanonAbi::Custom => ExternAbi::Custom,
CanonAbi::Swift => ExternAbi::Swift,
CanonAbi::Arm(arm_call) => match arm_call {
diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs
index 3def8a8ccf0ba..f30b923eeed17 100644
--- a/compiler/rustc_abi/src/extern_abi.rs
+++ b/compiler/rustc_abi/src/extern_abi.rs
@@ -49,6 +49,11 @@ pub enum ExternAbi {
/// forcing callers to save all registers.
RustPreserveNone,
+ /// Ensures that calls in tail position can always be optimized into a jump.
+ ///
+ /// This ABI is not stable, and relies on LLVM implementation details.
+ RustTail,
+
/// Unstable impl detail that directly uses Rust types to describe the ABI to LLVM.
/// Even normally-compatible Rust types can become ABI-incompatible with this ABI!
Unadjusted,
@@ -205,6 +210,7 @@ abi_impls! {
System { unwind: true } =><= "system-unwind",
SysV64 { unwind: false } =><= "sysv64",
SysV64 { unwind: true } =><= "sysv64-unwind",
+ RustTail =><= "tail",
Thiscall { unwind: false } =><= "thiscall",
Thiscall { unwind: true } =><= "thiscall-unwind",
Unadjusted =><= "unadjusted",
@@ -280,7 +286,7 @@ impl ExternAbi {
/// - are subject to change between compiler versions
pub fn is_rustic_abi(self) -> bool {
use ExternAbi::*;
- matches!(self, Rust | RustCall | RustCold | RustPreserveNone)
+ matches!(self, Rust | RustCall | RustCold | RustPreserveNone | RustTail)
}
/// Returns whether the ABI supports C variadics. This only controls whether we allow *imports*
@@ -354,6 +360,7 @@ impl ExternAbi {
| Self::SysV64 { .. }
| Self::Win64 { .. }
| Self::RustPreserveNone
+ | Self::RustTail
| Self::Swift => true,
}
}
diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs
index e8df8ce6e6dc3..5628dffd51358 100644
--- a/compiler/rustc_ast_lowering/src/asm.rs
+++ b/compiler/rustc_ast_lowering/src/asm.rs
@@ -9,8 +9,7 @@ use rustc_session::errors::feature_err;
use rustc_span::{Span, sym};
use rustc_target::asm;
-use super::LoweringContext;
-use super::errors::{
+use crate::diagnostics::{
AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported,
InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst,
InvalidAsmTemplateModifierLabel, InvalidAsmTemplateModifierRegClass,
@@ -18,7 +17,9 @@ use super::errors::{
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterClassOnlyClobberStable,
RegisterConflict,
};
-use crate::{AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, ParamMode};
+use crate::{
+ AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
+};
impl<'hir> LoweringContext<'_, 'hir> {
pub(crate) fn lower_inline_asm(
diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs
index 5af13c70ef693..68ae9e68b029a 100644
--- a/compiler/rustc_ast_lowering/src/delegation.rs
+++ b/compiler/rustc_ast_lowering/src/delegation.rs
@@ -56,7 +56,7 @@ use rustc_span::symbol::kw;
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol};
use crate::delegation::generics::{GenericsGenerationResult, GenericsGenerationResults};
-use crate::errors::{
+use crate::diagnostics::{
CycleInDelegationSignatureResolution, DelegationAttemptedBlockWithDefsDeletion,
DelegationBlockSpecifiedWhenNoParams, UnresolvedDelegationCallee,
};
diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/diagnostics.rs
similarity index 100%
rename from compiler/rustc_ast_lowering/src/errors.rs
rename to compiler/rustc_ast_lowering/src/diagnostics.rs
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index ce20aaf4e0276..23c7159cb91fe 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -19,17 +19,17 @@ use visit::{Visitor, walk_expr};
mod closure;
-use super::errors::{
+use crate::diagnostics::{
AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks,
- FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd, MatchArmWithNoBody,
- MoveExprOnlyInPlainClosures, NeverPatternWithBody, NeverPatternWithGuard,
- UnderscoreExprLhsAssign,
+ FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd,
+ InvalidLegacyConstGenericArg, MatchArmWithNoBody, MoveExprOnlyInPlainClosures,
+ NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign, UseConstGenericArg,
+ YieldInClosure,
};
-use super::{
- GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt,
+use crate::{
+ AllowReturnTypeNotation, GenericArgsMode, ImplTraitContext, ImplTraitPosition, LoweringContext,
+ ParamMode, ResolverAstLoweringExt, TryBlockScope,
};
-use crate::errors::{InvalidLegacyConstGenericArg, UseConstGenericArg, YieldInClosure};
-use crate::{AllowReturnTypeNotation, ImplTraitPosition, TryBlockScope};
pub(super) struct WillCreateDefIdsVisitor;
diff --git a/compiler/rustc_ast_lowering/src/expr/closure.rs b/compiler/rustc_ast_lowering/src/expr/closure.rs
index 1c2a22e475232..cc2c6ae2879c1 100644
--- a/compiler/rustc_ast_lowering/src/expr/closure.rs
+++ b/compiler/rustc_ast_lowering/src/expr/closure.rs
@@ -7,7 +7,7 @@ use rustc_span::Span;
use super::{LoweringContext, MoveExprInitializerFinder, MoveExprState};
use crate::FnDeclKind;
-use crate::errors::{ClosureCannotBeStatic, CoroutineTooManyParameters};
+use crate::diagnostics::{ClosureCannotBeStatic, CoroutineTooManyParameters};
impl<'hir> LoweringContext<'_, 'hir> {
// Entry point for `ExprKind::Closure`. Plain closures go through
diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs
index 99c31551d234d..0e518c10e3bb7 100644
--- a/compiler/rustc_ast_lowering/src/item.rs
+++ b/compiler/rustc_ast_lowering/src/item.rs
@@ -19,7 +19,9 @@ use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;
use tracing::instrument;
-use super::errors::{InvalidAbi, InvalidAbiSuggestion, TupleStructWithDefault, UnionWithDefault};
+use super::diagnostics::{
+ InvalidAbi, InvalidAbiSuggestion, TupleStructWithDefault, UnionWithDefault,
+};
use super::stability::{enabled_names, gate_unstable_abi};
use super::{
AstOwner, FnDeclKind, GenericArgsMode, ImplTraitContext, ImplTraitPosition, LoweringContext,
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 6dc7de2911c0c..8b4a2795ec90c 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -70,7 +70,7 @@ use smallvec::SmallVec;
use thin_vec::ThinVec;
use tracing::{debug, instrument, trace};
-use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
+use crate::diagnostics::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
use crate::item::Owners;
macro_rules! arena_vec {
@@ -83,7 +83,7 @@ mod asm;
mod block;
mod contract;
mod delegation;
-mod errors;
+mod diagnostics;
mod expr;
mod format;
mod index;
@@ -1145,17 +1145,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
{
let err = match (&data.inputs[..], &data.output) {
([_, ..], FnRetTy::Default(_)) => {
- errors::BadReturnTypeNotation::Inputs { span: data.inputs_span }
+ diagnostics::BadReturnTypeNotation::Inputs {
+ span: data.inputs_span,
+ }
}
([], FnRetTy::Default(_)) => {
- errors::BadReturnTypeNotation::NeedsDots { span: data.inputs_span }
+ diagnostics::BadReturnTypeNotation::NeedsDots {
+ span: data.inputs_span,
+ }
}
// The case `T: Trait Ret>` is handled in the parser.
(_, FnRetTy::Ty(ty)) => {
let span = data.inputs_span.shrink_to_hi().to(ty.span);
- errors::BadReturnTypeNotation::Output {
+ diagnostics::BadReturnTypeNotation::Output {
span,
- suggestion: errors::RTNSuggestion {
+ suggestion: diagnostics::RTNSuggestion {
output: span,
input: data.inputs_span,
},
@@ -1226,7 +1230,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
_ => None,
};
- let guar = self.dcx().emit_err(errors::MisplacedAssocTyBinding {
+ let guar = self.dcx().emit_err(diagnostics::MisplacedAssocTyBinding {
span: constraint.span,
suggestion,
});
@@ -1529,7 +1533,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ast::GenericBound::Use(_, span) => Some(span),
_ => None,
}) {
- self.tcx.dcx().emit_err(errors::NoPreciseCapturesOnApit { span });
+ self.tcx.dcx().emit_err(diagnostics::NoPreciseCapturesOnApit { span });
}
let def_id = self.local_def_id(*def_node_id);
@@ -2123,7 +2127,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.filter(|_| match source {
hir::GenericParamSource::Generics => true,
hir::GenericParamSource::Binder => {
- self.dcx().emit_err(errors::GenericParamDefaultInBinder {
+ self.dcx().emit_err(diagnostics::GenericParamDefaultInBinder {
span: param.span(),
});
@@ -2154,7 +2158,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
.filter(|anon_const| match source {
hir::GenericParamSource::Generics => true,
hir::GenericParamSource::Binder => {
- let err = errors::GenericParamDefaultInBinder { span: param.span() };
+ let err =
+ diagnostics::GenericParamDefaultInBinder { span: param.span() };
if expr::WillCreateDefIdsVisitor
.visit_expr(&anon_const.value)
.is_break()
diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs
index cf0615b8244e5..8780b70fadfa4 100644
--- a/compiler/rustc_ast_lowering/src/pat.rs
+++ b/compiler/rustc_ast_lowering/src/pat.rs
@@ -7,10 +7,10 @@ use rustc_hir::{self as hir, LangItem, Target};
use rustc_middle::span_bug;
use rustc_span::{DesugaringKind, Ident, Span, Spanned, respan};
-use super::errors::{
+use crate::diagnostics::{
ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,
};
-use super::{
+use crate::{
AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
};
diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs
index f5a306aa9140d..42c4af5add12d 100644
--- a/compiler/rustc_ast_lowering/src/path.rs
+++ b/compiler/rustc_ast_lowering/src/path.rs
@@ -11,11 +11,11 @@ use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
use smallvec::smallvec;
use tracing::{debug, instrument};
-use super::errors::{
+use crate::diagnostics::{
AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation,
GenericTypeWithParentheses, RTNSuggestion, UseAngleBrackets,
};
-use super::{
+use crate::{
AllowReturnTypeNotation, GenericArgsCtor, GenericArgsMode, ImplTraitContext, ImplTraitPosition,
LifetimeRes, LoweringContext, ParamMode,
};
diff --git a/compiler/rustc_ast_lowering/src/stability.rs b/compiler/rustc_ast_lowering/src/stability.rs
index 00b6a353d93f6..b58087e4aa3a6 100644
--- a/compiler/rustc_ast_lowering/src/stability.rs
+++ b/compiler/rustc_ast_lowering/src/stability.rs
@@ -100,6 +100,9 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
feature: sym::rust_preserve_none_cc,
explain: GateReason::Experimental,
}),
+ ExternAbi::RustTail => {
+ Err(UnstableAbi { abi, feature: sym::rust_tail_cc, explain: GateReason::Experimental })
+ }
ExternAbi::RustInvalid => {
Err(UnstableAbi { abi, feature: sym::rustc_attrs, explain: GateReason::ImplDetail })
}
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs
index afaee6e542082..db0c5256184c5 100644
--- a/compiler/rustc_ast_passes/src/ast_validation.rs
+++ b/compiler/rustc_ast_passes/src/ast_validation.rs
@@ -39,7 +39,7 @@ use rustc_span::{Ident, Span, kw, sym};
use rustc_target::spec::{AbiMap, AbiMapping};
use thin_vec::thin_vec;
-use crate::errors::{self, TildeConstReason};
+use crate::diagnostics::{self, TildeConstReason};
/// Is `self` allowed semantically as the first parameter in an `FnDecl`?
enum SelfSemantic {
@@ -161,7 +161,7 @@ impl<'a> AstValidator<'a> {
fn check_type_alias_where_clause_location(
&mut self,
ty_alias: &TyAlias,
- ) -> Result<(), errors::WhereClauseBeforeTypeAlias> {
+ ) -> Result<(), diagnostics::WhereClauseBeforeTypeAlias> {
if ty_alias.ty.is_none() || !ty_alias.generics.where_clause.has_where_token {
return Ok(());
}
@@ -189,16 +189,16 @@ impl<'a> AstValidator<'a> {
state.print_where_predicate(p);
}
- errors::WhereClauseBeforeTypeAliasSugg::Move {
+ diagnostics::WhereClauseBeforeTypeAliasSugg::Move {
left: span,
snippet: state.s.eof(),
right: ty_alias.after_where_clause.span.shrink_to_hi(),
}
} else {
- errors::WhereClauseBeforeTypeAliasSugg::Remove { span }
+ diagnostics::WhereClauseBeforeTypeAliasSugg::Remove { span }
};
- Err(errors::WhereClauseBeforeTypeAlias { span, sugg })
+ Err(diagnostics::WhereClauseBeforeTypeAlias { span, sugg })
}
fn with_impl_trait(&mut self, outer_span: Option, f: impl FnOnce(&mut Self)) {
@@ -226,7 +226,7 @@ impl<'a> AstValidator<'a> {
if let Some(bound1) = use_bounds.next()
&& let Some(bound2) = use_bounds.next()
{
- self.dcx().emit_err(errors::DuplicatePreciseCapturing { bound1, bound2 });
+ self.dcx().emit_err(diagnostics::DuplicatePreciseCapturing { bound1, bound2 });
}
}
TyKind::TraitObject(..) => self
@@ -241,12 +241,16 @@ impl<'a> AstValidator<'a> {
self.sess.dcx()
}
- fn visibility_not_permitted(&self, vis: &Visibility, note: errors::VisibilityNotPermittedNote) {
+ fn visibility_not_permitted(
+ &self,
+ vis: &Visibility,
+ note: diagnostics::VisibilityNotPermittedNote,
+ ) {
if let VisibilityKind::Inherited = vis.kind {
return;
}
- self.dcx().emit_err(errors::VisibilityNotPermitted {
+ self.dcx().emit_err(diagnostics::VisibilityNotPermitted {
span: vis.span,
note,
remove_qualifier_sugg: vis.span,
@@ -276,7 +280,7 @@ impl<'a> AstValidator<'a> {
return;
};
- self.dcx().emit_err(errors::ImplFnConst { span, parent_constness });
+ self.dcx().emit_err(diagnostics::ImplFnConst { span, parent_constness });
}
fn check_trait_fn_not_const(&self, constness: Const, parent: &TraitOrImpl) {
@@ -309,7 +313,7 @@ impl<'a> AstValidator<'a> {
};
let parent_constness = parent.constness();
- self.dcx().emit_err(errors::TraitFnConst {
+ self.dcx().emit_err(diagnostics::TraitFnConst {
span,
in_impl: matches!(parent, TraitOrImpl::TraitImpl { .. }),
const_context_label: parent_constness,
@@ -341,7 +345,7 @@ impl<'a> AstValidator<'a> {
TraitOrImpl::Impl { .. } => "impl",
};
- self.dcx().emit_err(errors::AsyncFnInConstTraitOrTraitImpl {
+ self.dcx().emit_err(diagnostics::AsyncFnInConstTraitOrTraitImpl {
async_keyword,
context,
const_keyword,
@@ -361,7 +365,7 @@ impl<'a> AstValidator<'a> {
let max_num_args: usize = u16::MAX.into();
if fn_decl.inputs.len() > max_num_args {
let Param { span, .. } = fn_decl.inputs[0];
- self.dcx().emit_fatal(errors::FnParamTooMany { span, max_num_args });
+ self.dcx().emit_fatal(diagnostics::FnParamTooMany { span, max_num_args });
}
}
@@ -373,7 +377,7 @@ impl<'a> AstValidator<'a> {
[ps @ .., _] => {
for Param { ty, span, .. } in ps {
if let TyKind::CVarArgs = ty.kind {
- self.dcx().emit_err(errors::FnParamCVarArgsNotLast { span: *span });
+ self.dcx().emit_err(diagnostics::FnParamCVarArgsNotLast { span: *span });
}
}
}
@@ -400,9 +404,9 @@ impl<'a> AstValidator<'a> {
})
.for_each(|attr| {
if attr.is_doc_comment() {
- self.dcx().emit_err(errors::FnParamDocComment { span: attr.span });
+ self.dcx().emit_err(diagnostics::FnParamDocComment { span: attr.span });
} else {
- self.dcx().emit_err(errors::FnParamForbiddenAttr { span: attr.span });
+ self.dcx().emit_err(diagnostics::FnParamForbiddenAttr { span: attr.span });
}
});
}
@@ -410,7 +414,7 @@ impl<'a> AstValidator<'a> {
fn check_decl_self_param(&self, fn_decl: &FnDecl, self_semantic: SelfSemantic) {
if let (SelfSemantic::No, [param, ..]) = (self_semantic, &*fn_decl.inputs) {
if param.is_self() {
- self.dcx().emit_err(errors::FnParamForbiddenSelf { span: param.span });
+ self.dcx().emit_err(diagnostics::FnParamForbiddenSelf { span: param.span });
}
}
}
@@ -424,6 +428,7 @@ impl<'a> AstValidator<'a> {
| CanonAbi::Rust
| CanonAbi::RustCold
| CanonAbi::RustPreserveNone
+ | CanonAbi::RustTail
| CanonAbi::Swift
| CanonAbi::Arm(_)
| CanonAbi::X86(_) => { /* nothing to check */ }
@@ -462,7 +467,8 @@ impl<'a> AstValidator<'a> {
if spans.is_empty() {
spans = vec![sig.span];
}
- self.dcx().emit_err(errors::AbiX86Interrupt { spans, param_count });
+ self.dcx()
+ .emit_err(diagnostics::AbiX86Interrupt { spans, param_count });
}
self.reject_return(abi, sig);
@@ -485,12 +491,15 @@ impl<'a> AstValidator<'a> {
Safety::Safe(safe_span) => {
let source_map = self.sess.psess.source_map();
let safe_span = source_map.span_until_non_whitespace(safe_span.to(sig.span));
- dcx.emit_err(errors::AbiCustomSafeForeignFunction { span: sig.span, safe_span });
+ dcx.emit_err(diagnostics::AbiCustomSafeForeignFunction {
+ span: sig.span,
+ safe_span,
+ });
}
Safety::Default => match ctxt {
FnCtxt::Foreign => { /* all good */ }
FnCtxt::Free | FnCtxt::Assoc(_) => {
- dcx.emit_err(errors::AbiCustomSafeFunction {
+ dcx.emit_err(diagnostics::AbiCustomSafeFunction {
span: sig.span,
abi,
unsafe_span: sig.span.shrink_to_lo(),
@@ -508,7 +517,7 @@ impl<'a> AstValidator<'a> {
.source_map()
.span_until_non_whitespace(coroutine_kind.span().to(sig.span));
- self.dcx().emit_err(errors::AbiCannotBeCoroutine {
+ self.dcx().emit_err(diagnostics::AbiCannotBeCoroutine {
span: sig.span,
abi,
coroutine_kind_span,
@@ -525,7 +534,7 @@ impl<'a> AstValidator<'a> {
_ => true,
}
{
- self.dcx().emit_err(errors::AbiMustNotHaveReturnType { span: ret_ty.span, abi });
+ self.dcx().emit_err(diagnostics::AbiMustNotHaveReturnType { span: ret_ty.span, abi });
}
}
@@ -546,7 +555,7 @@ impl<'a> AstValidator<'a> {
let suggestion_span = header_span.shrink_to_hi().to(sig.decl.output.span());
let padding = if header_span.is_empty() { "" } else { " " };
- self.dcx().emit_err(errors::AbiMustNotHaveParametersOrReturnType {
+ self.dcx().emit_err(diagnostics::AbiMustNotHaveParametersOrReturnType {
spans,
symbol: ident.name,
suggestion_span,
@@ -567,7 +576,7 @@ impl<'a> AstValidator<'a> {
if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_))
&& extern_safety == Safety::Default
{
- self.dcx().emit_err(errors::InvalidSafetyOnExtern {
+ self.dcx().emit_err(diagnostics::InvalidSafetyOnExtern {
item_span: span,
block: Some(self.current_extern_span().shrink_to_lo()),
});
@@ -575,7 +584,7 @@ impl<'a> AstValidator<'a> {
}
None => {
if matches!(safety, Safety::Safe(_)) {
- self.dcx().emit_err(errors::InvalidSafetyOnItem { span });
+ self.dcx().emit_err(diagnostics::InvalidSafetyOnItem { span });
}
}
}
@@ -583,7 +592,7 @@ impl<'a> AstValidator<'a> {
fn check_fn_ptr_safety(&self, span: Span, safety: Safety) {
if matches!(safety, Safety::Safe(_)) {
- self.dcx().emit_err(errors::InvalidSafetyOnFnPtr { span });
+ self.dcx().emit_err(diagnostics::InvalidSafetyOnFnPtr { span });
}
}
@@ -597,11 +606,11 @@ impl<'a> AstValidator<'a> {
match defaultness {
Defaultness::Default(def_span) if matches!(allow_default, AllowDefault::No) => {
let span = self.sess.source_map().guess_head_span(span);
- self.dcx().emit_err(errors::ForbiddenDefault { span, def_span });
+ self.dcx().emit_err(diagnostics::ForbiddenDefault { span, def_span });
}
Defaultness::Final(def_span) if matches!(allow_final, AllowFinal::No) => {
let span = self.sess.source_map().guess_head_span(span);
- self.dcx().emit_err(errors::ForbiddenFinal { span, def_span });
+ self.dcx().emit_err(diagnostics::ForbiddenFinal { span, def_span });
}
_ => (),
}
@@ -612,7 +621,7 @@ impl<'a> AstValidator<'a> {
&& let Defaultness::Final(def_span) = defaultness
{
let span = self.sess.source_map().guess_head_span(item.span);
- self.dcx().emit_err(errors::ForbiddenFinalWithoutBody { span, def_span });
+ self.dcx().emit_err(diagnostics::ForbiddenFinalWithoutBody { span, def_span });
}
}
@@ -635,12 +644,12 @@ impl<'a> AstValidator<'a> {
[b0] => b0.span(),
[b0, .., bl] => b0.span().to(bl.span()),
};
- self.dcx().emit_err(errors::BoundInContext { span, ctx });
+ self.dcx().emit_err(diagnostics::BoundInContext { span, ctx });
}
fn check_foreign_ty_genericless(&self, generics: &Generics, after_where_clause: &WhereClause) {
let cannot_have = |span, descr, remove_descr| {
- self.dcx().emit_err(errors::ExternTypesCannotHave {
+ self.dcx().emit_err(diagnostics::ExternTypesCannotHave {
span,
descr,
remove_descr,
@@ -666,7 +675,7 @@ impl<'a> AstValidator<'a> {
let Some(body_span) = body_span else {
return;
};
- self.dcx().emit_err(errors::BodyInExtern {
+ self.dcx().emit_err(diagnostics::BodyInExtern {
span: ident.span,
body: body_span,
block: self.current_extern_span(),
@@ -679,7 +688,7 @@ impl<'a> AstValidator<'a> {
let Some(body) = body else {
return;
};
- self.dcx().emit_err(errors::FnBodyInExtern {
+ self.dcx().emit_err(diagnostics::FnBodyInExtern {
span: ident.span,
body: body.span,
block: self.current_extern_span(),
@@ -697,7 +706,7 @@ impl<'a> AstValidator<'a> {
FnHeader { safety: _, coroutine_kind, constness, ext }: FnHeader,
) {
let report_err = |span, kw| {
- self.dcx().emit_err(errors::FnQualifierInExtern {
+ self.dcx().emit_err(diagnostics::FnQualifierInExtern {
span,
kw,
block: self.current_extern_span(),
@@ -720,7 +729,7 @@ impl<'a> AstValidator<'a> {
/// An item in `extern { ... }` cannot use non-ascii identifier.
fn check_foreign_item_ascii_only(&self, ident: Ident) {
if !ident.as_str().is_ascii() {
- self.dcx().emit_err(errors::ExternItemAscii {
+ self.dcx().emit_err(diagnostics::ExternItemAscii {
span: ident.span,
block: self.current_extern_span(),
});
@@ -752,7 +761,7 @@ impl<'a> AstValidator<'a> {
}
if let Some(coroutine_kind) = sig.header.coroutine_kind {
- self.dcx().emit_err(errors::CoroutineAndCVariadic {
+ self.dcx().emit_err(diagnostics::CoroutineAndCVariadic {
spans: vec![coroutine_kind.span(), variadic_param.span],
coroutine_kind: coroutine_kind.as_str(),
coroutine_span: coroutine_kind.span(),
@@ -765,7 +774,7 @@ impl<'a> AstValidator<'a> {
FnCtxt::Free | FnCtxt::Assoc(_) => {
match self.sess.target.supports_c_variadic_definitions() {
CVariadicStatus::NotSupported => {
- self.dcx().emit_err(errors::CVariadicNotSupported {
+ self.dcx().emit_err(diagnostics::CVariadicNotSupported {
variadic_span: variadic_param.span,
target: &*self.sess.target.llvm_target,
});
@@ -785,7 +794,7 @@ impl<'a> AstValidator<'a> {
match sig.header.ext {
Extern::Implicit(_) => {
if !matches!(sig.header.safety, Safety::Unsafe(_)) {
- self.dcx().emit_err(errors::CVariadicMustBeUnsafe {
+ self.dcx().emit_err(diagnostics::CVariadicMustBeUnsafe {
span: variadic_param.span,
unsafe_span: sig.safety_span(),
});
@@ -800,14 +809,14 @@ impl<'a> AstValidator<'a> {
self.check_c_variadic_abi(abi, attrs, variadic_param.span, sig);
if !matches!(sig.header.safety, Safety::Unsafe(_)) {
- self.dcx().emit_err(errors::CVariadicMustBeUnsafe {
+ self.dcx().emit_err(diagnostics::CVariadicMustBeUnsafe {
span: variadic_param.span,
unsafe_span: sig.safety_span(),
});
}
}
Extern::None => {
- let err = errors::CVariadicNoExtern { span: variadic_param.span };
+ let err = diagnostics::CVariadicNoExtern { span: variadic_param.span };
self.dcx().emit_err(err);
}
}
@@ -854,7 +863,7 @@ impl<'a> AstValidator<'a> {
}
CVariadicStatus::NotSupported => {
// Some ABIs, e.g. `extern "Rust"`, never support c-variadic functions.
- self.dcx().emit_err(errors::CVariadicBadNakedExtern {
+ self.dcx().emit_err(diagnostics::CVariadicBadNakedExtern {
span: dotdotdot_span,
abi: abi.as_str(),
extern_span: sig.extern_span(),
@@ -862,7 +871,7 @@ impl<'a> AstValidator<'a> {
}
}
} else if !matches!(abi, ExternAbi::C { .. }) {
- self.dcx().emit_err(errors::CVariadicBadExtern {
+ self.dcx().emit_err(diagnostics::CVariadicBadExtern {
span: dotdotdot_span,
abi: abi.as_str(),
extern_span: sig.extern_span(),
@@ -874,7 +883,7 @@ impl<'a> AstValidator<'a> {
if ident.name != kw::Underscore {
return;
}
- self.dcx().emit_err(errors::ItemUnderscore { span: ident.span, kind });
+ self.dcx().emit_err(diagnostics::ItemUnderscore { span: ident.span, kind });
}
fn check_nomangle_item_asciionly(&self, ident: Ident, item_span: Span) {
@@ -882,26 +891,26 @@ impl<'a> AstValidator<'a> {
return;
}
let span = self.sess.source_map().guess_head_span(item_span);
- self.dcx().emit_err(errors::NoMangleAscii { span });
+ self.dcx().emit_err(diagnostics::NoMangleAscii { span });
}
fn check_mod_file_item_asciionly(&self, ident: Ident) {
if ident.name.as_str().is_ascii() {
return;
}
- self.dcx().emit_err(errors::ModuleNonAscii { span: ident.span, name: ident.name });
+ self.dcx().emit_err(diagnostics::ModuleNonAscii { span: ident.span, name: ident.name });
}
fn deny_const_auto_traits(&self, constness: Const) {
if let Const::Yes(span) = constness {
- self.dcx().emit_err(errors::ConstAutoTrait { span });
+ self.dcx().emit_err(diagnostics::ConstAutoTrait { span });
}
}
fn deny_generic_params(&self, generics: &Generics, ident_span: Span) {
if !generics.params.is_empty() {
self.dcx()
- .emit_err(errors::AutoTraitGeneric { span: generics.span, ident: ident_span });
+ .emit_err(diagnostics::AutoTraitGeneric { span: generics.span, ident: ident_span });
}
}
@@ -909,7 +918,7 @@ impl<'a> AstValidator<'a> {
if let [.., last] = &bounds[..] {
let span = bounds.iter().map(|b| b.span()).collect();
let removal = ident.shrink_to_hi().to(last.span());
- self.dcx().emit_err(errors::AutoTraitBounds { span, removal, ident });
+ self.dcx().emit_err(diagnostics::AutoTraitBounds { span, removal, ident });
}
}
@@ -917,7 +926,7 @@ impl<'a> AstValidator<'a> {
if !where_clause.predicates.is_empty() {
// FIXME: The current diagnostic is misleading since it only talks about
// super trait and lifetime bounds while we should just say “bounds”.
- self.dcx().emit_err(errors::AutoTraitBounds {
+ self.dcx().emit_err(diagnostics::AutoTraitBounds {
span: vec![where_clause.span],
removal: where_clause.span,
ident,
@@ -929,7 +938,7 @@ impl<'a> AstValidator<'a> {
if !trait_items.is_empty() {
let spans: Vec<_> = trait_items.iter().map(|i| i.kind.ident().unwrap().span).collect();
let total = trait_items.first().unwrap().span.to(trait_items.last().unwrap().span);
- self.dcx().emit_err(errors::AutoTraitItems { spans, total, ident: ident_span });
+ self.dcx().emit_err(diagnostics::AutoTraitItems { spans, total, ident: ident_span });
}
}
@@ -975,13 +984,13 @@ impl<'a> AstValidator<'a> {
let args_len = arg_spans.len();
let constraint_len = constraint_spans.len();
// ...and then error:
- self.dcx().emit_err(errors::ArgsBeforeConstraint {
+ self.dcx().emit_err(diagnostics::ArgsBeforeConstraint {
arg_spans: arg_spans.clone(),
constraints: constraint_spans[0],
args: *arg_spans.iter().last().unwrap(),
data: data.span,
- constraint_spans: errors::EmptyLabelManySpans(constraint_spans),
- arg_spans2: errors::EmptyLabelManySpans(arg_spans),
+ constraint_spans: diagnostics::EmptyLabelManySpans(constraint_spans),
+ arg_spans2: diagnostics::EmptyLabelManySpans(arg_spans),
suggestion: self.correct_generic_order_suggestion(data),
constraint_len,
args_len,
@@ -994,7 +1003,7 @@ impl<'a> AstValidator<'a> {
self.check_fn_ptr_safety(bfty.decl_span, bfty.safety);
self.check_fn_decl(&bfty.decl, SelfSemantic::No);
Self::check_decl_no_pat(&bfty.decl, |span, _, _| {
- self.dcx().emit_err(errors::PatternFnPointer { span });
+ self.dcx().emit_err(diagnostics::PatternFnPointer { span });
});
if let Extern::Implicit(extern_span) = bfty.ext {
self.handle_missing_abi(extern_span, ty.id);
@@ -1005,8 +1014,9 @@ impl<'a> AstValidator<'a> {
for bound in bounds {
if let GenericBound::Outlives(lifetime) = bound {
if any_lifetime_bounds {
- self.dcx()
- .emit_err(errors::TraitObjectBound { span: lifetime.ident.span });
+ self.dcx().emit_err(diagnostics::TraitObjectBound {
+ span: lifetime.ident.span,
+ });
break;
}
any_lifetime_bounds = true;
@@ -1015,7 +1025,7 @@ impl<'a> AstValidator<'a> {
}
TyKind::ImplTrait(_, bounds) => {
if let Some(outer_impl_trait_sp) = self.outer_impl_trait_span {
- self.dcx().emit_err(errors::NestedImplTrait {
+ self.dcx().emit_err(diagnostics::NestedImplTrait {
span: ty.span,
outer: outer_impl_trait_sp,
inner: ty.span,
@@ -1023,7 +1033,7 @@ impl<'a> AstValidator<'a> {
}
if !bounds.iter().any(|b| matches!(b, GenericBound::Trait(..))) {
- self.dcx().emit_err(errors::AtLeastOneTrait { span: ty.span });
+ self.dcx().emit_err(diagnostics::AtLeastOneTrait { span: ty.span });
}
}
_ => {}
@@ -1034,7 +1044,7 @@ impl<'a> AstValidator<'a> {
// FIXME(davidtwco): This is a hack to detect macros which produce spans of the
// call site which do not have a macro backtrace. See #61963.
if span.edition().at_least_edition_future() && self.features.explicit_extern_abis() {
- self.dcx().emit_err(errors::MissingAbi { span });
+ self.dcx().emit_err(diagnostics::MissingAbi { span });
} else if self
.sess
.source_map()
@@ -1045,7 +1055,7 @@ impl<'a> AstValidator<'a> {
MISSING_ABI,
id,
span,
- errors::MissingAbiSugg { span, default_abi: ExternAbi::FALLBACK },
+ diagnostics::MissingAbiSugg { span, default_abi: ExternAbi::FALLBACK },
)
}
}
@@ -1126,7 +1136,7 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
ordered_params += ">";
for (param_ord, (max_param, spans)) in &out_of_order {
- dcx.emit_err(errors::OutOfOrderParams {
+ dcx.emit_err(diagnostics::OutOfOrderParams {
spans: spans.clone(),
sugg_span: span,
param_ord: param_ord.to_string(),
@@ -1171,15 +1181,15 @@ impl Visitor<'_> for AstValidator<'_> {
self.visit_attrs_vis(&item.attrs, &item.vis);
self.visibility_not_permitted(
&item.vis,
- errors::VisibilityNotPermittedNote::TraitImpl,
+ diagnostics::VisibilityNotPermittedNote::TraitImpl,
);
if let TyKind::Dummy = self_ty.kind {
// Abort immediately otherwise the `TyKind::Dummy` will reach HIR lowering,
// which isn't allowed. Not a problem for this obscure, obsolete syntax.
- self.dcx().emit_fatal(errors::ObsoleteAuto { span: item.span });
+ self.dcx().emit_fatal(diagnostics::ObsoleteAuto { span: item.span });
}
if let (&Safety::Unsafe(span), &ImplPolarity::Negative(sp)) = (safety, polarity) {
- self.dcx().emit_err(errors::UnsafeNegativeImpl {
+ self.dcx().emit_err(diagnostics::UnsafeNegativeImpl {
span: sp.to(t.path.span),
negative: sp,
r#unsafe: span,
@@ -1212,7 +1222,7 @@ impl Visitor<'_> for AstValidator<'_> {
self.visit_attrs_vis(&item.attrs, &item.vis);
self.visibility_not_permitted(
&item.vis,
- errors::VisibilityNotPermittedNote::IndividualImplItems,
+ diagnostics::VisibilityNotPermittedNote::IndividualImplItems,
);
let disallowed = matches!(constness, ast::Const::No)
@@ -1254,19 +1264,19 @@ impl Visitor<'_> for AstValidator<'_> {
let is_intrinsic = item.attrs.iter().any(|a| a.has_name(sym::rustc_intrinsic));
if body.is_none() && !is_intrinsic && !self.is_sdylib_interface {
- self.dcx().emit_err(errors::FnWithoutBody {
+ self.dcx().emit_err(diagnostics::FnWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
extern_block_suggestion: match sig.header.ext {
Extern::None => None,
Extern::Implicit(start_span) => {
- Some(errors::ExternBlockSuggestion::Implicit {
+ Some(diagnostics::ExternBlockSuggestion::Implicit {
start_span,
end_span: item.span.shrink_to_hi(),
})
}
Extern::Explicit(abi, start_span) => {
- Some(errors::ExternBlockSuggestion::Explicit {
+ Some(diagnostics::ExternBlockSuggestion::Explicit {
start_span,
end_span: item.span.shrink_to_hi(),
abi: abi.symbol_unescaped,
@@ -1283,18 +1293,18 @@ impl Visitor<'_> for AstValidator<'_> {
let old_item = mem::replace(&mut self.extern_mod_span, Some(item.span));
self.visibility_not_permitted(
&item.vis,
- errors::VisibilityNotPermittedNote::IndividualForeignItems,
+ diagnostics::VisibilityNotPermittedNote::IndividualForeignItems,
);
if &Safety::Default == safety {
if item.span.at_least_rust_2024() {
- self.dcx().emit_err(errors::MissingUnsafeOnExtern { span: item.span });
+ self.dcx().emit_err(diagnostics::MissingUnsafeOnExtern { span: item.span });
} else {
self.lint_buffer.buffer_lint(
MISSING_UNSAFE_ON_EXTERN,
item.id,
item.span,
- errors::MissingUnsafeOnExternLint {
+ diagnostics::MissingUnsafeOnExternLint {
suggestion: item.span.shrink_to_lo(),
},
);
@@ -1315,12 +1325,12 @@ impl Visitor<'_> for AstValidator<'_> {
for variant in &def.variants {
self.visibility_not_permitted(
&variant.vis,
- errors::VisibilityNotPermittedNote::EnumVariant,
+ diagnostics::VisibilityNotPermittedNote::EnumVariant,
);
for field in variant.data.fields() {
self.visibility_not_permitted(
&field.vis,
- errors::VisibilityNotPermittedNote::EnumVariant,
+ diagnostics::VisibilityNotPermittedNote::EnumVariant,
);
}
}
@@ -1364,7 +1374,7 @@ impl Visitor<'_> for AstValidator<'_> {
}
ItemKind::Mod(safety, ident, mod_kind) => {
if let &Safety::Unsafe(span) = safety {
- self.dcx().emit_err(errors::UnsafeItem { span, kind: "module" });
+ self.dcx().emit_err(diagnostics::UnsafeItem { span, kind: "module" });
}
// Ensure that `path` attributes on modules are recorded as used (cf. issue #35584).
if !matches!(mod_kind, ModKind::Loaded(_, Inline::Yes, _))
@@ -1381,13 +1391,15 @@ impl Visitor<'_> for AstValidator<'_> {
item.attrs.iter().find(|attr| attr.has_name(sym::rustc_scalable_vector));
if let Some(attr) = scalable_vector_attr {
if !matches!(vdata, VariantData::Tuple(..)) {
- this.dcx()
- .emit_err(errors::ScalableVectorNotTupleStruct { span: item.span });
+ this.dcx().emit_err(diagnostics::ScalableVectorNotTupleStruct {
+ span: item.span,
+ });
}
if !self.sess.target.arch.supports_scalable_vectors()
&& !self.sess.opts.actually_rustdoc
{
- this.dcx().emit_err(errors::ScalableVectorBadArch { span: attr.span });
+ this.dcx()
+ .emit_err(diagnostics::ScalableVectorBadArch { span: attr.span });
}
}
@@ -1403,7 +1415,7 @@ impl Visitor<'_> for AstValidator<'_> {
}
ItemKind::Union(ident, generics, vdata) => {
if vdata.fields().is_empty() {
- self.dcx().emit_err(errors::FieldlessUnion { span: item.span });
+ self.dcx().emit_err(diagnostics::FieldlessUnion { span: item.span });
}
self.with_tilde_const(Some(TildeConstReason::Union { span: item.span }), |this| {
match vdata {
@@ -1419,7 +1431,7 @@ impl Visitor<'_> for AstValidator<'_> {
ItemKind::Const(ConstItem { defaultness, ident, rhs_kind, .. }) => {
self.check_defaultness(item.span, *defaultness, AllowDefault::No, AllowFinal::No);
if !rhs_kind.has_expr() {
- self.dcx().emit_err(errors::ConstWithoutBody {
+ self.dcx().emit_err(diagnostics::ConstWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
@@ -1432,7 +1444,7 @@ impl Visitor<'_> for AstValidator<'_> {
UNUSED_VISIBILITIES,
item.id,
item.vis.span,
- errors::UnusedVisibility { span: item.vis.span },
+ diagnostics::UnusedVisibility { span: item.vis.span },
)
}
@@ -1441,11 +1453,11 @@ impl Visitor<'_> for AstValidator<'_> {
ItemKind::Static(StaticItem { expr, safety, .. }) => {
self.check_item_safety(item.span, *safety);
if matches!(safety, Safety::Unsafe(_)) {
- self.dcx().emit_err(errors::UnsafeStatic { span: item.span });
+ self.dcx().emit_err(diagnostics::UnsafeStatic { span: item.span });
}
if expr.is_none() {
- self.dcx().emit_err(errors::StaticWithoutBody {
+ self.dcx().emit_err(diagnostics::StaticWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
@@ -1457,7 +1469,7 @@ impl Visitor<'_> for AstValidator<'_> {
) => {
self.check_defaultness(item.span, *defaultness, AllowDefault::No, AllowFinal::No);
if ty.is_none() {
- self.dcx().emit_err(errors::TyAliasWithoutBody {
+ self.dcx().emit_err(diagnostics::TyAliasWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
@@ -1469,7 +1481,7 @@ impl Visitor<'_> for AstValidator<'_> {
self.dcx().emit_err(err);
}
} else if after_where_clause.has_where_token {
- self.dcx().emit_err(errors::WhereClauseAfterTypeAlias {
+ self.dcx().emit_err(diagnostics::WhereClauseAfterTypeAlias {
span: after_where_clause.span,
help: self.sess.is_nightly_build(),
});
@@ -1499,7 +1511,7 @@ impl Visitor<'_> for AstValidator<'_> {
if let Some(attr) = attr::find_by_name(fi.attrs(), sym::track_caller)
&& self.extern_mod_abi != Some(ExternAbi::Rust)
{
- self.dcx().emit_err(errors::RequiresRustAbi {
+ self.dcx().emit_err(diagnostics::RequiresRustAbi {
track_caller_span: attr.span,
extern_abi_span: self.current_extern_span(),
});
@@ -1573,7 +1585,7 @@ impl Visitor<'_> for AstValidator<'_> {
}
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
if let Some(span) = prev_param_default {
- self.dcx().emit_err(errors::GenericDefaultTrailing { span });
+ self.dcx().emit_err(diagnostics::GenericDefaultTrailing { span });
break;
}
}
@@ -1602,8 +1614,9 @@ impl Visitor<'_> for AstValidator<'_> {
match bound {
GenericBound::Trait(t) => {
if !t.bound_generic_params.is_empty() {
- self.dcx()
- .emit_err(errors::NestedLifetimes { span: t.span });
+ self.dcx().emit_err(diagnostics::NestedLifetimes {
+ span: t.span,
+ });
}
}
GenericBound::Outlives(_) => {}
@@ -1627,12 +1640,13 @@ impl Visitor<'_> for AstValidator<'_> {
BoundConstness::Always(_),
BoundPolarity::Positive,
) => {
- self.dcx().emit_err(errors::ConstBoundTraitObject { span: trait_ref.span });
+ self.dcx()
+ .emit_err(diagnostics::ConstBoundTraitObject { span: trait_ref.span });
}
(_, BoundConstness::Maybe(span), BoundPolarity::Positive)
if let Some(reason) = self.disallow_tilde_const =>
{
- self.dcx().emit_err(errors::TildeConstDisallowed { span, reason });
+ self.dcx().emit_err(diagnostics::TildeConstDisallowed { span, reason });
}
_ => {}
}
@@ -1645,7 +1659,7 @@ impl Visitor<'_> for AstValidator<'_> {
Some(ast::GenericArgs::AngleBracketed(args)) => {
for arg in &args.args {
if let ast::AngleBracketedArg::Constraint(constraint) = arg {
- self.dcx().emit_err(errors::ConstraintOnNegativeBound {
+ self.dcx().emit_err(diagnostics::ConstraintOnNegativeBound {
span: constraint.span,
});
}
@@ -1653,9 +1667,11 @@ impl Visitor<'_> for AstValidator<'_> {
}
// The lowered form of parenthesized generic args contains an associated type binding.
Some(ast::GenericArgs::Parenthesized(args)) => {
- self.dcx().emit_err(errors::NegativeBoundWithParentheticalNotation {
- span: args.span,
- });
+ self.dcx().emit_err(
+ diagnostics::NegativeBoundWithParentheticalNotation {
+ span: args.span,
+ },
+ );
}
Some(ast::GenericArgs::ParenthesizedElided(_)) | None => {}
}
@@ -1665,7 +1681,7 @@ impl Visitor<'_> for AstValidator<'_> {
GenericBound::Use(_, span) => match ctxt {
BoundKind::Impl => {}
BoundKind::Bound | BoundKind::TraitObject | BoundKind::SuperTraits => {
- self.dcx().emit_err(errors::PreciseCapturingNotAllowedHere {
+ self.dcx().emit_err(diagnostics::PreciseCapturingNotAllowedHere {
loc: ctxt.descr(),
span: *span,
});
@@ -1705,7 +1721,7 @@ impl Visitor<'_> for AstValidator<'_> {
if let Some(attr) = attr::find_by_name(attrs, sym::track_caller)
&& extern_abi != ExternAbi::Rust
{
- self.dcx().emit_err(errors::RequiresRustAbi {
+ self.dcx().emit_err(diagnostics::RequiresRustAbi {
track_caller_span: attr.span,
extern_abi_span,
});
@@ -1722,7 +1738,7 @@ impl Visitor<'_> for AstValidator<'_> {
..
}) = fk.header()
{
- self.dcx().emit_err(errors::ConstAndCoroutine {
+ self.dcx().emit_err(diagnostics::ConstAndCoroutine {
spans: vec![coroutine_kind.span(), const_span],
const_span,
coroutine_span: coroutine_kind.span(),
@@ -1754,11 +1770,11 @@ impl Visitor<'_> for AstValidator<'_> {
id,
span,
move |dcx, level| {
- let sub = errors::PatternsInFnsWithoutBodySub { ident, span };
+ let sub = diagnostics::PatternsInFnsWithoutBodySub { ident, span };
if is_foreign {
- errors::PatternsInFnsWithoutBody::Foreign { sub }
+ diagnostics::PatternsInFnsWithoutBody::Foreign { sub }
} else {
- errors::PatternsInFnsWithoutBody::Bodiless { sub }
+ diagnostics::PatternsInFnsWithoutBody::Bodiless { sub }
}
.into_diag(dcx, level)
},
@@ -1766,8 +1782,10 @@ impl Visitor<'_> for AstValidator<'_> {
}
} else {
match ctxt {
- FnCtxt::Foreign => self.dcx().emit_err(errors::PatternInForeign { span }),
- _ => self.dcx().emit_err(errors::PatternInBodiless { span }),
+ FnCtxt::Foreign => {
+ self.dcx().emit_err(diagnostics::PatternInForeign { span })
+ }
+ _ => self.dcx().emit_err(diagnostics::PatternInBodiless { span }),
};
}
});
@@ -1814,7 +1832,7 @@ impl Visitor<'_> for AstValidator<'_> {
match &item.kind {
AssocItemKind::Const(ConstItem { rhs_kind, .. }) => {
if !rhs_kind.has_expr() {
- self.dcx().emit_err(errors::AssocConstWithoutBody {
+ self.dcx().emit_err(diagnostics::AssocConstWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
@@ -1822,7 +1840,7 @@ impl Visitor<'_> for AstValidator<'_> {
}
AssocItemKind::Fn(Fn { body, .. }) => {
if body.is_none() && !self.is_sdylib_interface {
- self.dcx().emit_err(errors::AssocFnWithoutBody {
+ self.dcx().emit_err(diagnostics::AssocFnWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
@@ -1830,7 +1848,7 @@ impl Visitor<'_> for AstValidator<'_> {
}
AssocItemKind::Type(TyAlias { bounds, ty, .. }) => {
if ty.is_none() {
- self.dcx().emit_err(errors::AssocTypeWithoutBody {
+ self.dcx().emit_err(diagnostics::AssocTypeWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
@@ -1845,8 +1863,8 @@ impl Visitor<'_> for AstValidator<'_> {
&& let Err(err) = self.check_type_alias_where_clause_location(ty_alias)
{
let sugg = match err.sugg {
- errors::WhereClauseBeforeTypeAliasSugg::Remove { .. } => None,
- errors::WhereClauseBeforeTypeAliasSugg::Move { snippet, right, .. } => {
+ diagnostics::WhereClauseBeforeTypeAliasSugg::Remove { .. } => None,
+ diagnostics::WhereClauseBeforeTypeAliasSugg::Move { snippet, right, .. } => {
Some((right, snippet))
}
};
@@ -1862,17 +1880,17 @@ impl Visitor<'_> for AstValidator<'_> {
move |dcx, level| {
let suggestion = match sugg {
Some((right_sp, sugg)) => {
- errors::DeprecatedWhereClauseLocationSugg::MoveToEnd {
+ diagnostics::DeprecatedWhereClauseLocationSugg::MoveToEnd {
left: left_sp,
right: right_sp,
sugg,
}
}
- None => errors::DeprecatedWhereClauseLocationSugg::RemoveWhere {
+ None => diagnostics::DeprecatedWhereClauseLocationSugg::RemoveWhere {
span: err.span,
},
};
- errors::DeprecatedWhereClauseLocation { suggestion }.into_diag(dcx, level)
+ diagnostics::DeprecatedWhereClauseLocation { suggestion }.into_diag(dcx, level)
},
);
}
@@ -1881,7 +1899,7 @@ impl Visitor<'_> for AstValidator<'_> {
Some(parent @ (TraitOrImpl::Trait { .. } | TraitOrImpl::TraitImpl { .. })) => {
self.visibility_not_permitted(
&item.vis,
- errors::VisibilityNotPermittedNote::TraitImpl,
+ diagnostics::VisibilityNotPermittedNote::TraitImpl,
);
if let AssocItemKind::Fn(Fn { sig, .. }) = &item.kind {
self.check_trait_fn_not_const(sig.header.constness, parent);
@@ -1952,7 +1970,7 @@ fn deny_equality_constraints(
predicate_span: Span,
generics: &Generics,
) {
- let mut err = errors::EqualityInWhere { span: predicate_span, assoc: None, assoc2: None };
+ let mut err = diagnostics::EqualityInWhere { span: predicate_span, assoc: None, assoc2: None };
// Given `::Bar = RhsTy`, suggest `A: Foo`.
if let TyKind::Path(Some(qself), full_path) = &predicate.lhs_ty.kind
@@ -1995,7 +2013,7 @@ fn deny_equality_constraints(
);
}
}
- err.assoc = Some(errors::AssociatedSuggestion {
+ err.assoc = Some(diagnostics::AssociatedSuggestion {
span: predicate_span,
ident: *ident,
param: param.ident,
@@ -2046,7 +2064,7 @@ fn deny_equality_constraints(
}
span
};
- err.assoc2 = Some(errors::AssociatedSuggestion2 {
+ err.assoc2 = Some(diagnostics::AssociatedSuggestion2 {
span,
args,
predicate: removal_span,
diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/diagnostics.rs
similarity index 100%
rename from compiler/rustc_ast_passes/src/errors.rs
rename to compiler/rustc_ast_passes/src/diagnostics.rs
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs
index fd0070bd9c529..09672d1e69f11 100644
--- a/compiler/rustc_ast_passes/src/feature_gate.rs
+++ b/compiler/rustc_ast_passes/src/feature_gate.rs
@@ -10,7 +10,7 @@ use rustc_session::errors::{feature_err, feature_warn};
use rustc_span::{Span, Spanned, Symbol, sym};
use thin_vec::ThinVec;
-use crate::errors;
+use crate::diagnostics;
/// The common case.
macro_rules! gate {
@@ -133,7 +133,7 @@ impl<'a> PostExpansionVisitor<'a> {
.collect();
if !const_param_spans.is_empty() {
- self.sess.dcx().emit_err(errors::ForbiddenConstParam { const_param_spans });
+ self.sess.dcx().emit_err(diagnostics::ForbiddenConstParam { const_param_spans });
}
}
@@ -144,9 +144,9 @@ impl<'a> PostExpansionVisitor<'a> {
// Issue #149695
// Abort immediately otherwise items defined in complex bounds will be lowered into HIR,
// which will cause ICEs when errors of the items visit unlowered parents.
- self.sess.dcx().emit_fatal(errors::ForbiddenBound { spans });
+ self.sess.dcx().emit_fatal(diagnostics::ForbiddenBound { spans });
} else {
- self.sess.dcx().emit_err(errors::ForbiddenBound { spans });
+ self.sess.dcx().emit_err(diagnostics::ForbiddenBound { spans });
}
}
}
@@ -553,7 +553,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
// Under no circumstances do we want to advertise the feature name to users!
if !visitor.features.negative_bounds() {
for &span in spans.get(&sym::negative_bounds).into_iter().flatten() {
- sess.dcx().emit_err(errors::NegativeBoundUnsupported { span });
+ sess.dcx().emit_err(diagnostics::NegativeBoundUnsupported { span });
}
}
@@ -570,7 +570,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
.emit();
} else {
let suggestion = span.shrink_to_hi();
- sess.dcx().emit_err(errors::MatchArmWithNoBody { span, suggestion });
+ sess.dcx().emit_err(diagnostics::MatchArmWithNoBody { span, suggestion });
}
}
}
@@ -645,7 +645,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
AttributeParser::parse_limited(sess, &krate.attrs, &[sym::feature])
{
// `feature(...)` used on non-nightly. This is definitely an error.
- let mut err = errors::FeatureOnNonNightly {
+ let mut err = diagnostics::FeatureOnNonNightly {
span: first_span,
channel: option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)"),
stable_features: vec![],
@@ -662,7 +662,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
.map(|feat| feat.stable_since)
.flatten();
if let Some(since) = stable_since {
- err.stable_features.push(errors::StableFeature { name, since });
+ err.stable_features.push(diagnostics::StableFeature { name, since });
} else {
all_stable = false;
}
@@ -688,7 +688,11 @@ fn check_incompatible_features(sess: &Session, features: &Features) {
&& let Some((f2_name, f2_span)) = enabled_features.clone().find(|(name, _)| name == f2)
{
let spans = vec![f1_span, f2_span];
- sess.dcx().emit_err(errors::IncompatibleFeatures { spans, f1: f1_name, f2: f2_name });
+ sess.dcx().emit_err(diagnostics::IncompatibleFeatures {
+ spans,
+ f1: f1_name,
+ f2: f2_name,
+ });
}
}
}
@@ -709,7 +713,11 @@ fn check_dependent_features(sess: &Session, features: &Features) {
.map(|s| format!("`{}`", s.as_str()))
.intersperse(String::from(", "))
.collect();
- sess.dcx().emit_err(errors::MissingDependentFeatures { parent_span, parent, missing });
+ sess.dcx().emit_err(diagnostics::MissingDependentFeatures {
+ parent_span,
+ parent,
+ missing,
+ });
}
}
}
@@ -727,7 +735,7 @@ fn check_new_solver_banned_features(sess: &Session, features: &Features) {
.map(|feat| feat.attr_sp)
{
#[allow(rustc::symbol_intern_string_literal)]
- sess.dcx().emit_err(errors::IncompatibleFeatures {
+ sess.dcx().emit_err(diagnostics::IncompatibleFeatures {
spans: vec![gce_span],
f1: Symbol::intern("-Znext-solver=globally"),
f2: sym::generic_const_exprs,
@@ -749,7 +757,7 @@ fn check_features_requiring_new_solver(sess: &Session, features: &Features) {
.map(|feat| feat.attr_sp)
{
#[allow(rustc::symbol_intern_string_literal)]
- sess.dcx().emit_err(errors::MissingDependentFeatures {
+ sess.dcx().emit_err(diagnostics::MissingDependentFeatures {
parent_span: gca_span,
parent: sym::generic_const_args,
missing: String::from("-Znext-solver=globally"),
diff --git a/compiler/rustc_ast_passes/src/lib.rs b/compiler/rustc_ast_passes/src/lib.rs
index 8bf51dd10a844..86ad758807584 100644
--- a/compiler/rustc_ast_passes/src/lib.rs
+++ b/compiler/rustc_ast_passes/src/lib.rs
@@ -9,5 +9,5 @@
// tidy-alphabetical-end
pub mod ast_validation;
-mod errors;
+mod diagnostics;
pub mod feature_gate;
diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs
index cf5a722f0529e..27960e96bc111 100644
--- a/compiler/rustc_attr_parsing/src/interface.rs
+++ b/compiler/rustc_attr_parsing/src/interface.rs
@@ -8,7 +8,7 @@ use rustc_ast::token::DocFragmentKind;
use rustc_ast::{AttrItemKind, AttrStyle, CRATE_NODE_ID, NodeId, Safety};
use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan};
-use rustc_feature::{AttributeTemplate, Features};
+use rustc_feature::{AttributeTemplate, BUILTIN_ATTRIBUTE_MAP, Features};
use rustc_hir::attrs::AttributeKind;
use rustc_hir::{AttrArgs, AttrItem, AttrPath, Attribute, HashIgnoredAttrId, Target};
use rustc_lint_defs::RegisteredTools;
@@ -355,6 +355,9 @@ impl<'sess> AttributeParser<'sess> {
&mut emit_lint,
);
self.check_attribute_stability(&attr_path, attr_span, accept.stability);
+ if let [part] = parts.as_slice() {
+ debug_assert!(BUILTIN_ATTRIBUTE_MAP.contains(&part));
+ }
let Some(args) = ArgParser::from_attr_args(
args,
diff --git a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
index bca2de041b657..4d93fa08fe0bd 100644
--- a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
+++ b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
@@ -1,7 +1,7 @@
use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def_id::LocalDefId;
use rustc_infer::infer::SubregionOrigin;
-use rustc_infer::infer::canonical::QueryRegionConstraints;
+use rustc_infer::infer::canonical::{QueryRegionConstraint, QueryRegionConstraints};
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
use rustc_infer::infer::region_constraints::{GenericKind, VerifyBound};
@@ -74,9 +74,9 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
let assumptions =
elaborate::elaborate_outlives_assumptions(self.infcx.tcx, assumptions.iter().copied());
- for &(constraint, constraint_category, _) in constraints {
+ for &QueryRegionConstraint { constraint, category, .. } in constraints {
constraint.iter_outlives().for_each(|predicate| {
- self.convert(predicate, constraint_category, &assumptions);
+ self.convert(predicate, category, &assumptions);
});
}
}
@@ -296,7 +296,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
// FIXME(higher_ranked_auto): What should we do with the assumptions here?
if let Some(QueryRegionConstraints { constraints, assumptions: _ }) = constraints {
next_outlives_predicates.extend(constraints.iter().flat_map(
- |(constraint, category, _)| {
+ |QueryRegionConstraint { constraint, category, .. }| {
constraint.iter_outlives().map(|outlives| (outlives, *category))
},
));
diff --git a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs
index 5f78758513e17..544ad86120356 100644
--- a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs
+++ b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs
@@ -6,7 +6,7 @@ use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::{Ident, Span, kw, sym};
use thin_vec::{ThinVec, thin_vec};
-use crate::errors;
+use crate::diagnostics;
use crate::util::check_builtin_macro_attribute;
pub(crate) fn expand(
@@ -31,7 +31,7 @@ pub(crate) fn expand(
{
(item, fn_kind.ident, true, ecx.with_def_site_ctxt(fn_kind.sig.span))
} else {
- ecx.dcx().emit_err(errors::AllocErrorMustBeFn { span: item.span() });
+ ecx.dcx().emit_err(diagnostics::AllocErrorMustBeFn { span: item.span() });
return vec![orig_item];
};
diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs
index a1e14b5245137..b67b1fdb42048 100644
--- a/compiler/rustc_builtin_macros/src/asm.rs
+++ b/compiler/rustc_builtin_macros/src/asm.rs
@@ -12,7 +12,7 @@ use rustc_span::{ErrorGuaranteed, InnerSpan, Span, Symbol, sym};
use rustc_target::asm::InlineAsmArch;
use smallvec::smallvec;
-use crate::errors;
+use crate::diagnostics;
use crate::util::{ExprToSpannedString, expr_to_spanned_string};
/// Validated assembly arguments, ready for macro expansion.
@@ -65,7 +65,7 @@ fn validate_asm_args<'a>(
for arg in args {
for attr in arg.attributes.0.iter() {
if !matches!(attr.name(), Some(sym::cfg | sym::cfg_attr)) {
- ecx.dcx().emit_err(errors::AsmAttributeNotSupported { span: attr.span() });
+ ecx.dcx().emit_err(diagnostics::AsmAttributeNotSupported { span: attr.span() });
}
}
@@ -86,7 +86,7 @@ fn validate_asm_args<'a>(
) => {}
ast::ExprKind::MacCall(..) => {}
_ => {
- let err = dcx.create_err(errors::AsmExpectedOther {
+ let err = dcx.create_err(diagnostics::AsmExpectedOther {
span: template.span,
is_inline_asm: matches!(asm_macro, AsmMacro::Asm),
});
@@ -111,12 +111,12 @@ fn validate_asm_args<'a>(
if explicit_reg {
if name.is_some() {
- dcx.emit_err(errors::AsmExplicitRegisterName { span });
+ dcx.emit_err(diagnostics::AsmExplicitRegisterName { span });
}
validated.reg_args.insert(slot);
} else if let Some(name) = name {
if let Some(&prev) = validated.named_args.get(&name) {
- dcx.emit_err(errors::AsmDuplicateArg {
+ dcx.emit_err(diagnostics::AsmDuplicateArg {
span,
name,
prev: validated.operands[prev].1,
@@ -130,7 +130,7 @@ fn validate_asm_args<'a>(
let explicit =
validated.reg_args.iter().map(|p| validated.operands[p].1).collect();
- dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit });
+ dcx.emit_err(diagnostics::AsmPositionalAfter { span, named, explicit });
}
}
AsmArgKind::Options(new_options) => {
@@ -141,7 +141,7 @@ fn validate_asm_args<'a>(
if !asm_macro.is_supported_option(options) {
// Tool-only output.
- dcx.emit_err(errors::AsmUnsupportedOption {
+ dcx.emit_err(diagnostics::AsmUnsupportedOption {
span,
symbol,
span_with_comma,
@@ -149,7 +149,7 @@ fn validate_asm_args<'a>(
});
} else if validated.options.contains(options) {
// Tool-only output.
- dcx.emit_err(errors::AsmOptAlreadyprovided {
+ dcx.emit_err(diagnostics::AsmOptAlreadyprovided {
span,
symbol,
span_with_comma,
@@ -178,13 +178,13 @@ fn validate_asm_args<'a>(
&& validated.options.contains(ast::InlineAsmOptions::READONLY)
{
let spans = validated.options_spans.clone();
- dcx.emit_err(errors::AsmMutuallyExclusive { spans, opt1: "nomem", opt2: "readonly" });
+ dcx.emit_err(diagnostics::AsmMutuallyExclusive { spans, opt1: "nomem", opt2: "readonly" });
}
if validated.options.contains(ast::InlineAsmOptions::PURE)
&& validated.options.contains(ast::InlineAsmOptions::NORETURN)
{
let spans = validated.options_spans.clone();
- dcx.emit_err(errors::AsmMutuallyExclusive { spans, opt1: "pure", opt2: "noreturn" });
+ dcx.emit_err(diagnostics::AsmMutuallyExclusive { spans, opt1: "pure", opt2: "noreturn" });
}
if validated.options.contains(ast::InlineAsmOptions::PURE)
&& !validated
@@ -192,7 +192,7 @@ fn validate_asm_args<'a>(
.intersects(ast::InlineAsmOptions::NOMEM | ast::InlineAsmOptions::READONLY)
{
let spans = validated.options_spans.clone();
- dcx.emit_err(errors::AsmPureCombine { spans });
+ dcx.emit_err(diagnostics::AsmPureCombine { spans });
}
let mut have_real_output = false;
@@ -223,24 +223,24 @@ fn validate_asm_args<'a>(
}
}
if validated.options.contains(ast::InlineAsmOptions::PURE) && !have_real_output {
- dcx.emit_err(errors::AsmPureNoOutput { spans: validated.options_spans.clone() });
+ dcx.emit_err(diagnostics::AsmPureNoOutput { spans: validated.options_spans.clone() });
}
if validated.options.contains(ast::InlineAsmOptions::NORETURN)
&& !outputs_sp.is_empty()
&& labels_sp.is_empty()
{
- let err = dcx.create_err(errors::AsmNoReturn { outputs_sp });
+ let err = dcx.create_err(diagnostics::AsmNoReturn { outputs_sp });
// Bail out now since this is likely to confuse MIR
return Err(err);
}
if validated.options.contains(ast::InlineAsmOptions::MAY_UNWIND) && !labels_sp.is_empty() {
- dcx.emit_err(errors::AsmMayUnwind { labels_sp });
+ dcx.emit_err(diagnostics::AsmMayUnwind { labels_sp });
}
if !validated.clobber_abis.is_empty() {
match asm_macro {
AsmMacro::GlobalAsm | AsmMacro::NakedAsm => {
- let err = dcx.create_err(errors::AsmUnsupportedClobberAbi {
+ let err = dcx.create_err(diagnostics::AsmUnsupportedClobberAbi {
spans: validated.clobber_abis.iter().map(|(_, span)| *span).collect(),
macro_name: asm_macro.macro_name(),
});
@@ -250,7 +250,7 @@ fn validate_asm_args<'a>(
}
AsmMacro::Asm => {
if !regclass_outputs.is_empty() {
- dcx.emit_err(errors::AsmClobberNoReg {
+ dcx.emit_err(diagnostics::AsmClobberNoReg {
spans: regclass_outputs,
clobbers: validated.clobber_abis.iter().map(|(_, span)| *span).collect(),
});
@@ -354,7 +354,7 @@ fn expand_preparsed_asm(
lint::builtin::BAD_ASM_STYLE,
find_span(".intel_syntax"),
ecx.current_expansion.lint_node_id,
- errors::AvoidIntelSyntax,
+ diagnostics::AvoidIntelSyntax,
);
}
if template_str.contains(".att_syntax") {
@@ -362,7 +362,7 @@ fn expand_preparsed_asm(
lint::builtin::BAD_ASM_STYLE,
find_span(".att_syntax"),
ecx.current_expansion.lint_node_id,
- errors::AvoidAttSyntax,
+ diagnostics::AvoidAttSyntax,
);
}
}
@@ -482,7 +482,7 @@ fn expand_preparsed_asm(
None => {
let span = arg.position_span;
ecx.dcx()
- .create_err(errors::AsmNoMatchedArgumentName {
+ .create_err(diagnostics::AsmNoMatchedArgumentName {
name: name.to_owned(),
span: span_in_template(span),
})
@@ -497,7 +497,7 @@ fn expand_preparsed_asm(
let mut modifier = chars.next();
if chars.next().is_some() {
let span = arg.format.ty_span.map(span_in_template).unwrap_or(template_sp);
- ecx.dcx().emit_err(errors::AsmModifierInvalid { span });
+ ecx.dcx().emit_err(diagnostics::AsmModifierInvalid { span });
modifier = None;
}
diff --git a/compiler/rustc_builtin_macros/src/assert.rs b/compiler/rustc_builtin_macros/src/assert.rs
index 855da5caa312c..444510ee50572 100644
--- a/compiler/rustc_builtin_macros/src/assert.rs
+++ b/compiler/rustc_builtin_macros/src/assert.rs
@@ -11,8 +11,8 @@ use rustc_parse::parser::Parser;
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, sym};
use thin_vec::thin_vec;
+use crate::diagnostics;
use crate::edition_panic::use_panic_2021;
-use crate::errors;
pub(crate) fn expand_assert<'cx>(
cx: &'cx mut ExtCtxt<'_>,
@@ -114,7 +114,7 @@ fn parse_assert<'a>(cx: &ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PResult<
let mut parser = cx.new_parser_from_tts(stream);
if parser.token == token::Eof {
- return Err(cx.dcx().create_err(errors::AssertRequiresBoolean { span: sp }));
+ return Err(cx.dcx().create_err(diagnostics::AssertRequiresBoolean { span: sp }));
}
let cond_expr = parser.parse_expr()?;
@@ -127,7 +127,8 @@ fn parse_assert<'a>(cx: &ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PResult<
//
// Emit an error about semicolon and suggest removing it.
if parser.token == token::Semi {
- cx.dcx().emit_err(errors::AssertRequiresExpression { span: sp, token: parser.token.span });
+ cx.dcx()
+ .emit_err(diagnostics::AssertRequiresExpression { span: sp, token: parser.token.span });
parser.bump();
}
@@ -140,7 +141,7 @@ fn parse_assert<'a>(cx: &ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PResult<
let custom_message =
if let token::Literal(token::Lit { kind: token::Str, .. }) = parser.token.kind {
let comma = parser.prev_token.span.shrink_to_hi();
- cx.dcx().emit_err(errors::AssertMissingComma { span: parser.token.span, comma });
+ cx.dcx().emit_err(diagnostics::AssertMissingComma { span: parser.token.span, comma });
parse_custom_message(&mut parser)
} else if parser.eat(exp!(Comma)) {
diff --git a/compiler/rustc_builtin_macros/src/autodiff.rs b/compiler/rustc_builtin_macros/src/autodiff.rs
index 76c43e0df1a24..595a8b1fecb87 100644
--- a/compiler/rustc_builtin_macros/src/autodiff.rs
+++ b/compiler/rustc_builtin_macros/src/autodiff.rs
@@ -24,7 +24,7 @@ mod llvm_enzyme {
use thin_vec::{ThinVec, thin_vec};
use tracing::{debug, trace};
- use crate::errors;
+ use crate::diagnostics;
pub(crate) fn outer_normal_attr(
kind: &Box,
@@ -101,7 +101,7 @@ mod llvm_enzyme {
match x.try_into() {
Ok(x) => x,
Err(_) => {
- dcx.emit_err(errors::AutoDiffInvalidWidth {
+ dcx.emit_err(diagnostics::AutoDiffInvalidWidth {
span: meta_item[1].span(),
width: x,
});
@@ -120,7 +120,7 @@ mod llvm_enzyme {
match res {
Ok(x) => activities.push(x),
Err(_) => {
- dcx.emit_err(errors::AutoDiffUnknownActivity {
+ dcx.emit_err(diagnostics::AutoDiffUnknownActivity {
span: x.span(),
act: activity_str,
});
@@ -238,14 +238,14 @@ mod llvm_enzyme {
}
_ => None,
}) else {
- dcx.emit_err(errors::AutoDiffInvalidApplication { span: item.span() });
+ dcx.emit_err(diagnostics::AutoDiffInvalidApplication { span: item.span() });
return vec![item];
};
let meta_item_vec: ThinVec = match meta_item.kind {
ast::MetaItemKind::List(ref vec) => vec.clone(),
_ => {
- dcx.emit_err(errors::AutoDiffMissingConfig { span: item.span() });
+ dcx.emit_err(diagnostics::AutoDiffMissingConfig { span: item.span() });
return vec![item];
}
};
@@ -257,7 +257,7 @@ mod llvm_enzyme {
let mut ts: Vec = vec![];
if meta_item_vec.len() < 1 {
// At the bare minimum, we need a fnc name.
- dcx.emit_err(errors::AutoDiffMissingConfig { span: item.span() });
+ dcx.emit_err(diagnostics::AutoDiffMissingConfig { span: item.span() });
return vec![item];
}
@@ -658,7 +658,7 @@ mod llvm_enzyme {
let sig_args = sig.decl.inputs.len() + if has_ret { 1 } else { 0 };
let num_activities = x.input_activity.len() + if x.has_ret_activity() { 1 } else { 0 };
if sig_args != num_activities {
- dcx.emit_err(errors::AutoDiffInvalidNumberActivities {
+ dcx.emit_err(diagnostics::AutoDiffInvalidNumberActivities {
span,
expected: sig_args,
found: num_activities,
@@ -679,7 +679,7 @@ mod llvm_enzyme {
let mut errors = false;
for (arg, activity) in sig.decl.inputs.iter().zip(x.input_activity.iter()) {
if !valid_input_activity(x.mode, *activity) {
- dcx.emit_err(errors::AutoDiffInvalidApplicationModeAct {
+ dcx.emit_err(diagnostics::AutoDiffInvalidApplicationModeAct {
span,
mode: x.mode.to_string(),
act: activity.to_string(),
@@ -687,7 +687,7 @@ mod llvm_enzyme {
errors = true;
}
if !valid_ty_for_activity(&arg.ty, *activity) {
- dcx.emit_err(errors::AutoDiffInvalidTypeForActivity {
+ dcx.emit_err(diagnostics::AutoDiffInvalidTypeForActivity {
span: arg.ty.span,
act: activity.to_string(),
});
@@ -696,7 +696,7 @@ mod llvm_enzyme {
}
if has_ret && !valid_ret_activity(x.mode, x.ret_activity) {
- dcx.emit_err(errors::AutoDiffInvalidRetAct {
+ dcx.emit_err(diagnostics::AutoDiffInvalidRetAct {
span,
mode: x.mode.to_string(),
act: x.ret_activity.to_string(),
diff --git a/compiler/rustc_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs
index 2872cff0fdc7a..f2771f125ff54 100644
--- a/compiler/rustc_builtin_macros/src/cfg.rs
+++ b/compiler/rustc_builtin_macros/src/cfg.rs
@@ -16,7 +16,7 @@ use rustc_parse::exp;
use rustc_parse::parser::Recovery;
use rustc_span::{ErrorGuaranteed, Span, sym};
-use crate::errors;
+use crate::diagnostics;
pub(crate) fn expand_cfg(
cx: &mut ExtCtxt<'_>,
@@ -38,7 +38,7 @@ pub(crate) fn expand_cfg(
fn parse_cfg(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream) -> Result {
let mut parser = cx.new_parser_from_tts(tts);
if parser.token == token::Eof {
- return Err(cx.dcx().emit_err(errors::RequiresCfgPattern { span }));
+ return Err(cx.dcx().emit_err(diagnostics::RequiresCfgPattern { span }));
}
let meta = MetaItemOrLitParser::parse_single(
@@ -70,7 +70,7 @@ fn parse_cfg(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream) -> Result(ecx: &ExtCtxt<'_>, mi: &'a ast::MetaItem) -> Option<&'a ast::Path> {
- use errors::CfgAccessibleInvalid::*;
+ use diagnostics::CfgAccessibleInvalid::*;
match mi.meta_item_list() {
None => {}
Some([]) => {
@@ -62,7 +62,7 @@ impl MultiItemModifier for Expander {
Ok(true) => ExpandResult::Ready(vec![item]),
Ok(false) => ExpandResult::Ready(Vec::new()),
Err(Indeterminate) if ecx.force_mode => {
- ecx.dcx().emit_err(errors::CfgAccessibleIndeterminate { span });
+ ecx.dcx().emit_err(diagnostics::CfgAccessibleIndeterminate { span });
ExpandResult::Ready(vec![item])
}
Err(Indeterminate) => ExpandResult::Retry(item),
diff --git a/compiler/rustc_builtin_macros/src/cfg_select.rs b/compiler/rustc_builtin_macros/src/cfg_select.rs
index 35098722a910e..526ddd6a3811d 100644
--- a/compiler/rustc_builtin_macros/src/cfg_select.rs
+++ b/compiler/rustc_builtin_macros/src/cfg_select.rs
@@ -6,7 +6,7 @@ use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExp
use rustc_span::{Ident, Span, sym};
use smallvec::SmallVec;
-use crate::errors::CfgSelectNoMatches;
+use crate::diagnostics::CfgSelectNoMatches;
/// This intermediate structure is used to emit parse errors for the branches that are not chosen.
/// The `MacResult` instance below parses all branches, emitting any errors it encounters, but only
diff --git a/compiler/rustc_builtin_macros/src/concat.rs b/compiler/rustc_builtin_macros/src/concat.rs
index c200539e12872..f359b8336dbd5 100644
--- a/compiler/rustc_builtin_macros/src/concat.rs
+++ b/compiler/rustc_builtin_macros/src/concat.rs
@@ -4,7 +4,7 @@ use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpa
use rustc_session::errors::report_lit_error;
use rustc_span::Symbol;
-use crate::errors;
+use crate::diagnostics;
use crate::util::get_exprs_from_tts;
pub(crate) fn expand_concat(
@@ -38,10 +38,10 @@ pub(crate) fn expand_concat(
accumulator.push_str(&b.to_string());
}
Ok(LitKind::CStr(..)) => {
- guar = Some(cx.dcx().emit_err(errors::ConcatCStrLit { span: e.span }));
+ guar = Some(cx.dcx().emit_err(diagnostics::ConcatCStrLit { span: e.span }));
}
Ok(LitKind::Byte(..) | LitKind::ByteStr(..)) => {
- guar = Some(cx.dcx().emit_err(errors::ConcatBytestr { span: e.span }));
+ guar = Some(cx.dcx().emit_err(diagnostics::ConcatBytestr { span: e.span }));
}
Ok(LitKind::Err(guarantee)) => {
guar = Some(guarantee);
@@ -62,7 +62,7 @@ pub(crate) fn expand_concat(
}
}
ExprKind::IncludedBytes(..) => {
- cx.dcx().emit_err(errors::ConcatBytestr { span: e.span });
+ cx.dcx().emit_err(diagnostics::ConcatBytestr { span: e.span });
}
ExprKind::Err(guarantee) => {
guar = Some(guarantee);
@@ -75,7 +75,7 @@ pub(crate) fn expand_concat(
}
ExpandResult::Ready(if !missing_literal.is_empty() {
- let guar = cx.dcx().emit_err(errors::ConcatMissingLiteral { spans: missing_literal });
+ let guar = cx.dcx().emit_err(diagnostics::ConcatMissingLiteral { spans: missing_literal });
DummyResult::any(sp, guar)
} else if let Some(guar) = guar {
DummyResult::any(sp, guar)
diff --git a/compiler/rustc_builtin_macros/src/concat_bytes.rs b/compiler/rustc_builtin_macros/src/concat_bytes.rs
index 8885017b930d9..f86b1daa13d2d 100644
--- a/compiler/rustc_builtin_macros/src/concat_bytes.rs
+++ b/compiler/rustc_builtin_macros/src/concat_bytes.rs
@@ -4,7 +4,7 @@ use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpa
use rustc_session::errors::report_lit_error;
use rustc_span::{ErrorGuaranteed, Span};
-use crate::errors;
+use crate::diagnostics;
use crate::util::get_exprs_from_tts;
/// Emits errors for literal expressions that are invalid inside and outside of an array.
@@ -14,7 +14,7 @@ fn invalid_type_err(
span: Span,
is_nested: bool,
) -> ErrorGuaranteed {
- use errors::{
+ use diagnostics::{
ConcatBytesInvalid, ConcatBytesInvalidSuggestion, ConcatBytesNonU8, ConcatBytesOob,
};
let snippet = cx.sess.source_map().span_to_snippet(span).ok();
@@ -105,7 +105,10 @@ fn handle_array_element(
Ok(LitKind::Byte(val)) => return Some(val),
Ok(LitKind::ByteStr(..)) => {
guar.get_or_insert_with(|| {
- dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: true })
+ dcx.emit_err(diagnostics::ConcatBytesArray {
+ span: expr.span,
+ bytestr: true,
+ })
});
}
_ => {
@@ -115,12 +118,12 @@ fn handle_array_element(
}
ExprKind::Array(_) | ExprKind::Repeat(_, _) => {
guar.get_or_insert_with(|| {
- dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false })
+ dcx.emit_err(diagnostics::ConcatBytesArray { span: expr.span, bytestr: false })
});
}
ExprKind::IncludedBytes(..) => {
guar.get_or_insert_with(|| {
- dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false })
+ dcx.emit_err(diagnostics::ConcatBytesArray { span: expr.span, bytestr: false })
});
}
_ => missing_literals.push(expr.span),
@@ -167,9 +170,10 @@ pub(crate) fn expand_concat_bytes(
}
}
} else {
- guar = Some(
- cx.dcx().emit_err(errors::ConcatBytesBadRepeat { span: count.value.span }),
- );
+ guar =
+ Some(cx.dcx().emit_err(diagnostics::ConcatBytesBadRepeat {
+ span: count.value.span,
+ }));
}
}
&ExprKind::Lit(token_lit) => match LitKind::from_token_lit(token_lit) {
@@ -196,7 +200,8 @@ pub(crate) fn expand_concat_bytes(
}
}
ExpandResult::Ready(if !missing_literals.is_empty() {
- let guar = cx.dcx().emit_err(errors::ConcatBytesMissingLiteral { spans: missing_literals });
+ let guar =
+ cx.dcx().emit_err(diagnostics::ConcatBytesMissingLiteral { spans: missing_literals });
MacEager::expr(DummyResult::raw_expr(sp, Some(guar)))
} else if let Some(guar) = guar {
MacEager::expr(DummyResult::raw_expr(sp, Some(guar)))
diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs
index 09d827b0635e6..79c0563b9d183 100644
--- a/compiler/rustc_builtin_macros/src/derive.rs
+++ b/compiler/rustc_builtin_macros/src/derive.rs
@@ -9,7 +9,7 @@ use rustc_session::Session;
use rustc_span::{ErrorGuaranteed, Ident, Span, sym};
use crate::cfg_eval::cfg_eval;
-use crate::errors;
+use crate::diagnostics;
pub(crate) struct Expander {
pub is_const: bool,
@@ -131,7 +131,7 @@ fn report_bad_target(
let bad_target =
!matches!(item_kind, Some(ItemKind::Struct(..) | ItemKind::Enum(..) | ItemKind::Union(..)));
if bad_target {
- return Err(sess.dcx().emit_err(errors::BadDeriveTarget { span, item: item.span() }));
+ return Err(sess.dcx().emit_err(diagnostics::BadDeriveTarget { span, item: item.span() }));
}
Ok(())
}
@@ -141,11 +141,11 @@ fn report_unexpected_meta_item_lit(sess: &Session, lit: &ast::MetaItemLit) {
ast::LitKind::Str(_, ast::StrStyle::Cooked)
if rustc_lexer::is_ident(lit.symbol.as_str()) =>
{
- errors::BadDeriveLitHelp::StrLit { sym: lit.symbol }
+ diagnostics::BadDeriveLitHelp::StrLit { sym: lit.symbol }
}
- _ => errors::BadDeriveLitHelp::Other,
+ _ => diagnostics::BadDeriveLitHelp::Other,
};
- sess.dcx().emit_err(errors::BadDeriveLit { span: lit.span, help });
+ sess.dcx().emit_err(diagnostics::BadDeriveLit { span: lit.span, help });
}
fn report_path_args(sess: &Session, meta: &ast::MetaItem) {
@@ -154,10 +154,10 @@ fn report_path_args(sess: &Session, meta: &ast::MetaItem) {
match meta.kind {
MetaItemKind::Word => {}
MetaItemKind::List(..) => {
- sess.dcx().emit_err(errors::DerivePathArgsList { span });
+ sess.dcx().emit_err(diagnostics::DerivePathArgsList { span });
}
MetaItemKind::NameValue(..) => {
- sess.dcx().emit_err(errors::DerivePathArgsValue { span });
+ sess.dcx().emit_err(diagnostics::DerivePathArgsValue { span });
}
}
}
diff --git a/compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs b/compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs
index 1d9551f93a14c..43399b614b50a 100644
--- a/compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs
@@ -12,7 +12,7 @@ use rustc_macros::Diagnostic;
use rustc_span::{Ident, Span, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
-use crate::errors;
+use crate::diagnostics;
macro_rules! path {
($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] }
@@ -409,7 +409,7 @@ struct DetectNonGenericPointeeAttr<'a, 'b> {
impl<'a, 'b> rustc_ast::visit::Visitor<'a> for DetectNonGenericPointeeAttr<'a, 'b> {
fn visit_attribute(&mut self, attr: &'a rustc_ast::Attribute) -> Self::Result {
if attr.has_name(sym::pointee) {
- self.cx.dcx().emit_err(errors::NonGenericPointee { span: attr.span });
+ self.cx.dcx().emit_err(diagnostics::NonGenericPointee { span: attr.span });
}
}
@@ -457,7 +457,7 @@ struct AlwaysErrorOnGenericParam<'a, 'b> {
impl<'a, 'b> rustc_ast::visit::Visitor<'a> for AlwaysErrorOnGenericParam<'a, 'b> {
fn visit_attribute(&mut self, attr: &'a rustc_ast::Attribute) -> Self::Result {
if attr.has_name(sym::pointee) {
- self.cx.dcx().emit_err(errors::NonGenericPointee { span: attr.span });
+ self.cx.dcx().emit_err(diagnostics::NonGenericPointee { span: attr.span });
}
}
}
diff --git a/compiler/rustc_builtin_macros/src/deriving/default.rs b/compiler/rustc_builtin_macros/src/deriving/default.rs
index 263ba2968eab4..cf48ff96aed1e 100644
--- a/compiler/rustc_builtin_macros/src/deriving/default.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/default.rs
@@ -9,7 +9,7 @@ use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
-use crate::errors;
+use crate::diagnostics;
pub(crate) fn expand_deriving_default(
cx: &ExtCtxt<'_>,
@@ -177,10 +177,13 @@ fn extract_default_variant<'a>(
.filter(|variant| !attr::contains_name(&variant.attrs, sym::non_exhaustive));
let suggs = possible_defaults
- .map(|v| errors::NoDefaultVariantSugg { span: v.span.shrink_to_lo() })
+ .map(|v| diagnostics::NoDefaultVariantSugg { span: v.span.shrink_to_lo() })
.collect();
- let guar =
- cx.dcx().emit_err(errors::NoDefaultVariant { span: trait_span, item_span, suggs });
+ let guar = cx.dcx().emit_err(diagnostics::NoDefaultVariant {
+ span: trait_span,
+ item_span,
+ suggs,
+ });
return Err(guar);
}
@@ -196,11 +199,13 @@ fn extract_default_variant<'a>(
.filter_map(|attr| (attr.span != keep).then_some(attr.span))
})
.collect();
- (!spans.is_empty())
- .then_some(errors::MultipleDefaultsSugg { spans, ident: variant.ident })
+ (!spans.is_empty()).then_some(diagnostics::MultipleDefaultsSugg {
+ spans,
+ ident: variant.ident,
+ })
})
.collect();
- let guar = cx.dcx().emit_err(errors::MultipleDefaults {
+ let guar = cx.dcx().emit_err(diagnostics::MultipleDefaults {
span: trait_span,
first: first.span,
additional: rest.iter().map(|v| v.span).collect(),
@@ -223,12 +228,13 @@ fn extract_default_variant<'a>(
} else {
""
};
- let guar = cx.dcx().emit_err(errors::NonUnitDefault { span: variant.ident.span, post });
+ let guar =
+ cx.dcx().emit_err(diagnostics::NonUnitDefault { span: variant.ident.span, post });
return Err(guar);
}
if let Some(non_exhaustive_attr) = attr::find_by_name(&variant.attrs, sym::non_exhaustive) {
- let guar = cx.dcx().emit_err(errors::NonExhaustiveDefault {
+ let guar = cx.dcx().emit_err(diagnostics::NonExhaustiveDefault {
span: variant.ident.span,
non_exhaustive: non_exhaustive_attr.span,
});
@@ -252,10 +258,10 @@ fn validate_default_attribute(
"this method must only be called with a variant that has a `#[default]` attribute",
),
[first, rest @ ..] => {
- let sugg = errors::MultipleDefaultAttrsSugg {
+ let sugg = diagnostics::MultipleDefaultAttrsSugg {
spans: rest.iter().map(|attr| attr.span).collect(),
};
- let guar = cx.dcx().emit_err(errors::MultipleDefaultAttrs {
+ let guar = cx.dcx().emit_err(diagnostics::MultipleDefaultAttrs {
span: default_variant.ident.span,
first: first.span,
first_rest: rest[0].span,
@@ -268,7 +274,7 @@ fn validate_default_attribute(
}
};
if !attr.is_word() {
- let guar = cx.dcx().emit_err(errors::DefaultHasArg { span: attr.span });
+ let guar = cx.dcx().emit_err(diagnostics::DefaultHasArg { span: attr.span });
return Err(guar);
}
@@ -287,7 +293,7 @@ impl<'a, 'b> rustc_ast::visit::Visitor<'a> for DetectNonVariantDefaultAttr<'a, '
} else {
""
};
- self.cx.dcx().emit_err(errors::NonUnitDefault { span: attr.span, post });
+ self.cx.dcx().emit_err(diagnostics::NonUnitDefault { span: attr.span, post });
}
rustc_ast::visit::walk_attribute(self, attr);
diff --git a/compiler/rustc_builtin_macros/src/deriving/from.rs b/compiler/rustc_builtin_macros/src/deriving/from.rs
index 2e4369f3bb1c8..c5fd0d87251f6 100644
--- a/compiler/rustc_builtin_macros/src/deriving/from.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/from.rs
@@ -11,7 +11,7 @@ use crate::deriving::generic::{
combine_substructure,
};
use crate::deriving::pathvec_std;
-use crate::errors;
+use crate::diagnostics;
/// Generate an implementation of the `From` trait, provided that `item`
/// is a struct or a tuple struct with exactly one field.
@@ -38,7 +38,7 @@ pub(crate) fn expand_deriving_from(
if let [field] = data.fields() {
Ok(field.clone())
} else {
- let guar = cx.dcx().emit_err(errors::DeriveFromWrongFieldCount {
+ let guar = cx.dcx().emit_err(diagnostics::DeriveFromWrongFieldCount {
span: err_span(),
multiple_fields: data.fields().len() > 1,
});
@@ -46,7 +46,7 @@ pub(crate) fn expand_deriving_from(
}
}
ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => {
- let guar = cx.dcx().emit_err(errors::DeriveFromWrongTarget {
+ let guar = cx.dcx().emit_err(diagnostics::DeriveFromWrongTarget {
span: err_span(),
kind: &format!("{} {}", item.kind.article(), item.kind.descr()),
});
diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
index 8b8af1685287c..ff6b15b173ed1 100644
--- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
@@ -194,7 +194,7 @@ use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use ty::{Bounds, Path, Ref, Self_, Ty};
-use crate::{deriving, errors};
+use crate::{deriving, diagnostics};
pub(crate) mod ty;
@@ -456,7 +456,7 @@ fn find_type_parameters(
}
fn visit_mac_call(&mut self, mac: &ast::MacCall) {
- self.cx.dcx().emit_err(errors::DeriveMacroCall { span: mac.span() });
+ self.cx.dcx().emit_err(diagnostics::DeriveMacroCall { span: mac.span() });
}
}
@@ -525,7 +525,7 @@ impl<'a> TraitDef<'a> {
is_packed,
)
} else {
- cx.dcx().emit_err(errors::DeriveUnion { span: mitem.span });
+ cx.dcx().emit_err(diagnostics::DeriveUnion { span: mitem.span });
return;
}
}
diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/diagnostics.rs
similarity index 100%
rename from compiler/rustc_builtin_macros/src/errors.rs
rename to compiler/rustc_builtin_macros/src/diagnostics.rs
diff --git a/compiler/rustc_builtin_macros/src/eii.rs b/compiler/rustc_builtin_macros/src/eii.rs
index d8d749cd35c4b..9bb34cdd642a0 100644
--- a/compiler/rustc_builtin_macros/src/eii.rs
+++ b/compiler/rustc_builtin_macros/src/eii.rs
@@ -9,7 +9,7 @@ use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym};
use thin_vec::{ThinVec, thin_vec};
-use crate::errors::{
+use crate::diagnostics::{
EiiAttributeNotSupported, EiiExternTargetExpectedList, EiiExternTargetExpectedMacro,
EiiExternTargetExpectedUnsafe, EiiMacroExpectedMaxOneArgument, EiiOnlyOnce,
EiiSharedMacroInStatementPosition, EiiSharedMacroTarget, EiiStaticArgumentRequired,
diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs
index d9af43fcd1c3d..aaa9117bb092b 100644
--- a/compiler/rustc_builtin_macros/src/env.rs
+++ b/compiler/rustc_builtin_macros/src/env.rs
@@ -15,7 +15,7 @@ use rustc_span::edit_distance::edit_distance;
use rustc_span::{Ident, Span, Symbol, kw, sym};
use thin_vec::thin_vec;
-use crate::errors;
+use crate::diagnostics;
use crate::util::{expr_to_string, get_exprs_from_tts, get_single_expr_from_tts};
fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Result {
@@ -76,7 +76,7 @@ pub(crate) fn expand_option_env<'cx>(
unreachable!("`expr_to_string` ensures this is a string lit")
};
- let guar = cx.dcx().emit_err(errors::EnvNotUnicode { span: sp, var: *symbol });
+ let guar = cx.dcx().emit_err(diagnostics::EnvNotUnicode { span: sp, var: *symbol });
return ExpandResult::Ready(DummyResult::any(sp, guar));
}
Ok(value) => cx.expr_call_global(
@@ -98,7 +98,7 @@ pub(crate) fn expand_env<'cx>(
};
let mut exprs = match mac {
Ok(exprs) if exprs.is_empty() || exprs.len() > 2 => {
- let guar = cx.dcx().emit_err(errors::EnvTakesArgs { span: sp });
+ let guar = cx.dcx().emit_err(diagnostics::EnvTakesArgs { span: sp });
return ExpandResult::Ready(DummyResult::any(sp, guar));
}
Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)),
@@ -145,24 +145,26 @@ pub(crate) fn expand_env<'cx>(
let guar = match err {
VarError::NotPresent => {
if let Some(msg_from_user) = custom_msg {
- cx.dcx()
- .emit_err(errors::EnvNotDefinedWithUserMessage { span, msg_from_user })
+ cx.dcx().emit_err(diagnostics::EnvNotDefinedWithUserMessage {
+ span,
+ msg_from_user,
+ })
} else if let Some(suggested_var) = find_similar_cargo_var(var)
&& suggested_var != var
{
- cx.dcx().emit_err(errors::EnvNotDefined::CargoEnvVarTypo {
+ cx.dcx().emit_err(diagnostics::EnvNotDefined::CargoEnvVarTypo {
span,
var: *symbol,
suggested_var: Symbol::intern(suggested_var),
})
} else if is_cargo_env_var(var) {
- cx.dcx().emit_err(errors::EnvNotDefined::CargoEnvVar {
+ cx.dcx().emit_err(diagnostics::EnvNotDefined::CargoEnvVar {
span,
var: *symbol,
var_expr: pprust::expr_to_string(&var_expr),
})
} else {
- cx.dcx().emit_err(errors::EnvNotDefined::CustomEnvVar {
+ cx.dcx().emit_err(diagnostics::EnvNotDefined::CustomEnvVar {
span,
var: *symbol,
var_expr: pprust::expr_to_string(&var_expr),
@@ -170,7 +172,7 @@ pub(crate) fn expand_env<'cx>(
}
}
VarError::NotUnicode(_) => {
- cx.dcx().emit_err(errors::EnvNotUnicode { span, var: *symbol })
+ cx.dcx().emit_err(diagnostics::EnvNotUnicode { span, var: *symbol })
}
};
diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs
index 6bb3fa884027e..007251ff3df05 100644
--- a/compiler/rustc_builtin_macros/src/format.rs
+++ b/compiler/rustc_builtin_macros/src/format.rs
@@ -20,7 +20,7 @@ use rustc_parse::exp;
use rustc_parse_format as parse;
use rustc_span::{BytePos, ErrorGuaranteed, Ident, InnerSpan, Span, Symbol};
-use crate::errors;
+use crate::diagnostics;
use crate::util::{ExprToSpannedString, expr_to_spanned_string};
// The format_args!() macro is expanded in three steps:
@@ -73,7 +73,9 @@ fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a,
// parse the format string
let fmtstr = match p.token.kind {
- token::Eof => return Err(ecx.dcx().create_err(errors::FormatRequiresString { span: sp })),
+ token::Eof => {
+ return Err(ecx.dcx().create_err(diagnostics::FormatRequiresString { span: sp }));
+ }
// This allows us to properly handle cases when the first comma
// after the format string is mistakenly replaced with any operator,
// which cause the expression parser to eat too much tokens.
@@ -122,7 +124,7 @@ fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a,
p.expect(exp!(Eq))?;
let expr = p.parse_expr()?;
if let Some((_, prev)) = args.by_name(ident.name) {
- ecx.dcx().emit_err(errors::FormatDuplicateArg {
+ ecx.dcx().emit_err(diagnostics::FormatDuplicateArg {
span: ident.span,
prev: prev.kind.ident().unwrap().span,
duplicate: ident.span,
@@ -135,7 +137,7 @@ fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a,
_ => {
let expr = p.parse_expr()?;
if !args.named_args().is_empty() {
- return Err(ecx.dcx().create_err(errors::PositionalAfterNamed {
+ return Err(ecx.dcx().create_err(diagnostics::PositionalAfterNamed {
span: expr.span,
args: args
.named_args()
@@ -304,7 +306,7 @@ fn make_format_args(
// argument span here.
fmt_span
};
- let mut e = errors::InvalidFormatString {
+ let mut e = diagnostics::InvalidFormatString {
span: sp,
note_: None,
label_: None,
@@ -313,12 +315,12 @@ fn make_format_args(
label1: err.label,
};
if let Some(note) = err.note {
- e.note_ = Some(errors::InvalidFormatStringNote { note });
+ e.note_ = Some(diagnostics::InvalidFormatStringNote { note });
}
if let Some((label, span)) = err.secondary_label
&& is_source_literal
{
- e.label_ = Some(errors::InvalidFormatStringLabel {
+ e.label_ = Some(diagnostics::InvalidFormatStringLabel {
span: fmt_span.from_inner(InnerSpan::new(span.start, span.end)),
label,
});
@@ -333,7 +335,7 @@ fn make_format_args(
Some(arg) => arg.expr.span,
None => fmt_span,
};
- e.sugg_ = Some(errors::InvalidFormatStringSuggestion::UsePositional {
+ e.sugg_ = Some(diagnostics::InvalidFormatStringSuggestion::UsePositional {
captured: captured_arg_span,
len: args.unnamed_args().len().to_string(),
span: span.shrink_to_hi(),
@@ -344,19 +346,22 @@ fn make_format_args(
parse::Suggestion::RemoveRawIdent(span) => {
if is_source_literal {
let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
- e.sugg_ = Some(errors::InvalidFormatStringSuggestion::RemoveRawIdent { span })
+ e.sugg_ =
+ Some(diagnostics::InvalidFormatStringSuggestion::RemoveRawIdent { span })
}
}
parse::Suggestion::ReorderFormatParameter(span, replacement) => {
let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
- e.sugg_ = Some(errors::InvalidFormatStringSuggestion::ReorderFormatParameter {
- span,
- replacement,
- });
+ e.sugg_ =
+ Some(diagnostics::InvalidFormatStringSuggestion::ReorderFormatParameter {
+ span,
+ replacement,
+ });
}
parse::Suggestion::AddMissingColon(span) => {
let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
- e.sugg_ = Some(errors::InvalidFormatStringSuggestion::AddMissingColon { span });
+ e.sugg_ =
+ Some(diagnostics::InvalidFormatStringSuggestion::AddMissingColon { span });
}
parse::Suggestion::UseRustDebugPrintingMacro => {
// This targets `println!("{=}", x);` and `println!("{0=}", x);`
@@ -367,7 +372,7 @@ fn make_format_args(
let call_span = macro_span.source_callsite();
e.sugg_ = Some(
- errors::InvalidFormatStringSuggestion::UseRustDebugPrintingMacro {
+ diagnostics::InvalidFormatStringSuggestion::UseRustDebugPrintingMacro {
macro_span: call_span,
replacement,
},
@@ -436,7 +441,7 @@ fn make_format_args(
} else {
// For the moment capturing variables from format strings expanded from macros is
// disabled (see RFC #2795)
- let guar = ecx.dcx().emit_err(errors::FormatNoArgNamed { span, name });
+ let guar = ecx.dcx().emit_err(diagnostics::FormatNoArgNamed { span, name });
unnamed_arg_after_named_arg = true;
DummyResult::raw_expr(span, Some(guar))
};
@@ -659,7 +664,7 @@ fn make_format_args(
(None, String::new())
};
- errors::NamedArgumentUsedPositionally {
+ diagnostics::NamedArgumentUsedPositionally {
named_arg_sp: arg_name.span,
position_label_sp: position_sp_for_msg,
suggestion,
@@ -701,12 +706,12 @@ fn invalid_placeholder_type_error(
("X", "UpperHex"),
]
.into_iter()
- .map(|(fmt, trait_name)| errors::FormatUnknownTraitSugg { span: sp, fmt, trait_name })
+ .map(|(fmt, trait_name)| diagnostics::FormatUnknownTraitSugg { span: sp, fmt, trait_name })
.collect()
} else {
vec![]
};
- ecx.dcx().emit_err(errors::FormatUnknownTrait { span: sp.unwrap_or(fmt_span), ty, suggs });
+ ecx.dcx().emit_err(diagnostics::FormatUnknownTrait { span: sp.unwrap_or(fmt_span), ty, suggs });
}
fn report_missing_placeholders(
@@ -723,12 +728,14 @@ fn report_missing_placeholders(
fmt_span: Span,
) {
let mut diag = if let &[(span, named)] = &unused[..] {
- ecx.dcx().create_err(errors::FormatUnusedArg { span, named })
+ ecx.dcx().create_err(diagnostics::FormatUnusedArg { span, named })
} else {
- let unused_labels =
- unused.iter().map(|&(span, named)| errors::FormatUnusedArg { span, named }).collect();
+ let unused_labels = unused
+ .iter()
+ .map(|&(span, named)| diagnostics::FormatUnusedArg { span, named })
+ .collect();
let unused_spans = unused.iter().map(|&(span, _)| span).collect();
- ecx.dcx().create_err(errors::FormatUnusedArgs {
+ ecx.dcx().create_err(diagnostics::FormatUnusedArgs {
fmt: fmt_span,
unused: unused_spans,
unused_labels,
@@ -920,12 +927,12 @@ fn report_redundant_format_arguments<'a>(
}
let sugg = if args.named_args().len() == 0 {
- Some(errors::FormatRedundantArgsSugg { spans: suggestion_spans })
+ Some(diagnostics::FormatRedundantArgsSugg { spans: suggestion_spans })
} else {
None
};
- return Some(ecx.dcx().create_err(errors::FormatRedundantArgs {
+ return Some(ecx.dcx().create_err(diagnostics::FormatRedundantArgs {
n: args_spans.len(),
span: MultiSpan::from(args_spans),
note: multispan,
@@ -1034,7 +1041,7 @@ fn report_invalid_references(
} else {
MultiSpan::from_spans(spans)
};
- e = ecx.dcx().create_err(errors::FormatPositionalMismatch {
+ e = ecx.dcx().create_err(diagnostics::FormatPositionalMismatch {
span,
n: num_placeholders,
desc: num_args_desc,
diff --git a/compiler/rustc_builtin_macros/src/global_allocator.rs b/compiler/rustc_builtin_macros/src/global_allocator.rs
index 684411d64d943..db034f6fb7011 100644
--- a/compiler/rustc_builtin_macros/src/global_allocator.rs
+++ b/compiler/rustc_builtin_macros/src/global_allocator.rs
@@ -9,7 +9,7 @@ use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::{Ident, Span, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
-use crate::errors;
+use crate::diagnostics;
use crate::util::check_builtin_macro_attribute;
pub(crate) fn expand(
@@ -34,13 +34,14 @@ pub(crate) fn expand(
{
(item, *ident, true, ecx.with_def_site_ctxt(ty.span))
} else {
- ecx.dcx().emit_err(errors::AllocMustStatics { span: item.span() });
+ ecx.dcx().emit_err(diagnostics::AllocMustStatics { span: item.span() });
return vec![orig_item];
};
// Forbid `#[thread_local]` attributes on the item
if let Some(attr) = item.attrs.iter().find(|x| x.has_name(sym::thread_local)) {
- ecx.dcx().emit_err(errors::AllocCannotThreadLocal { span: item.span, attr: attr.span });
+ ecx.dcx()
+ .emit_err(diagnostics::AllocCannotThreadLocal { span: item.span, attr: attr.span });
return vec![orig_item];
}
diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs
index 9e29262042f21..4a5ff44c402ab 100644
--- a/compiler/rustc_builtin_macros/src/lib.rs
+++ b/compiler/rustc_builtin_macros/src/lib.rs
@@ -33,10 +33,10 @@ mod concat_bytes;
mod define_opaque;
mod derive;
mod deriving;
+mod diagnostics;
mod edition_panic;
mod eii;
mod env;
-mod errors;
mod format;
mod format_foreign;
mod global_allocator;
diff --git a/compiler/rustc_builtin_macros/src/offload.rs b/compiler/rustc_builtin_macros/src/offload.rs
index 9dbd2d45a93af..d20c07f8619dc 100644
--- a/compiler/rustc_builtin_macros/src/offload.rs
+++ b/compiler/rustc_builtin_macros/src/offload.rs
@@ -6,7 +6,7 @@ use rustc_session::config::Offload;
use rustc_span::{Ident, Span, sym};
use thin_vec::thin_vec;
-use crate::errors;
+use crate::diagnostics;
fn compile_for_device(ecx: &mut ExtCtxt<'_>) -> bool {
ecx.sess.opts.unstable_opts.offload.contains(&Offload::Device)
@@ -74,7 +74,7 @@ pub(crate) fn expand_kernel(
let dcx = ecx.sess.dcx();
let Some((vis, sig, ident, generics, body)) = extract_fn(&item) else {
- dcx.emit_err(errors::AutoDiffInvalidApplication { span: item.span() });
+ dcx.emit_err(diagnostics::AutoDiffInvalidApplication { span: item.span() });
return vec![item];
};
diff --git a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs
index aa936b46eec20..df9cebb8f7c03 100644
--- a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs
+++ b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs
@@ -16,7 +16,7 @@ use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
use smallvec::smallvec;
use thin_vec::{ThinVec, thin_vec};
-use crate::errors;
+use crate::diagnostics;
struct ProcMacroDerive {
id: NodeId,
@@ -91,7 +91,7 @@ pub fn inject(
impl<'a> CollectProcMacros<'a> {
fn check_not_pub_in_root(&self, vis: &ast::Visibility, sp: Span) {
if self.is_proc_macro_crate && self.in_root && vis.kind.is_pub() {
- self.dcx.emit_err(errors::ProcMacro { span: sp });
+ self.dcx.emit_err(diagnostics::ProcMacro { span: sp });
}
}
@@ -174,7 +174,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
fn visit_item(&mut self, item: &'a ast::Item) {
if let ast::ItemKind::MacroDef(..) = item.kind {
if self.is_proc_macro_crate && attr::contains_name(&item.attrs, sym::macro_export) {
- self.dcx.emit_err(errors::ExportMacroRules {
+ self.dcx.emit_err(diagnostics::ExportMacroRules {
span: self.source_map.guess_head_span(item.span),
});
}
@@ -238,7 +238,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
if !self.is_proc_macro_crate {
self.dcx
- .create_err(errors::AttributeOnlyUsableWithCrateType {
+ .create_err(diagnostics::AttributeOnlyUsableWithCrateType {
span: attr.span,
path: &pprust::path_to_string(&attr.get_normal_item().path),
})
diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs
index ab7a9c3bccb38..fe2b5e1a45920 100644
--- a/compiler/rustc_builtin_macros/src/source_util.rs
+++ b/compiler/rustc_builtin_macros/src/source_util.rs
@@ -21,7 +21,7 @@ use rustc_span::source_map::SourceMap;
use rustc_span::{ByteSymbol, Pos, Span, Symbol};
use smallvec::SmallVec;
-use crate::errors;
+use crate::diagnostics;
use crate::util::{
check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr,
};
@@ -153,7 +153,7 @@ pub(crate) fn expand_include<'cx>(
INCOMPLETE_INCLUDE,
p.token.span,
self.node_id,
- errors::IncompleteInclude,
+ diagnostics::IncompleteInclude,
);
}
Some(expr)
@@ -176,7 +176,7 @@ pub(crate) fn expand_include<'cx>(
Ok(Some(item)) => ret.push(item),
Ok(None) => {
if p.token != token::Eof {
- p.dcx().emit_err(errors::ExpectedItem {
+ p.dcx().emit_err(diagnostics::ExpectedItem {
span: p.token.span,
token: &pprust::token_to_string(&p.token),
});
diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs
index ac865958011a6..fda0660c48403 100644
--- a/compiler/rustc_builtin_macros/src/test.rs
+++ b/compiler/rustc_builtin_macros/src/test.rs
@@ -14,7 +14,7 @@ use rustc_span::{ErrorGuaranteed, Ident, RemapPathScopeComponents, Span, Symbol,
use thin_vec::{ThinVec, thin_vec};
use tracing::debug;
-use crate::errors;
+use crate::diagnostics;
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
/// #[test_case] is used by custom test authors to mark tests
@@ -44,7 +44,7 @@ pub(crate) fn expand_test_case(
}
}
_ => {
- ecx.dcx().emit_err(errors::TestCaseNonItem { span: anno_item.span() });
+ ecx.dcx().emit_err(diagnostics::TestCaseNonItem { span: anno_item.span() });
return vec![];
}
};
@@ -136,7 +136,7 @@ pub(crate) fn expand_test_or_bench(
}
if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) {
- cx.dcx().emit_err(errors::NakedFunctionTestingAttribute {
+ cx.dcx().emit_err(diagnostics::NakedFunctionTestingAttribute {
testing_span: attr_sp,
naked_span: attr.span,
});
@@ -525,27 +525,31 @@ fn check_test_signature(
let dcx = cx.dcx();
if let ast::Safety::Unsafe(span) = f.sig.header.safety {
- return Err(dcx.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" }));
+ return Err(dcx.emit_err(diagnostics::TestBadFn {
+ span: i.span,
+ cause: span,
+ kind: "unsafe",
+ }));
}
if let Some(coroutine_kind) = f.sig.header.coroutine_kind {
match coroutine_kind {
ast::CoroutineKind::Async { span, .. } => {
- return Err(dcx.emit_err(errors::TestBadFn {
+ return Err(dcx.emit_err(diagnostics::TestBadFn {
span: i.span,
cause: span,
kind: "async",
}));
}
ast::CoroutineKind::Gen { span, .. } => {
- return Err(dcx.emit_err(errors::TestBadFn {
+ return Err(dcx.emit_err(diagnostics::TestBadFn {
span: i.span,
cause: span,
kind: "gen",
}));
}
ast::CoroutineKind::AsyncGen { span, .. } => {
- return Err(dcx.emit_err(errors::TestBadFn {
+ return Err(dcx.emit_err(diagnostics::TestBadFn {
span: i.span,
cause: span,
kind: "async gen",
@@ -588,7 +592,7 @@ fn check_bench_signature(
// N.B., inadequate check, but we're running
// well before resolve, can't get too deep.
if f.sig.decl.inputs.len() != 1 {
- return Err(cx.dcx().emit_err(errors::BenchSig { span: i.span }));
+ return Err(cx.dcx().emit_err(diagnostics::BenchSig { span: i.span }));
}
Ok(())
}
diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs
index db5aecde3472c..0b68b44769987 100644
--- a/compiler/rustc_builtin_macros/src/test_harness.rs
+++ b/compiler/rustc_builtin_macros/src/test_harness.rs
@@ -22,7 +22,7 @@ use smallvec::smallvec;
use thin_vec::{ThinVec, thin_vec};
use tracing::debug;
-use crate::errors;
+use crate::diagnostics;
#[derive(Clone)]
struct Test {
@@ -71,7 +71,7 @@ pub fn inject(
// Silently allow compiling with panic=abort on these platforms,
// but with old behavior (abort if a test fails).
} else {
- dcx.emit_err(errors::TestsNotSupport {});
+ dcx.emit_err(diagnostics::TestsNotSupport {});
}
PanicStrategy::Unwind
}
@@ -166,7 +166,7 @@ impl<'a> Visitor<'a> for InnerItemLinter<'_> {
UNNAMEABLE_TEST_ITEMS,
attr.span,
i.id,
- errors::UnnameableTestItems,
+ diagnostics::UnnameableTestItems,
);
}
}
diff --git a/compiler/rustc_builtin_macros/src/trace_macros.rs b/compiler/rustc_builtin_macros/src/trace_macros.rs
index 8264c17b4d171..88837e01a9407 100644
--- a/compiler/rustc_builtin_macros/src/trace_macros.rs
+++ b/compiler/rustc_builtin_macros/src/trace_macros.rs
@@ -2,7 +2,7 @@ use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
use rustc_span::{Span, kw};
-use crate::errors;
+use crate::diagnostics;
pub(crate) fn expand_trace_macros(
cx: &mut ExtCtxt<'_>,
@@ -21,7 +21,7 @@ pub(crate) fn expand_trace_macros(
};
err |= iter.next().is_some();
if err {
- cx.dcx().emit_err(errors::TraceMacros { span: sp });
+ cx.dcx().emit_err(diagnostics::TraceMacros { span: sp });
} else {
cx.set_trace_macros(value);
}
diff --git a/compiler/rustc_builtin_macros/src/util.rs b/compiler/rustc_builtin_macros/src/util.rs
index 9ac3d0e7eac12..769016ecac2a7 100644
--- a/compiler/rustc_builtin_macros/src/util.rs
+++ b/compiler/rustc_builtin_macros/src/util.rs
@@ -10,7 +10,7 @@ use rustc_parse::{exp, parser};
use rustc_session::errors::report_lit_error;
use rustc_span::{BytePos, Span, Symbol};
-use crate::errors;
+use crate::diagnostics;
pub(crate) fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, name: Symbol) {
// All the built-in macro attributes are "words" at the moment.
@@ -48,7 +48,7 @@ pub(crate) fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable,
DUPLICATE_MACRO_ATTRIBUTES,
attr.span,
ecx.current_expansion.lint_node_id,
- errors::DuplicateMacroAttribute,
+ diagnostics::DuplicateMacroAttribute,
);
}
}
@@ -150,7 +150,7 @@ pub(crate) fn expr_to_string(
/// (this should be done as rarely as possible).
pub(crate) fn check_zero_tts(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream, name: &str) {
if !tts.is_empty() {
- cx.dcx().emit_err(errors::TakesNoArguments { span, name });
+ cx.dcx().emit_err(diagnostics::TakesNoArguments { span, name });
}
}
@@ -209,7 +209,7 @@ pub(crate) fn get_single_expr_from_tts(
) -> ExpandResult, ErrorGuaranteed>, ()> {
let mut p = cx.new_parser_from_tts(tts);
if p.token == token::Eof {
- let guar = cx.dcx().emit_err(errors::OnlyOneArgument { span, name });
+ let guar = cx.dcx().emit_err(diagnostics::OnlyOneArgument { span, name });
return ExpandResult::Ready(Err(guar));
}
let ret = match parse_expr(&mut p) {
@@ -219,7 +219,7 @@ pub(crate) fn get_single_expr_from_tts(
let _ = p.eat(exp!(Comma));
if p.token != token::Eof {
- cx.dcx().emit_err(errors::OnlyOneArgument { span, name });
+ cx.dcx().emit_err(diagnostics::OnlyOneArgument { span, name });
}
ExpandResult::Ready(Ok(ret))
}
@@ -253,7 +253,7 @@ pub(crate) fn get_exprs_from_tts(
continue;
}
if p.token != token::Eof {
- let guar = cx.dcx().emit_err(errors::ExpectedCommaInList { span: p.token.span });
+ let guar = cx.dcx().emit_err(diagnostics::ExpectedCommaInList { span: p.token.span });
return ExpandResult::Ready(Err(guar));
}
}
diff --git a/compiler/rustc_codegen_cranelift/.github/workflows/cranelift-release-branch.yml b/compiler/rustc_codegen_cranelift/.github/workflows/cranelift-release-branch.yml
new file mode 100644
index 0000000000000..5cfdc3e8f2936
--- /dev/null
+++ b/compiler/rustc_codegen_cranelift/.github/workflows/cranelift-release-branch.yml
@@ -0,0 +1,64 @@
+name: Test upcoming Cranelift release branch
+
+on:
+ schedule:
+ - cron: "0 3 6 * *"
+ workflow_dispatch: {}
+
+permissions: {}
+
+env:
+ CARGO_BUILD_INCREMENTAL: false
+ RUSTFLAGS: "-Dwarnings"
+
+jobs:
+ test_upcoming_cranelift_release:
+ runs-on: ubuntu-latest
+ timeout-minutes: 90
+
+ steps:
+ - uses: actions/checkout@v6
+
+ - name: Determine latest Wasmtime release branch
+ id: wasmtime_release_branch
+ run: |
+ branches="$(
+ git ls-remote --heads https://github.com/bytecodealliance/wasmtime.git "refs/heads/release-*" \
+ | awk '{print $2}' \
+ | sed 's#refs/heads/##' \
+ | sort -V
+ )"
+ if [[ -z "${branches}" ]]; then
+ echo "No wasmtime release branches found"
+ exit 1
+ fi
+ latest="$(echo "${branches}" | tail -n 1)"
+ echo "Latest release branch: ${latest}"
+ echo "branch=${latest}" >> "$GITHUB_OUTPUT"
+
+ - name: Patch Cargo.toml to use release branch Cranelift
+ run: |
+ cat >>Cargo.toml <",
);
diff --git a/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs b/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs
index 216c87f095533..5c8b719ad5404 100644
--- a/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs
@@ -231,6 +231,8 @@ fn build_clif_sysroot_for_triple(
// inlining.
rustflags.push("-Zinline-mir".to_owned());
+ rustflags.push("-Zdisable-incr-comp-backend-caching".to_owned());
+
if let Some(prefix) = env::var_os("CG_CLIF_STDLIB_REMAP_PATH_PREFIX") {
rustflags.push("--remap-path-prefix".to_owned());
rustflags.push(format!("library/={}/library", prefix.to_str().unwrap()));
diff --git a/compiler/rustc_codegen_cranelift/build_system/main.rs b/compiler/rustc_codegen_cranelift/build_system/main.rs
index 0720d72c6d7cb..852fda950d88b 100644
--- a/compiler/rustc_codegen_cranelift/build_system/main.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/main.rs
@@ -59,7 +59,6 @@ fn main() {
if env::var_os("RUST_BACKTRACE").is_none() {
env::set_var("RUST_BACKTRACE", "1");
}
- env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");
let mut args = env::args().skip(1);
let command = match args.next().as_deref() {
diff --git a/compiler/rustc_codegen_cranelift/build_system/prepare.rs b/compiler/rustc_codegen_cranelift/build_system/prepare.rs
index ba5cc9a29f599..1bc56e311ec7d 100644
--- a/compiler/rustc_codegen_cranelift/build_system/prepare.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/prepare.rs
@@ -11,11 +11,13 @@ pub(crate) fn prepare(dirs: &Dirs) {
std::fs::create_dir_all(&dirs.download_dir).unwrap();
crate::tests::RAND_REPO.fetch(dirs);
crate::tests::REGEX_REPO.fetch(dirs);
+ crate::tests::GRAVIOLA_REPO.fetch(dirs);
}
pub(crate) struct GitRepo {
url: GitRepoUrl,
rev: &'static str,
+ submodules: &'static [&'static str],
content_hash: &'static str,
patch_name: &'static str,
}
@@ -71,10 +73,17 @@ impl GitRepo {
user: &'static str,
repo: &'static str,
rev: &'static str,
+ submodules: &'static [&'static str],
content_hash: &'static str,
patch_name: &'static str,
) -> GitRepo {
- GitRepo { url: GitRepoUrl::Github { user, repo }, rev, content_hash, patch_name }
+ GitRepo {
+ url: GitRepoUrl::Github { user, repo },
+ rev,
+ submodules,
+ content_hash,
+ patch_name,
+ }
}
fn download_dir(&self, dirs: &Dirs) -> PathBuf {
@@ -132,6 +141,7 @@ impl GitRepo {
&download_dir,
&format!("https://github.com/{}/{}.git", user, repo),
self.rev,
+ self.submodules,
);
}
}
@@ -160,7 +170,7 @@ impl GitRepo {
}
}
-fn clone_repo(download_dir: &Path, repo: &str, rev: &str) {
+fn clone_repo(download_dir: &Path, repo: &str, rev: &str, submodules: &[&str]) {
eprintln!("[CLONE] {}", repo);
match fs::remove_dir_all(download_dir) {
@@ -180,6 +190,13 @@ fn clone_repo(download_dir: &Path, repo: &str, rev: &str) {
checkout_cmd.arg("-q").arg(rev);
spawn_and_wait(checkout_cmd);
+ if !submodules.is_empty() {
+ let mut submodule_cmd = git_command(download_dir, "submodule");
+ submodule_cmd.arg("update").arg("--init");
+ submodule_cmd.args(submodules);
+ spawn_and_wait(submodule_cmd);
+ }
+
std::fs::remove_dir_all(download_dir.join(".git")).unwrap();
}
diff --git a/compiler/rustc_codegen_cranelift/build_system/tests.rs b/compiler/rustc_codegen_cranelift/build_system/tests.rs
index 3b6a2e7a055cb..685bf8ce9a891 100644
--- a/compiler/rustc_codegen_cranelift/build_system/tests.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/tests.rs
@@ -125,6 +125,7 @@ pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
"rust-random",
"rand",
"1f4507a8e1cf8050e4ceef95eeda8f64645b6719",
+ &[],
"981f8bf489338978",
"rand",
);
@@ -135,12 +136,24 @@ pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
"rust-lang",
"regex",
"061ee815ef2c44101dba7b0b124600fcb03c1912",
+ &[],
"dc26aefbeeac03ca",
"regex",
);
static REGEX: CargoProject = CargoProject::new(REGEX_REPO.source_dir(), "regex_target");
+pub(crate) static GRAVIOLA_REPO: GitRepo = GitRepo::github(
+ "ctz",
+ "graviola",
+ "c779b83cfd7114c4802293700c92cfb5e05cb4b7",
+ &["thirdparty/cavp", "thirdparty/wycheproof"],
+ "e0925ceb21a56101",
+ "graviola",
+);
+
+static GRAVIOLA: CargoProject = CargoProject::new(GRAVIOLA_REPO.source_dir(), "graviola_target");
+
static PORTABLE_SIMD_SRC: RelPath = RelPath::build("portable-simd");
static PORTABLE_SIMD: CargoProject = CargoProject::new(PORTABLE_SIMD_SRC, "portable-simd_target");
@@ -199,6 +212,43 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
spawn_and_wait(build_cmd);
}
}),
+ TestCase::custom("test.graviola", &|runner| {
+ let (arch, _) = runner.target_compiler.triple.split_once('-').unwrap();
+
+ if !["aarch64", "x86_64"].contains(&arch) {
+ eprintln!("Skipping `graviola` tests: unsupported target");
+ return;
+ }
+
+ GRAVIOLA_REPO.patch(&runner.dirs);
+ GRAVIOLA.clean(&runner.dirs);
+
+ if runner.is_native {
+ let mut test_cmd = GRAVIOLA.test(&runner.target_compiler, &runner.dirs);
+
+ // FIXME: Disable AVX-512 until intrinsics are supported.
+ test_cmd.env("GRAVIOLA_CPU_DISABLE_avx512f", "1");
+ test_cmd.env("GRAVIOLA_CPU_DISABLE_avx512bw", "1");
+ test_cmd.env("GRAVIOLA_CPU_DISABLE_avx512vl", "1");
+
+ test_cmd.args([
+ "-p",
+ "graviola",
+ "--lib",
+ "--",
+ "-q",
+ // FIXME: Disable AVX-512 until intrinsics are supported.
+ "--skip",
+ "check_counter512",
+ ]);
+ spawn_and_wait(test_cmd);
+ } else {
+ eprintln!("Cross-Compiling: Not running tests");
+ let mut build_cmd = GRAVIOLA.build(&runner.target_compiler, &runner.dirs);
+ build_cmd.args(["-p", "graviola", "--lib"]);
+ spawn_and_wait(build_cmd);
+ }
+ }),
TestCase::custom("test.portable-simd", &|runner| {
apply_patches(
&runner.dirs,
diff --git a/compiler/rustc_codegen_cranelift/config.txt b/compiler/rustc_codegen_cranelift/config.txt
index 72631355733c4..7c516e2164b40 100644
--- a/compiler/rustc_codegen_cranelift/config.txt
+++ b/compiler/rustc_codegen_cranelift/config.txt
@@ -20,7 +20,7 @@ aot.mini_core_hello_world
testsuite.base_sysroot
aot.arbitrary_self_types_pointers_and_wrappers
-#jit.std_example # FIXME(#1619) broken for some reason
+jit.std_example
aot.std_example
aot.dst_field_align
aot.subslice-patterns-const-eval
@@ -36,4 +36,5 @@ test.sysroot
testsuite.extended_sysroot
test.rust-random/rand
test.regex
+test.graviola
test.portable-simd
diff --git a/compiler/rustc_codegen_cranelift/example/neon.rs b/compiler/rustc_codegen_cranelift/example/neon.rs
index 98a2a7af38f6b..1aec5badcbc26 100644
--- a/compiler/rustc_codegen_cranelift/example/neon.rs
+++ b/compiler/rustc_codegen_cranelift/example/neon.rs
@@ -9,6 +9,25 @@ use std::mem::transmute;
#[cfg(target_arch = "aarch64")]
use std::simd::*;
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "crc")]
+unsafe fn test_crc32() {
+ assert!(std::arch::is_aarch64_feature_detected!("crc"));
+
+ let a: u32 = 42;
+ let b: u64 = 0xdeadbeef;
+
+ assert_eq!(__crc32b(a, b as u8), 0xEB0E363F);
+ assert_eq!(__crc32h(a, b as u16), 0x9A54BD80);
+ assert_eq!(__crc32w(a, b as u32), 0xF491F059);
+ assert_eq!(__crc32d(a, b as u64), 0xD14BBEA6);
+
+ assert_eq!(__crc32cb(a, b as u8), 0xF67C32D8);
+ assert_eq!(__crc32ch(a, b as u16), 0x479108B8);
+ assert_eq!(__crc32cw(a, b as u32), 0x979F49F8);
+ assert_eq!(__crc32cd(a, b as u64), 0x0E6BE593);
+}
+
#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmin_s8() {
let a = i8x8::from([1, -2, 3, -4, 5, 6, 7, 8]);
@@ -240,6 +259,272 @@ unsafe fn test_vrndnq_f32() {
assert_eq!(r, e);
}
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "aes")]
+unsafe fn test_vaeseq_u8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.crypto.aese
+ let a = u8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
+ let b = u8x16::from([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]);
+ let e = u8x16::from([
+ 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca, 0xca,
+ 0xca,
+ ]);
+ let r: u8x16 = unsafe { transmute(vaeseq_u8(transmute(a), transmute(b))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "aes")]
+unsafe fn test_vaesdq_u8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.crypto.aesd
+ let a = u8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
+ let b = u8x16::from([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]);
+ let e = u8x16::from([
+ 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
+ 0x7c,
+ ]);
+ let r: u8x16 = unsafe { transmute(vaesdq_u8(transmute(a), transmute(b))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "aes")]
+unsafe fn test_vaesmcq_u8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.crypto.aesmc
+ let a = u8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
+ let e = u8x16::from([2, 7, 0, 5, 6, 3, 4, 1, 10, 15, 8, 13, 14, 11, 12, 9]);
+ let r: u8x16 = unsafe { transmute(vaesmcq_u8(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "aes")]
+unsafe fn test_vaesimcq_u8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.crypto.aesimc
+ let a = u8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
+ let e = u8x16::from([10, 15, 8, 13, 14, 11, 12, 9, 2, 7, 0, 5, 6, 3, 4, 1]);
+ let r: u8x16 = unsafe { transmute(vaesimcq_u8(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "sha2")]
+unsafe fn test_vsha256hq_u32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha256h
+ let a = u32x4::from([0, 1, 2, 3]);
+ let b = u32x4::from([4, 5, 6, 7]);
+ let c = u32x4::from([8, 9, 10, 11]);
+ let e = u32x4::from([0x27bb4ae0, 0xd8f61f7c, 0xb7c1ecdc, 0x10800215]);
+ let r: u32x4 = unsafe { transmute(vsha256hq_u32(transmute(a), transmute(b), transmute(c))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "sha2")]
+unsafe fn test_vsha256h2q_u32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha256h2
+ let a = u32x4::from([0, 1, 2, 3]);
+ let b = u32x4::from([4, 5, 6, 7]);
+ let c = u32x4::from([8, 9, 10, 11]);
+ let e = u32x4::from([0x6989ee0d, 0x4b055920, 0x52800a12, 0x00000014]);
+ let r: u32x4 = unsafe { transmute(vsha256h2q_u32(transmute(a), transmute(b), transmute(c))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "sha2")]
+unsafe fn test_vsha256su0q_u32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha256su0
+ let a = u32x4::from([0, 1, 2, 3]);
+ let b = u32x4::from([4, 5, 6, 7]);
+ let e = u32x4::from([0x02004000, 0x04008001, 0x0600c002, 0x08010003]);
+ let r: u32x4 = unsafe { transmute(vsha256su0q_u32(transmute(a), transmute(b))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "sha2")]
+unsafe fn test_vsha256su1q_u32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha256su1
+ let a = u32x4::from([0, 1, 2, 3]);
+ let b = u32x4::from([4, 5, 6, 7]);
+ let c = u32x4::from([8, 9, 10, 11]);
+ let e = u32x4::from([0x00044005, 0x0004e007, 0xa802211b, 0xec036145]);
+ let r: u32x4 = unsafe { transmute(vsha256su1q_u32(transmute(a), transmute(b), transmute(c))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+#[target_feature(enable = "aes")]
+fn test_vmull_p64() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.pmull64
+ let a: u64 = 3;
+ let b: u64 = 6;
+ let e: u128 = 10;
+ let r: u128 = vmull_p64(a, b);
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vmull_p8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.pmull.v8i16
+ let a = u8x8::from([0, 1, 2, 3, 4, 5, 6, 7]);
+ let b = u8x8::from([8, 9, 10, 11, 12, 13, 14, 15]);
+ let e = u16x8::from([0x0000, 0x0009, 0x0014, 0x001d, 0x0030, 0x0039, 0x0024, 0x002d]);
+ let r: u16x8 = unsafe { transmute(vmull_p8(transmute(a), transmute(b))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vqdmulh_s16() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.sqdmulh.v4i16
+ let a = i16x4::from([1, 2, 4, 8]);
+ let b = i16x4::from([16384, 16384, 16384, 16384]);
+ let e = i16x4::from([0, 1, 2, 4]);
+ let r: i16x4 = unsafe { transmute(vqdmulh_s16(transmute(a), transmute(b))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vqdmulh_s32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.sqdmulh.v2i32
+ let a = i32x2::from([1, 2]);
+ let b = i32x2::from([1073741824, 1073741824]);
+ let e = i32x2::from([0, 1]);
+ let r: i32x2 = unsafe { transmute(vqdmulh_s32(transmute(a), transmute(b))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vqdmulhq_s16() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.sqdmulh.v8i16
+ let a = i16x8::from([1, 2, 4, 8, 16, 32, 64, 128]);
+ let b = i16x8::from([16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384]);
+ let e = i16x8::from([0, 1, 2, 4, 8, 16, 32, 64]);
+ let r: i16x8 = unsafe { transmute(vqdmulhq_s16(transmute(a), transmute(b))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vqdmulhq_s32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.sqdmulh.v4i32
+ let a = i32x4::from([1, 2, 4, 8]);
+ let b = i32x4::from([1073741824, 1073741824, 1073741824, 1073741824]);
+ let e = i32x4::from([0, 1, 2, 4]);
+ let r: i32x4 = unsafe { transmute(vqdmulhq_s32(transmute(a), transmute(b))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddl_s8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.saddlp.v4i16.v8i8
+ let a = i8x8::from([1, 2, 3, 4, -5, -6, -7, -8]);
+ let e = i16x4::from([3, 7, -11, -15]);
+ let r: i16x4 = unsafe { transmute(vpaddl_s8(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddl_s16() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.saddlp.v2i32.v4i16
+ let a = i16x4::from([1, 2, -3, -4]);
+ let e = i32x2::from([3, -7]);
+ let r: i32x2 = unsafe { transmute(vpaddl_s16(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddl_s32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.saddlp.v1i64.v2i32
+ let a = i32x2::from([1, -2]);
+ let e = i64x1::from([-1]);
+ let r: i64x1 = unsafe { transmute(vpaddl_s32(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddlq_s8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.saddlp.v8i16.v16i8
+ let a = i8x16::from([1, 2, 3, 4, 5, 6, 7, 8, -9, -10, -11, -12, -13, -14, -15, -16]);
+ let e = i16x8::from([3, 7, 11, 15, -19, -23, -27, -31]);
+ let r: i16x8 = unsafe { transmute(vpaddlq_s8(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddlq_s16() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.saddlp.v4i32.v8i16
+ let a = i16x8::from([1, 2, 3, 4, -5, -6, -7, -8]);
+ let e = i32x4::from([3, 7, -11, -15]);
+ let r: i32x4 = unsafe { transmute(vpaddlq_s16(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddlq_s32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.saddlp.v2i64.v4i32
+ let a = i32x4::from([1, 2, -3, -4]);
+ let e = i64x2::from([3, -7]);
+ let r: i64x2 = unsafe { transmute(vpaddlq_s32(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddl_u8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.uaddlp.v4i16.v8i8
+ let a = u8x8::from([255, 254, 253, 252, 251, 250, 249, 248]);
+ let e = u16x4::from([509, 505, 501, 497]);
+ let r: u16x4 = unsafe { transmute(vpaddl_u8(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddl_u16() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.uaddlp.v2i32.v4i16
+ let a = u16x4::from([65535, 65534, 65533, 65532]);
+ let e = u32x2::from([131069, 131065]);
+ let r: u32x2 = unsafe { transmute(vpaddl_u16(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddl_u32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.uaddlp.v1i64.v2i32
+ let a = u32x2::from([4294967295, 4294967294]);
+ let e = u64x1::from([8589934589]);
+ let r: u64x1 = unsafe { transmute(vpaddl_u32(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddlq_u8() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.uaddlp.v8i16.v16i8
+ let a = u8x16::from([
+ 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240,
+ ]);
+ let e = u16x8::from([509, 505, 501, 497, 493, 489, 485, 481]);
+ let r: u16x8 = unsafe { transmute(vpaddlq_u8(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddlq_u16() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.uaddlp.v4i32.v8i16
+ let a = u16x8::from([65535, 65534, 65533, 65532, 65531, 65530, 65529, 65528]);
+ let e = u32x4::from([131069, 131065, 131061, 131057]);
+ let r: u32x4 = unsafe { transmute(vpaddlq_u16(transmute(a))) };
+ assert_eq!(r, e);
+}
+
+#[cfg(target_arch = "aarch64")]
+unsafe fn test_vpaddlq_u32() {
+ // AArch64 llvm intrinsic: llvm.aarch64.neon.uaddlp.v2i64.v4i32
+ let a = u32x4::from([4294967295, 4294967294, 4294967293, 4294967292]);
+ let e = u64x2::from([8589934589, 8589934585]);
+ let r: u64x2 = unsafe { transmute(vpaddlq_u32(transmute(a))) };
+ assert_eq!(r, e);
+}
+
#[cfg(target_arch = "aarch64")]
fn main() {
unsafe {
@@ -272,6 +557,40 @@ fn main() {
test_vminq_f32();
test_vaddvq_f32();
test_vrndnq_f32();
+
+ test_crc32();
+
+ test_vaeseq_u8();
+ test_vaesdq_u8();
+ test_vaesmcq_u8();
+ test_vaesimcq_u8();
+
+ test_vsha256hq_u32();
+ test_vsha256h2q_u32();
+ test_vsha256su0q_u32();
+ test_vsha256su1q_u32();
+
+ test_vmull_p64();
+ test_vmull_p8();
+
+ test_vqdmulh_s16();
+ test_vqdmulh_s32();
+ test_vqdmulhq_s16();
+ test_vqdmulhq_s32();
+
+ test_vpaddl_s8();
+ test_vpaddl_s16();
+ test_vpaddl_s32();
+ test_vpaddlq_s8();
+ test_vpaddlq_s16();
+ test_vpaddlq_s32();
+
+ test_vpaddl_u8();
+ test_vpaddl_u16();
+ test_vpaddl_u32();
+ test_vpaddlq_u8();
+ test_vpaddlq_u16();
+ test_vpaddlq_u32();
}
}
diff --git a/compiler/rustc_codegen_cranelift/example/std_example.rs b/compiler/rustc_codegen_cranelift/example/std_example.rs
index f0e38ae0610c9..252344b378e8a 100644
--- a/compiler/rustc_codegen_cranelift/example/std_example.rs
+++ b/compiler/rustc_codegen_cranelift/example/std_example.rs
@@ -1,8 +1,6 @@
#![feature(core_intrinsics, coroutines, coroutine_trait, repr_simd, tuple_trait, unboxed_closures)]
#![allow(internal_features)]
-#[cfg(target_arch = "x86_64")]
-use std::arch::asm;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
use std::hint::black_box;
@@ -591,7 +589,7 @@ unsafe fn test_xmm_roundtrip() {
let input = [1u8; 16];
let mut output = [0u8; 16];
- asm!(
+ std::arch::asm!(
"movups {xmm}, [{input}]",
"movups [{output}], {xmm}",
input = in(reg) input.as_ptr(),
@@ -611,7 +609,7 @@ unsafe fn test_ymm_roundtrip() {
let input = [1u8; 32];
let mut output = [0u8; 32];
- asm!(
+ std::arch::asm!(
"vmovups {ymm}, [{input}]",
"vmovups [{output}], {ymm}",
input = in(reg) input.as_ptr(),
@@ -631,7 +629,7 @@ unsafe fn test_zmm_roundtrip() {
let input = [1u8; 64];
let mut output = [0u8; 64];
- asm!(
+ std::arch::asm!(
"vmovups {zmm}, [{input}]",
"vmovups [{output}], {zmm}",
input = in(reg) input.as_ptr(),
diff --git a/compiler/rustc_codegen_cranelift/patches/0001-portable-simd-Disable-f16-usage-in-portable-simd.patch b/compiler/rustc_codegen_cranelift/patches/0001-portable-simd-Disable-f16-usage-in-portable-simd.patch
index 029e493227cd1..a2fcd97349e2b 100644
--- a/compiler/rustc_codegen_cranelift/patches/0001-portable-simd-Disable-f16-usage-in-portable-simd.patch
+++ b/compiler/rustc_codegen_cranelift/patches/0001-portable-simd-Disable-f16-usage-in-portable-simd.patch
@@ -154,6 +154,21 @@ index 510f4c9..175cbce 100644
-impl_trait! { f16 { bits: u16, mask: i16 }, f32 { bits: u32, mask: i32 }, f64 { bits: u64, mask: i64 } }
+impl_trait! { f32 { bits: u32, mask: i32 }, f64 { bits: u64, mask: i64 } }
+diff --git a/crates/core_simd/src/simd/prelude.rs b/crates/core_simd/src/simd/prelude.rs
+index 51b8def..6e93f16 100644
+--- a/crates/core_simd/src/simd/prelude.rs
++++ b/crates/core_simd/src/simd/prelude.rs
+@@ -14,10 +14,6 @@ pub use super::{
+ simd_swizzle,
+ };
+
+-#[rustfmt::skip]
+-#[doc(no_inline)]
+-pub use super::{f16x1, f16x2, f16x4, f16x8, f16x16, f16x32, f16x64};
+-
+ #[rustfmt::skip]
+ #[doc(no_inline)]
+ pub use super::{f32x1, f32x2, f32x4, f32x8, f32x16, f32x32, f32x64};
diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs
index fbef69f..c8e0b8c 100644
--- a/crates/core_simd/src/vector.rs
diff --git a/compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch b/compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch
index b7276e43153bc..717495cbcdf33 100644
--- a/compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch
+++ b/compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch
@@ -34,17 +34,17 @@ index a60f0799c0e..af056fbf41f 100644
#[cfg(target_has_atomic_load_store = "8")]
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
-index bf2b6d59f88..d5ccce03bbf 100644
+index 8a9a0b5..92ed9a6 100644
--- a/library/core/src/sync/atomic.rs
+++ b/library/core/src/sync/atomic.rs
-@@ -3585,42 +3585,6 @@ pub const fn as_ptr(&self) -> *mut $int_type {
+@@ -3762,42 +3757,6 @@ atomic_int! {
8,
u64 AtomicU64
}
-#[cfg(target_has_atomic_load_store = "128")]
-atomic_int! {
- cfg(target_has_atomic = "128"),
-- cfg(target_has_atomic_equal_alignment = "128"),
+- cfg(target_has_atomic_primitive_alignment = "128"),
- unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "99069"),
@@ -62,7 +62,7 @@ index bf2b6d59f88..d5ccce03bbf 100644
-#[cfg(target_has_atomic_load_store = "128")]
-atomic_int! {
- cfg(target_has_atomic = "128"),
-- cfg(target_has_atomic_equal_alignment = "128"),
+- cfg(target_has_atomic_primitive_alignment = "128"),
- unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "99069"),
diff --git a/compiler/rustc_codegen_cranelift/patches/0029-sysroot_tests-disable-f16-math.patch b/compiler/rustc_codegen_cranelift/patches/0029-sysroot_tests-disable-f16-math.patch
index 2aeb4a8a1874c..8d21359aa0043 100644
--- a/compiler/rustc_codegen_cranelift/patches/0029-sysroot_tests-disable-f16-math.patch
+++ b/compiler/rustc_codegen_cranelift/patches/0029-sysroot_tests-disable-f16-math.patch
@@ -7,11 +7,389 @@ Subject: [PATCH] Disable f16 math tests for cranelift
coretests/tests/num/floats.rs | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
-diff --git a/coretests/tests/floats/mod.rs b/coretests/tests/floats/mod.rs
-index c61961f8584..d7b4fa20322 100644
+diff --git a/coretests/tests/num/floats.rs b/coretests/tests/num/floats.rs
+index 1d7956b..01e4caa 100644
--- a/coretests/tests/num/floats.rs
+++ b/coretests/tests/num/floats.rs
-@@ -1534,7 +1534,7 @@ fn s_nan() -> Float {
+@@ -444,7 +444,7 @@ pub(crate) use float_test;
+ float_test! {
+ name: num,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -463,7 +463,7 @@ float_test! {
+ name: num_rem,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -476,7 +476,7 @@ float_test! {
+ float_test! {
+ name: nan,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -496,7 +496,7 @@ float_test! {
+ float_test! {
+ name: infinity,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -514,7 +514,7 @@ float_test! {
+ float_test! {
+ name: neg_infinity,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -532,7 +532,7 @@ float_test! {
+ float_test! {
+ name: zero,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -550,7 +550,7 @@ float_test! {
+ float_test! {
+ name: neg_zero,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -570,7 +570,7 @@ float_test! {
+ float_test! {
+ name: one,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -588,7 +588,7 @@ float_test! {
+ float_test! {
+ name: is_nan,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -609,7 +609,7 @@ float_test! {
+ float_test! {
+ name: is_infinite,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -630,7 +630,7 @@ float_test! {
+ float_test! {
+ name: is_finite,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -651,7 +651,7 @@ float_test! {
+ float_test! {
+ name: is_normal,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -673,7 +673,7 @@ float_test! {
+ float_test! {
+ name: classify,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ },
+ test {
+ let nan: Float = Float::NAN;
+@@ -695,7 +695,7 @@ float_test! {
+ name: min,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -737,7 +737,7 @@ float_test! {
+ name: max,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -780,7 +780,7 @@ float_test! {
+ name: minimum,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -812,7 +812,7 @@ float_test! {
+ name: maximum,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -845,7 +845,7 @@ float_test! {
+ name: midpoint,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -898,7 +898,7 @@ float_test! {
+ attrs: {
+ const: #[cfg(false)],
+ // Needs powi
+- f16: #[cfg(target_has_reliable_f16_math)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128_math)],
+ },
+ test {
+@@ -929,7 +929,7 @@ float_test! {
+ name: abs,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -948,7 +948,7 @@ float_test! {
+ name: copysign,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -964,7 +964,7 @@ float_test! {
+ attrs: {
+ const: #[cfg(false)],
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -982,7 +982,7 @@ float_test! {
+ attrs: {
+ const: #[cfg(false)],
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -998,7 +998,7 @@ float_test! {
+ name: floor,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1028,7 +1028,7 @@ float_test! {
+ name: ceil,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1058,7 +1058,7 @@ float_test! {
+ name: round,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1089,7 +1089,7 @@ float_test! {
+ name: round_ties_even,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1120,7 +1120,7 @@ float_test! {
+ name: trunc,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1150,7 +1150,7 @@ float_test! {
+ name: fract,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1182,7 +1182,7 @@ float_test! {
+ name: signum,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1200,7 +1200,7 @@ float_test! {
+ float_test! {
+ name: is_sign_positive,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -1219,7 +1219,7 @@ float_test! {
+ float_test! {
+ name: is_sign_negative,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -1238,7 +1238,7 @@ float_test! {
+ float_test! {
+ name: next_up,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -1269,7 +1269,7 @@ float_test! {
+ float_test! {
+ name: next_down,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -1303,7 +1303,7 @@ float_test! {
+ attrs: {
+ const: #[cfg(false)],
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1321,7 +1321,7 @@ float_test! {
+ name: clamp_min_greater_than_max,
+ attrs: {
+ const: #[cfg(false)],
+- f16: #[should_panic, cfg(target_has_reliable_f16)],
++ f16: #[should_panic, cfg(false)],
+ f32: #[should_panic],
+ f64: #[should_panic],
+ f128: #[should_panic, cfg(target_has_reliable_f128)],
+@@ -1335,7 +1335,7 @@ float_test! {
+ name: clamp_min_is_nan,
+ attrs: {
+ const: #[cfg(false)],
+- f16: #[should_panic, cfg(target_has_reliable_f16)],
++ f16: #[should_panic, cfg(false)],
+ f32: #[should_panic],
+ f64: #[should_panic],
+ f128: #[should_panic, cfg(target_has_reliable_f128)],
+@@ -1349,7 +1349,7 @@ float_test! {
+ name: clamp_max_is_nan,
+ attrs: {
+ const: #[cfg(false)],
+- f16: #[should_panic, cfg(target_has_reliable_f16)],
++ f16: #[should_panic, cfg(false)],
+ f32: #[should_panic],
+ f64: #[should_panic],
+ f128: #[should_panic, cfg(target_has_reliable_f128)],
+@@ -1363,7 +1363,7 @@ float_test! {
+ name: total_cmp,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1469,7 +1469,7 @@ float_test! {
+ attrs: {
+ const: #[cfg(false)],
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1526,7 +1526,7 @@ float_test! {
+ name: recip,
+ attrs: {
+ // Miri only uses softfloats here, so that always works
+- f16: #[cfg(any(miri, target_has_reliable_f16_math))],
++ f16: #[cfg(false)],
+ f128: #[cfg(any(miri, target_has_reliable_f128_math))],
+ },
+ test {
+@@ -1549,7 +1549,7 @@ float_test! {
+ name: powi,
+ attrs: {
+ const: #[cfg(false)],
+- f16: #[cfg(target_has_reliable_f16_math)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128_math)],
+ },
+ test {
+@@ -1570,7 +1570,7 @@ float_test! {
name: powf,
attrs: {
const: #[cfg(false)],
@@ -20,7 +398,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1557,7 +1557,7 @@ fn s_nan() -> Float {
+@@ -1593,7 +1593,7 @@ float_test! {
name: exp,
attrs: {
const: #[cfg(false)],
@@ -29,7 +407,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1578,7 +1578,7 @@ fn s_nan() -> Float {
+@@ -1614,7 +1614,7 @@ float_test! {
name: exp2,
attrs: {
const: #[cfg(false)],
@@ -38,7 +416,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1598,7 +1598,7 @@ fn s_nan() -> Float {
+@@ -1634,7 +1634,7 @@ float_test! {
name: ln,
attrs: {
const: #[cfg(false)],
@@ -47,7 +425,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1620,7 +1620,7 @@ fn s_nan() -> Float {
+@@ -1656,7 +1656,7 @@ float_test! {
name: log,
attrs: {
const: #[cfg(false)],
@@ -56,7 +434,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1645,7 +1645,7 @@ fn s_nan() -> Float {
+@@ -1681,7 +1681,7 @@ float_test! {
name: log2,
attrs: {
const: #[cfg(false)],
@@ -65,7 +443,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1668,7 +1668,7 @@ fn s_nan() -> Float {
+@@ -1704,7 +1704,7 @@ float_test! {
name: log10,
attrs: {
const: #[cfg(false)],
@@ -74,7 +452,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1692,7 +1692,7 @@ fn s_nan() -> Float {
+@@ -1728,7 +1728,7 @@ float_test! {
name: asinh,
attrs: {
const: #[cfg(false)],
@@ -83,7 +461,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1725,7 +1725,7 @@ fn s_nan() -> Float {
+@@ -1764,7 +1764,7 @@ float_test! {
name: acosh,
attrs: {
const: #[cfg(false)],
@@ -92,7 +470,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1753,7 +1753,7 @@ fn s_nan() -> Float {
+@@ -1795,7 +1795,7 @@ float_test! {
name: atanh,
attrs: {
const: #[cfg(false)],
@@ -101,7 +479,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1779,7 +1779,7 @@ fn s_nan() -> Float {
+@@ -1821,7 +1821,7 @@ float_test! {
name: gamma,
attrs: {
const: #[cfg(false)],
@@ -110,7 +488,7 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -1814,7 +1814,7 @@ fn s_nan() -> Float {
+@@ -1856,7 +1856,7 @@ float_test! {
name: ln_gamma,
attrs: {
const: #[cfg(false)],
@@ -119,7 +497,79 @@ index c61961f8584..d7b4fa20322 100644
f128: #[cfg(target_has_reliable_f128_math)],
},
test {
-@@ -2027,7 +2027,7 @@ fn s_nan() -> Float {
+@@ -1874,7 +1874,7 @@ float_test! {
+ float_test! {
+ name: to_degrees,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -1895,7 +1895,7 @@ float_test! {
+ float_test! {
+ name: to_radians,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -1916,7 +1916,7 @@ float_test! {
+ float_test! {
+ name: to_algebraic,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -1940,7 +1940,7 @@ float_test! {
+ float_test! {
+ name: to_bits_conv,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -1967,7 +1967,7 @@ float_test! {
+ float_test! {
+ name: mul_add,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ // FIXME(#140515): mingw has an incorrect fma https://sourceforge.net/p/mingw-w64/bugs/848/
+ f32: #[cfg_attr(all(target_os = "windows", target_env = "gnu", not(target_abi = "llvm")), ignore)],
+ f64: #[cfg_attr(all(target_os = "windows", target_env = "gnu", not(target_abi = "llvm")), ignore)],
+@@ -1992,7 +1992,7 @@ float_test! {
+ float_test! {
+ name: from,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -2049,7 +2049,7 @@ float_test! {
+ float_test! {
+ name: max_exact_integer_constant,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -2091,7 +2091,7 @@ float_test! {
+ float_test! {
+ name: min_exact_integer_constant,
+ attrs: {
+- f16: #[cfg(target_has_reliable_f16)],
++ f16: #[cfg(false)],
+ f128: #[cfg(target_has_reliable_f128)],
+ },
+ test {
+@@ -2156,7 +2156,7 @@ float_test! {
attrs: {
// FIXME(f16_f128): add math tests when available
const: #[cfg(false)],
diff --git a/compiler/rustc_codegen_cranelift/rust-toolchain.toml b/compiler/rustc_codegen_cranelift/rust-toolchain.toml
index 486078185db84..faadf08929557 100644
--- a/compiler/rustc_codegen_cranelift/rust-toolchain.toml
+++ b/compiler/rustc_codegen_cranelift/rust-toolchain.toml
@@ -1,4 +1,4 @@
[toolchain]
-channel = "nightly-2026-04-28"
+channel = "nightly-2026-06-06"
components = ["rust-src", "rustc-dev", "llvm-tools", "rustfmt"]
profile = "minimal"
diff --git a/compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh b/compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh
index 7ce54a45e2ce6..ab31c43fb1b12 100644
--- a/compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh
+++ b/compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh
@@ -54,7 +54,7 @@ index 2e16f2cf27..3ac3df99a8 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -1147,6 +1147,8 @@ class RustBuild(object):
- args += ["-Zwarnings"]
+ if deny_warnings:
env["CARGO_BUILD_WARNINGS"] = "deny"
+ env["RUSTFLAGS"] += " -Zbinary-dep-depinfo"
diff --git a/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh b/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
index 4a663c48c0aff..683adeb49edd1 100755
--- a/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
+++ b/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
@@ -88,6 +88,8 @@ rm -r tests/run-make/reproducible-build-2
rm -r tests/run-make/no-builtins-lto
rm -r tests/run-make/reachable-extern-fn-available-lto
rm -r tests/run-make/no-builtins-linker-plugin-lto
+rm -r tests/run-make/fat-then-thin-lto
+rm -r tests/run-make/cross-lang-lto-upstream-rlibs
# coverage instrumentation
rm tests/ui/consts/precise-drop-with-coverage.rs
@@ -146,6 +148,7 @@ rm tests/ui/consts/const-mut-refs-crate.rs # same
rm tests/ui/abi/large-byval-align.rs # exceeds implementation limit of Cranelift
rm -r tests/run-make/short-ice # ICE backtrace begin/end marker mismatch
rm -r tests/run-make/naked-dead-code-elimination # function not eliminated
+rm tests/ui/codegen/huge-stacks.rs # Cranelift doesn't allow stack frames to exceed 4GB
# doesn't work due to the way the rustc test suite is invoked.
# should work when using ./x.py test the way it is intended
diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs
index a8b179f169bf6..0eb493036ce51 100644
--- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs
@@ -31,6 +31,11 @@ use crate::base::codegen_unwind_terminate;
use crate::debuginfo::EXCEPTION_HANDLER_CLEANUP;
use crate::prelude::*;
+struct ArgValue<'tcx> {
+ value: CValue<'tcx>,
+ is_underaligned_pointee: bool,
+}
+
fn clif_sig_from_fn_abi<'tcx>(
tcx: TyCtxt<'tcx>,
default_call_conv: CallConv,
@@ -55,8 +60,9 @@ pub(crate) fn conv_to_call_conv(
match c {
CanonAbi::Rust | CanonAbi::RustCold | CanonAbi::C => default_call_conv,
- // Cranelift doesn't currently have anything for this.
- CanonAbi::RustPreserveNone => default_call_conv,
+ CanonAbi::RustPreserveNone | CanonAbi::RustTail => {
+ sess.dcx().fatal(format!("call conv {c:?} is LLVM-specific"))
+ }
// Functions with this calling convention can only be called from assembly, but it is
// possible to declare an `extern "custom"` block, so the backend still needs a calling
@@ -71,7 +77,7 @@ pub(crate) fn conv_to_call_conv(
},
CanonAbi::Interrupt(_) | CanonAbi::Arm(_) | CanonAbi::Swift => {
- sess.dcx().fatal("call conv {c:?} is not yet implemented")
+ sess.dcx().fatal(format!("call conv {c:?} is not yet implemented"))
}
CanonAbi::GpuKernel => {
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target")
@@ -245,8 +251,8 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
// None means pass_mode == NoPass
enum ArgKind<'tcx> {
- Normal(Option>),
- Spread(Vec