Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_feature::AttributeStability;

use super::macro_attrs::check_macro_only;
use super::prelude::*;
use crate::session_diagnostics;
use crate::diagnostics;

pub(crate) struct AllowInternalUnstableParser;
impl CombineAttributeParser for AllowInternalUnstableParser {
Expand Down Expand Up @@ -92,7 +92,7 @@ fn parse_unstable(
let mut res = Vec::new();

let Some(list) = args.as_list() else {
cx.emit_err(session_diagnostics::ExpectsFeatureList {
cx.emit_err(diagnostics::ExpectsFeatureList {
span: cx.attr_span,
name: symbol.to_ident_string(),
});
Expand All @@ -104,7 +104,7 @@ fn parse_unstable(
if let Some(ident) = param.meta_item_no_args().and_then(|i| i.path().word()) {
res.push(ident.name);
} else {
cx.emit_err(session_diagnostics::ExpectsFeatures {
cx.emit_err(diagnostics::ExpectsFeatures {
span: param_span,
name: symbol.to_ident_string(),
});
Expand Down
28 changes: 9 additions & 19 deletions compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ use thin_vec::ThinVec;

use crate::attributes::AttributeSafety;
use crate::context::{AcceptContext, ShouldEmit};
use crate::parser::{
AllowExprMetavar, ArgParser, MetaItemListParser, MetaItemOrLitParser, NameValueParser,
};
use crate::session_diagnostics::{
use crate::diagnostics::{
AttributeParseError, AttributeParseErrorReason, CfgAttrBadDelim, MetaBadDelimSugg,
ParsedDescription,
};
use crate::{
AttributeParser, AttributeTemplate, check_cfg, parse_version, session_diagnostics, template,
use crate::parser::{
AllowExprMetavar, ArgParser, MetaItemListParser, MetaItemOrLitParser, NameValueParser,
};
use crate::{AttributeParser, AttributeTemplate, check_cfg, diagnostics, parse_version, template};

pub const CFG_TEMPLATE: AttributeTemplate = template!(
List: &["predicate"],
Expand Down Expand Up @@ -131,25 +129,17 @@ fn parse_cfg_entry_version(
) -> Result<CfgEntry, ErrorGuaranteed> {
try_gate_cfg(sym::version, meta_span, cx.sess(), cx.features_option());
let Some(version) = list.as_single() else {
return Err(
cx.emit_err(session_diagnostics::ExpectedSingleVersionLiteral { span: list.span })
);
return Err(cx.emit_err(diagnostics::ExpectedSingleVersionLiteral { span: list.span }));
};
let Some(version_lit) = version.as_lit() else {
return Err(
cx.emit_err(session_diagnostics::ExpectedVersionLiteral { span: version.span() })
);
return Err(cx.emit_err(diagnostics::ExpectedVersionLiteral { span: version.span() }));
};
let Some(version_str) = version_lit.value_as_str() else {
return Err(
cx.emit_err(session_diagnostics::ExpectedVersionLiteral { span: version_lit.span })
);
return Err(cx.emit_err(diagnostics::ExpectedVersionLiteral { span: version_lit.span }));
};

let min_version = parse_version(version_str).or_else(|| {
cx.sess()
.dcx()
.emit_warn(session_diagnostics::UnknownVersionLiteral { span: version_lit.span });
cx.sess().dcx().emit_warn(diagnostics::UnknownVersionLiteral { span: version_lit.span });
None
});

Expand Down Expand Up @@ -362,7 +352,7 @@ pub fn parse_cfg_attr(
path: AttrPath::from_ast(&cfg_attr.get_normal_item().path, identity),
description: ParsedDescription::Attribute,
reason,
suggestions: session_diagnostics::AttributeParseErrorSuggestions::CreatedByTemplate(
suggestions: diagnostics::AttributeParseErrorSuggestions::CreatedByTemplate(
CFG_ATTR_TEMPLATE.suggestions(
ParsedDescription::Attribute,
cfg_attr.get_normal_item().unsafety,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_span::edition::Edition::Edition2024;

use super::prelude::*;
use crate::attributes::AttributeSafety;
use crate::session_diagnostics::{
use crate::diagnostics::{
EmptyExportName, EmptySection, NakedFunctionIncompatibleAttribute, NullOnExport,
NullOnObjcClass, NullOnObjcSelector, NullOnSection, ObjcClassExpectedStringLiteral,
ObjcSelectorExpectedStringLiteral, SanitizeInvalidStatic, TargetFeatureOnLangItem,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/confusables.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_feature::AttributeStability;

use super::prelude::*;
use crate::session_diagnostics::EmptyConfusables;
use crate::diagnostics::EmptyConfusables;

#[derive(Default)]
pub(crate) struct ConfusablesParser {
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_attr_parsing/src/attributes/deprecation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use rustc_hir::attrs::{DeprecatedSince, Deprecation, RustcVersion};

use super::prelude::*;
use super::util::parse_version;
use crate::session_diagnostics::{
DeprecatedItemSuggestion, InvalidSince, MissingNote, MissingSince,
};
use crate::diagnostics::{DeprecatedItemSuggestion, InvalidSince, MissingNote, MissingSince};

fn get(
cx: &mut AcceptContext<'_, '_>,
Expand Down
14 changes: 6 additions & 8 deletions compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@ use super::prelude::{ALL_TARGETS, AllowedTargets};
use super::{AcceptMapping, AttributeParser, template};
use crate::context::{AcceptContext, FinalizeContext};
use crate::diagnostics::{
AttrCrateLevelOnly, DocAliasDuplicated, DocAutoCfgExpectsHideOrShow,
AttrCrateLevelOnly, DocAliasBadChar, DocAliasDuplicated, DocAliasEmpty, DocAliasMalformed,
DocAliasStartEnd, DocAttrNotCrateLevel, DocAttributeNotAttribute, DocAutoCfgExpectsHideOrShow,
DocAutoCfgHideShowExpectsList, DocAutoCfgHideShowNoIdentBeforeValues,
DocAutoCfgHideShowUnexpectedItem, DocAutoCfgHideShowUnexpectedItemAfterValues,
DocAutoCfgHideShowValuesMix, DocAutoCfgWrongLiteral, DocTestLiteral, DocTestTakesList,
DocTestUnknown, DocUnknownAny, DocUnknownInclude, DocUnknownPasses, DocUnknownPlugins,
DocUnknownSpotlight, ExpectedNameValue, ExpectedNoArgs, IllFormedAttributeInput, MalformedDoc,
DocAutoCfgHideShowValuesMix, DocAutoCfgWrongLiteral, DocKeywordNotKeyword, DocTestLiteral,
DocTestTakesList, DocTestUnknown, DocUnknownAny, DocUnknownInclude, DocUnknownPasses,
DocUnknownPlugins, DocUnknownSpotlight, ExpectedNameValue, ExpectedNoArgs,
IllFormedAttributeInput, MalformedDoc, UnusedDuplicate,
};
use crate::parser::{
ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser,
};
use crate::session_diagnostics::{
DocAliasBadChar, DocAliasEmpty, DocAliasMalformed, DocAliasStartEnd, DocAttrNotCrateLevel,
DocAttributeNotAttribute, DocKeywordNotKeyword, UnusedDuplicate,
};

fn check_keyword(cx: &mut AcceptContext<'_, '_>, keyword: Symbol, span: Span) -> bool {
// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_hir::find_attr;
use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT;

use super::prelude::*;
use crate::session_diagnostics::InlineForceInlineConflict;
use crate::diagnostics::InlineForceInlineConflict;

pub(crate) struct InlineParser;

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/instruction_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc_feature::AttributeStability;
use rustc_hir::attrs::InstructionSetAttr;

use super::prelude::*;
use crate::session_diagnostics;
use crate::diagnostics;

pub(crate) struct InstructionSetParser;

Expand Down Expand Up @@ -43,7 +43,7 @@ impl SingleAttributeParser for InstructionSetParser {
let instruction_set = match architecture.name {
sym::arm => {
if !cx.sess.target.has_thumb_interworking {
cx.dcx().emit_err(session_diagnostics::UnsupportedInstructionSet {
cx.dcx().emit_err(diagnostics::UnsupportedInstructionSet {
span: cx.attr_span,
instruction_set: sym::arm,
current_target: &cx.sess.opts.target_triple,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/link_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::prelude::*;
use super::util::parse_single_integer;
use crate::attributes::AttributeSafety;
use crate::attributes::cfg::parse_cfg_entry;
use crate::session_diagnostics::{
use crate::diagnostics::{
AsNeededCompatibility, BothFfiConstAndPure, BundleNeedsStatic, EmptyLinkName,
ExportSymbolsNeedsStatic, ImportNameTypeRaw, ImportNameTypeX86, IncompatibleWasmLink,
InvalidLinkModifier, InvalidMachoSection, InvalidMachoSectionReason, LinkFrameworkApple,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_hir::attrs::ReprAttr;
use rustc_hir::find_attr;

use super::prelude::*;
use crate::session_diagnostics::RustcPubTransparent;
use crate::diagnostics::RustcPubTransparent;

pub(crate) struct RustcAsPtrParser;
impl NoArgsAttributeParser for RustcAsPtrParser {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_hir::find_attr;
use rustc_session::lint::builtin::INVALID_MACRO_EXPORT_ARGUMENTS;

use super::prelude::*;
use crate::session_diagnostics::MacroOnlyAttribute;
use crate::diagnostics::MacroOnlyAttribute;

pub(crate) struct MacroEscapeParser;
impl NoArgsAttributeParser for MacroEscapeParser {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use rustc_span::{Span, Symbol};
use thin_vec::ThinVec;

use crate::context::{AcceptContext, FinalizeCheckContext, FinalizeCheckFn, FinalizeContext};
use crate::diagnostics::UnusedMultiple;
use crate::parser::ArgParser;
use crate::session_diagnostics::UnusedMultiple;
use crate::target_checking::AllowedTargets;
use crate::{AttributeTemplate, template};

Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_attr_parsing/src/attributes/prototype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::context::AcceptContext;
use crate::parser::{ArgParser, NameValueParser};
use crate::target_checking::AllowedTargets;
use crate::target_checking::Policy::Allow;
use crate::{AttributeTemplate, session_diagnostics, template, unstable};
use crate::{AttributeTemplate, diagnostics, template, unstable};

pub(crate) struct CustomMirParser;

Expand Down Expand Up @@ -140,10 +140,7 @@ fn check_custom_mir(
let Some((dialect, dialect_span)) = dialect else {
if let Some((_, phase_span)) = phase {
*failed = true;
cx.emit_err(session_diagnostics::CustomMirPhaseRequiresDialect {
attr_span,
phase_span,
});
cx.emit_err(diagnostics::CustomMirPhaseRequiresDialect { attr_span, phase_span });
}
return;
};
Expand All @@ -152,7 +149,7 @@ fn check_custom_mir(
MirDialect::Analysis => {
if let Some((MirPhase::Optimized, phase_span)) = phase {
*failed = true;
cx.emit_err(session_diagnostics::CustomMirIncompatibleDialectAndPhase {
cx.emit_err(diagnostics::CustomMirIncompatibleDialectAndPhase {
dialect,
phase: MirPhase::Optimized,
attr_span,
Expand All @@ -165,7 +162,7 @@ fn check_custom_mir(
MirDialect::Built => {
if let Some((phase, phase_span)) = phase {
*failed = true;
cx.emit_err(session_diagnostics::CustomMirIncompatibleDialectAndPhase {
cx.emit_err(diagnostics::CustomMirIncompatibleDialectAndPhase {
dialect,
phase,
attr_span,
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_attr_parsing/src/attributes/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_hir::attrs::ReprAttr;
use rustc_session::diagnostics::feature_err;

use super::prelude::*;
use crate::session_diagnostics;
use crate::diagnostics;

/// Parse #[repr(...)] forms.
///
Expand Down Expand Up @@ -236,10 +236,7 @@ fn parse_repr_align(
AlignKind::Align => ReprAttr::ReprAlign(literal),
}),
Err(message) => {
cx.emit_err(session_diagnostics::InvalidAlignmentValue {
span: lit.span,
error_part: message,
});
cx.emit_err(diagnostics::InvalidAlignmentValue { span: lit.span, error_part: message });
None
}
}
Expand Down Expand Up @@ -298,7 +295,7 @@ impl RustcAlignParser {
match parse_alignment(&lit.kind, cx) {
Ok(literal) => self.0 = Ord::max(self.0, Some((literal, cx.attr_span))),
Err(message) => {
cx.emit_err(session_diagnostics::InvalidAlignmentValue {
cx.emit_err(diagnostics::InvalidAlignmentValue {
span: lit.span,
error_part: message,
});
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use rustc_span::Symbol;
use super::prelude::*;
use super::util::parse_single_integer;
use crate::diagnostics;
use crate::diagnostics::UnknownExternLangItem;
use crate::session_diagnostics::{
AttributeRequiresOpt, CguFieldsMissing, RustcScalableVectorCountOutOfRange, UnknownLangItem,
use crate::diagnostics::{
AttributeRequiresOpt, CguFieldsMissing, RustcScalableVectorCountOutOfRange,
UnknownExternLangItem, UnknownLangItem,
};

pub(crate) struct RustcMainParser;
Expand Down
Loading
Loading