Skip to content

Rollup of 9 pull requests #35639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1403df7
Implement From for Cell, RefCell and UnsafeCell
malbarbo Aug 5, 2016
6ca9094
Add --test-threads option to test binaries
jupp0r Aug 6, 2016
9d6fa40
Add regression test for #22894.
frewsxcv Aug 8, 2016
6bc494b
Proc_macro is alive
cgswords Aug 4, 2016
16cc8a7
Implemented a smarter concatenation system that will hopefully produc…
cgswords Aug 2, 2016
045c8c8
std: Optimize panic::catch_unwind slightly
alexcrichton Jul 9, 2016
d77a136
add SetDiscriminant StatementKind to enable deaggregation of enums
scottcarr Aug 4, 2016
d099e30
Introduce `as_slice` method on `std::vec::IntoIter` struct.
frewsxcv Aug 7, 2016
01a766e
Introduce `as_mut_slice` method on `std::vec::IntoIter` struct.
frewsxcv Aug 7, 2016
f76a737
Correct span for pub_restricted field
sanxiyn Aug 8, 2016
ad247ce
Rollup merge of #35348 - scottcarr:discriminant2, r=nikomatsakis
Manishearth Aug 13, 2016
7e2fa43
Rollup merge of #35392 - malbarbo:cell-from, r=brson
Manishearth Aug 13, 2016
c105a05
Rollup merge of #35414 - jupp0r:feature/test-threads-flag, r=alexcric…
Manishearth Aug 13, 2016
78cbbd4
Rollup merge of #35444 - alexcrichton:optimize-catch-unwind, r=brson
Manishearth Aug 13, 2016
d1e286a
Rollup merge of #35447 - frewsxcv:vec-into-iter-as-slice, r=alexcrichton
Manishearth Aug 13, 2016
6e59f49
Rollup merge of #35491 - sanxiyn:pub-restricted-span, r=nikomatsakis
Manishearth Aug 13, 2016
b61adfb
Rollup merge of #35533 - frewsxcv:22984, r=brson
Manishearth Aug 13, 2016
3a86773
Rollup merge of #35538 - cgswords:libproc_macro, r=nrc
Manishearth Aug 13, 2016
cbed977
Rollup merge of #35539 - cgswords:ts_concat, r=nrc
Manishearth Aug 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand All @@ -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)`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,23 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Regression test for issue #26083
// Test that span for public struct fields start at `pub` instead of the identifier
// Regression test for issue #26083 and #35435
// Test that span for public struct fields start at `pub`

struct Foo {
pub bar: u8,
#![feature(pub_restricted)]

pub
//~^ error: field `bar` is already declared [E0124]
struct Foo {
bar: u8,

pub bar:
//~^ error: field `bar` is already declared [E0124]
u8,

bar:
//~^ error: field `bar` is already declared [E0124]
u8,
pub bar: u8,
pub(crate) bar: u8,
}

fn main() { }
fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/span/pub-struct-field.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0124]: field `bar` is already declared
--> $DIR/pub-struct-field.rs:18:5
|
17 | bar: u8,
| ------- `bar` first declared here
18 | pub bar: u8,
| ^^^^^^^^^^^ field already declared

error[E0124]: field `bar` is already declared
--> $DIR/pub-struct-field.rs:19:5
|
17 | bar: u8,
| ------- `bar` first declared here
18 | pub bar: u8,
19 | pub(crate) bar: u8,
| ^^^^^^^^^^^^^^^^^^ field already declared

error: aborting due to 2 previous errors