Commit Graph

48 Commits

Author SHA1 Message Date
Jonathan Brouwer 4babf87ac3 Rollup merge of #156577 - AsakuraMizu:eii-default-dynamic, r=mejrs
Test EII UI tests with prefer-dynamic

Tracking issue: rust-lang/rust#125418

Remove `no-prefer-dynamic` from the EII UI tests now that rust-lang/rust#153648 fixed exporting EII declaration aliases from dylibs.

Fixes rust-lang/rust#151271.

Tested with:

```sh
python3 x.py test tests/ui/eii --force-rerun
```
2026-05-17 15:52:39 +02:00
朝倉水希 124126e083 Test EII UI tests with prefer-dynamic 2026-05-16 03:08:00 +08:00
bjorn3 860813dd9d Require EIIs to be defined when we compile a rust dylib
The linker will complain about undefined symbols otherwise and on object
file formats with two level namespaces (Mach-O and PE/COFF) it is
required to know which dylib a symbol will be imported from when linking
a dylib or executable.
2026-05-15 15:49:35 +02:00
Jonathan Brouwer 106b16cd2d Add support for static EIIs in late resolution 2026-04-12 11:06:40 +02:00
Jonathan Brouwer 1f2b0900a7 Reject multiple EII implementations on one static 2026-04-11 10:17:44 +02:00
Jonathan Brouwer 59ed245945 Reject mutable externally implementable statics 2026-04-11 10:17:44 +02:00
Jonathan Brouwer fca29ada74 Uitests for external statics 2026-04-11 10:17:44 +02:00
Jonathan Brouwer 45223feeba Rollup merge of #153796 - GokhanKabar:fix-ice-missing-tokens-eii-attr-expansion, r=jdonszelmann
Fix ICE when combining #[eii] with #[core::contracts::ensures]

Fixes rust-lang/rust#153745

Builtin attribute macros like #[eii] generate AST items programmatically without collected tokens. When another attribute macro was present on the same item, the compiler would panic in TokenStream::from_ast() trying to tokenize the generated items during subsequent attribute expansion.

Generate fake token streams (via pretty-print and re-parse) for Item and ForeignItem nodes that lack collected tokens, following the existing pattern used for Crate and out-of-line modules.
2026-04-10 15:33:12 +02:00
GokhanKabar 48eced88b5 Fix platform-specific stderr mismatch in ice_contract_attr_on_eii_generated_item test
The previous test used `fn implementation() {}` with a body, which caused
`generate_default_impl` to generate a `const _: () = { fn implementation() {} }`
item containing `self::implementation`. On Linux (aarch64-gnu-llvm-21), the
resolver's `suggest_ident_hidden_by_hygiene` emitted an extra help span on the
resulting E0425 error that did not appear on macOS, causing a stderr mismatch.

Switch the declaration to `fn implementation();` (no body) so that
`generate_default_impl` is not called and no `self::implementation` path is
emitted. The test still validates that `#[eii]` + `#[core::contracts::ensures]`
produces graceful errors instead of an ICE, via the two contract-annotation
errors on the generated foreign item.
2026-04-08 10:44:42 +02:00
enthropy7 5961ba1631 Restrict EII declarations to functions via PathSource in name resolution 2026-04-07 21:28:12 +03:00
GokhanKabar b544edd56c Preserve EII link through AttrProcMacro token roundtrip and add run-pass test
When a function has `eii_impls` set (via `eii_shared_macro`), the `#[hello]`
attribute is consumed from `node.attrs()`. A subsequent `AttrProcMacro` expander
like `contracts::requires` calls `item.to_tokens()` which uses the current
`node.attrs()` — so `#[hello]` is missing from the token stream. After the
roundtrip and `parse_ast_fragment`, the new AST item has empty `eii_impls`
and the EII link is broken.

Fix this by using `fake_token_stream_for_item` when the item is a function
with non-empty `eii_impls`. The pretty-printer re-emits `eii_impls` as
`#[hello]` in `print_fn_full`, which survives the roundtrip and gets
re-expanded by `eii_shared_macro` on the resulting item.

Add a run-pass test to verify EII + contract annotation works correctly
at runtime.
2026-04-07 15:25:55 +02:00
Kcang-gna 99e1aa7798 add regression test for EII declaration conflicting with constructor 2026-04-04 10:50:57 +08:00
GokhanKabar 99821e168e Fix ICE when combining #[eii] with #[core::contracts::ensures]
Builtin attribute macros like #[eii] generate AST items
programmatically without collected tokens. When another attribute macro
was present on the same item, the compiler would panic in
TokenStream::from_ast() trying to tokenize the generated items during
subsequent attribute expansion.

Generate fake token streams (via pretty-print and re-parse) for Item
and ForeignItem nodes that lack collected tokens, following the
existing pattern used for Crate and out-of-line modules.
2026-03-13 00:16:15 +01:00
Takayuki Maeda 6084bf541b add regression test for EII declaration conflicting with constructor 2026-03-08 23:04:14 +09:00
mu001999 0436634084 Remove unused features in tests 2026-03-04 08:06:45 +08:00
Jonathan Brouwer 46126ac931 Rollup merge of #151733 - jdonszelmann:eii-on-apple, r=oli-obk
Use function shims to make sure EII works on apple targets

Use function shims to make sure EII works on apple targets (and generally accepts target-arch attributes)

Explainer: https://github.com/rust-lang/rust/pull/146348#issuecomment-3631810110
Tracking issue: https://github.com/rust-lang/rust/issues/125418
2026-02-19 10:56:36 +01:00
Esteban Küber c73b3d20c6 Unify wording of resolve error
Remove "failed to resolve" and use the same format we use in other resolution errors "cannot find `name`".

```
error[E0433]: cannot find `nonexistent` in `existent`
  --> $DIR/custom_attr_multisegment_error.rs:5:13
   |
LL | #[existent::nonexistent]
   |             ^^^^^^^^^^^ could not find `nonexistent` in `existent`
```
2026-02-17 16:51:44 +00:00
Jana Dönszelmann b14799754e test backtraces 2026-02-17 14:22:52 +01:00
Jana Dönszelmann d6db0ed612 run tests on apple 2026-02-17 14:22:52 +01:00
Jonathan Brouwer 46d4bbf6df Rollup merge of #150971 - disallow-eii-in-statement-position, r=wafflelapkin
Disallow eii in statement position

With how v2 macros resolve, and the name resolution of `super` works, I realized with @WaffleLapkin that there's actually no way to consistently expand EIIs in statement position.

r? @WaffleLapkin
2026-01-14 22:29:58 +01:00
Jana Dönszelmann 8dd701cec7 add test for rejecting EIIs in statement position 2026-01-13 12:08:10 +01:00
Jana Dönszelmann b454f76bd1 ensure generics are still properly reported on EII *implementations*, and test this 2026-01-13 11:59:59 +01:00
Jana Dönszelmann b64a9be97e bless the tests 2026-01-13 11:59:59 +01:00
Jana Dönszelmann 1d96806788 type params on eii 2026-01-13 11:59:59 +01:00
Jana Dönszelmann 322bbdfaaf rename eii-extern-target 2026-01-12 08:07:23 +01:00
Jana Dönszelmann 9b811544f2 once again reorganize the EII tests a bit 2026-01-10 11:10:44 +01:00
Jana Dönszelmann 7791bc2213 mark ICE regression test as fixed 2026-01-09 09:29:02 +01:00
Jana Dönszelmann 5ddda0c37b fix up diagnostics referring to the right items 2026-01-09 09:29:02 +01:00
Jana Dönszelmann 5e5c724194 turn panics into span_delayed_bug to make sure this pattern doesn't go unnoticed 2026-01-09 09:29:02 +01:00
Jana Dönszelmann 3c8265a29f add test for 149981 2026-01-09 09:29:02 +01:00
Matthias Krüger 5e365fd9de Rollup merge of #150160 - jdonszelmann:fix-149980, r=Kivooeo
Fix ICE (#149980) for invalid EII in statement position

Based on https://github.com/rust-lang/rust/pull/150159

Fixes rust-lang/rust#149980
2025-12-21 18:50:44 +01:00
Jana Dönszelmann c316c05dc5 refactor how eii expansion is wrapped fixing 149980 2025-12-19 18:43:04 +01:00
Jana Dönszelmann 897e88c63d add test for 149980 2025-12-19 18:43:04 +01:00
Stuart Cook 77491e7878 Rollup merge of #150150 - jdonszelmann:move-eii-tests, r=JonathanBrouwer
move eii tests

Just a little housekeeping. This feature is getting a lot of tests, so it felt good to put some tests for type checking in its own folder to organise a little. Should be trivial!
2025-12-20 00:32:32 +11:00
Jana Dönszelmann c040bb1c7e move eii tests 2025-12-19 12:42:49 +01:00
Jana Dönszelmann 08b7d34e06 another related case that deserved a test 2025-12-17 18:05:13 +01:00
Jana Dönszelmann 1cd7cb1e8d turn panic into span_delayed_bug 2025-12-17 18:04:03 +01:00
Jana Dönszelmann bd137df64a test for duplicate default eii ICE 149985
Co-authored-by: SATVIKsynopsis <futureiitianisme@gmail.com>
2025-12-17 18:02:37 +01:00
Jana Dönszelmann 065e4c1c8a ignore windows 2025-12-13 22:49:45 +01:00
Jana Dönszelmann e7b729cd92 ignore test with defaults on macos 2025-12-12 12:14:54 +01:00
Jana Dönszelmann 5768b234de use our own alternative to STD_INTERNAL_SYMBOL and make sure we mangle EIIs properly 2025-12-12 12:14:54 +01:00
Jana Dönszelmann 13de732df5 add test for symbol mangling issue 2025-12-12 11:53:59 +01:00
Jana Dönszelmann 52e0bfccb0 rename feature gate to extern_item_impls 2025-12-12 11:32:35 +01:00
Jana Dönszelmann 3cf74cb2a4 disable gcc for now 2025-12-12 11:32:32 +01:00
Jana Dönszelmann 92c03a26fd EII (builtin) macros in std 2025-12-12 11:17:33 +01:00
Jana Dönszelmann 615acd8b4d add tests for using a single impl for two EIIs 2025-12-12 11:17:32 +01:00
Jana Dönszelmann be98443639 TEMP: fixes error codes in non-codegen tests. those work after the type checking 2025-12-12 11:17:32 +01:00
Jana Dönszelmann 0ac215aabe EII tests 2025-12-12 11:17:32 +01:00