diff options
| author | bors <bors@rust-lang.org> | 2019-11-08 15:52:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-11-08 15:52:14 +0000 |
| commit | 9e346646e93cc243567e27bb0f4e8716d56ad1f1 (patch) | |
| tree | 32241bdad56a558bbfa93093ba4cc65797df3498 /src/libsyntax | |
| parent | 76ade3e8ac42cd7a7b7c3c5ef54818ab68e3ebdc (diff) | |
| parent | 65c77bc09ab38b3d9377168d673ed7b0a2c1e0c3 (diff) | |
| download | rust-9e346646e93cc243567e27bb0f4e8716d56ad1f1.tar.gz rust-9e346646e93cc243567e27bb0f4e8716d56ad1f1.zip | |
Auto merge of #66225 - Centril:rollup-it0t5tk, r=Centril
Rollup of 5 pull requests
Successful merges:
- #65785 (Transition future compat lints to {ERROR, DENY} - Take 2)
- #66007 (Remove "here" from "expected one of X here")
- #66043 (rename Memory::get methods to get_raw to indicate their unchecked nature)
- #66154 (miri: Rename to_{u,i}size to to_machine_{u,i}size)
- #66188 (`MethodSig` -> `FnSig` & Use it in `ItemKind::Fn`)
Failed merges:
r? @ghost
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/mut_visit.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser/diagnostics.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser/item.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser/module.rs | 26 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 11 |
8 files changed, 31 insertions, 49 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 18151a1586c..b57d2238991 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1501,10 +1501,10 @@ pub struct MutTy { pub mutbl: Mutability, } -/// Represents a method's signature in a trait declaration, -/// or in an implementation. +/// Represents a function's signature in a trait declaration, +/// trait implementation, or free function. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub struct MethodSig { +pub struct FnSig { pub header: FnHeader, pub decl: P<FnDecl>, } @@ -1528,7 +1528,7 @@ pub struct TraitItem { #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum TraitItemKind { Const(P<Ty>, Option<P<Expr>>), - Method(MethodSig, Option<P<Block>>), + Method(FnSig, Option<P<Block>>), Type(GenericBounds, Option<P<Ty>>), Macro(Mac), } @@ -1552,7 +1552,7 @@ pub struct ImplItem { #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum ImplItemKind { Const(P<Ty>, P<Expr>), - Method(MethodSig, P<Block>), + Method(FnSig, P<Block>), TyAlias(P<Ty>), OpaqueTy(GenericBounds), Macro(Mac), @@ -2433,7 +2433,7 @@ pub enum ItemKind { /// A function declaration (`fn`). /// /// E.g., `fn foo(bar: usize) -> usize { .. }`. - Fn(P<FnDecl>, FnHeader, Generics, P<Block>), + Fn(FnSig, Generics, P<Block>), /// A module declaration (`mod`). /// /// E.g., `mod foo;` or `mod foo { .. }`. diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 0c90652526d..7696ea48f93 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -357,7 +357,7 @@ pub fn visit_bounds<T: MutVisitor>(bounds: &mut GenericBounds, vis: &mut T) { } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_method_sig<T: MutVisitor>(MethodSig { header, decl }: &mut MethodSig, vis: &mut T) { +pub fn visit_fn_sig<T: MutVisitor>(FnSig { header, decl }: &mut FnSig, vis: &mut T) { vis.visit_fn_header(header); vis.visit_fn_decl(decl); } @@ -878,9 +878,8 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) { vis.visit_ty(ty); vis.visit_expr(expr); } - ItemKind::Fn(decl, header, generics, body) => { - vis.visit_fn_decl(decl); - vis.visit_fn_header(header); + ItemKind::Fn(sig, generics, body) => { + visit_fn_sig(sig, vis); vis.visit_generics(generics); vis.visit_block(body); } @@ -938,7 +937,7 @@ pub fn noop_flat_map_trait_item<T: MutVisitor>(mut item: TraitItem, vis: &mut T) visit_opt(default, |default| vis.visit_expr(default)); } TraitItemKind::Method(sig, body) => { - visit_method_sig(sig, vis); + visit_fn_sig(sig, vis); visit_opt(body, |body| vis.visit_block(body)); } TraitItemKind::Type(bounds, default) => { @@ -970,7 +969,7 @@ pub fn noop_flat_map_impl_item<T: MutVisitor>(mut item: ImplItem, visitor: &mut visitor.visit_expr(expr); } ImplItemKind::Method(sig, body) => { - visit_method_sig(sig, visitor); + visit_fn_sig(sig, visitor); visitor.visit_block(body); } ImplItemKind::TyAlias(ty) => visitor.visit_ty(ty), diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 18550762017..b54f4862f12 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -37,7 +37,7 @@ pub enum DirectoryOwnership { relative: Option<ast::Ident>, }, UnownedViaBlock, - UnownedViaMod(bool /* legacy warnings? */), + UnownedViaMod, } // A bunch of utility functions of the form `parse_<thing>_from_<source>` diff --git a/src/libsyntax/parse/parser/diagnostics.rs b/src/libsyntax/parse/parser/diagnostics.rs index 26d7f48025e..5df24804a76 100644 --- a/src/libsyntax/parse/parser/diagnostics.rs +++ b/src/libsyntax/parse/parser/diagnostics.rs @@ -287,7 +287,7 @@ impl<'a> Parser<'a> { }; (format!("expected one of {}, found {}", expect, actual), (self.sess.source_map().next_point(self.prev_span), - format!("expected one of {} here", short_expect))) + format!("expected one of {}", short_expect))) } else if expected.is_empty() { (format!("unexpected token: {}", actual), (self.prev_span, "unexpected token after this".to_string())) diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index 3c618d75d34..531ad532a54 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -8,7 +8,7 @@ use crate::ast::{ItemKind, ImplItem, ImplItemKind, TraitItem, TraitItemKind, Use use crate::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness}; use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind}; use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField}; -use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, MethodSig, SelfKind, Param}; +use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, FnSig, SelfKind, Param}; use crate::parse::token; use crate::tokenstream::{TokenTree, TokenStream}; use crate::symbol::{kw, sym}; @@ -1800,7 +1800,7 @@ impl<'a> Parser<'a> { is_name_required: |_| true, })?; let (inner_attrs, body) = self.parse_inner_attrs_and_block()?; - let kind = ItemKind::Fn(decl, header, generics, body); + let kind = ItemKind::Fn(FnSig { decl, header }, generics, body); self.mk_item_with_info(attrs, lo, vis, (ident, kind, Some(inner_attrs))) } @@ -1897,14 +1897,14 @@ impl<'a> Parser<'a> { fn parse_method_sig( &mut self, is_name_required: fn(&token::Token) -> bool, - ) -> PResult<'a, (Ident, MethodSig, Generics)> { + ) -> PResult<'a, (Ident, FnSig, Generics)> { let header = self.parse_fn_front_matter()?; let (ident, decl, generics) = self.parse_fn_sig(ParamCfg { is_self_allowed: true, allow_c_variadic: false, is_name_required, })?; - Ok((ident, MethodSig { header, decl }, generics)) + Ok((ident, FnSig { header, decl }, generics)) } /// Parses all the "front matter" for a `fn` declaration, up to diff --git a/src/libsyntax/parse/parser/module.rs b/src/libsyntax/parse/parser/module.rs index 72049daaed3..3e5974c2eee 100644 --- a/src/libsyntax/parse/parser/module.rs +++ b/src/libsyntax/parse/parser/module.rs @@ -23,7 +23,6 @@ pub(super) struct ModulePath { pub(super) struct ModulePathSuccess { pub path: PathBuf, pub directory_ownership: DirectoryOwnership, - warn: bool, } impl<'a> Parser<'a> { @@ -57,17 +56,10 @@ impl<'a> Parser<'a> { if self.eat(&token::Semi) { if in_cfg && self.recurse_into_file_modules { // This mod is in an external file. Let's go get it! - let ModulePathSuccess { path, directory_ownership, warn } = + let ModulePathSuccess { path, directory_ownership } = self.submod_path(id, &outer_attrs, id_span)?; - let (module, mut attrs) = + let (module, attrs) = self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?; - // Record that we fetched the mod from an external file. - if warn { - let attr = attr::mk_attr_outer( - attr::mk_word_item(Ident::with_dummy_span(sym::warn_directory_ownership))); - attr::mark_known(&attr); - attrs.push(attr); - } Ok((id, ItemKind::Mod(module), Some(attrs))) } else { let placeholder = ast::Mod { @@ -138,17 +130,16 @@ impl<'a> Parser<'a> { // `#[path]` included and contains a `mod foo;` declaration. // If you encounter this, it's your own darn fault :P Some(_) => DirectoryOwnership::Owned { relative: None }, - _ => DirectoryOwnership::UnownedViaMod(true), + _ => DirectoryOwnership::UnownedViaMod, }, path, - warn: false, }); } let relative = match self.directory.ownership { DirectoryOwnership::Owned { relative } => relative, DirectoryOwnership::UnownedViaBlock | - DirectoryOwnership::UnownedViaMod(_) => None, + DirectoryOwnership::UnownedViaMod => None, }; let paths = Parser::default_submod_path( id, relative, &self.directory.path, self.sess.source_map()); @@ -169,12 +160,7 @@ impl<'a> Parser<'a> { } Err(err) } - DirectoryOwnership::UnownedViaMod(warn) => { - if warn { - if let Ok(result) = paths.result { - return Ok(ModulePathSuccess { warn: true, ..result }); - } - } + DirectoryOwnership::UnownedViaMod => { let mut err = self.diagnostic().struct_span_err(id_sp, "cannot declare a new module at this location"); if !id_sp.is_dummy() { @@ -252,14 +238,12 @@ impl<'a> Parser<'a> { directory_ownership: DirectoryOwnership::Owned { relative: Some(id), }, - warn: false, }), (false, true) => Ok(ModulePathSuccess { path: secondary_path, directory_ownership: DirectoryOwnership::Owned { relative: None, }, - warn: false, }), (false, false) => Err(Error::FileNotFoundForModule { mod_name: mod_name.clone(), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 4ca4bdeb046..2203e8d9d06 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1199,11 +1199,11 @@ impl<'a> State<'a> { self.s.word(";"); self.end(); // end the outer cbox } - ast::ItemKind::Fn(ref decl, header, ref param_names, ref body) => { + ast::ItemKind::Fn(ref sig, ref param_names, ref body) => { self.head(""); self.print_fn( - decl, - header, + &sig.decl, + sig.header, Some(item.ident), param_names, &item.vis @@ -1541,7 +1541,7 @@ impl<'a> State<'a> { crate fn print_method_sig(&mut self, ident: ast::Ident, generics: &ast::Generics, - m: &ast::MethodSig, + m: &ast::FnSig, vis: &ast::Visibility) { self.print_fn(&m.decl, diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index cfd160fd577..ea2dc357e6e 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -25,7 +25,7 @@ pub enum FnKind<'a> { ItemFn(Ident, &'a FnHeader, &'a Visibility, &'a Block), /// E.g., `fn foo(&self)`. - Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a Block), + Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a Block), /// E.g., `|x, y| body`. Closure(&'a Expr), @@ -244,12 +244,11 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { visitor.visit_ty(typ); visitor.visit_expr(expr); } - ItemKind::Fn(ref declaration, ref header, ref generics, ref body) => { + ItemKind::Fn(ref sig, ref generics, ref body) => { visitor.visit_generics(generics); - visitor.visit_fn_header(header); - visitor.visit_fn(FnKind::ItemFn(item.ident, header, - &item.vis, body), - declaration, + visitor.visit_fn_header(&sig.header); + visitor.visit_fn(FnKind::ItemFn(item.ident, &sig.header, &item.vis, body), + &sig.decl, item.span, item.id) } |
