rust/src/librustc
bors 40fc8ba5f9 Auto merge of #53902 - dtolnay:group, r=petrochenkov
proc_macro::Group::span_open and span_close

Before this addition, every delimited group like `(`...`)` `[`...`]` `{`...`}` has only a single Span that covers the full source location from opening delimiter to closing delimiter. This makes it impossible for a procedural macro to trigger an error pointing to just the opening or closing delimiter. The Rust compiler does not seem to have the same limitation:

```rust
mod m {
    type T =
}
```

```console
error: expected type, found `}`
 --> src/main.rs:3:1
  |
3 | }
  | ^
```

On that same input, a procedural macro would be forced to trigger the error on the last token inside the block, on the entire block, or on the next token after the block, none of which is really what you want for an error like above.

This commit adds `group.span_open()` and `group.span_close()` which access the Span associated with just the opening delimiter and just the closing delimiter of the group. Relevant to Syn as we implement real error messages for when parsing fails in a procedural macro: https://github.com/dtolnay/syn/issues/476.

```diff
  impl Group {
      fn span(&self) -> Span;
+     fn span_open(&self) -> Span;
+     fn span_close(&self) -> Span;
  }
```

Fixes #48187
r? @alexcrichton
2018-09-09 13:27:44 +00:00
..
benches
cfg introduce Guard enum 2018-08-30 12:18:11 +08:00
dep_graph Rollup merge of #53315 - nikomatsakis:newtype-index, r=Mark-Simulacrum 2018-09-08 18:28:13 +08:00
hir rewrite constants to use NewType::MAX instead of u32::MAX 2018-09-07 11:37:47 -04:00
ich Auto merge of #53902 - dtolnay:group, r=petrochenkov 2018-09-09 13:27:44 +00:00
infer Auto merge of #53705 - ms2300:tmp, r=oli-obk 2018-09-08 14:16:37 +00:00
lint deprcated -> deprecated 2018-09-01 21:45:44 +05:30
middle Rollup merge of #53315 - nikomatsakis:newtype-index, r=Mark-Simulacrum 2018-09-08 18:28:13 +08:00
mir Auto merge of #53909 - mikhail-m1:53643, r=nikomatsakis 2018-09-08 19:57:14 +00:00
session Rollup merge of #54007 - japaric:gh53964, r=cramertj 2018-09-08 18:26:59 +08:00
traits Changing TyAnon -> TyOpaque and relevant functions 2018-09-05 13:01:16 -06:00
ty Auto merge of #53903 - GabrielMajeri:opt-miri-array-slice, r=oli-obk 2018-09-08 17:36:09 +00:00
util Auto merge of #53705 - ms2300:tmp, r=oli-obk 2018-09-08 14:16:37 +00:00
build.rs
Cargo.toml Breaking change upgrades 2018-09-04 13:22:08 -06:00
diagnostics.rs Convert unknown_features lint into an error 2018-08-05 15:54:49 +01:00
lib.rs Restrict most uses of const_fn to min_const_fn 2018-08-31 08:40:00 +02:00
macros.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
README.md

For more information about how rustc works, see the rustc guide.