Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
d8e5a3d
Implement aarch64 SHA-1/SHA-512 LLVM intrinsics
CathalMullan May 30, 2026
e945563
add `extern "tail"` calling convention
folkertdev May 27, 2026
ce5a62c
Merge commit 'f2ef4150da1c50e5b04607cdab771530cac4ffe4' into sync_cg_…
bjorn3 Jun 6, 2026
997468c
Merge branch 'sync_from_rust'
bjorn3 Jun 6, 2026
b734647
Rollup merge of #157016 - folkertdev:add-tailcc-abi, r=WaffleLapkin
jhpratt Jun 7, 2026
7c540e5
Use WorkProductMap instead of FxIndexMap
bjorn3 Jun 3, 2026
7227b9c
Merge pull request #1661 from CathalMullan/sha1
bjorn3 Jun 7, 2026
2c81a77
Implement remaining aarch64 SHA-3 LLVM intrinsics
CathalMullan Jun 10, 2026
ab13f75
Sync from rust 3daae5e42ec9ba435212987331af1b7b8634fa90
bjorn3 Jun 15, 2026
b2fee30
Rustup to rustc 1.98.0-nightly (3daae5e42 2026-06-14)
bjorn3 Jun 15, 2026
07ed5e9
Fix rustc test suite
bjorn3 Jun 15, 2026
59969ea
remove LLVM `va_end` calls
folkertdev Jun 8, 2026
0f5ef63
Sync from rust 91fe22da8084a1c9e993d78d4a56f22ab8396236
bjorn3 Jun 22, 2026
bcdbc4c
Rustup to rustc 1.98.0-nightly (91fe22da8 2026-06-21)
bjorn3 Jun 22, 2026
84632b1
Fix rustc test suite
bjorn3 Jun 22, 2026
871eb58
Extract all instance shim variants into new `ShimKind` enum
camelid Jun 18, 2026
6adf588
Strip vestigial `Shim` suffix from `ShimKind` variants
camelid Jun 18, 2026
604d40f
Update to Cranelift 0.133
bjorn3 Jun 19, 2026
052d958
ci: monthly Cranelift release branch automation regex (#1665)
0xmuon Jun 23, 2026
a105126
add IsRigid marker to TyKind::Alias and constants
adwinwhite May 22, 2026
316b36f
Bump `graviola` to v0.4.1
CathalMullan Jun 25, 2026
014bb13
Impl MIR lowering side-tables for #[splat]
teor2345 Jun 12, 2026
cd00d47
use `"llvm.prefetch.p0"` instead of `"llvm.prefetch"`
folkertdev Jun 27, 2026
98ff4dc
Rollup merge of #158497 - folkertdev:stdarch-sync-2026-06-27, r=folke…
jhpratt Jun 28, 2026
f079d01
Remove trailing whitespace
bjorn3 Jun 29, 2026
fd13d66
Sync from rust df6ee909ef35c75aa58aa45af6ac071a9b8285c2
bjorn3 Jun 29, 2026
c2f57f2
Rustup to rustc 1.98.0-nightly (df6ee909e 2026-06-28)
bjorn3 Jun 29, 2026
49bde28
Merge pull request #1668 from CathalMullan/graviola-v0.4
bjorn3 Jun 29, 2026
c232e62
Minor formatting change
bjorn3 Jun 29, 2026
b25de25
Rename `align` to `platform_align` on `Scalar` and `Primitive`
scottmcm Jun 29, 2026
63e1a99
Rollup merge of #158542 - scottmcm:scalar-but-packed, r=workingjubilee
jhpratt Jul 1, 2026
cbff888
Better panic messages
bjorn3 Jul 2, 2026
e9ad5d9
Replace keep_sysroot config with --keep-sysroot cli flag
bjorn3 Jul 2, 2026
1629cba
Introduce SysrootConfig struct
bjorn3 Jul 2, 2026
34efabd
Sync from rust 4c9d2bfe4ad7a65669098754964aaebe0ec1ced2
bjorn3 Jul 2, 2026
49795a1
Rustup to rustc 1.98.0-nightly (4c9d2bfe4 2026-07-01)
bjorn3 Jul 2, 2026
6c83401
Update list of ignored rustc tests
bjorn3 Jul 2, 2026
4b57ec9
Fix rustc test suite on arm64
bjorn3 Jul 2, 2026
a6618fe
Merge pull request #1666 from CathalMullan/sha3
bjorn3 Jul 3, 2026
fca1bc4
Distinguish null reference production from null pointer dereference
raushan728 Jul 5, 2026
23c7935
codegen_cranelift: Fix backend limit diagnostics (#1673)
Dnreikronos Jul 6, 2026
44273d6
Carry the `b_offset` inside `BackendRepr::ScalarPair`
scottmcm Jul 1, 2026
28eb697
Revert an error change
bjorn3 Jul 8, 2026
8450a00
Sync from rust f10db292a3733b5c67c8da8c7661195ff4b05774
bjorn3 Jul 8, 2026
5de4124
Rustup to rustc 1.99.0-nightly (f10db292a 2026-07-07)
bjorn3 Jul 8, 2026
5bbb9e4
Support -Zforce-intrinsic-fallback
bjorn3 Jul 8, 2026
70bfa0a
Recover from GCE const exprs in next solver
Dnreikronos Jul 3, 2026
6e45dd2
Reject GCE with the global next solver
Dnreikronos Jul 8, 2026
952e3ff
place FnDef behind a binder, instantiate w/ Dummy
Jun 17, 2026
007fcda
Add test for two cases 1. const argument expression 2. const argument…
Shourya742 Jun 27, 2026
fc02351
make sure to emit error during hir_lowering for const statics
Shourya742 Jul 11, 2026
2a57476
Sync from rust 375b1431b7d89d1c2e2bc168c011848ae12b7d14
bjorn3 Jul 11, 2026
720e683
Rustup to rustc 1.99.0-nightly (375b1431b 2026-07-10)
bjorn3 Jul 11, 2026
1302a4f
Minor cleanup
bjorn3 Jul 11, 2026
7685cde
Fix f128 ABI on s390x
bjorn3 Jul 11, 2026
e997dc7
remove f16-math patch
folkertdev Jul 11, 2026
1ca1217
Merge pull request #1674 from folkertdev/remove-f16-math-patch
bjorn3 Jul 12, 2026
fe2d52d
Introduce InstanceKind::LlvmIntrinsic
bjorn3 Jan 8, 2026
fa86122
Rollup merge of #159183 - bjorn3:instance_llvm_intrinsic, r=RalfJung,…
JonathanBrouwer Jul 14, 2026
b1cc00e
Update uses of `rustc_codegen_ssa::errors`
GuillaumeGomez Jul 15, 2026
44ad529
Sync from rust 3d50c25bc66853bf0ad205529d0f305a1d841b5e
bjorn3 Jul 17, 2026
3601f44
Rustup to rustc 1.99.0-nightly (3d50c25bc 2026-07-16)
bjorn3 Jul 17, 2026
6c9b08f
Fix rustc test suite
bjorn3 Jul 17, 2026
b5e1509
Treat `-Ctarget-cpu` as a target-modifier when targeting AVR, AMDGCN …
kulst Jan 6, 2026
eb271b6
Remove Android GDB special case
Kobzol Jul 17, 2026
9ca2cb1
Store test revision in a `TestVariant` struct
Kobzol Jul 17, 2026
7c1d9a9
Add debugger field to `TestVariant`
Kobzol Jul 17, 2026
0d0d03a
Stop cloning configs in compiletest
Kobzol Jul 17, 2026
e2596cf
Sync from rust eff8269f797067c30555e77f160ec84c0ed15cd9
bjorn3 Jul 19, 2026
a474ad8
Rustup to rustc 1.99.0-nightly (eff8269f7 2026-07-18)
bjorn3 Jul 19, 2026
0047b65
Fix rustc test suite
bjorn3 Jul 19, 2026
f35ca57
Fix rustc bootstrap testing
bjorn3 Jul 19, 2026
b0e9b44
Rollup merge of #150732 - kulst:cpu_is_target_modifier, r=bjorn3
JonathanBrouwer Jul 19, 2026
17b3642
Remove `ResultsVisitor::visit_block_end`
nnethercote Jul 14, 2026
f2063f9
Avoid some `IS_FORWARD` tests
nnethercote Jul 14, 2026
642e9d2
Simplify `apply_effects_in_range`
nnethercote Jul 14, 2026
61b5db6
Eliminate `ResultsVisitor::visit_block_entry`
nnethercote Jul 20, 2026
e736635
Inline and remove `Direction::apply_effects_in_range`
nnethercote Jul 20, 2026
a5a918c
Restore next solver flag in const trait test
Dnreikronos Jul 20, 2026
d28bb79
Update to Cranelift 0.134
bjorn3 Jul 9, 2026
abf20f6
Use JITModule::get_address in relocate_for_jit
bjorn3 Jul 14, 2026
57fca5a
Move limit file
mejrs Jul 21, 2026
ac91844
Fixup Limit imports
mejrs Jul 21, 2026
013c95a
Handle debugger line directives
Kobzol Jul 17, 2026
490b344
increase depth for float fallback hack visitor
adwinwhite Jul 21, 2026
3559c7d
Prefer `cfg!(not(test))` when skipping code paths during unit tests
Zalathar Jul 22, 2026
e895ed8
unify the AST repr of type const and const RHS
khyperia Jul 22, 2026
2f5a71d
LLVM 24 updates (in llvm/llvm-project@bff9c544bd87) the diagnostic st…
durin42 Jul 22, 2026
480c37d
Prefer `cfg!(not(test))` when skipping downloads
Zalathar Jul 22, 2026
e1fa066
Sync from rust 0e29c21d93abc9bdc330182be1fbd33cfd5fee68
bjorn3 Jul 22, 2026
d7ea382
Stabilize `c_variadic`
folkertdev Feb 13, 2026
6da84ff
Rustup to rustc 1.99.0-nightly (0e29c21d9 2026-07-21)
bjorn3 Jul 22, 2026
cb89537
Fix rustc test suite
bjorn3 Jul 22, 2026
39c2db0
Merge commit 'cb89537d435ec9cc9c812cd47c6130bd96aa0050' into sync_cg_…
bjorn3 Jul 22, 2026
c22fbbe
fix error when a dangling ref in a ManuallyDrop is used in a pattern
RalfJung Jul 22, 2026
2a759b1
Rollup merge of #159712 - bjorn3:sync_cg_clif-2026-07-22, r=bjorn3
JonathanBrouwer Jul 22, 2026
cb8995a
Rollup merge of #155697 - folkertdev:stabilize-c-variadic, r=tgross35…
JonathanBrouwer Jul 22, 2026
3378f49
Rollup merge of #159285 - nnethercote:simplify-apply_effects_in_range…
JonathanBrouwer Jul 22, 2026
fce3572
Rollup merge of #159596 - khyperia:type-const-rhs-expr, r=BoxyUwU
JonathanBrouwer Jul 22, 2026
88341be
Rollup merge of #159607 - durin42:llvm-23-riscv32e-error-msg, r=nikic
JonathanBrouwer Jul 22, 2026
51a5bb6
Rollup merge of #159659 - mejrs:limit, r=petrochenkov
JonathanBrouwer Jul 22, 2026
cc0c467
Rollup merge of #159707 - RalfJung:dangling-ref-in-pattern, r=WaffleL…
JonathanBrouwer Jul 22, 2026
0a0d2b0
Rollup merge of #158479 - Shourya742:2026-06-27-emit-error-during-ast…
JonathanBrouwer Jul 22, 2026
01e2980
Rollup merge of #158738 - Dnreikronos:next_trait_solver/gce_expr_reco…
JonathanBrouwer Jul 22, 2026
b395ba8
Rollup merge of #159451 - Kobzol:compiletest-debuginfo, r=Zalathar,ji…
JonathanBrouwer Jul 22, 2026
d3e22d3
Rollup merge of #159646 - adwinwhite:fix-f16-hack, r=lcnr
JonathanBrouwer Jul 22, 2026
8b72e0a
Rollup merge of #159705 - Zalathar:cfg-test, r=Kobzol
JonathanBrouwer Jul 22, 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
42 changes: 7 additions & 35 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4010,44 +4010,16 @@ pub struct ConstItem {
pub ident: Ident,
pub generics: Generics,
pub ty: Box<Ty>,
pub rhs_kind: ConstItemRhsKind,
pub body: Option<Box<Expr>>,
#[visitable(ignore)]
pub kind: ConstItemKind,
pub define_opaque: Option<ThinVec<(NodeId, Path)>>,
}

#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
pub enum ConstItemRhsKind {
Body { rhs: Option<Box<Expr>> },
TypeConst { rhs: Option<AnonConst> },
}

impl ConstItemRhsKind {
pub fn new_body(rhs: Box<Expr>) -> Self {
Self::Body { rhs: Some(rhs) }
}

pub fn span(&self) -> Option<Span> {
Some(self.expr()?.span)
}

pub fn expr(&self) -> Option<&Expr> {
match self {
Self::Body { rhs: Some(body) } => Some(&body),
Self::TypeConst { rhs: Some(anon) } => Some(&anon.value),
_ => None,
}
}

pub fn has_expr(&self) -> bool {
match self {
Self::Body { rhs: Some(_) } => true,
Self::TypeConst { rhs: Some(_) } => true,
_ => false,
}
}

pub fn is_type_const(&self) -> bool {
matches!(self, &Self::TypeConst { .. })
}
#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq, Eq)]
pub enum ConstItemKind {
Body,
TypeConst,
}

#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ macro_rules! common_visitor_and_walkers {
Const,
ConstBlockItem,
ConstItem,
ConstItemRhsKind,
Defaultness,
Delegation,
DelegationMac,
Expand Down
21 changes: 12 additions & 9 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
ident,
generics,
ty,
rhs_kind,
body,
kind,
define_opaque,
}) => {
let ident = self.lower_ident(*ident);
Expand All @@ -282,7 +283,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ty,
ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy),
);
let rhs = this.lower_const_item_rhs(rhs_kind, span);
let rhs = this.lower_const_item_rhs(body, *kind, span);
(ty, rhs)
},
);
Expand Down Expand Up @@ -918,7 +919,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
ident,
generics,
ty,
rhs_kind,
body,
kind,
define_opaque,
..
}) => {
Expand All @@ -931,8 +933,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy),
);
// Trait associated consts don't need an expression/body.
let rhs = if rhs_kind.has_expr() {
Some(this.lower_const_item_rhs(rhs_kind, i.span))
let rhs = if body.is_some() {
Some(this.lower_const_item_rhs(body, *kind, i.span))
} else {
None
};
Expand All @@ -941,7 +943,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
);

if define_opaque.is_some() {
if rhs_kind.has_expr() {
if body.is_some() {
self.lower_define_opaque(hir_id, &define_opaque);
} else {
self.dcx().span_err(
Expand All @@ -951,7 +953,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

(*ident, generics, kind, rhs_kind.has_expr())
(*ident, generics, kind, body.is_some())
}
AssocItemKind::Fn(Fn { sig, ident, generics, body: None, define_opaque, .. }) => {
// FIXME(contracts): Deny contract here since it won't apply to
Expand Down Expand Up @@ -1180,7 +1182,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
ident,
generics,
ty,
rhs_kind,
body,
kind,
define_opaque,
..
}) => (
Expand All @@ -1194,7 +1197,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy),
);
this.lower_define_opaque(hir_id, &define_opaque);
let rhs = this.lower_const_item_rhs(rhs_kind, i.span);
let rhs = this.lower_const_item_rhs(body, *kind, i.span);
hir::ImplItemKind::Const(ty, rhs)
},
),
Expand Down
20 changes: 9 additions & 11 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2671,28 +2671,26 @@ impl<'hir> LoweringContext<'_, 'hir> {

fn lower_const_item_rhs(
&mut self,
rhs_kind: &ConstItemRhsKind,
body: &Option<Box<Expr>>,
kind: ConstItemKind,
span: Span,
) -> hir::ConstItemRhs<'hir> {
match rhs_kind {
ConstItemRhsKind::Body { rhs: Some(body) } => {
hir::ConstItemRhs::Body(self.lower_const_body(span, Some(body)))
match (body, kind) {
(body, ConstItemKind::Body) => {
hir::ConstItemRhs::Body(self.lower_const_body(span, body.as_deref()))
}
ConstItemRhsKind::Body { rhs: None } => {
hir::ConstItemRhs::Body(self.lower_const_body(span, None))
}
ConstItemRhsKind::TypeConst { rhs: Some(anon) } => {
(Some(body), ConstItemKind::TypeConst) => {
hir::ConstItemRhs::TypeConst(self.arena.alloc(
match self.can_lower_expr_to_const_arg_direct(
&anon.value,
&body,
DirectConstArgContext::MacrolessMinGenericConstArgs,
) {
Ok(()) => self.lower_expr_to_const_arg_direct(&anon.value, Some(anon.id)),
Ok(()) => self.lower_expr_to_const_arg_direct(&body, None),
Err(err) => err.emit(self),
},
))
}
ConstItemRhsKind::TypeConst { rhs: None } => {
(None, ConstItemKind::TypeConst) => {
let const_arg = ConstArg {
hir_id: self.next_id(),
kind: hir::ConstArgKind::Error(
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1544,9 +1544,9 @@ impl Visitor<'_> for AstValidator<'_> {
visit::walk_item(this, item)
});
}
ItemKind::Const(ConstItem { defaultness, ident, rhs_kind, .. }) => {
ItemKind::Const(ConstItem { defaultness, ident, body, .. }) => {
self.check_defaultness(item.span, *defaultness, AllowDefault::No, AllowFinal::No);
if !rhs_kind.has_expr() {
if body.is_none() {
self.dcx().emit_err(diagnostics::ConstWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
Expand Down Expand Up @@ -1941,8 +1941,8 @@ impl Visitor<'_> for AstValidator<'_> {

if let AssocCtxt::Impl { .. } = ctxt {
match &item.kind {
AssocItemKind::Const(ConstItem { rhs_kind, .. }) => {
if !rhs_kind.has_expr() {
AssocItemKind::Const(ConstItem { body, .. }) => {
if body.is_none() {
self.dcx().emit_err(diagnostics::AssocConstWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
Expand Down
20 changes: 9 additions & 11 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
use rustc_ast::visit::{self, AssocCtxt, FnKind, Visitor};
use rustc_ast::{self as ast, AttrVec, GenericBound, NodeId, PatKind, attr, token};
use rustc_attr_parsing::AttributeParser;
use rustc_errors::msg;
Expand Down Expand Up @@ -220,8 +220,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
self.check_impl_trait(ty, false)
}
ast::ItemKind::Const(ast::ConstItem {
rhs_kind: ast::ConstItemRhsKind::TypeConst { .. },
..
kind: ast::ConstItemKind::TypeConst, ..
}) => {
// Make sure this is only allowed if the feature gate is enabled.
// #![feature(min_generic_const_args)]
Expand Down Expand Up @@ -366,7 +365,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
visit::walk_poly_trait_ref(self, t);
}

fn visit_fn(&mut self, fn_kind: FnKind<'a>, _: &AttrVec, span: Span, _: NodeId) {
fn visit_fn(&mut self, fn_kind: FnKind<'a>, _: &AttrVec, _: Span, _: NodeId) {
if let Some(_header) = fn_kind.header() {
// Stability of const fn methods are covered in `visit_assoc_item` below.
}
Expand All @@ -375,10 +374,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
self.check_late_bound_lifetime_defs(generic_params);
}

if fn_kind.ctxt() != Some(FnCtxt::Foreign) && fn_kind.decl().c_variadic() {
gate!(self, c_variadic, span, "C-variadic functions are unstable");
}

visit::walk_fn(self, fn_kind)
}

Expand All @@ -400,7 +395,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
false
}
ast::AssocItemKind::Const(ast::ConstItem {
rhs_kind: ast::ConstItemRhsKind::TypeConst { rhs },
body,
kind: ast::ConstItemKind::TypeConst,
..
}) => {
// Make sure this is only allowed if the feature gate is enabled.
Expand All @@ -409,7 +405,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
// Make sure associated `type const` defaults in traits are only allowed
// if the feature gate is enabled.
// #![feature(associated_type_defaults)]
if ctxt == AssocCtxt::Trait && rhs.is_some() {
if ctxt == AssocCtxt::Trait && body.is_some() {
gate!(
self,
associated_type_defaults,
Expand Down Expand Up @@ -730,8 +726,10 @@ fn check_new_solver_banned_features(sess: &Session, features: &Features) {
.find(|feat| feat.gate_name == sym::generic_const_exprs)
.map(|feat| feat.attr_sp)
{
// Abort immediately, otherwise GCE can lower to `ConstKind::Expr`,
// which the new solver intentionally does not support.
#[allow(rustc::symbol_intern_string_literal)]
sess.dcx().emit_err(diagnostics::IncompatibleFeatures {
sess.dcx().emit_fatal(diagnostics::IncompatibleFeatures {
spans: vec![gce_span],
f1: Symbol::intern("-Znext-solver=globally"),
f2: sym::generic_const_exprs,
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_ast_pretty/src/pprust/state/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,16 @@ impl<'a> State<'a> {
ident,
generics,
ty,
rhs_kind,
body,
kind: _,
define_opaque,
}) => {
self.print_item_const(
*ident,
None,
generics,
ty,
rhs_kind.expr(),
body.as_deref(),
&item.vis,
ast::Safety::Default,
*defaultness,
Expand Down Expand Up @@ -617,15 +618,16 @@ impl<'a> State<'a> {
ident,
generics,
ty,
rhs_kind,
body,
kind: _,
define_opaque,
}) => {
self.print_item_const(
*ident,
None,
generics,
ty,
rhs_kind.expr(),
body.as_deref(),
vis,
ast::Safety::Default,
*defaultness,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/util.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::num::IntErrorKind;

use rustc_ast::{LitKind, ast};
use rustc_data_structures::Limit;
use rustc_feature::is_builtin_attr_name;
use rustc_hir::RustcVersion;
use rustc_hir::limit::Limit;
use rustc_span::Symbol;

use crate::context::AcceptContext;
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_builtin_macros/src/alloc_error_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ pub(crate) fn expand(

// Generate anonymous constant serving as container for the allocator methods.
let const_ty = ecx.ty(sig_span, TyKind::Tup(ThinVec::new()));
let const_body = ast::ConstItemRhsKind::new_body(ecx.expr_block(ecx.block(span, stmts)));
let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body);
let const_body = ecx.expr_block(ecx.block(span, stmts));
let const_item = ecx.item_const(
span,
Ident::new(kw::Underscore, span),
const_ty,
Some(const_body),
ast::ConstItemKind::Body,
);
let const_item = if is_stmt {
Annotatable::Stmt(Box::new(ecx.stmt_item(span, const_item)))
} else {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_builtin_macros/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ fn generate_default_impl(
span,
underscore,
unit,
ast::ConstItemRhsKind::new_body(ecx.expr_block(ecx.block(span, stmts))),
Some(ecx.expr_block(ecx.block(span, stmts))),
ast::ConstItemKind::Body,
)
};

Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_builtin_macros/src/global_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ pub(crate) fn expand(

// Generate anonymous constant serving as container for the allocator methods.
let const_ty = ecx.ty(ty_span, TyKind::Tup(ThinVec::new()));
let const_body = ast::ConstItemRhsKind::new_body(ecx.expr_block(ecx.block(span, stmts)));
let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body);
let const_body = ecx.expr_block(ecx.block(span, stmts));
let const_item = ecx.item_const(
span,
Ident::new(kw::Underscore, span),
const_ty,
Some(const_body),
ast::ConstItemKind::Body,
);
let const_item = if is_stmt {
Annotatable::Stmt(Box::new(ecx.stmt_item(span, const_item)))
} else {
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_builtin_macros/src/proc_macro_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,16 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> Box<ast::Item> {
cx.attr_nested_word(sym::allow, sym::deprecated, span),
]);

let block = ast::ConstItemRhsKind::new_body(cx.expr_block(
let block = cx.expr_block(
cx.block(span, thin_vec![cx.stmt_item(span, krate), cx.stmt_item(span, decls_static)]),
));
);

let anon_constant = cx.item_const(
span,
Ident::new(kw::Underscore, span),
cx.ty(span, ast::TyKind::Tup(ThinVec::new())),
block,
Some(block),
ast::ConstItemKind::Body,
);

// Integrate the new item into existing module structures.
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ pub(crate) fn expand_test_or_bench(
generics: ast::Generics::default(),
ty: cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),
define_opaque: None,
kind: ast::ConstItemKind::Body,
// test::TestDescAndFn {
rhs_kind: ast::ConstItemRhsKind::new_body(
body: Some(
cx.expr_struct(
sp,
test_path("TestDescAndFn"),
Expand Down
Loading
Loading