diff options
| author | bors <bors@rust-lang.org> | 2019-07-28 20:22:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-28 20:22:42 +0000 |
| commit | c7312fe4ff85ada30103cea58db25d83e0bec4b0 (patch) | |
| tree | c45aed285c4e04591ea7d6e8bc6c90b3461671a6 /src/libsyntax | |
| parent | 4560cb830fce63fcffdc4558f4281aaac6a3a1ba (diff) | |
| parent | 29c377882f545e24b9cc6e1198ee4f72c20d5449 (diff) | |
| download | rust-c7312fe4ff85ada30103cea58db25d83e0bec4b0.tar.gz rust-c7312fe4ff85ada30103cea58db25d83e0bec4b0.zip | |
Auto merge of #63090 - Centril:rollup-xnjwm2h, r=Centril
Rollup of 8 pull requests Successful merges: - #61856 (Lint attributes on function arguments) - #62360 (Document that ManuallyDrop::drop should not called more than once) - #62392 (Update minifier-rs version) - #62871 (Explicit error message for async recursion.) - #62995 (Avoid ICE when suggestion span is at Eof) - #63053 (SystemTime docs: recommend Instant for elapsed time) - #63081 (tidy: Cleanup the directory whitelist) - #63088 (Remove anonymous_parameters from unrelated test) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/mut_visit.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/parse/diagnostics.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 15 |
6 files changed, 23 insertions, 8 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a7453f4f9da..58a1c4aee9a 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1796,6 +1796,7 @@ pub struct Arg { pub ty: P<Ty>, pub pat: P<Pat>, pub id: NodeId, + pub span: Span, } /// Alternative representation for `Arg`s describing `self` parameter of methods. @@ -1854,6 +1855,7 @@ impl Arg { node: PatKind::Ident(BindingMode::ByValue(mutbl), eself_ident, None), span, }), + span, ty, id: DUMMY_NODE_ID, }; diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 528b27d6153..b30fefe5b96 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -966,6 +966,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { attrs: ThinVec::default(), id: ast::DUMMY_NODE_ID, pat: arg_pat, + span, ty, } } diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 86525406718..43b6bea69d9 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -558,10 +558,11 @@ pub fn noop_visit_meta_item<T: MutVisitor>(mi: &mut MetaItem, vis: &mut T) { vis.visit_span(span); } -pub fn noop_visit_arg<T: MutVisitor>(Arg { attrs, id, pat, ty }: &mut Arg, vis: &mut T) { +pub fn noop_visit_arg<T: MutVisitor>(Arg { attrs, id, pat, span, ty }: &mut Arg, vis: &mut T) { vis.visit_id(id); visit_thin_attrs(attrs, vis); vis.visit_pat(pat); + vis.visit_span(span); vis.visit_ty(ty); } diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index f4fc87506f3..39cb5042fbc 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -30,7 +30,7 @@ crate fn dummy_arg(ident: Ident) -> Arg { span: ident.span, id: ast::DUMMY_NODE_ID }; - Arg { attrs: ThinVec::default(), id: ast::DUMMY_NODE_ID, pat, ty: P(ty) } + Arg { attrs: ThinVec::default(), id: ast::DUMMY_NODE_ID, pat, span: ident.span, ty: P(ty) } } pub enum Error { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8f8ed411180..6cb965bf817 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1515,6 +1515,7 @@ impl<'a> Parser<'a> { where F: Fn(&token::Token) -> bool { + let lo = self.token.span; let attrs = self.parse_arg_attributes()?; if let Some(mut arg) = self.parse_self_arg()? { arg.attrs = attrs.into(); @@ -1578,11 +1579,14 @@ impl<'a> Parser<'a> { } }; - Ok(Arg { attrs: attrs.into(), id: ast::DUMMY_NODE_ID, pat, ty }) + let span = lo.to(self.token.span); + + Ok(Arg { attrs: attrs.into(), id: ast::DUMMY_NODE_ID, pat, span, ty }) } /// Parses an argument in a lambda header (e.g., `|arg, arg|`). fn parse_fn_block_arg(&mut self) -> PResult<'a, Arg> { + let lo = self.token.span; let attrs = self.parse_arg_attributes()?; let pat = self.parse_pat(Some("argument name"))?; let t = if self.eat(&token::Colon) { @@ -1594,10 +1598,12 @@ impl<'a> Parser<'a> { span: self.prev_span, }) }; + let span = lo.to(self.token.span); Ok(Arg { attrs: attrs.into(), ty: t, pat, + span, id: ast::DUMMY_NODE_ID }) } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index ff6440fb9dc..50be8c68f7f 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -66,6 +66,7 @@ pub trait Visitor<'ast>: Sized { fn visit_local(&mut self, l: &'ast Local) { walk_local(self, l) } fn visit_block(&mut self, b: &'ast Block) { walk_block(self, b) } fn visit_stmt(&mut self, s: &'ast Stmt) { walk_stmt(self, s) } + fn visit_arg(&mut self, arg: &'ast Arg) { walk_arg(self, arg) } fn visit_arm(&mut self, a: &'ast Arm) { walk_arm(self, a) } fn visit_pat(&mut self, p: &'ast Pat) { walk_pat(self, p) } fn visit_anon_const(&mut self, c: &'ast AnonConst) { walk_anon_const(self, c) } @@ -547,12 +548,10 @@ pub fn walk_fn_ret_ty<'a, V: Visitor<'a>>(visitor: &mut V, ret_ty: &'a FunctionR } pub fn walk_fn_decl<'a, V: Visitor<'a>>(visitor: &mut V, function_declaration: &'a FnDecl) { - for argument in &function_declaration.inputs { - walk_list!(visitor, visit_attribute, argument.attrs.iter()); - visitor.visit_pat(&argument.pat); - visitor.visit_ty(&argument.ty); + for arg in &function_declaration.inputs { + visitor.visit_arg(arg); } - visitor.visit_fn_ret_ty(&function_declaration.output) + visitor.visit_fn_ret_ty(&function_declaration.output); } pub fn walk_fn<'a, V>(visitor: &mut V, kind: FnKind<'a>, declaration: &'a FnDecl, _span: Span) @@ -822,6 +821,12 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { visitor.visit_expr_post(expression) } +pub fn walk_arg<'a, V: Visitor<'a>>(visitor: &mut V, arg: &'a Arg) { + walk_list!(visitor, visit_attribute, arg.attrs.iter()); + visitor.visit_pat(&arg.pat); + visitor.visit_ty(&arg.ty); +} + pub fn walk_arm<'a, V: Visitor<'a>>(visitor: &mut V, arm: &'a Arm) { walk_list!(visitor, visit_pat, &arm.pats); if let Some(ref e) = &arm.guard { |
