Skip to content
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

(internal compiler error: unprintable span) #25385

Closed
bytwise opened this issue May 13, 2015 · 0 comments
Closed

(internal compiler error: unprintable span) #25385

bytwise opened this issue May 13, 2015 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@bytwise
Copy link
Contributor

bytwise commented May 13, 2015

code

macro_rules! foo {
    ($e:expr) => { $e.foo() }
}

fn main() {
    let (a,) = 1i32.foo();
    foo!(a);
}

output

main.rs:6:21: 6:26 error: type `i32` does not implement any method in scope named `foo`
main.rs:6     let (a,) = 1i32.foo();
                              ^~~~~
main.rs:7:10: 2:28 error: the type of this value must be known in this context
(internal compiler error: unprintable span)
main.rs:1:1: 3:2 note: in expansion of foo!
main.rs:7:5: 7:13 note: expansion site
error: aborting due to 2 previous errors

rustc version

rustc 1.1.0-nightly (c2b30b86d 2015-05-12) (built 2015-05-12)
binary: rustc
commit-hash: c2b30b86df6b34ba19e87e63402e43d9e81a64fb
commit-date: 2015-05-12
build-date: 2015-05-12
host: x86_64-apple-darwin
release: 1.1.0-nightly
@sfackler sfackler added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-diagnostics Area: Messages for errors, warnings, and lints labels May 14, 2015
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.
@bors bors closed this as completed in b285ebc Jan 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants