Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d780821
Ensure inferred let pattern types are well-formed
s7tya May 27, 2026
9633071
Don't suggest wrong unwrap expect
lokirithm May 31, 2026
2314457
borrowck: avoid ICE describing fields on generic params
pbkx Jun 1, 2026
b573841
Use a placeholder self type for escaping dyn principals in WF
Dnreikronos Jun 2, 2026
0676d4a
Add regression tests for WF-checking dyn in HRTB bounds
Dnreikronos Jun 2, 2026
de37dfd
Add or_try_* variants for HashMap Entry API
peterjoel Feb 6, 2024
92175ed
platform support: add SNaN erratum to MIPS targets
RalfJung Jun 2, 2026
51001cf
Make the retained dep graph deterministic under the parallel frontend
xmakro Jun 3, 2026
d00722c
Re-enable dep-graph ui tests under the parallel frontend
xmakro Jun 3, 2026
5a7ca04
Use field-index fallback for undescribed fields
pbkx Jun 5, 2026
c1cd236
Attribute post-monomorphization error notes by emitting thread
xmakro Jun 5, 2026
2e128c7
Re-enable parallel frontend tests for post-monomorphization errors
xmakro Jun 5, 2026
3ecbb39
Update `browser-ui-test` version to `0.24.0`
GuillaumeGomez Jun 8, 2026
0d980a5
Update nodejs version used in CI to `24.15.0`
GuillaumeGomez Jun 8, 2026
1e125ce
Support defaults for static EIIs
AsakuraMizu May 14, 2026
3669c24
Allow escaping self types in ExistentialTraitRef::with_self_ty
Dnreikronos Jun 9, 2026
e069f47
Add a regression test
oli-obk Jun 8, 2026
947a5b6
Mark `trait_info_of` as comptime and adjust the compiler to handle it
oli-obk Jun 8, 2026
b3c6e82
Mark more reflection things as comptime
oli-obk Jun 8, 2026
5bc21b1
Fix parser error recovery for 'dyn' in Rust 2015
i-like-ICEs Jun 9, 2026
c010b25
Implement or_try_* methods on BTreeMap Entry API
asder8215 Jun 3, 2026
6324b4a
Add flush strategy to allow observing bytes before they are flushed.
Daniel-B-Smith Jun 8, 2026
8ee1dfa
Move symbol hiding code to a new file
cezarbbb Jun 10, 2026
2a5673f
Rename `rustc_expand/src/errors.rs` into `rustc_expand/src/diagnostic…
GuillaumeGomez Jun 9, 2026
96eb195
Rename `rustc_metadata/src/errors.rs` into `rustc_metadata/src/diagno…
GuillaumeGomez Jun 9, 2026
32a2f0c
Add more tests that exercise the well-formedness checking of lazy typ…
fmease Jun 10, 2026
00ac562
Rename `rustc_mir_build/src/errors.rs` into `rustc_mir_build/src/diag…
GuillaumeGomez Jun 10, 2026
b679cbd
Rename `rustc_mir_dataflow/src/errors.rs` into `rustc_mir_dataflow/sr…
GuillaumeGomez Jun 10, 2026
6708111
Emit error for unused target expression in glob and list delegations
aerooneqq Jun 10, 2026
6a0f2d4
Fix doc link to Instant sub in saturating caveat
orlp Jun 10, 2026
f5e5709
Only register the `atexit` hook when `cleanup` is unloadable
ohadravid Jun 9, 2026
7f0f6e0
Add #[rustc_dump_generics] attribute, tests
Jun 3, 2026
88f3ac1
Manually download chrome instead of letting yarn/npm doing it
GuillaumeGomez Jun 8, 2026
cdb6acc
Reject static EII defaults on Apple targets
AsakuraMizu Jun 9, 2026
1c511f4
compiletest: ignore SVG `y` offset in by-lines comparison
xmakro Jun 5, 2026
816c70b
resolve: Partially revert "Remove a special case for dummy imports"
petrochenkov Jun 10, 2026
96362fc
Rollup merge of #157280 - Dnreikronos:existential_trait_ref_escaping_…
jhpratt Jun 10, 2026
f7d3474
Rollup merge of #157282 - xmakro:fix/parallel-pme-note, r=petrochenkov
jhpratt Jun 10, 2026
ab955d4
Rollup merge of #157352 - xmakro:fix/parallel-dep-graph-determinism, …
jhpratt Jun 10, 2026
446f02b
Rollup merge of #157601 - aerooneqq:delegation-glob-useless-target-ex…
jhpratt Jun 10, 2026
e6a9ac7
Rollup merge of #157611 - GuillaumeGomez:update-browser-ui-test, r=ji…
jhpratt Jun 10, 2026
7ffda80
Rollup merge of #157620 - Daniel-B-Smith:smithdb3/fileencoder-strateg…
jhpratt Jun 10, 2026
60c0690
Rollup merge of #157645 - ohadravid:windows-tls-leak-on-dll-instead-o…
jhpratt Jun 10, 2026
e81aa2c
Rollup merge of #157647 - oli-obk:start-using-comptime, r=fee1-dead
jhpratt Jun 10, 2026
75f9a32
Rollup merge of #157719 - petrochenkov:regr197err, r=jackh726
jhpratt Jun 10, 2026
604ea02
Rollup merge of #156497 - lokirithm:fix-155516, r=cjgillot
jhpratt Jun 10, 2026
45c682c
Rollup merge of #156583 - AsakuraMizu:eii-static-default, r=JonathanB…
jhpratt Jun 10, 2026
fcb54aa
Rollup merge of #157013 - s7tya:fix-let-pat-inferred-wf, r=lcnr
jhpratt Jun 10, 2026
5f9d389
Rollup merge of #157230 - pbkx:issue-155344-borrowck-field-param, r=c…
jhpratt Jun 10, 2026
62238c4
Rollup merge of #157288 - RalfJung:mips-snan, r=ehuss,chenx97,Cyanoxygen
jhpratt Jun 10, 2026
c00d504
Rollup merge of #157350 - xmakro:fix/parallel-svg-y-offset, r=petroch…
jhpratt Jun 10, 2026
8900e13
Rollup merge of #157355 - asder8215:entry_try, r=jhpratt
jhpratt Jun 10, 2026
0d69ce2
Rollup merge of #157384 - addiesh:turbofisherwoman, r=oli-obk
jhpratt Jun 10, 2026
e6ff3ff
Rollup merge of #157577 - i-like-ICEs:fix-dyn-2015-parser, r=fmease
jhpratt Jun 10, 2026
7f14df4
Rollup merge of #157670 - GuillaumeGomez:rename-err-to-diag, r=Jonath…
jhpratt Jun 10, 2026
dc03fbd
Rollup merge of #157691 - cezarbbb:staticlib-move-symbol-edit, r=petr…
jhpratt Jun 10, 2026
c3c980d
Rollup merge of #157697 - fmease:lta-more-wf-tests, r=TaKO8Ki
jhpratt Jun 10, 2026
b43c6e9
Rollup merge of #157700 - GuillaumeGomez:rename-err-to-diag-2, r=Jona…
jhpratt Jun 10, 2026
8367944
Rollup merge of #157703 - orlp:fix-instant-comment, r=SimonSapin
jhpratt Jun 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
Prev Previous commit
Next Next commit
Support defaults for static EIIs
  • Loading branch information
AsakuraMizu committed Jun 9, 2026
commit 1e125ceba9a27466b10ed5584b8b0d0a3abc2b19
8 changes: 0 additions & 8 deletions compiler/rustc_builtin_macros/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,14 +1134,6 @@ pub(crate) struct EiiStaticMultipleImplementations {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("`#[{$name}]` cannot be used on statics with a value")]
pub(crate) struct EiiStaticDefault {
#[primary_span]
pub span: Span,
pub name: String,
}

#[derive(Diagnostic)]
#[diag("`#[{$name}]` requires the name as an explicit argument when used on a static")]
pub(crate) struct EiiStaticArgumentRequired {
Expand Down
83 changes: 48 additions & 35 deletions compiler/rustc_builtin_macros/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::diagnostics::{
EiiAttributeNotSupported, EiiExternTargetExpectedList, EiiExternTargetExpectedMacro,
EiiExternTargetExpectedUnsafe, EiiMacroExpectedMaxOneArgument, EiiOnlyOnce,
EiiSharedMacroInStatementPosition, EiiSharedMacroTarget, EiiStaticArgumentRequired,
EiiStaticDefault, EiiStaticMultipleImplementations, EiiStaticMutable,
EiiStaticMultipleImplementations, EiiStaticMutable,
};

/// ```rust
Expand Down Expand Up @@ -86,14 +86,6 @@ fn eii_(
let (item_span, foreign_item_name) = match kind {
ItemKind::Fn(func) => (func.sig.span, func.ident),
ItemKind::Static(stat) => {
// Statics with a default are not supported yet
if let Some(stat_body) = &stat.expr {
ecx.dcx().emit_err(EiiStaticDefault {
span: stat_body.span,
name: path_to_string(&meta_item.path),
});
return vec![];
}
// Statics must have an explicit name for the eii
if meta_item.is_word() {
ecx.dcx().emit_err(EiiStaticArgumentRequired {
Expand Down Expand Up @@ -139,19 +131,17 @@ fn eii_(

let mut module_items = Vec::new();

if let ItemKind::Fn(func) = kind
&& func.body.is_some()
{
module_items.push(generate_default_func_impl(
ecx,
&func,
impl_unsafe,
macro_name,
eii_attr_span,
item_span,
foreign_item_name,
default_func_attrs,
))
if let Some(default_impl) = generate_default_impl(
ecx,
kind,
impl_unsafe,
macro_name,
eii_attr_span,
item_span,
foreign_item_name,
default_func_attrs,
) {
module_items.push(default_impl);
}

module_items.push(generate_foreign_item(
Expand Down Expand Up @@ -266,18 +256,31 @@ fn filter_attrs_for_multiple_eii_attr(
.collect()
}

fn generate_default_func_impl(
fn generate_default_impl(
ecx: &mut ExtCtxt<'_>,
func: &ast::Fn,
item_kind: &ItemKind,
impl_unsafe: bool,
macro_name: Ident,
eii_attr_span: Span,
item_span: Span,
foreign_item_name: Ident,
attrs: ThinVec<Attribute>,
) -> Box<ast::Item> {
let mut default_func = func.clone();
default_func.eii_impls.push(EiiImpl {
) -> Option<Box<ast::Item>> {
match item_kind {
ItemKind::Fn(func) => {
if func.body.is_none() {
return None;
}
}
ItemKind::Static(stat) => {
if stat.expr.is_none() {
return None;
}
}
_ => unreachable!("Target was checked earlier"),
};

let eii_impl = EiiImpl {
node_id: DUMMY_NODE_ID,
inner_span: macro_name.span,
eii_macro_path: ast::Path::from_ident(macro_name),
Expand All @@ -297,7 +300,18 @@ fn generate_default_func_impl(
),
impl_unsafe,
}),
});
};

let mut item_kind = item_kind.clone();
match &mut item_kind {
ItemKind::Fn(func) => {
func.eii_impls.push(eii_impl);
}
ItemKind::Static(stat) => {
stat.eii_impls.push(eii_impl);
}
_ => unreachable!("Target was checked earlier"),
};

let anon_mod = |span: Span, stmts: ThinVec<ast::Stmt>| {
let unit = ecx.ty(item_span, ast::TyKind::Tup(ThinVec::new()));
Expand All @@ -311,15 +325,12 @@ fn generate_default_func_impl(
};

// const _: () = {
// <orig fn>
// <orig item>
// }
anon_mod(
Some(anon_mod(
item_span,
thin_vec![ecx.stmt_item(
item_span,
ecx.item(item_span, attrs, ItemKind::Fn(Box::new(default_func)))
),],
)
thin_vec![ecx.stmt_item(item_span, ecx.item(item_span, attrs, item_kind))],
))
}

/// Generates a foreign item, like
Expand Down Expand Up @@ -405,6 +416,8 @@ fn generate_foreign_static(mut stat: Box<ast::StaticItem>) -> ast::ForeignItemKi
stat.safety = ast::Safety::Safe(stat.ident.span);
}

stat.expr = None;

ast::ForeignItemKind::Static(stat)
}

Expand Down
5 changes: 5 additions & 0 deletions tests/ui/eii/static/auxiliary/decl_with_default.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![crate_type = "rlib"]
#![feature(extern_item_impls)]

#[eii(eii1)]
pub static DECL1: u64 = 5;
8 changes: 8 additions & 0 deletions tests/ui/eii/static/auxiliary/impl_default_override.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ aux-build: decl_with_default.rs
#![crate_type = "rlib"]
#![feature(extern_item_impls)]

extern crate decl_with_default as decl;

#[decl::eii1]
pub static EII1_IMPL: u64 = 10;
15 changes: 15 additions & 0 deletions tests/ui/eii/static/default.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ run-pass
//@ check-run-results
//@ ignore-backends: gcc
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
//@ ignore-windows
// Tests static EIIs with default implementations.

#![feature(extern_item_impls)]

#[eii(eii1)]
pub static DECL1: u64 = 5;

fn main() {
println!("{DECL1}");
}
1 change: 1 addition & 0 deletions tests/ui/eii/static/default.run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
13 changes: 13 additions & 0 deletions tests/ui/eii/static/default_cross_crate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ aux-build: decl_with_default.rs
//@ run-pass
//@ check-run-results
//@ ignore-backends: gcc
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
//@ ignore-windows
// Tests that a static EII default can be used from another crate.

extern crate decl_with_default;

fn main() {
println!("{}", decl_with_default::DECL1);
}
1 change: 1 addition & 0 deletions tests/ui/eii/static/default_cross_crate.run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
15 changes: 15 additions & 0 deletions tests/ui/eii/static/default_cross_crate_explicit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ aux-build: decl_with_default.rs
//@ aux-build: impl_default_override.rs
//@ run-pass
//@ check-run-results
//@ ignore-backends: gcc
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
//@ ignore-windows
// Tests that an explicit static EII implementation overrides a cross-crate default.

extern crate decl_with_default;
extern crate impl_default_override;

fn main() {
println!("{}", decl_with_default::DECL1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
19 changes: 19 additions & 0 deletions tests/ui/eii/static/default_explicit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ run-pass
//@ check-run-results
//@ ignore-backends: gcc
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
//@ ignore-windows
// Tests that an explicit static EII implementation overrides a local default.

#![feature(extern_item_impls)]
#![allow(dead_code)]

#[eii(eii1)]
pub static DECL1: u64 = 5;

#[eii1]
pub static EII1_IMPL: u64 = 10;

fn main() {
println!("{DECL1}");
}
1 change: 1 addition & 0 deletions tests/ui/eii/static/default_explicit.run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10