You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use nom::{IResult, not_line_ending, line_ending};fncsv_line(input:&[u8]) -> IResult<&[u8],Vec<&[u8]>>{terminated!(input, separated_list!(filter!(apply!(check_characters, b"\n\r,")), not_line_ending), line_ending)}fncheck_characters(data:&[u8],characters:&[u8]) -> bool{for i in0..data.len(){for c in characters {if data[i] == *c {returnfalse;}}}true}#[test]fncheck_file(){let f = b"nom,age\ncarles,30\nlaure,28";csv_line(f);}
which gives the following error (and ICE):
<nom macros>:15:56: 5:48 error: mismatched types:
expected `&[u8]`,
found `u8`
(expected &-ptr,
found u8) [E0308]
(internal compiler error: unprintable span)
<nom macros>:1:1: 13:71 note: in expansion of apply!<nom macros>:5:20: 5:67 note: expansion site
note: in expansion of for loop expansion
<nom macros>:3:45: 6:27 note: expansion site
<nom macros>:1:1: 12:79 note: in expansion of filter!<nom macros>:15:46: 16:2 note: expansion site
note: in expansion of iflet expansion
<nom macros>:15:1: 20:43 note: expansion site
<nom macros>:1:1: 27:65 note: in expansion of separated_list!<nom macros>:23:1: 23:74 note: expansion site
<nom macros>:1:1: 27:65 note: in expansion of separated_list!<nom macros>:5:7: 5:42 note: expansion site
<nom macros>:1:1: 18:61 note: in expansion of terminated!<nom macros>:14:6: 14:75 note: expansion site
<nom macros>:1:1: 18:61 note: in expansion of terminated!
src/parser.rs:4:2: 4:112 note: expansion site
<nom macros>:15:56: 5:48 help: run `rustc --explain E0308` to see a detailed explanation
<nom macros>:15:56: 5:48 error: mismatched types:
expected `&[u8]`,
found `u8`
(expected &-ptr,
found u8) [E0308]
(internal compiler error: unprintable span)
<nom macros>:1:1: 13:71 note: in expansion of apply!<nom macros>:5:20: 5:67 note: expansion site
note: in expansion of for loop expansion
<nom macros>:3:45: 6:27 note: expansion site
<nom macros>:1:1: 12:79 note: in expansion of filter!<nom macros>:15:46: 16:2 note: expansion site
note: in expansion of iflet expansion
<nom macros>:15:1: 20:43 note: expansion site
<nom macros>:1:1: 27:65 note: in expansion of separated_list!<nom macros>:23:1: 23:74 note: expansion site
<nom macros>:1:1: 27:65 note: in expansion of separated_list!<nom macros>:5:7: 5:42 note: expansion site
<nom macros>:1:1: 18:61 note: in expansion of terminated!<nom macros>:14:6: 14:75 note: expansion site
<nom macros>:1:1: 18:61 note: in expansion of terminated!
src/parser.rs:4:2: 4:112 note: expansion site
<nom macros>:15:56: 5:48 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error
error: aborting due to previous error
I have the following rustc version:
rustc 1.4.0-nightly (f6aac8037 2015-09-06)
The text was updated successfully, but these errors were encountered:
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.
The following code:
which gives the following error (and ICE):
I have the following rustc version:
The text was updated successfully, but these errors were encountered: