diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-08-14 20:29:48 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-14 20:29:48 +0300 |
| commit | c35d8dba7f3594458023fe2afa08d155c8a490b9 (patch) | |
| tree | 48e2dd9c2e6f3fefdc8b6968c635c10dfbaf962d /src/libsyntax/parse | |
| parent | 6d8af8cf5de41d2bdc88c84bf9461b12e76194f9 (diff) | |
| parent | f76a737bae12788ba6180c13ec5fcba9177d80d4 (diff) | |
| download | rust-c35d8dba7f3594458023fe2afa08d155c8a490b9.tar.gz rust-c35d8dba7f3594458023fe2afa08d155c8a490b9.zip | |
Rollup merge of #35491 - sanxiyn:pub-restricted-span, r=nikomatsakis
Correct span for pub_restricted field Fix #35435.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4c279b2fe48..e174f3ad08d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3788,19 +3788,18 @@ impl<'a> Parser<'a> { } /// Parse a structure field - fn parse_name_and_ty(&mut self, pr: Visibility, - attrs: Vec<Attribute> ) -> PResult<'a, StructField> { - let lo = match pr { - Visibility::Inherited => self.span.lo, - _ => self.last_span.lo, - }; + fn parse_name_and_ty(&mut self, + lo: BytePos, + vis: Visibility, + attrs: Vec<Attribute>) + -> PResult<'a, StructField> { let name = self.parse_ident()?; self.expect(&token::Colon)?; let ty = self.parse_ty_sum()?; Ok(StructField { span: mk_sp(lo, self.last_span.hi), ident: Some(name), - vis: pr, + vis: vis, id: ast::DUMMY_NODE_ID, ty: ty, attrs: attrs, @@ -5120,10 +5119,11 @@ impl<'a> Parser<'a> { /// Parse a structure field declaration pub fn parse_single_struct_field(&mut self, + lo: BytePos, vis: Visibility, attrs: Vec<Attribute> ) -> PResult<'a, StructField> { - let a_var = self.parse_name_and_ty(vis, attrs)?; + let a_var = self.parse_name_and_ty(lo, vis, attrs)?; match self.token { token::Comma => { self.bump(); @@ -5144,8 +5144,9 @@ impl<'a> Parser<'a> { /// Parse an element of a struct definition fn parse_struct_decl_field(&mut self) -> PResult<'a, StructField> { let attrs = self.parse_outer_attributes()?; + let lo = self.span.lo; let vis = self.parse_visibility(true)?; - self.parse_single_struct_field(vis, attrs) + self.parse_single_struct_field(lo, vis, attrs) } // If `allow_path` is false, just parse the `pub` in `pub(path)` (but still parse `pub(crate)`) |
