]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #31089 - fhahn:macro-ice, r=pnkfelix
authorbors <bors@rust-lang.org>
Wed, 27 Jan 2016 12:12:52 +0000 (12:12 +0000)
committerbors <bors@rust-lang.org>
Wed, 27 Jan 2016 12:12:52 +0000 (12:12 +0000)
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.

1  2 
src/libsyntax/parse/parser.rs

Simple merge