Skip to content

Commit 114fc69

Browse files
committed
Auto merge of #142313 - fmease:rollup-lktx4uz, r=fmease
Rollup of 13 pull requests Successful merges: - #128425 (Make `missing_fragment_specifier` an unconditional error) - #141639 (Expose discriminant values in stable_mir) - #141967 (Configure bootstrap backport nominations through triagebot) - #142042 (Make E0621 missing lifetime suggestion verbose) - #142176 (tests: Split dont-shuffle-bswaps along opt-levels and arches) - #142235 (Build rustc with assertions in `dist-alt` jobs) - #142248 (Add supported asm types for LoongArch32) - #142272 (tests: Change ABIs in tests to more future-resilient ones) - #142282 (Only run `citool` tests on the `auto` branch) - #142285 (tests: Do not run afoul of asm.validity.non-exhaustive in input-stats) - #142297 (Implement `//@ needs-target-std` compiletest directive) - #142298 (Make loongarch-none target maintainers more easily pingable) - #142306 (Dont unwrap and re-wrap typing envs) Failed merges: - #141942 (Implement representation options to smir) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1c04750 + f92aa1c commit 114fc69

File tree

88 files changed

+700
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+700
-509
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,18 @@ jobs:
6464
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
6565
with:
6666
workspaces: src/ci/citool
67+
- name: Test citool
68+
# Only test citool on the auto branch, to reduce latency of the calculate matrix job
69+
# on PR/try builds.
70+
if: ${{ github.ref == 'refs/heads/auto' }}
71+
run: |
72+
cd src/ci/citool
73+
CARGO_INCREMENTAL=0 cargo test
6774
- name: Calculate the CI job matrix
6875
env:
6976
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
7077
run: |
7178
cd src/ci/citool
72-
CARGO_INCREMENTAL=0 cargo test
7379
CARGO_INCREMENTAL=0 cargo run calculate-job-matrix >> $GITHUB_OUTPUT
7480
id: jobs
7581
job:

compiler/rustc_expand/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ expand_meta_var_expr_unrecognized_var =
113113
variable `{$key}` is not recognized in meta-variable expression
114114
115115
expand_missing_fragment_specifier = missing fragment specifier
116-
.note = fragment specifiers must be specified in the 2024 edition
116+
.note = fragment specifiers must be provided
117117
.suggestion_add_fragspec = try adding a specifier here
118118
.valid = {$valid}
119119

compiler/rustc_expand/src/mbe/macro_check.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ use rustc_ast::{DUMMY_NODE_ID, NodeId};
112112
use rustc_data_structures::fx::FxHashMap;
113113
use rustc_errors::MultiSpan;
114114
use rustc_lint_defs::BuiltinLintDiag;
115-
use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER};
115+
use rustc_session::lint::builtin::META_VARIABLE_MISUSE;
116116
use rustc_session::parse::ParseSess;
117-
use rustc_span::edition::Edition;
118117
use rustc_span::{ErrorGuaranteed, MacroRulesNormalizedIdent, Span, kw};
119118
use smallvec::SmallVec;
120119

@@ -266,23 +265,11 @@ fn check_binders(
266265
// Similarly, this can only happen when checking a toplevel macro.
267266
TokenTree::MetaVarDecl(span, name, kind) => {
268267
if kind.is_none() && node_id != DUMMY_NODE_ID {
269-
// FIXME: Report this as a hard error eventually and remove equivalent errors from
270-
// `parse_tt_inner` and `nameize`. Until then the error may be reported twice, once
271-
// as a hard error and then once as a buffered lint.
272-
if span.edition() >= Edition::Edition2024 {
273-
psess.dcx().emit_err(errors::MissingFragmentSpecifier {
274-
span,
275-
add_span: span.shrink_to_hi(),
276-
valid: VALID_FRAGMENT_NAMES_MSG,
277-
});
278-
} else {
279-
psess.buffer_lint(
280-
MISSING_FRAGMENT_SPECIFIER,
281-
span,
282-
node_id,
283-
BuiltinLintDiag::MissingFragmentSpecifier,
284-
);
285-
}
268+
psess.dcx().emit_err(errors::MissingFragmentSpecifier {
269+
span,
270+
add_span: span.shrink_to_hi(),
271+
valid: VALID_FRAGMENT_NAMES_MSG,
272+
});
286273
}
287274
if !macros.is_empty() {
288275
psess.dcx().span_bug(span, "unexpected MetaVarDecl in nested lhs");

compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,6 @@ lint_mismatched_lifetime_syntaxes_suggestion_implicit =
533533
lint_mismatched_lifetime_syntaxes_suggestion_mixed =
534534
one option is to remove the lifetime for references and use the anonymous lifetime for paths
535535
536-
lint_missing_fragment_specifier = missing fragment specifier
537-
538536
lint_missing_unsafe_on_extern = extern blocks should be unsafe
539537
.suggestion = needs `unsafe` before the extern keyword
540538

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,6 @@ pub fn decorate_builtin_lint(
432432
BuiltinLintDiag::CfgAttrNoAttributes => {
433433
lints::CfgAttrNoAttributes.decorate_lint(diag);
434434
}
435-
BuiltinLintDiag::MissingFragmentSpecifier => {
436-
lints::MissingFragmentSpecifier.decorate_lint(diag);
437-
}
438435
BuiltinLintDiag::MetaVariableStillRepeating(name) => {
439436
lints::MetaVariableStillRepeating { name }.decorate_lint(diag);
440437
}

compiler/rustc_lint/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@ fn register_builtins(store: &mut LintStore) {
619619
"converted into hard error, \
620620
see <https://github.com/rust-lang/rust/issues/116558> for more information",
621621
);
622+
store.register_removed(
623+
"missing_fragment_specifier",
624+
"converted into hard error, \
625+
see <https://github.com/rust-lang/rust/issues/40107> for more information",
626+
);
622627
}
623628

624629
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,10 +2616,6 @@ pub(crate) struct DuplicateMacroAttribute;
26162616
#[diag(lint_cfg_attr_no_attributes)]
26172617
pub(crate) struct CfgAttrNoAttributes;
26182618

2619-
#[derive(LintDiagnostic)]
2620-
#[diag(lint_missing_fragment_specifier)]
2621-
pub(crate) struct MissingFragmentSpecifier;
2622-
26232619
#[derive(LintDiagnostic)]
26242620
#[diag(lint_metavariable_still_repeating)]
26252621
pub(crate) struct MetaVariableStillRepeating {

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ declare_lint_pass! {
6565
MACRO_USE_EXTERN_CRATE,
6666
META_VARIABLE_MISUSE,
6767
MISSING_ABI,
68-
MISSING_FRAGMENT_SPECIFIER,
6968
MISSING_UNSAFE_ON_EXTERN,
7069
MUST_NOT_SUSPEND,
7170
NAMED_ARGUMENTS_USED_POSITIONALLY,
@@ -1417,51 +1416,6 @@ declare_lint! {
14171416
};
14181417
}
14191418

1420-
declare_lint! {
1421-
/// The `missing_fragment_specifier` lint is issued when an unused pattern in a
1422-
/// `macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
1423-
/// followed by a fragment specifier (e.g. `:expr`).
1424-
///
1425-
/// This warning can always be fixed by removing the unused pattern in the
1426-
/// `macro_rules!` macro definition.
1427-
///
1428-
/// ### Example
1429-
///
1430-
/// ```rust,compile_fail,edition2021
1431-
/// macro_rules! foo {
1432-
/// () => {};
1433-
/// ($name) => { };
1434-
/// }
1435-
///
1436-
/// fn main() {
1437-
/// foo!();
1438-
/// }
1439-
/// ```
1440-
///
1441-
/// {{produces}}
1442-
///
1443-
/// ### Explanation
1444-
///
1445-
/// To fix this, remove the unused pattern from the `macro_rules!` macro definition:
1446-
///
1447-
/// ```rust
1448-
/// macro_rules! foo {
1449-
/// () => {};
1450-
/// }
1451-
/// fn main() {
1452-
/// foo!();
1453-
/// }
1454-
/// ```
1455-
pub MISSING_FRAGMENT_SPECIFIER,
1456-
Deny,
1457-
"detects missing fragment specifiers in unused `macro_rules!` patterns",
1458-
@future_incompatible = FutureIncompatibleInfo {
1459-
reason: FutureIncompatibilityReason::FutureReleaseError,
1460-
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
1461-
report_in_deps: true,
1462-
};
1463-
}
1464-
14651419
declare_lint! {
14661420
/// The `late_bound_lifetime_arguments` lint detects generic lifetime
14671421
/// arguments in path segments with late bound lifetime parameters.

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ pub enum BuiltinLintDiag {
778778
UnnameableTestItems,
779779
DuplicateMacroAttribute,
780780
CfgAttrNoAttributes,
781-
MissingFragmentSpecifier,
782781
MetaVariableStillRepeating(MacroRulesNormalizedIdent),
783782
MetaVariableWrongOperator,
784783
DuplicateMatcherBinding,

compiler/rustc_middle/src/query/erase.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ tcx_lifetime! {
389389
rustc_middle::ty::layout::FnAbiError,
390390
rustc_middle::ty::layout::LayoutError,
391391
rustc_middle::ty::ParamEnv,
392+
rustc_middle::ty::TypingEnv,
392393
rustc_middle::ty::Predicate,
393394
rustc_middle::ty::SymbolName,
394395
rustc_middle::ty::TraitRef,

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ rustc_queries! {
15661566
/// Like `param_env`, but returns the `ParamEnv` after all opaque types have been
15671567
/// replaced with their hidden type. This is used in the old trait solver
15681568
/// when in `PostAnalysis` mode and should not be called directly.
1569-
query param_env_normalized_for_post_analysis(def_id: DefId) -> ty::ParamEnv<'tcx> {
1569+
query typing_env_normalized_for_post_analysis(def_id: DefId) -> ty::TypingEnv<'tcx> {
15701570
desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
15711571
}
15721572

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,10 +1116,7 @@ impl<'tcx> TypingEnv<'tcx> {
11161116
}
11171117

11181118
pub fn post_analysis(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryParam<DefId>) -> TypingEnv<'tcx> {
1119-
TypingEnv {
1120-
typing_mode: TypingMode::PostAnalysis,
1121-
param_env: tcx.param_env_normalized_for_post_analysis(def_id),
1122-
}
1119+
tcx.typing_env_normalized_for_post_analysis(def_id)
11231120
}
11241121

11251122
/// Modify the `typing_mode` to `PostAnalysis` and eagerly reveal all
@@ -1133,7 +1130,7 @@ impl<'tcx> TypingEnv<'tcx> {
11331130
// No need to reveal opaques with the new solver enabled,
11341131
// since we have lazy norm.
11351132
let param_env = if tcx.next_trait_solver_globally() {
1136-
ParamEnv::new(param_env.caller_bounds())
1133+
param_env
11371134
} else {
11381135
ParamEnv::new(tcx.reveal_opaque_types_in_bounds(param_env.caller_bounds()))
11391136
};

compiler/rustc_smir/src/rustc_smir/context.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use rustc_middle::ty::layout::{
1212
};
1313
use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths};
1414
use rustc_middle::ty::{
15-
GenericPredicates, Instance, List, ScalarInt, TyCtxt, TypeVisitableExt, ValTree,
15+
CoroutineArgsExt, GenericPredicates, Instance, List, ScalarInt, TyCtxt, TypeVisitableExt,
16+
ValTree,
1617
};
1718
use rustc_middle::{mir, ty};
1819
use rustc_span::def_id::LOCAL_CRATE;
@@ -22,9 +23,9 @@ use stable_mir::mir::mono::{InstanceDef, StaticDef};
2223
use stable_mir::mir::{BinOp, Body, Place, UnOp};
2324
use stable_mir::target::{MachineInfo, MachineSize};
2425
use stable_mir::ty::{
25-
AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, FieldDef, FnDef, ForeignDef,
26-
ForeignItemKind, GenericArgs, IntrinsicDef, LineInfo, MirConst, PolyFnSig, RigidTy, Span, Ty,
27-
TyConst, TyKind, UintTy, VariantDef,
26+
AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, CoroutineDef, Discr, FieldDef, FnDef,
27+
ForeignDef, ForeignItemKind, GenericArgs, IntrinsicDef, LineInfo, MirConst, PolyFnSig, RigidTy,
28+
Span, Ty, TyConst, TyKind, UintTy, VariantDef, VariantIdx,
2829
};
2930
use stable_mir::{Crate, CrateDef, CrateItem, CrateNum, DefId, Error, Filename, ItemKind, Symbol};
3031

@@ -440,6 +441,30 @@ impl<'tcx> SmirCtxt<'tcx> {
440441
def.internal(&mut *tables, tcx).variants().len()
441442
}
442443

444+
/// Discriminant for a given variant index of AdtDef
445+
pub fn adt_discr_for_variant(&self, adt: AdtDef, variant: VariantIdx) -> Discr {
446+
let mut tables = self.0.borrow_mut();
447+
let tcx = tables.tcx;
448+
let adt = adt.internal(&mut *tables, tcx);
449+
let variant = variant.internal(&mut *tables, tcx);
450+
adt.discriminant_for_variant(tcx, variant).stable(&mut *tables)
451+
}
452+
453+
/// Discriminant for a given variand index and args of a coroutine
454+
pub fn coroutine_discr_for_variant(
455+
&self,
456+
coroutine: CoroutineDef,
457+
args: &GenericArgs,
458+
variant: VariantIdx,
459+
) -> Discr {
460+
let mut tables = self.0.borrow_mut();
461+
let tcx = tables.tcx;
462+
let coroutine = coroutine.def_id().internal(&mut *tables, tcx);
463+
let args = args.internal(&mut *tables, tcx);
464+
let variant = variant.internal(&mut *tables, tcx);
465+
args.as_coroutine().discriminant_for_variant(coroutine, tcx, variant).stable(&mut *tables)
466+
}
467+
443468
/// The name of a variant.
444469
pub fn variant_name(&self, def: VariantDef) -> Symbol {
445470
let mut tables = self.0.borrow_mut();

compiler/rustc_smir/src/rustc_smir/convert/ty.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,3 +959,11 @@ impl<'tcx> Stable<'tcx> for ty::ImplTraitInTraitData {
959959
}
960960
}
961961
}
962+
963+
impl<'tcx> Stable<'tcx> for rustc_middle::ty::util::Discr<'tcx> {
964+
type T = stable_mir::ty::Discr;
965+
966+
fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
967+
stable_mir::ty::Discr { val: self.val, ty: self.ty.stable(tables) }
968+
}
969+
}

compiler/rustc_smir/src/stable_mir/compiler_interface.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use stable_mir::mir::mono::{Instance, InstanceDef, StaticDef};
1313
use stable_mir::mir::{BinOp, Body, Place, UnOp};
1414
use stable_mir::target::MachineInfo;
1515
use stable_mir::ty::{
16-
AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, FieldDef, FnDef, ForeignDef,
17-
ForeignItemKind, ForeignModule, ForeignModuleDef, GenericArgs, GenericPredicates, Generics,
18-
ImplDef, ImplTrait, IntrinsicDef, LineInfo, MirConst, PolyFnSig, RigidTy, Span, TraitDecl,
19-
TraitDef, Ty, TyConst, TyConstId, TyKind, UintTy, VariantDef,
16+
AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, CoroutineDef, Discr, FieldDef, FnDef,
17+
ForeignDef, ForeignItemKind, ForeignModule, ForeignModuleDef, GenericArgs, GenericPredicates,
18+
Generics, ImplDef, ImplTrait, IntrinsicDef, LineInfo, MirConst, PolyFnSig, RigidTy, Span,
19+
TraitDecl, TraitDef, Ty, TyConst, TyConstId, TyKind, UintTy, VariantDef, VariantIdx,
2020
};
2121
use stable_mir::{
2222
AssocItems, Crate, CrateItem, CrateItems, CrateNum, DefId, Error, Filename, ImplTraitDecls,
@@ -225,6 +225,21 @@ impl<'tcx> SmirInterface<'tcx> {
225225
self.cx.adt_variants_len(def)
226226
}
227227

228+
/// Discriminant for a given variant index of AdtDef
229+
pub(crate) fn adt_discr_for_variant(&self, adt: AdtDef, variant: VariantIdx) -> Discr {
230+
self.cx.adt_discr_for_variant(adt, variant)
231+
}
232+
233+
/// Discriminant for a given variand index and args of a coroutine
234+
pub(crate) fn coroutine_discr_for_variant(
235+
&self,
236+
coroutine: CoroutineDef,
237+
args: &GenericArgs,
238+
variant: VariantIdx,
239+
) -> Discr {
240+
self.cx.coroutine_discr_for_variant(coroutine, args, variant)
241+
}
242+
228243
/// The name of a variant.
229244
pub(crate) fn variant_name(&self, def: VariantDef) -> Symbol {
230245
self.cx.variant_name(def)

compiler/rustc_smir/src/stable_mir/ty.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,12 @@ crate_def! {
747747
pub CoroutineDef;
748748
}
749749

750+
impl CoroutineDef {
751+
pub fn discriminant_for_variant(&self, args: &GenericArgs, idx: VariantIdx) -> Discr {
752+
with(|cx| cx.coroutine_discr_for_variant(*self, args, idx))
753+
}
754+
}
755+
750756
crate_def! {
751757
#[derive(Serialize)]
752758
pub CoroutineClosureDef;
@@ -818,6 +824,15 @@ impl AdtDef {
818824
pub fn variant(&self, idx: VariantIdx) -> Option<VariantDef> {
819825
(idx.to_index() < self.num_variants()).then_some(VariantDef { idx, adt_def: *self })
820826
}
827+
828+
pub fn discriminant_for_variant(&self, idx: VariantIdx) -> Discr {
829+
with(|cx| cx.adt_discr_for_variant(*self, idx))
830+
}
831+
}
832+
833+
pub struct Discr {
834+
pub val: u128,
835+
pub ty: Ty,
821836
}
822837

823838
/// Definition of a variant, which can be either a struct / union field or an enum variant.

compiler/rustc_target/src/asm/loongarch.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ impl LoongArchInlineAsmRegClass {
3434

3535
pub fn supported_types(
3636
self,
37-
_arch: InlineAsmArch,
37+
arch: InlineAsmArch,
3838
) -> &'static [(InlineAsmType, Option<Symbol>)] {
39-
match self {
40-
Self::reg => types! { _: I8, I16, I32, I64, F32, F64; },
41-
Self::freg => types! { f: F32; d: F64; },
39+
match (self, arch) {
40+
(Self::reg, InlineAsmArch::LoongArch64) => types! { _: I8, I16, I32, I64, F32, F64; },
41+
(Self::reg, InlineAsmArch::LoongArch32) => types! { _: I8, I16, I32, F32; },
42+
(Self::freg, _) => types! { f: F32; d: F64; },
43+
_ => unreachable!("unsupported register class"),
4244
}
4345
}
4446
}

0 commit comments

Comments
 (0)