about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-24 00:21:00 +0000
committerbors <bors@rust-lang.org>2019-05-24 00:21:00 +0000
commitfd8e23c6b2902299cb76e89d868fbb84f48035ab (patch)
tree923ca6815de27674d8c5767f691c072eb369c74b /src/libsyntax/parse/parser.rs
parent8869ee03d7f258e1b76a11c6fbb01b5708a9f504 (diff)
parent92fda925e3c945dccb1e5b6c3f662bfd9aadedc3 (diff)
downloadrust-fd8e23c6b2902299cb76e89d868fbb84f48035ab.tar.gz
rust-fd8e23c6b2902299cb76e89d868fbb84f48035ab.zip
Auto merge of #61105 - Centril:rollup-t9lemjf, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #59545 (Use arenas to avoid Lrc in queries #2)
 - #61054 (Suggest dereferencing on assignment to mutable borrow)
 - #61056 (tweak discriminant on non-nullary enum diagnostic)
 - #61082 (fix dangling reference in Vec::append)
 - #61086 (Box::into_unique: do the reborrow-to-raw *after* destroying the Box)
 - #61098 (Fix overflowing literal lint in loops)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index ae3665c834b..df801515082 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -7466,7 +7466,6 @@ impl<'a> Parser<'a> {
     /// Parses the part of an enum declaration following the `{`.
     fn parse_enum_def(&mut self, _generics: &ast::Generics) -> PResult<'a, EnumDef> {
         let mut variants = Vec::new();
-        let mut all_nullary = true;
         let mut any_disr = vec![];
         while self.token != token::CloseDelim(token::Brace) {
             let variant_attrs = self.parse_outer_attributes()?;
@@ -7478,11 +7477,9 @@ impl<'a> Parser<'a> {
             let ident = self.parse_ident()?;
             if self.check(&token::OpenDelim(token::Brace)) {
                 // Parse a struct variant.
-                all_nullary = false;
                 let (fields, recovered) = self.parse_record_struct_body()?;
                 struct_def = VariantData::Struct(fields, recovered);
             } else if self.check(&token::OpenDelim(token::Paren)) {
-                all_nullary = false;
                 struct_def = VariantData::Tuple(
                     self.parse_tuple_struct_body()?,
                     ast::DUMMY_NODE_ID,
@@ -7526,16 +7523,7 @@ impl<'a> Parser<'a> {
             }
         }
         self.expect(&token::CloseDelim(token::Brace))?;
-        if !any_disr.is_empty() && !all_nullary {
-            let mut err = self.struct_span_err(
-                any_disr.clone(),
-                "discriminator values can only be used with a field-less enum",
-            );
-            for sp in any_disr {
-                err.span_label(sp, "only valid in field-less enums");
-            }
-            err.emit();
-        }
+        self.maybe_report_invalid_custom_discriminants(any_disr, &variants);
 
         Ok(ast::EnumDef { variants })
     }