Closed
Description
This is a subissue of #43081 but likely fixable without fixing #43081 in full generality.
src/lib.rs
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn repro(_args: TokenStream, input: TokenStream) -> TokenStream {
println!("{:#?}", input);
input.into_iter().collect()
}
src/main.rs
#[repro::repro]
fn repro() {
f :: < Vec < _ > > ( ) ;
}
fn main() {}
When running cargo check
, notice that all the spans in the output are #0 bytes(0..0)
(classic #43081) and therefore all error reporting within the function body is broken; there is no line number on the "cannot find function `f` in this scope" error.
The following script reproduces the issue as of rustc 1.42.0-nightly (d1e594f 2020-01-22):
#!/bin/bash
cargo new repro
echo >>repro/Cargo.toml '
[lib]
proc-macro = true
'
echo >repro/src/lib.rs '
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn repro(_args: TokenStream, input: TokenStream) -> TokenStream {
println!("{:#?}", input);
TokenStream::new()
}
'
echo >repro/src/main.rs '
#[repro::repro]
fn repro() {
f :: < Vec < _ > > ( ) ;
}
fn main() {}
'
cargo +nightly check --manifest-path repro/Cargo.toml
cc @petrochenkov who fixed a previous special case of #43081.