-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #8667 - Jarcho:proc_macro_check, r=flip1995
Don't lint various match lints when expanded by a proc-macro fixes #4952 As always for proc-macro output this is a hack-job of a fix. It would be really nice if more proc-macro authors would set spans correctly. changelog: Don't lint various lints on proc-macro output.
- Loading branch information
Showing
5 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// compile-flags: --emit=link | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::{token_stream::IntoIter, Group, Span, TokenStream, TokenTree}; | ||
|
||
#[proc_macro] | ||
pub fn with_span(input: TokenStream) -> TokenStream { | ||
let mut iter = input.into_iter(); | ||
let span = iter.next().unwrap().span(); | ||
let mut res = TokenStream::new(); | ||
write_with_span(span, iter, &mut res); | ||
res | ||
} | ||
|
||
fn write_with_span(s: Span, input: IntoIter, out: &mut TokenStream) { | ||
for mut tt in input { | ||
if let TokenTree::Group(g) = tt { | ||
let mut stream = TokenStream::new(); | ||
write_with_span(s, g.stream().into_iter(), &mut stream); | ||
let mut group = Group::new(g.delimiter(), stream); | ||
group.set_span(s); | ||
out.extend([TokenTree::Group(group)]); | ||
} else { | ||
tt.set_span(s); | ||
out.extend([tt]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters