Skip to content

Conversation

@Enselic
Copy link
Member

@Enselic Enselic commented Jan 13, 2026

Otherwise eiis defined by std will produce large amounts of missing stability attribute errors. This problem is not eii specific, as can be seen in #146993 and which is demonstrated in #151022.

As can be seen with

$ git grep rustc_macro_transparency
compiler/rustc_arena/src/lib.rs:#[rustc_macro_transparency = "semiopaque"]
[...]

it is very common for macros to use "semiopaque".

r? @jdonszelmann

Tracking issue: #125418

Needed for: #150588

Otherwise eiis defined by std will produce large amounts of `missing
stability attribute` errors.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 13, 2026
@Enselic Enselic added the F-extern_item_impls `#![feature(extern_item_impls)]` label Jan 13, 2026
@jdonszelmann
Copy link
Contributor

what does opaque/semiopaque exactly mean? like what effect does that have? Is there a nice reference somewhere?

@jdonszelmann
Copy link
Contributor

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 13, 2026
@Enselic
Copy link
Member Author

Enselic commented Jan 13, 2026

@jdonszelmann Hopefully the in-tree docs can help?

/// A property of a macro expansion that determines how identifiers
/// produced by that expansion are resolved.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Hash, Debug, Encodable, Decodable)]
#[derive(HashStable_Generic)]
pub enum Transparency {
/// Identifier produced by a transparent expansion is always resolved at call-site.
/// Call-site spans in procedural macros, hygiene opt-out in `macro` should use this.
Transparent,
/// Identifier produced by a semi-opaque expansion may be resolved
/// either at call-site or at definition-site.
/// If it's a local variable, label or `$crate` then it's resolved at def-site.
/// Otherwise it's resolved at call-site.
/// `macro_rules` macros behave like this, built-in macros currently behave like this too,
/// but that's an implementation detail.
SemiOpaque,
/// Identifier produced by an opaque expansion is always resolved at definition-site.
/// Def-site spans in procedural macros, identifiers from `macro` by default use this.
Opaque,
}

Also, this seems to be the most important place for where the difference of the variants matter (but I don't understand the code myself):

// Evaluate opaque and semi-opaque versions of the new syntax context.
let (opaque, opaque_and_semiopaque) = match transparency {
Transparency::Transparent => (parent_opaque, parent_opaque_and_semiopaque),
Transparency::SemiOpaque => (
parent_opaque,
// Will be the same as `ctxt` if the expn chain contains only (semi-)opaques.
self.alloc_ctxt(parent_opaque_and_semiopaque, expn_id, transparency),
),
Transparency::Opaque => (
// Will be the same as `ctxt` if the expn chain contains only opaques.
self.alloc_ctxt(parent_opaque, expn_id, transparency),
// Will be the same as `ctxt` if the expn chain contains only (semi-)opaques.
self.alloc_ctxt(parent_opaque_and_semiopaque, expn_id, transparency),
),
};

I personally find the discussion that starts here interesting.

In the end, for me, it boils down to:

  • Doing this makes errors go away.
  • The same thing is done to a lot of other macros already.
  • We are making changes to an unstable feature and don't have to get everything perfect on the first try.

@jdonszelmann
Copy link
Contributor

jdonszelmann commented Jan 14, 2026

Yea, makes sense. Just wanted to understand what we were doing to it :3
Thanks for the explaination!

@jdonszelmann
Copy link
Contributor

@bors r+ rollup

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 14, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 14, 2026

📌 Commit 8a8b31a has been approved by jdonszelmann

It is now in the queue for this repository.

@rust-bors rust-bors bot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 14, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 14, 2026
compiler: Make Externally Implementable Item (eii) macros "semiopaque"

Otherwise eiis defined by std will produce large amounts of `missing stability attribute` errors. This problem is not eii specific, as can be seen in rust-lang#146993 and which is demonstrated in rust-lang#151022.

As can be seen with

```console
$ git grep rustc_macro_transparency
compiler/rustc_arena/src/lib.rs:#[rustc_macro_transparency = "semiopaque"]
[...]
```

it is very common for macros to use `"semiopaque"`.

r? @jdonszelmann

Tracking issue: rust-lang#125418

Needed for: rust-lang#150588
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 14, 2026
compiler: Make Externally Implementable Item (eii) macros "semiopaque"

Otherwise eiis defined by std will produce large amounts of `missing stability attribute` errors. This problem is not eii specific, as can be seen in rust-lang#146993 and which is demonstrated in rust-lang#151022.

As can be seen with

```console
$ git grep rustc_macro_transparency
compiler/rustc_arena/src/lib.rs:#[rustc_macro_transparency = "semiopaque"]
[...]
```

it is very common for macros to use `"semiopaque"`.

r? @jdonszelmann

Tracking issue: rust-lang#125418

Needed for: rust-lang#150588
rust-bors bot pushed a commit that referenced this pull request Jan 14, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #150585 (Add a context-consistency check before emitting redundant generic-argument suggestions)
 - #150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items)
 - #150590 (Don't try to recover keyword as non-keyword identifier )
 - #150817 (cleanup: remove borrowck handling for inline const patterns)
 - #150939 (resolve: Relax some asserts in glob overwriting and add tests)
 - #150966 (rustc_target: Remove unused Arch::PowerPC64LE)
 - #150971 (Disallow eii in statement position)
 - #151016 (fix: WASI threading regression by disabling pthread usage)
 - #151046 (compiler: Make Externally Implementable Item (eii) macros "semiopaque")
 - #151103 (mir_build: Simplify length-determination and indexing for array/slice patterns)
 - #151117 (Avoid serde dependency in build_helper when not necessary)
 - #151127 (Delete `MetaItemOrLitParser::Err`)

r? @ghost
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 14, 2026
compiler: Make Externally Implementable Item (eii) macros "semiopaque"

Otherwise eiis defined by std will produce large amounts of `missing stability attribute` errors. This problem is not eii specific, as can be seen in rust-lang#146993 and which is demonstrated in rust-lang#151022.

As can be seen with

```console
$ git grep rustc_macro_transparency
compiler/rustc_arena/src/lib.rs:#[rustc_macro_transparency = "semiopaque"]
[...]
```

it is very common for macros to use `"semiopaque"`.

r? @jdonszelmann

Tracking issue: rust-lang#125418

Needed for: rust-lang#150588
rust-bors bot pushed a commit that referenced this pull request Jan 14, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - #150585 (Add a context-consistency check before emitting redundant generic-argument suggestions)
 - #150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items)
 - #150590 (Don't try to recover keyword as non-keyword identifier )
 - #150817 (cleanup: remove borrowck handling for inline const patterns)
 - #150939 (resolve: Relax some asserts in glob overwriting and add tests)
 - #150962 (Remove `FeedConstTy` and provide ty when lowering const arg)
 - #150966 (rustc_target: Remove unused Arch::PowerPC64LE)
 - #150971 (Disallow eii in statement position)
 - #151016 (fix: WASI threading regression by disabling pthread usage)
 - #151046 (compiler: Make Externally Implementable Item (eii) macros "semiopaque")
 - #151099 (Recover parse gracefully from `<const N>`)
 - #151117 (Avoid serde dependency in build_helper when not necessary)
 - #151127 (Delete `MetaItemOrLitParser::Err`)
 - #151128 (Add temporary new bors e-mail address to the mailmap)
 - #151130 (resolve: Downgrade `ambiguous_glob_imports` to warn-by-default)
 - #151138 (Rename `rust.use-lld` to `rust.bootstrap-override-lld` in INSTALL.md)

r? @ghost
rust-bors bot pushed a commit that referenced this pull request Jan 14, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #150585 (Add a context-consistency check before emitting redundant generic-argument suggestions)
 - #150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items)
 - #150590 (Don't try to recover keyword as non-keyword identifier )
 - #150817 (cleanup: remove borrowck handling for inline const patterns)
 - #150939 (resolve: Relax some asserts in glob overwriting and add tests)
 - #150962 (Remove `FeedConstTy` and provide ty when lowering const arg)
 - #150966 (rustc_target: Remove unused Arch::PowerPC64LE)
 - #150971 (Disallow eii in statement position)
 - #151016 (fix: WASI threading regression by disabling pthread usage)
 - #151046 (compiler: Make Externally Implementable Item (eii) macros "semiopaque")
 - #151099 (Recover parse gracefully from `<const N>`)
 - #151117 (Avoid serde dependency in build_helper when not necessary)
 - #151127 (Delete `MetaItemOrLitParser::Err`)
 - #151128 (Add temporary new bors e-mail address to the mailmap)
 - #151138 (Rename `rust.use-lld` to `rust.bootstrap-override-lld` in INSTALL.md)

r? @ghost
@rust-bors rust-bors bot merged commit daae660 into rust-lang:main Jan 15, 2026
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 15, 2026
rust-timer added a commit that referenced this pull request Jan 15, 2026
Rollup merge of #151046 - semiopaque-eii-fix, r=jdonszelmann

compiler: Make Externally Implementable Item (eii) macros "semiopaque"

Otherwise eiis defined by std will produce large amounts of `missing stability attribute` errors. This problem is not eii specific, as can be seen in #146993 and which is demonstrated in #151022.

As can be seen with

```console
$ git grep rustc_macro_transparency
compiler/rustc_arena/src/lib.rs:#[rustc_macro_transparency = "semiopaque"]
[...]
```

it is very common for macros to use `"semiopaque"`.

r? @jdonszelmann

Tracking issue: #125418

Needed for: #150588
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 15, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#150585 (Add a context-consistency check before emitting redundant generic-argument suggestions)
 - rust-lang/rust#150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items)
 - rust-lang/rust#150590 (Don't try to recover keyword as non-keyword identifier )
 - rust-lang/rust#150817 (cleanup: remove borrowck handling for inline const patterns)
 - rust-lang/rust#150939 (resolve: Relax some asserts in glob overwriting and add tests)
 - rust-lang/rust#150962 (Remove `FeedConstTy` and provide ty when lowering const arg)
 - rust-lang/rust#150966 (rustc_target: Remove unused Arch::PowerPC64LE)
 - rust-lang/rust#150971 (Disallow eii in statement position)
 - rust-lang/rust#151016 (fix: WASI threading regression by disabling pthread usage)
 - rust-lang/rust#151046 (compiler: Make Externally Implementable Item (eii) macros "semiopaque")
 - rust-lang/rust#151099 (Recover parse gracefully from `<const N>`)
 - rust-lang/rust#151117 (Avoid serde dependency in build_helper when not necessary)
 - rust-lang/rust#151127 (Delete `MetaItemOrLitParser::Err`)
 - rust-lang/rust#151128 (Add temporary new bors e-mail address to the mailmap)
 - rust-lang/rust#151138 (Rename `rust.use-lld` to `rust.bootstrap-override-lld` in INSTALL.md)

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-extern_item_impls `#![feature(extern_item_impls)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants