Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
99821e1
Fix ICE when combining #[eii] with #[core::contracts::ensures]
GokhanKabar Mar 12, 2026
2f46855
Fix pattern macro note detection for bit-or expr
ver-nyan Mar 23, 2026
b544edd
Preserve EII link through AttrProcMacro token roundtrip and add run-p…
GokhanKabar Apr 7, 2026
5961ba1
Restrict EII declarations to functions via PathSource in name resolution
enthropy7 Feb 9, 2026
48eced8
Fix platform-specific stderr mismatch in ice_contract_attr_on_eii_gen…
GokhanKabar Apr 7, 2026
1e59341
Fix code block whitespace handling
yalagadapavankumar Apr 9, 2026
ef3a89c
Fix tabs in test file to satisfy tidy check
yalagadapavankumar Apr 9, 2026
3afb618
Move the `cache_on_disk` check out of `try_load_from_disk_fn`.
nnethercote Apr 10, 2026
4fb83f6
Move profiling of query loading outwards.
nnethercote Apr 10, 2026
9e8069f
Fix unelided lifetime ICE, refactoring of GenericArgPosition
aerooneqq Apr 10, 2026
0e0d12c
introduce TypingModeEqWrapper and make TypingMode !Eq
jdonszelmann Apr 9, 2026
63c212e
make typing_mode getter
jdonszelmann Apr 9, 2026
2facd34
add `#[rustc_must_match_exhaustively]`
jdonszelmann Apr 9, 2026
357f670
Rename `#[rustc_layout]` to `#[rustc_dump_layout]`
fmease Apr 9, 2026
7025605
Rename `#[rustc_dump_layout]`'s `abi` option to `backend_repr`
fmease Apr 9, 2026
dda1ea0
Rename `#[rustc_hidden_type_of_opaques]` to `#[rustc_dump_hidden_type…
fmease Apr 9, 2026
0a59706
Rename `#[rustc_def_path]` to `#[rustc_dump_def_path]`
fmease Apr 9, 2026
cb4a7f4
Rename `#[rustc_symbol_name]` to `#[rustc_dump_symbol_name]`
fmease Apr 9, 2026
64b4284
Simplify impl of `dump_symbol_names_and_def_paths`
fmease Apr 9, 2026
d5d0153
make all typing-mode conditional code an exhaustive match
jdonszelmann Apr 9, 2026
18d118a
fixup rustdoc,clippy,rustfmt
jdonszelmann Apr 9, 2026
610eaec
Rollup merge of #155047 - jdonszelmann:lint-against-eq-typing-mode, r…
JonathanBrouwer Apr 10, 2026
79a4c77
Rollup merge of #155080 - nnethercote:salvage, r=petrochenkov
JonathanBrouwer Apr 10, 2026
5b16a31
Rollup merge of #152384 - enthropy7:fix-eii-root-resolution-clean, r=…
JonathanBrouwer Apr 10, 2026
45223fe
Rollup merge of #153796 - GokhanKabar:fix-ice-missing-tokens-eii-attr…
JonathanBrouwer Apr 10, 2026
ad68dea
Rollup merge of #154369 - ver-nyan:fix-bit_or-pat_macro-msg, r=JohnTitor
JonathanBrouwer Apr 10, 2026
6547a33
Rollup merge of #155027 - fmease:more-test-attr-renamings, r=Jonathan…
JonathanBrouwer Apr 10, 2026
3b8c7ec
Rollup merge of #155031 - aerooneqq:delegation-generic-args-lowering-…
JonathanBrouwer Apr 10, 2026
eec05ee
Rollup merge of #155040 - yalagadapavankumar:fix-whitespace, r=JohnTitor
JonathanBrouwer Apr 10, 2026
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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4692,7 +4692,6 @@ dependencies = [
"rustc-demangle",
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_hashes",
"rustc_hir",
"rustc_middle",
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_ast_lowering/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
}
_ => {
let is_const_block = matches!(expr.kind, ExprKind::ConstBlock(_));
let pattern_from_macro = expr.is_approximately_pattern();
let pattern_from_macro = expr.is_approximately_pattern()
|| matches!(
expr.peel_parens().kind,
ExprKind::Binary(Spanned { node: BinOpKind::BitOr, .. }, ..)
);
let guar = self.dcx().emit_err(ArbitraryExpressionInPattern {
span,
pattern_from_macro_note: pattern_from_macro,
Expand Down
126 changes: 123 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use rustc_hir::attrs::AttributeKind;
use rustc_hir::attrs::{AttributeKind, RustcDumpLayoutKind};
use rustc_hir::{MethodKind, Target};
use rustc_span::{Span, Symbol, sym};

use crate::attributes::prelude::Allow;
use crate::attributes::{NoArgsAttributeParser, OnDuplicate};
use super::prelude::*;
use crate::context::Stage;
use crate::target_checking::AllowedTargets;

Expand All @@ -25,6 +24,39 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpDefParentsParser {
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpDefParents;
}

pub(crate) struct RustcDumpDefPathParser;

impl<S: Stage> SingleAttributeParser<S> for RustcDumpDefPathParser {
const PATH: &[Symbol] = &[sym::rustc_dump_def_path];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::ForeignFn),
Allow(Target::ForeignStatic),
Allow(Target::Impl { of_trait: false }),
]);
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const TEMPLATE: AttributeTemplate = template!(Word);
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
if let Err(span) = args.no_args() {
cx.adcx().expected_no_args(span);
return None;
}
Some(AttributeKind::RustcDumpDefPath(cx.attr_span))
}
}

pub(crate) struct RustcDumpHiddenTypeOfOpaquesParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpHiddenTypeOfOpaquesParser {
const PATH: &[Symbol] = &[sym::rustc_dump_hidden_type_of_opaques];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpHiddenTypeOfOpaques;
}

pub(crate) struct RustcDumpInferredOutlivesParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpInferredOutlivesParser {
Expand All @@ -48,6 +80,70 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpItemBoundsParser {
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpItemBounds;
}

pub(crate) struct RustcDumpLayoutParser;

impl<S: Stage> CombineAttributeParser<S> for RustcDumpLayoutParser {
const PATH: &[Symbol] = &[sym::rustc_dump_layout];

type Item = RustcDumpLayoutKind;

const CONVERT: ConvertFn<Self::Item> = |items, _| AttributeKind::RustcDumpLayout(items);

const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Struct),
Allow(Target::Enum),
Allow(Target::Union),
Allow(Target::TyAlias),
]);

const TEMPLATE: AttributeTemplate =
template!(List: &["abi", "align", "size", "homogenous_aggregate", "debug"]);
fn extend(
cx: &mut AcceptContext<'_, '_, S>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item> {
let ArgParser::List(items) = args else {
let attr_span = cx.attr_span;
cx.adcx().expected_list(attr_span, args);
return vec![];
};

let mut result = Vec::new();
for item in items.mixed() {
let Some(arg) = item.meta_item() else {
cx.adcx().expected_not_literal(item.span());
continue;
};
let Some(ident) = arg.ident() else {
cx.adcx().expected_identifier(arg.span());
return vec![];
};
let kind = match ident.name {
sym::align => RustcDumpLayoutKind::Align,
sym::backend_repr => RustcDumpLayoutKind::BackendRepr,
sym::debug => RustcDumpLayoutKind::Debug,
sym::homogeneous_aggregate => RustcDumpLayoutKind::HomogenousAggregate,
sym::size => RustcDumpLayoutKind::Size,
_ => {
cx.adcx().expected_specific_argument(
ident.span,
&[
sym::align,
sym::backend_repr,
sym::debug,
sym::homogeneous_aggregate,
sym::size,
],
);
continue;
}
};
result.push(kind);
}
result
}
}

pub(crate) struct RustcDumpObjectLifetimeDefaultsParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpObjectLifetimeDefaultsParser {
Expand Down Expand Up @@ -103,6 +199,30 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpPredicatesParser {
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDumpPredicates;
}

pub(crate) struct RustcDumpSymbolNameParser;

impl<S: Stage> SingleAttributeParser<S> for RustcDumpSymbolNameParser {
const PATH: &[Symbol] = &[sym::rustc_dump_symbol_name];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::ForeignFn),
Allow(Target::ForeignStatic),
Allow(Target::Impl { of_trait: false }),
]);
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const TEMPLATE: AttributeTemplate = template!(Word);
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
if let Err(span) = args.no_args() {
cx.adcx().expected_no_args(span);
return None;
}
Some(AttributeKind::RustcDumpSymbolName(cx.attr_span))
}
}

pub(crate) struct RustcDumpVariancesParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcDumpVariancesParser {
Expand Down
126 changes: 10 additions & 116 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use rustc_ast::{LitIntType, LitKind, MetaItemLit};
use rustc_hir::LangItem;
use rustc_hir::attrs::{
BorrowckGraphvizFormatKind, CguFields, CguKind, DivergingBlockBehavior,
DivergingFallbackBehavior, RustcCleanAttribute, RustcCleanQueries, RustcLayoutType,
RustcMirKind,
DivergingFallbackBehavior, RustcCleanAttribute, RustcCleanQueries, RustcMirKind,
};
use rustc_session::errors;
use rustc_span::Symbol;
Expand Down Expand Up @@ -681,14 +680,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for PanicHandlerParser {
const CREATE: fn(Span) -> AttributeKind = |span| AttributeKind::Lang(LangItem::PanicImpl, span);
}

pub(crate) struct RustcHiddenTypeOfOpaquesParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcHiddenTypeOfOpaquesParser {
const PATH: &[Symbol] = &[sym::rustc_hidden_type_of_opaques];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcHiddenTypeOfOpaques;
}
pub(crate) struct RustcNounwindParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcNounwindParser {
Expand All @@ -713,64 +704,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcOffloadKernelParser {
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcOffloadKernel;
}

pub(crate) struct RustcLayoutParser;

impl<S: Stage> CombineAttributeParser<S> for RustcLayoutParser {
const PATH: &[Symbol] = &[sym::rustc_layout];

type Item = RustcLayoutType;

const CONVERT: ConvertFn<Self::Item> = |items, _| AttributeKind::RustcLayout(items);

const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Struct),
Allow(Target::Enum),
Allow(Target::Union),
Allow(Target::TyAlias),
]);

const TEMPLATE: AttributeTemplate =
template!(List: &["abi", "align", "size", "homogenous_aggregate", "debug"]);
fn extend(
cx: &mut AcceptContext<'_, '_, S>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item> {
let ArgParser::List(items) = args else {
let attr_span = cx.attr_span;
cx.adcx().expected_list(attr_span, args);
return vec![];
};

let mut result = Vec::new();
for item in items.mixed() {
let Some(arg) = item.meta_item() else {
cx.adcx().expected_not_literal(item.span());
continue;
};
let Some(ident) = arg.ident() else {
cx.adcx().expected_identifier(arg.span());
return vec![];
};
let ty = match ident.name {
sym::abi => RustcLayoutType::Abi,
sym::align => RustcLayoutType::Align,
sym::size => RustcLayoutType::Size,
sym::homogeneous_aggregate => RustcLayoutType::HomogenousAggregate,
sym::debug => RustcLayoutType::Debug,
_ => {
cx.adcx().expected_specific_argument(
ident.span,
&[sym::abi, sym::align, sym::size, sym::homogeneous_aggregate, sym::debug],
);
continue;
}
};
result.push(ty);
}
result
}
}

pub(crate) struct RustcMirParser;

impl<S: Stage> CombineAttributeParser<S> for RustcMirParser {
Expand Down Expand Up @@ -1210,54 +1143,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcNonnullOptimizationGuaranteedPa
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNonnullOptimizationGuaranteed;
}

pub(crate) struct RustcSymbolNameParser;

impl<S: Stage> SingleAttributeParser<S> for RustcSymbolNameParser {
const PATH: &[Symbol] = &[sym::rustc_symbol_name];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::ForeignFn),
Allow(Target::ForeignStatic),
Allow(Target::Impl { of_trait: false }),
]);
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const TEMPLATE: AttributeTemplate = template!(Word);
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
if let Err(span) = args.no_args() {
cx.adcx().expected_no_args(span);
return None;
}
Some(AttributeKind::RustcSymbolName(cx.attr_span))
}
}

pub(crate) struct RustcDefPathParser;

impl<S: Stage> SingleAttributeParser<S> for RustcDefPathParser {
const PATH: &[Symbol] = &[sym::rustc_def_path];
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::ForeignFn),
Allow(Target::ForeignStatic),
Allow(Target::Impl { of_trait: false }),
]);
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const TEMPLATE: AttributeTemplate = template!(Word);
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
if let Err(span) = args.no_args() {
cx.adcx().expected_no_args(span);
return None;
}
Some(AttributeKind::RustcDefPath(cx.attr_span))
}
}

pub(crate) struct RustcStrictCoherenceParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcStrictCoherenceParser {
Expand Down Expand Up @@ -1349,3 +1234,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcIntrinsicConstStableIndirectPar
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect;
}

pub(crate) struct RustcExhaustiveParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcExhaustiveParser {
const PATH: &'static [Symbol] = &[sym::rustc_must_match_exhaustively];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Enum)]);
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcMustMatchExhaustively;
}
9 changes: 5 additions & 4 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ attribute_parsers!(
Combine<ReprParser>,
Combine<RustcAllowConstFnUnstableParser>,
Combine<RustcCleanParser>,
Combine<RustcLayoutParser>,
Combine<RustcDumpLayoutParser>,
Combine<RustcMirParser>,
Combine<RustcThenThisWouldNeedParser>,
Combine<TargetFeatureParser>,
Expand Down Expand Up @@ -211,11 +211,12 @@ attribute_parsers!(
Single<RustcAllocatorZeroedVariantParser>,
Single<RustcAutodiffParser>,
Single<RustcBuiltinMacroParser>,
Single<RustcDefPathParser>,
Single<RustcDeprecatedSafe2024Parser>,
Single<RustcDiagnosticItemParser>,
Single<RustcDocPrimitiveParser>,
Single<RustcDummyParser>,
Single<RustcDumpDefPathParser>,
Single<RustcDumpSymbolNameParser>,
Single<RustcForceInlineParser>,
Single<RustcIfThisChangedParser>,
Single<RustcLayoutScalarValidRangeEndParser>,
Expand All @@ -231,7 +232,6 @@ attribute_parsers!(
Single<RustcScalableVectorParser>,
Single<RustcSimdMonomorphizeLaneLimitParser>,
Single<RustcSkipDuringMethodDispatchParser>,
Single<RustcSymbolNameParser>,
Single<RustcTestMarkerParser>,
Single<SanitizeParser>,
Single<ShouldPanicParser>,
Expand Down Expand Up @@ -285,6 +285,7 @@ attribute_parsers!(
Single<WithoutArgs<RustcDenyExplicitImplParser>>,
Single<WithoutArgs<RustcDoNotConstCheckParser>>,
Single<WithoutArgs<RustcDumpDefParentsParser>>,
Single<WithoutArgs<RustcDumpHiddenTypeOfOpaquesParser>>,
Single<WithoutArgs<RustcDumpInferredOutlivesParser>>,
Single<WithoutArgs<RustcDumpItemBoundsParser>>,
Single<WithoutArgs<RustcDumpObjectLifetimeDefaultsParser>>,
Expand All @@ -297,8 +298,8 @@ attribute_parsers!(
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
Single<WithoutArgs<RustcEiiForeignItemParser>>,
Single<WithoutArgs<RustcEvaluateWhereClausesParser>>,
Single<WithoutArgs<RustcExhaustiveParser>>,
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
Single<WithoutArgs<RustcInheritOverflowChecksParser>>,
Single<WithoutArgs<RustcInsignificantDtorParser>>,
Single<WithoutArgs<RustcIntrinsicConstStableIndirectParser>>,
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,10 @@ impl Qualif for HasMutInterior {
// FIXME(#132279): Once we've got a typing mode which reveals opaque types using the HIR
// typeck results without causing query cycles, we should use this here instead of defining
// opaque types.
let typing_env = ty::TypingEnv {
typing_mode: ty::TypingMode::analysis_in_body(
cx.tcx,
cx.body.source.def_id().expect_local(),
),
param_env: cx.typing_env.param_env,
};
let typing_env = ty::TypingEnv::new(
cx.typing_env.param_env,
ty::TypingMode::analysis_in_body(cx.tcx, cx.body.source.def_id().expect_local()),
);
let (infcx, param_env) = cx.tcx.infer_ctxt().build_with_typing_env(typing_env);
let ocx = ObligationCtxt::new(&infcx);
let obligation = Obligation::new(
Expand Down
Loading
Loading