about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2018-11-23 14:09:08 -0500
committerGitHub <noreply@github.com>2018-11-23 14:09:08 -0500
commitebb1a48b415c1b586bb652d58f3d2078d87f44dd (patch)
treef7338faaa66791a15338a938f6a2bf94107de0d1 /src/libsyntax
parent033cbfec4d3bb23948a99379f8d63b7cfe5eed45 (diff)
parent821bad3a5b13862e9fbfae35b446ab91a976a75e (diff)
downloadrust-ebb1a48b415c1b586bb652d58f3d2078d87f44dd.tar.gz
rust-ebb1a48b415c1b586bb652d58f3d2078d87f44dd.zip
Merge branch 'master' into frewsxcv-dyn
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/feature_gate.rs5
-rw-r--r--src/libsyntax/parse/parser.rs15
2 files changed, 15 insertions, 5 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index a7c97feee49..2f5db9bd081 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -499,9 +499,6 @@ declare_features! (
     // Allows `const _: TYPE = VALUE`
     (active, underscore_const_names, "1.31.0", Some(54912), None),
 
-    // `extern crate foo as bar;` puts `bar` into extern prelude.
-    (active, extern_crate_item_prelude, "1.31.0", Some(55599), None),
-
     // `reason = ` in lint attributes and `expect` lint attribute
     (active, lint_reasons, "1.31.0", Some(54503), None),
 );
@@ -691,6 +688,8 @@ declare_features! (
     // impl<I:Iterator> Iterator for &mut Iterator
     // impl Debug for Foo<'_>
     (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
+    // `extern crate foo as bar;` puts `bar` into extern prelude.
+    (accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None),
 );
 
 // If you change this, please modify src/doc/unstable-book as well. You must
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index b4fc9c2c6fc..e2f09affd4f 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1824,6 +1824,14 @@ impl<'a> Parser<'a> {
     fn parse_arg_general(&mut self, require_name: bool) -> PResult<'a, Arg> {
         maybe_whole!(self, NtArg, |x| x);
 
+        if let Ok(Some(_)) = self.parse_self_arg() {
+            let mut err = self.struct_span_err(self.prev_span,
+                "unexpected `self` argument in function");
+            err.span_label(self.prev_span,
+                "`self` is only valid as the first argument of an associated function");
+            return Err(err);
+        }
+
         let (pat, ty) = if require_name || self.is_named_argument() {
             debug!("parse_arg_general parse_pat (require_name:{})",
                    require_name);
@@ -5385,11 +5393,12 @@ impl<'a> Parser<'a> {
 
     fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
                      -> PResult<'a, (Vec<Arg> , bool)> {
+        self.expect(&token::OpenDelim(token::Paren))?;
+
         let sp = self.span;
         let mut variadic = false;
         let args: Vec<Option<Arg>> =
-            self.parse_unspanned_seq(
-                &token::OpenDelim(token::Paren),
+            self.parse_seq_to_before_end(
                 &token::CloseDelim(token::Paren),
                 SeqSep::trailing_allowed(token::Comma),
                 |p| {
@@ -5436,6 +5445,8 @@ impl<'a> Parser<'a> {
                 }
             )?;
 
+        self.eat(&token::CloseDelim(token::Paren));
+
         let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
 
         if variadic && args.is_empty() {