forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#72026 - botika:master, r=estebank
Update annotate-snippets-rs to 0.8.0 rust-lang#59346 I made major changes to this library. In the previous version we worked with owned while in the current one with borrowed. I have adapted it without changing the behavior. I have modified the coverage since the previous one did not return correctly the index of the character in the line.
- Loading branch information
Showing
7 changed files
with
210 additions
and
128 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
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,37 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::{TokenStream, TokenTree, Span, Diagnostic}; | ||
|
||
fn parse(input: TokenStream) -> Result<(), Diagnostic> { | ||
let mut hi_spans = vec![]; | ||
for tree in input { | ||
if let TokenTree::Ident(ref ident) = tree { | ||
if ident.to_string() == "hi" { | ||
hi_spans.push(ident.span()); | ||
} | ||
} | ||
} | ||
|
||
if !hi_spans.is_empty() { | ||
return Err(Span::def_site() | ||
.error("hello to you, too!") | ||
.span_note(hi_spans, "found these 'hi's")); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
#[proc_macro] | ||
pub fn hello(input: TokenStream) -> TokenStream { | ||
if let Err(diag) = parse(input) { | ||
diag.emit(); | ||
} | ||
|
||
TokenStream::new() | ||
} |
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,28 @@ | ||
// aux-build:multispan.rs | ||
// compile-flags: --error-format human-annotate-rs | ||
|
||
#![feature(proc_macro_hygiene)] | ||
|
||
extern crate multispan; | ||
|
||
use multispan::hello; | ||
|
||
fn main() { | ||
// This one emits no error. | ||
hello!(); | ||
|
||
// Exactly one 'hi'. | ||
hello!(hi); //~ ERROR hello to you, too! | ||
|
||
// Now two, back to back. | ||
hello!(hi hi); //~ ERROR hello to you, too! | ||
|
||
// Now three, back to back. | ||
hello!(hi hi hi); //~ ERROR hello to you, too! | ||
|
||
// Now several, with spacing. | ||
hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! | ||
hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! | ||
hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! | ||
hello!(hi good hi and good bye); //~ ERROR hello to you, too! | ||
} |
Oops, something went wrong.