1
Fork 0
rust/compiler/rustc_expand/src
Aaron Hill 6c14aad58e
Improve handling of spans around macro result parse errors
Fixes #81543

After we expand a macro, we try to parse the resulting tokens as a AST
node. This commit makes several improvements to how we handle spans when
an error occurs:

* Only ovewrite the original `Span` if it's a dummy span. This preserves
  a more-specific span if one is available.
* Use `self.prev_token` instead of `self.token` when emitting an error
  message after encountering EOF, since an EOF token always has a dummy
  span
* Make `SourceMap::next_point` leave dummy spans unused. A dummy span
  does not have a logical 'next point', since it's a zero-length span.
  Re-using the span span preserves its 'dummy-ness' for other checks
2021-01-31 15:24:34 -05:00
..
mbe Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS lint 2021-01-28 08:51:43 -05:00
mut_visit rustc_ast: visit_mac -> visit_mac_call 2020-11-03 23:39:51 +03:00
parse Force token collection to run when parsing nonterminals 2021-01-20 18:09:32 -05:00
tokenstream mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
base.rs Make -Z time-passes less noisy 2021-01-23 11:44:46 -05:00
build.rs Properly handle attributes on statements 2020-11-26 17:08:35 -05:00
config.rs Use Option::map_or instead of .map(..).unwrap_or(..) 2021-01-14 19:23:59 +01:00
expand.rs Improve handling of spans around macro result parse errors 2021-01-31 15:24:34 -05:00
lib.rs Remove some no longer necessary #[cfg(test)]s 2020-12-12 19:20:37 +03:00
mbe.rs Revert "Promote missing_fragment_specifier to hard error" 2020-12-22 09:33:16 -05:00
module.rs Syntactically permit unsafety on mods 2020-09-10 06:56:33 -07:00
placeholders.rs resolve/expand: Improve attribute expansion on macro definitions and calls 2021-01-09 18:43:01 +03:00
proc_macro.rs Force token collection to run when parsing nonterminals 2021-01-20 18:09:32 -05:00
proc_macro_server.rs rustc_parse: Better spans for synthesized token streams 2021-01-07 17:48:13 +03:00
tests.rs remove redundant closures (clippy::redundant_closure) 2021-01-03 13:34:24 +01:00