-
Notifications
You must be signed in to change notification settings - Fork 13.4k
ICE: called Option::unwrap()
on a None
value in when using proc macro
#141764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
A-proc-macros
Area: Procedural macros
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
regression-from-stable-to-beta
Performance or correctness regression from stable to beta.
S-has-bisection
Status: A bisection has been found for this issue
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
bisects to #140580 cc @jdonszelmann |
simpler: //main.rs
a::ice! {} and //lib.rs
#[macro_export]
macro_rules! ice {
() => {
fn main() {
let d = &mut 0;
let c = || *d += 1;
c();
}
};
} @rustbot label S-has-mcve S-has-bisection |
Oops, I'll take a look. @rustbot claim |
alright, on it |
jdonszelmann
added a commit
to jdonszelmann/rust
that referenced
this issue
Jun 2, 2025
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this issue
Jun 3, 2025
Fix borrowck mentioning a name from an external macro we (deliberately) don't save Most of the info is already in the title 🤷 Closes rust-lang#141764
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this issue
Jun 3, 2025
Fix borrowck mentioning a name from an external macro we (deliberately) don't save Most of the info is already in the title 🤷 Closes rust-lang#141764
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-proc-macros
Area: Procedural macros
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
regression-from-stable-to-beta
Performance or correctness regression from stable to beta.
S-has-bisection
Status: A bisection has been found for this issue
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I encountered an ICE while writing a proc-macro. The idea is to wrap the content of a function with the attribute on it in a closure and then call it. (The real code does some extra steps but those are not important here).
This looks like the following in
quote!
:The problem is the missing
mut
when the original function mutates any of its arguments.It works without problems for functions that do not mutate their arguments.
When the code produced by the proc-macro is inlined by hand the compiler correctly identifies the missing
mut
and works as expected.Code
I uploaded my reproduction on https://github.com/FrTerstappen/rust-ice-20250530
Cargo.toml
ice_test/Cargo.toml
ice_test/src/main.rs
ice_proc_macro/Cargo.toml
ice_proc_macro/src/lib.rs
Meta
rustc --version --verbose
:Error output
Backtrace
rustc-ice-2025-05-30T11_13_14-190503.txt
The text was updated successfully, but these errors were encountered: