diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-06-26 00:39:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-26 00:39:08 -0700 |
| commit | 7f6dfb451a1d71c0ffa39688cfdeb8f7500e11e1 (patch) | |
| tree | 8863f4350b86ca2d53e66c1b6fe538df3a903e0a /src/librustc_parse/parser | |
| parent | 81d2d3cf35127632927559c4eb78cfd17ff41c17 (diff) | |
| parent | 86f6c0e0861f4d223d00280107cd0b31b6ebb85b (diff) | |
| download | rust-7f6dfb451a1d71c0ffa39688cfdeb8f7500e11e1.tar.gz rust-7f6dfb451a1d71c0ffa39688cfdeb8f7500e11e1.zip | |
Rollup merge of #73597 - ayazhafiz:i/const-span, r=ecstatic-morse
Record span of `const` kw in GenericParamKind Context: this is needed for a fix of https://github.com/rust-lang/rustfmt/issues/4263, which currently records the span of a const generic param incorrectly because the location of the `const` kw is not known. I am not sure how to add tests for this; any guidance in how to do so would be appreciated :slightly_smiling_face:
Diffstat (limited to 'src/librustc_parse/parser')
| -rw-r--r-- | src/librustc_parse/parser/generics.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/librustc_parse/parser/generics.rs b/src/librustc_parse/parser/generics.rs index 04b64d93c70..47794746126 100644 --- a/src/librustc_parse/parser/generics.rs +++ b/src/librustc_parse/parser/generics.rs @@ -47,21 +47,21 @@ impl<'a> Parser<'a> { } fn parse_const_param(&mut self, preceding_attrs: Vec<Attribute>) -> PResult<'a, GenericParam> { - let lo = self.token.span; + let const_span = self.token.span; self.expect_keyword(kw::Const)?; let ident = self.parse_ident()?; self.expect(&token::Colon)?; let ty = self.parse_ty()?; - self.sess.gated_spans.gate(sym::const_generics, lo.to(self.prev_token.span)); + self.sess.gated_spans.gate(sym::const_generics, const_span.to(self.prev_token.span)); Ok(GenericParam { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs.into(), bounds: Vec::new(), - kind: GenericParamKind::Const { ty }, + kind: GenericParamKind::Const { ty, kw_span: const_span }, is_placeholder: false, }) } |
