-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
ICE: "unprintable span" with macro and two files, no backtrace #29084
Labels
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Comments
steveklabnik
added
the
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
label
Oct 29, 2015
The following code also has the same problem: fn main() {
macro_rules! call_mut {
($e:expr, $i:expr) => {
$e.call_mut()
};
($e:expr, $i:expr, $($is:expr),+) => {
call_mut!($e.call(), $($is),+)
// ^ this is the problem, it should be call_mut
};
}
struct S;
impl S {
fn call(&self) -> &S { self }
fn call_mut(&mut self) -> &mut S { self }
}
let mut s = S;
let mut s2: &mut S = call_mut!(s, 1, 2);
} which gives the following output on https://play.rust-lang.org/ (this is the same on stable, beta, and nightly):
|
fhahn
added a commit
to fhahn/rust
that referenced
this issue
Jan 26, 2016
closes rust-lang#29084 closes rust-lang#28308 closes rust-lang#25385 closes rust-lang#28288 closes rust-lang#31011 closes rust-lang#26480 closes rust-lang#26093 closes rust-lang#26094 closes rust-lang#25386 closes rust-lang#26237 closes rust-lang#25793
bors
added a commit
that referenced
this issue
Jan 27, 2016
This is a work in progress PR that potentially should fix #29084, #28308, #25385, #28288, #31011. I think this may also adresse parts of #2887. The problem in this issues seems to be that when transcribing macro arguments, we just clone the argument Nonterminal, which still has to original spans. This leads to the unprintable spans. One solution would be to update the spans of the inserted argument to match the argument in the macro definition. So for [this testcase](https://github.com/rust-lang/rust/compare/master...fhahn:macro-ice?expand=1#diff-f7def7420c51621640707b6337726876R2) the error message would be displayed in the macro definition: src/test/compile-fail/issue-31011.rs:4:12: 4:22 error: attempted access of field `trace` on type `&T`, but no field with that name was found src/test/compile-fail/issue-31011.rs:4 if $ctx.trace { Currently I've added a very simple `update_span` function, which updates the span of the outer-most expression of a `NtExpr`, but this `update_span` function should be updated to handle all Nonterminals. But I'm pretty new to the macro system and would like to check if this approach makes sense, before doing that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiling the following two files results in an ICE without a backtrace:
Compiled with the command:
rustc lib.rs --crate-type lib
Results in the following output:
I could not reproduce it when module
m
is inlined inlib.rs
.Same result on stable, beta and nightly:
The text was updated successfully, but these errors were encountered: