about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authormoe <35686186+csmoe@users.noreply.github.com>2018-02-17 22:22:26 +0800
committerGitHub <noreply@github.com>2018-02-17 22:22:26 +0800
commit2cf683edc0c0481906749517cbefe631f7ed79d9 (patch)
tree8d2e8a91d176ed9193747a0d85f91b57d3c13ddb /src/libsyntax
parent0be2dc8d9b4765e59cf9bbf3d342de00fa1b9aec (diff)
parentb85bd51c944f8cbe3a9c4cc95b61e08e5f338052 (diff)
downloadrust-2cf683edc0c0481906749517cbefe631f7ed79d9.tar.gz
rust-2cf683edc0c0481906749517cbefe631f7ed79d9.zip
Merge branch 'master' into inform_type_annotations
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/codemap.rs8
-rw-r--r--src/libsyntax/feature_gate.rs2
-rw-r--r--src/libsyntax/parse/parser.rs21
3 files changed, 22 insertions, 9 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 3601b9ba8a8..ff6f32fc3be 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -690,14 +690,16 @@ impl CodeMap {
             return 1;
         }
 
+        let src = local_begin.fm.external_src.borrow();
+
         // We need to extend the snippet to the end of the src rather than to end_index so when
         // searching forwards for boundaries we've got somewhere to search.
         let snippet = if let Some(ref src) = local_begin.fm.src {
             let len = src.len();
-            (&src[start_index..len]).to_string()
-        } else if let Some(src) = local_begin.fm.external_src.borrow().get_source() {
+            (&src[start_index..len])
+        } else if let Some(src) = src.get_source() {
             let len = src.len();
-            (&src[start_index..len]).to_string()
+            (&src[start_index..len])
         } else {
             return 1;
         };
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index ea916d5168c..3b137f9570a 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -541,7 +541,7 @@ declare_features! (
     // instead of just the platforms on which it is the C ABI
     (accepted, abi_sysv64, "1.24.0", Some(36167)),
     // Allows `repr(align(16))` struct attribute (RFC 1358)
-    (accepted, repr_align, "1.24.0", Some(33626)),
+    (accepted, repr_align, "1.25.0", Some(33626)),
     // allow '|' at beginning of match arms (RFC 1925)
     (accepted, match_beginning_vert, "1.25.0", Some(44101)),
     // Nested groups in `use` (RFC 2128)
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index dc3745fc4a3..ac582627f88 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4859,19 +4859,30 @@ impl<'a> Parser<'a> {
                 |p| {
                     if p.token == token::DotDotDot {
                         p.bump();
+                        variadic = true;
                         if allow_variadic {
                             if p.token != token::CloseDelim(token::Paren) {
                                 let span = p.span;
                                 p.span_err(span,
                                     "`...` must be last in argument list for variadic function");
                             }
+                            Ok(None)
                         } else {
-                            let span = p.span;
-                            p.span_err(span,
-                                       "only foreign functions are allowed to be variadic");
+                            let span = p.prev_span;
+                            if p.token == token::CloseDelim(token::Paren) {
+                                // continue parsing to present any further errors
+                                p.struct_span_err(
+                                    span,
+                                    "only foreign functions are allowed to be variadic"
+                                ).emit();
+                                Ok(Some(dummy_arg(span)))
+                           } else {
+                               // this function definition looks beyond recovery, stop parsing
+                                p.span_err(span,
+                                           "only foreign functions are allowed to be variadic");
+                                Ok(None)
+                            }
                         }
-                        variadic = true;
-                        Ok(None)
                     } else {
                         match p.parse_arg_general(named_args) {
                             Ok(arg) => Ok(Some(arg)),