From 59481823675a7392e8160b659b0f7fa119df60fd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 10 Aug 2016 19:39:12 +0200 Subject: Add Span field for Generics structs --- src/libsyntax/parse/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse/mod.rs') diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index cd1fdcfe9d1..eb59a8e24d3 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -674,7 +674,7 @@ pub fn integer_lit(s: &str, mod tests { use super::*; use std::rc::Rc; - use syntax_pos::{Span, BytePos, Pos, NO_EXPANSION}; + use syntax_pos::{self, Span, BytePos, Pos, NO_EXPANSION}; use codemap::Spanned; use ast::{self, PatKind}; use abi::Abi; @@ -945,7 +945,8 @@ mod tests { where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), - } + }, + span: syntax_pos::DUMMY_SP, }, P(ast::Block { stmts: vec!(ast::Stmt { -- cgit 1.4.1-3-g733a5 From bfb01bbb263923106b33fdaa140a5fa464426162 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 23 Aug 2016 03:54:53 +0000 Subject: Refactor away `AttrMetaMethods`. --- src/librustc/hir/check_attr.rs | 1 - src/librustc/lint/context.rs | 2 +- src/librustc/middle/lang_items.rs | 1 - src/librustc/middle/recursion_limit.rs | 1 - src/librustc/middle/stability.rs | 2 +- src/librustc/session/config.rs | 2 - src/librustc/traits/error_reporting.rs | 1 - src/librustc/ty/mod.rs | 2 +- src/librustc_borrowck/borrowck/fragments.rs | 1 - src/librustc_borrowck/borrowck/mir/mod.rs | 3 - src/librustc_borrowck/borrowck/mod.rs | 1 - src/librustc_driver/driver.rs | 2 +- src/librustc_driver/lib.rs | 1 - src/librustc_incremental/assert_dep_graph.rs | 1 - src/librustc_incremental/persist/dirty_clean.rs | 1 - src/librustc_lint/bad_style.rs | 2 +- src/librustc_lint/builtin.rs | 4 +- src/librustc_lint/unused.rs | 2 +- src/librustc_metadata/creader.rs | 2 +- src/librustc_metadata/macro_import.rs | 2 +- src/librustc_mir/hair/cx/mod.rs | 1 - src/librustc_plugin/load.rs | 1 - src/librustc_trans/assert_module_sources.rs | 1 - src/librustc_trans/back/link.rs | 1 - src/librustc_trans/base.rs | 1 - src/librustc_trans/consts.rs | 2 +- src/librustc_trans/symbol_names_test.rs | 1 - src/librustc_typeck/check/mod.rs | 1 - src/librustdoc/clean/mod.rs | 59 +--------------- src/librustdoc/test.rs | 1 - src/librustdoc/visit_ast.rs | 1 - src/libsyntax/attr.rs | 92 +++++++++---------------- src/libsyntax/config.rs | 2 +- src/libsyntax/ext/expand.rs | 1 - src/libsyntax/feature_gate.rs | 2 +- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/print/pprust.rs | 1 - src/libsyntax/test.rs | 2 +- src/libsyntax_ext/deriving/generic/mod.rs | 1 - src/libsyntax_ext/deriving/mod.rs | 1 - 40 files changed, 50 insertions(+), 158 deletions(-) (limited to 'src/libsyntax/parse/mod.rs') diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 42f293577b3..21143f93a7d 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -11,7 +11,6 @@ use session::Session; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::visit; use syntax::visit::Visitor; diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index ed812471594..c9211586143 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -38,7 +38,7 @@ use util::nodemap::FnvHashMap; use std::cmp; use std::default::Default as StdDefault; use std::mem; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax::parse::token::InternedString; use syntax::ast; use syntax_pos::Span; diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index a209b1d1abd..d1769d5cbc5 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -30,7 +30,6 @@ use middle::weak_lang_items; use util::nodemap::FnvHashMap; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use hir::intravisit::Visitor; use hir; diff --git a/src/librustc/middle/recursion_limit.rs b/src/librustc/middle/recursion_limit.rs index 7dcd358165c..0764e817f43 100644 --- a/src/librustc/middle/recursion_limit.rs +++ b/src/librustc/middle/recursion_limit.rs @@ -17,7 +17,6 @@ use session::Session; use syntax::ast; -use syntax::attr::AttrMetaMethods; pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) { for attr in &krate.attrs { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index cbbc2c4f98f..405202bc634 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -27,7 +27,7 @@ use syntax_pos::{Span, DUMMY_SP}; use syntax::ast; use syntax::ast::{NodeId, Attribute}; use syntax::feature_gate::{GateIssue, emit_feature_err, find_lang_feature_accepted_version}; -use syntax::attr::{self, Stability, Deprecation, AttrMetaMethods}; +use syntax::attr::{self, Stability, Deprecation}; use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap}; use hir; diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 8a32797dbd7..7a1848f42d2 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -25,7 +25,6 @@ use middle::cstore; use syntax::ast::{self, IntTy, UintTy}; use syntax::attr; -use syntax::attr::AttrMetaMethods; use syntax::parse; use syntax::parse::token::InternedString; use syntax::feature_gate::UnstableFeatures; @@ -1774,7 +1773,6 @@ mod tests { use std::rc::Rc; use super::{OutputType, OutputTypes, Externs, PanicStrategy}; use syntax::attr; - use syntax::attr::AttrMetaMethods; fn optgroups() -> Vec { super::rustc_optgroups().into_iter() diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index b8c5ed51eab..a09ce38c4bb 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -37,7 +37,6 @@ use util::nodemap::{FnvHashMap, FnvHashSet}; use std::cmp; use std::fmt; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax_pos::Span; use errors::DiagnosticBuilder; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 6c82157c8ca..ded9867fa6f 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -43,7 +43,7 @@ use std::rc::Rc; use std::slice; use std::vec::IntoIter; use syntax::ast::{self, CrateNum, Name, NodeId}; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax::parse::token::InternedString; use syntax_pos::{DUMMY_SP, Span}; diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index d3d6fa9eb52..a8993724e67 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -27,7 +27,6 @@ use rustc::middle::mem_categorization as mc; use std::mem; use std::rc::Rc; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax_pos::{Span, DUMMY_SP}; #[derive(PartialEq, Eq, PartialOrd, Ord)] diff --git a/src/librustc_borrowck/borrowck/mir/mod.rs b/src/librustc_borrowck/borrowck/mir/mod.rs index 3285cecb79c..2d429aaab6a 100644 --- a/src/librustc_borrowck/borrowck/mir/mod.rs +++ b/src/librustc_borrowck/borrowck/mir/mod.rs @@ -11,7 +11,6 @@ use borrowck::BorrowckCtxt; use syntax::ast::{self, MetaItem}; -use syntax::attr::AttrMetaMethods; use syntax::ptr::P; use syntax_pos::{Span, DUMMY_SP}; @@ -127,8 +126,6 @@ fn do_dataflow<'a, 'tcx, BD>(tcx: TyCtxt<'a, 'tcx, 'tcx>, bd: BD) -> DataflowResults where BD: BitDenotation> + DataflowOperator { - use syntax::attr::AttrMetaMethods; - let name_found = |sess: &Session, attrs: &[ast::Attribute], name| -> Option { if let Some(item) = has_rustc_mir_with(attrs, name) { if let Some(s) = item.value_str() { diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 225895adefa..343e9251e1d 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -42,7 +42,6 @@ use std::fmt; use std::mem; use std::rc::Rc; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax_pos::{MultiSpan, Span}; use errors::DiagnosticBuilder; diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 3f2f6c84da1..c6ab4578f06 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -49,7 +49,7 @@ use std::fs; use std::io::{self, Write}; use std::path::{Path, PathBuf}; use syntax::{ast, diagnostics, visit}; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax::parse::{self, PResult, token}; use syntax::util::node_count::NodeCounter; use syntax; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 1f3f823d0b8..efadf1ff488 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -95,7 +95,6 @@ use std::thread; use rustc::session::early_error; use syntax::{ast, json}; -use syntax::attr::AttrMetaMethods; use syntax::codemap::{CodeMap, FileLoader, RealFileLoader}; use syntax::feature_gate::{GatedCfg, UnstableFeatures}; use syntax::parse::{self, PResult}; diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 7ab61d494b5..8df8f500371 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -56,7 +56,6 @@ use std::env; use std::fs::File; use std::io::Write; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use syntax_pos::Span; diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 0a87c083318..fda7ef207a3 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -32,7 +32,6 @@ use rustc::hir::def_id::DefId; use rustc::hir::intravisit::Visitor; use rustc_data_structures::fnv::FnvHashSet; use syntax::ast::{self, Attribute, NestedMetaItem}; -use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use rustc::ty::TyCtxt; diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index 15914838acf..0e130c3bb66 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -14,7 +14,7 @@ use lint::{LateContext, LintContext, LintArray}; use lint::{LintPass, LateLintPass}; use syntax::ast; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax_pos::Span; use rustc::hir::{self, PatKind}; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 6ab53b75f50..a103386e2c9 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -44,7 +44,7 @@ use lint::{LintPass, LateLintPass}; use std::collections::HashSet; use syntax::{ast}; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax_pos::{Span}; use rustc::hir::{self, PatKind}; @@ -1145,7 +1145,7 @@ impl LintPass for UnstableFeatures { impl LateLintPass for UnstableFeatures { fn check_attribute(&mut self, ctx: &LateContext, attr: &ast::Attribute) { - if attr::contains_name(&[attr.meta().clone()], "feature") { + if attr.meta().check_name("feature") { if let Some(items) = attr.meta().meta_item_list() { for item in items { ctx.span_lint(UNSTABLE_FEATURES, item.span(), "unstable feature"); diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 44c2ffe45cc..411daa0c12a 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -18,7 +18,7 @@ use lint::{LintPass, EarlyLintPass, LateLintPass}; use std::collections::hash_map::Entry::{Occupied, Vacant}; use syntax::ast; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType}; use syntax::ptr::P; use syntax_pos::Span; diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 91b7acff03f..7e1f3ea618c 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -35,7 +35,7 @@ use syntax::ast; use syntax::abi::Abi; use syntax::codemap; use syntax::parse; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax::parse::token::InternedString; use syntax::visit; use syntax_pos::{self, Span, mk_sp, Pos}; diff --git a/src/librustc_metadata/macro_import.rs b/src/librustc_metadata/macro_import.rs index 2482a53fe48..25fedb10201 100644 --- a/src/librustc_metadata/macro_import.rs +++ b/src/librustc_metadata/macro_import.rs @@ -18,7 +18,7 @@ use rustc::session::Session; use std::collections::{HashSet, HashMap}; use syntax::parse::token; use syntax::ast; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax::ext; use syntax_pos::Span; diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 972e7f5be70..f65680b567c 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -32,7 +32,6 @@ use rustc::ty::{self, Ty, TyCtxt}; use syntax::parse::token; use rustc::hir; use rustc_const_math::{ConstInt, ConstUsize}; -use syntax::attr::AttrMetaMethods; #[derive(Copy, Clone)] pub struct Cx<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { diff --git a/src/librustc_plugin/load.rs b/src/librustc_plugin/load.rs index 895645a76cb..9e56397bc99 100644 --- a/src/librustc_plugin/load.rs +++ b/src/librustc_plugin/load.rs @@ -20,7 +20,6 @@ use std::env; use std::mem; use std::path::PathBuf; use syntax::ast; -use syntax::attr::{AttrMetaMethods}; use syntax_pos::{Span, COMMAND_LINE_SP}; /// Pointer to a registrar function. diff --git a/src/librustc_trans/assert_module_sources.rs b/src/librustc_trans/assert_module_sources.rs index e0532e7476f..7fe6d2bbfe2 100644 --- a/src/librustc_trans/assert_module_sources.rs +++ b/src/librustc_trans/assert_module_sources.rs @@ -29,7 +29,6 @@ use rustc::ty::TyCtxt; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax::parse::token::InternedString; use {ModuleSource, ModuleTranslation}; diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 9f401b13d6f..b21785c27da 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -42,7 +42,6 @@ use std::process::Command; use std::str; use flate; use syntax::ast; -use syntax::attr::AttrMetaMethods; use syntax_pos::Span; // RLIB LLVM-BYTECODE OBJECT LAYOUT diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 165884c8f55..f231344f22f 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -93,7 +93,6 @@ use std::rc::Rc; use std::str; use std::i32; use syntax_pos::{Span, DUMMY_SP}; -use syntax::attr::AttrMetaMethods; use syntax::attr; use rustc::hir; use syntax::ast; diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index fa1e008d496..2b6e2a23261 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -29,7 +29,7 @@ use rustc::hir; use std::ffi::{CStr, CString}; use syntax::ast; -use syntax::attr::{self, AttrMetaMethods}; +use syntax::attr; use syntax::parse::token; pub fn ptrcast(val: ValueRef, ty: Type) -> ValueRef { diff --git a/src/librustc_trans/symbol_names_test.rs b/src/librustc_trans/symbol_names_test.rs index 9a7fe54e0d9..25c30151ad4 100644 --- a/src/librustc_trans/symbol_names_test.rs +++ b/src/librustc_trans/symbol_names_test.rs @@ -17,7 +17,6 @@ use rustc::hir; use rustc::hir::intravisit::{self, Visitor}; use syntax::ast; -use syntax::attr::AttrMetaMethods; use common::SharedCrateContext; use monomorphize::Instance; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 16300d869ab..619aafa799f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -113,7 +113,6 @@ use std::ops::Deref; use syntax::abi::Abi; use syntax::ast; use syntax::attr; -use syntax::attr::AttrMetaMethods; use syntax::codemap::{self, Spanned}; use syntax::feature_gate::{GateIssue, emit_feature_err}; use syntax::parse::token::{self, InternedString, keywords}; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 1f1844f9b73..3a1e22f81b5 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -26,9 +26,8 @@ pub use self::Visibility::*; use syntax::abi::Abi; use syntax::ast; use syntax::attr; -use syntax::attr::AttrMetaMethods; use syntax::codemap::Spanned; -use syntax::parse::token::{self, InternedString, keywords}; +use syntax::parse::token::keywords; use syntax::ptr::P; use syntax::print::pprust as syntax_pprust; use syntax_pos::{self, DUMMY_SP, Pos}; @@ -541,62 +540,6 @@ impl Clean for ast::Attribute { } } -// This is a rough approximation that gets us what we want. -impl Attribute { - fn check_name(&self, name: &str) -> bool { - self.name().map_or(false, |mi_name| &*mi_name == name) - } - - fn literal(&self) -> Option<&ast::Lit> { None } - - fn is_literal(&self) -> bool { - match *self { - Literal(..) => true, - _ => false, - } - } - - fn meta_item(&self) -> Option<&P> { None } - - fn name(&self) -> Option { - match *self { - Word(ref n) | List(ref n, _) | NameValue(ref n, _) => { - Some(token::intern_and_get_ident(n)) - }, - _ => None - } - } - - fn value_str(&self) -> Option { - match *self { - NameValue(_, ref v) => { - Some(token::intern_and_get_ident(v)) - } - _ => None, - } - } - - fn word(&self) -> Option<&P> { None } - - fn is_word(&self) -> bool { - match *self { - Word(_) => true, - _ => false, - } - } - - fn meta_item_list<'a>(&'a self) -> Option<&'a [ast::NestedMetaItem]> { None } - - fn is_meta_item_list(&self) -> bool { - match *self { - List(..) => true, - _ => false, - } - } - - fn span(&self) -> syntax_pos::Span { unimplemented!() } -} - #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)] pub struct TyParam { pub name: String, diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index caf05a947d3..1805da2385b 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -140,7 +140,6 @@ pub fn run(input: &str, // Look for #![doc(test(no_crate_inject))], used by crates in the std facade fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions { - use syntax::attr::AttrMetaMethods; use syntax::print::pprust; let mut opts = TestOptions { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index d3397a04b3a..e66d01e5c2d 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -17,7 +17,6 @@ use std::mem; use syntax::abi; use syntax::ast; use syntax::attr; -use syntax::attr::AttrMetaMethods; use syntax_pos::Span; use rustc::hir::map as hir_map; diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index f8fecd5fda0..6060ff529f2 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -160,40 +160,8 @@ impl NestedMetaItem { } } -pub trait AttrMetaMethods { - fn check_name(&self, name: &str) -> bool { - name == &self.name()[..] - } - - /// Retrieve the name of the meta item, e.g. `foo` in `#[foo]`, - /// `#[foo="bar"]` and `#[foo(bar)]` - fn name(&self) -> InternedString; - - /// Gets the string value if self is a MetaItemKind::NameValue variant - /// containing a string, otherwise None. - fn value_str(&self) -> Option; - - /// Gets a list of inner meta items from a list MetaItem type. - fn meta_item_list(&self) -> Option<&[NestedMetaItem]>; - - /// Indicates if the attribute is a Word. - fn is_word(&self) -> bool; - - /// Indicates if the attribute is a Value String. - fn is_value_str(&self) -> bool { - self.value_str().is_some() - } - - /// Indicates if the attribute is a Meta-Item List. - fn is_meta_item_list(&self) -> bool { - self.meta_item_list().is_some() - } - - fn span(&self) -> Span; -} - -impl AttrMetaMethods for Attribute { - fn check_name(&self, name: &str) -> bool { +impl Attribute { + pub fn check_name(&self, name: &str) -> bool { let matches = name == &self.name()[..]; if matches { mark_used(self); @@ -201,23 +169,32 @@ impl AttrMetaMethods for Attribute { matches } - fn name(&self) -> InternedString { self.meta().name() } + pub fn name(&self) -> InternedString { self.meta().name() } - fn value_str(&self) -> Option { + pub fn value_str(&self) -> Option { self.meta().value_str() } - fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { + pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { self.meta().meta_item_list() } - fn is_word(&self) -> bool { self.meta().is_word() } + pub fn is_word(&self) -> bool { self.meta().is_word() } + + pub fn span(&self) -> Span { self.meta().span } - fn span(&self) -> Span { self.meta().span } + pub fn is_meta_item_list(&self) -> bool { + self.meta_item_list().is_some() + } + + /// Indicates if the attribute is a Value String. + pub fn is_value_str(&self) -> bool { + self.value_str().is_some() + } } -impl AttrMetaMethods for MetaItem { - fn name(&self) -> InternedString { +impl MetaItem { + pub fn name(&self) -> InternedString { match self.node { MetaItemKind::Word(ref n) => (*n).clone(), MetaItemKind::NameValue(ref n, _) => (*n).clone(), @@ -225,7 +202,7 @@ impl AttrMetaMethods for MetaItem { } } - fn value_str(&self) -> Option { + pub fn value_str(&self) -> Option { match self.node { MetaItemKind::NameValue(_, ref v) => { match v.node { @@ -237,34 +214,33 @@ impl AttrMetaMethods for MetaItem { } } - fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { + pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { match self.node { MetaItemKind::List(_, ref l) => Some(&l[..]), _ => None } } - fn is_word(&self) -> bool { + pub fn is_word(&self) -> bool { match self.node { MetaItemKind::Word(_) => true, _ => false, } } - fn span(&self) -> Span { self.span } -} + pub fn span(&self) -> Span { self.span } + + pub fn check_name(&self, name: &str) -> bool { + name == &self.name()[..] + } -// Annoying, but required to get test_cfg to work -impl AttrMetaMethods for P { - fn name(&self) -> InternedString { (**self).name() } - fn value_str(&self) -> Option { (**self).value_str() } - fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { - (**self).meta_item_list() + pub fn is_value_str(&self) -> bool { + self.value_str().is_some() + } + + pub fn is_meta_item_list(&self) -> bool { + self.meta_item_list().is_some() } - fn is_word(&self) -> bool { (**self).is_word() } - fn is_value_str(&self) -> bool { (**self).is_value_str() } - fn is_meta_item_list(&self) -> bool { (**self).is_meta_item_list() } - fn span(&self) -> Span { (**self).span() } } impl Attribute { @@ -424,9 +400,9 @@ pub fn list_contains_name(items: &[NestedMetaItem], name: &str) -> bool { }) } -pub fn contains_name(metas: &[AM], name: &str) -> bool { +pub fn contains_name(attrs: &[Attribute], name: &str) -> bool { debug!("attr::contains_name (name={})", name); - metas.iter().any(|item| { + attrs.iter().any(|item| { debug!(" testing: {}", item.name()); item.check_name(name) }) diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index ed05dc243b3..ff1ecd44371 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use attr::{AttrMetaMethods, HasAttrs}; +use attr::HasAttrs; use feature_gate::{emit_feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features, GateIssue}; use fold::Folder; use {fold, attr}; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 031d9a2d3f4..bc0f4de4471 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -13,7 +13,6 @@ use ast::{MacStmtStyle, Stmt, StmtKind, ItemKind}; use ast; use ext::hygiene::Mark; use attr::{self, HasAttrs}; -use attr::AttrMetaMethods; use codemap::{dummy_spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute}; use syntax_pos::{self, Span, ExpnId}; use config::StripUnconfigured; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index d2aa9a4cb6b..cd2705fb7d8 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -27,7 +27,7 @@ use self::AttributeGate::*; use abi::Abi; use ast::{self, NodeId, PatKind}; -use attr::{self, AttrMetaMethods}; +use attr; use codemap::CodeMap; use syntax_pos::Span; use errors::Handler; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index cd1fdcfe9d1..6f06dd14d8f 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -678,7 +678,7 @@ mod tests { use codemap::Spanned; use ast::{self, PatKind}; use abi::Abi; - use attr::{first_attr_value_str_by_name, AttrMetaMethods}; + use attr::first_attr_value_str_by_name; use parse; use parse::parser::Parser; use parse::token::{str_to_ident}; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0caf9ae0d78..28f1016c51f 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -16,7 +16,6 @@ use ast::{SelfKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::Attribute; use util::parser::AssocOp; use attr; -use attr::AttrMetaMethods; use codemap::{self, CodeMap}; use syntax_pos::{self, BytePos}; use errors; diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 0a14eae7d35..e3e2457c471 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -19,7 +19,7 @@ use std::iter; use std::slice; use std::mem; use std::vec; -use attr::{self, AttrMetaMethods}; +use attr; use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos}; use std::rc::Rc; diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index bae40ddf45c..0d69fc00799 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -194,7 +194,6 @@ use std::vec; use syntax::abi::Abi; use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind, VariantData}; use syntax::attr; -use syntax::attr::AttrMetaMethods; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::codemap::{self, respan}; diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index fae17c0465b..81085122e87 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -11,7 +11,6 @@ //! The compiler code necessary to implement the `#[derive]` extensions. use syntax::ast::{self, MetaItem}; -use syntax::attr::AttrMetaMethods; use syntax::ext::base::{Annotatable, ExtCtxt, SyntaxEnv}; use syntax::ext::base::{MultiDecorator, MultiItemDecorator, MultiModifier}; use syntax::ext::build::AstBuilder; -- cgit 1.4.1-3-g733a5 From aa5c4bb05d1d5d10a2fdbb80f098ba06e73214b9 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 10 Aug 2016 16:20:12 -0700 Subject: Change Constness to Spanned --- src/librustc/hir/lowering.rs | 4 ++-- src/librustc/hir/map/blocks.rs | 6 +++--- src/librustc/infer/error_reporting.rs | 3 ++- src/librustc_passes/ast_validation.rs | 14 +++++++------ src/librustc_passes/consts.rs | 3 ++- src/libsyntax/ast.rs | 4 ++-- src/libsyntax/ext/build.rs | 4 ++-- src/libsyntax/feature_gate.rs | 8 ++++---- src/libsyntax/parse/mod.rs | 5 ++++- src/libsyntax/parse/parser.rs | 33 ++++++++++++++++++++++--------- src/libsyntax/print/pprust.rs | 4 ++-- src/libsyntax/test.rs | 4 ++-- src/libsyntax/visit.rs | 2 +- src/libsyntax_ext/deriving/generic/mod.rs | 5 +++-- 14 files changed, 61 insertions(+), 38 deletions(-) (limited to 'src/libsyntax/parse/mod.rs') diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index b45610c3fe8..be5eb7f8376 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -809,8 +809,8 @@ impl<'a> LoweringContext<'a> { } } - fn lower_constness(&mut self, c: Constness) -> hir::Constness { - match c { + fn lower_constness(&mut self, c: Spanned) -> hir::Constness { + match c.node { Constness::Const => hir::Constness::Const, Constness::NotConst => hir::Constness::NotConst, } diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index 50e8c6e7ab8..44872348856 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -23,13 +23,13 @@ pub use self::Code::*; +use hir as ast; use hir::map::{self, Node}; -use syntax::abi; use hir::{Block, FnDecl}; +use hir::intravisit::FnKind; +use syntax::abi; use syntax::ast::{Attribute, Name, NodeId}; -use hir as ast; use syntax_pos::Span; -use hir::intravisit::FnKind; /// An FnLikeNode is a Node that is like a fn, in that it has a decl /// and a body (as well as a NodeId, a span, etc). diff --git a/src/librustc/infer/error_reporting.rs b/src/librustc/infer/error_reporting.rs index 9169d299e04..eab7f37382e 100644 --- a/src/librustc/infer/error_reporting.rs +++ b/src/librustc/infer/error_reporting.rs @@ -1030,7 +1030,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { = node_inner.expect("expect item fn"); let rebuilder = Rebuilder::new(self.tcx, fn_decl, generics, same_regions, &life_giver); let (fn_decl, generics) = rebuilder.rebuild(); - self.give_expl_lifetime_param(err, &fn_decl, unsafety, constness, name, &generics, span); + self.give_expl_lifetime_param( + err, &fn_decl, unsafety, constness, name, &generics, span); } pub fn issue_32330_warnings(&self, span: Span, issue32330s: &[ty::Issue32330]) { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index f10f1fba4c2..dde1a4a7595 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -20,6 +20,7 @@ use rustc::lint; use rustc::session::Session; use syntax::ast::*; use syntax::attr; +use syntax::codemap::Spanned; use syntax::parse::token::{self, keywords}; use syntax::visit::{self, Visitor}; use syntax_pos::Span; @@ -70,11 +71,12 @@ impl<'a> AstValidator<'a> { } } - fn check_trait_fn_not_const(&self, span: Span, constness: Constness) { - match constness { + fn check_trait_fn_not_const(&self, constness: Spanned) { + match constness.node { Constness::Const => { - struct_span_err!(self.session, span, E0379, "trait fns cannot be declared const") - .span_label(span, &format!("trait fns cannot be const")) + struct_span_err!(self.session, constness.span, E0379, + "trait fns cannot be declared const") + .span_label(constness.span, &format!("trait fns cannot be const")) .emit(); } _ => {} @@ -158,7 +160,7 @@ impl<'a> Visitor for AstValidator<'a> { for impl_item in impl_items { self.invalid_visibility(&impl_item.vis, impl_item.span, None); if let ImplItemKind::Method(ref sig, _) = impl_item.node { - self.check_trait_fn_not_const(impl_item.span, sig.constness); + self.check_trait_fn_not_const(sig.constness); } } } @@ -186,7 +188,7 @@ impl<'a> Visitor for AstValidator<'a> { ItemKind::Trait(_, _, _, ref trait_items) => { for trait_item in trait_items { if let TraitItemKind::Method(ref sig, _) = trait_item.node { - self.check_trait_fn_not_const(trait_item.span, sig.constness); + self.check_trait_fn_not_const(sig.constness); } } } diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 4aae6d690c4..2d1b6e1315f 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -147,7 +147,8 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> { } let mode = match fk { - FnKind::ItemFn(_, _, _, hir::Constness::Const, _, _, _) => Mode::ConstFn, + FnKind::ItemFn(_, _, _, hir::Constness::Const, _, _, _) + => Mode::ConstFn, FnKind::Method(_, m, _, _) => { if m.constness == hir::Constness::Const { Mode::ConstFn diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f8a5cb0b04a..427a44d2e74 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1120,7 +1120,7 @@ pub struct MutTy { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct MethodSig { pub unsafety: Unsafety, - pub constness: Constness, + pub constness: Spanned, pub abi: Abi, pub decl: P, pub generics: Generics, @@ -1846,7 +1846,7 @@ pub enum ItemKind { /// A function declaration (`fn` or `pub fn`). /// /// E.g. `fn foo(bar: usize) -> usize { .. }` - Fn(P, Unsafety, Constness, Abi, Generics, P), + Fn(P, Unsafety, Spanned, Abi, Generics, P), /// A module declaration (`mod` or `pub mod`). /// /// E.g. `mod foo;` or `mod foo { .. }` diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 5d6429f7bdf..14c7e46246d 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -12,7 +12,7 @@ use abi::Abi; use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind}; use attr; use syntax_pos::{Span, DUMMY_SP, Pos}; -use codemap::{respan, Spanned}; +use codemap::{dummy_spanned, respan, Spanned}; use ext::base::ExtCtxt; use parse::token::{self, keywords, InternedString}; use ptr::P; @@ -1016,7 +1016,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { Vec::new(), ast::ItemKind::Fn(self.fn_decl(inputs, output), ast::Unsafety::Normal, - ast::Constness::NotConst, + dummy_spanned(ast::Constness::NotConst), Abi::Rust, generics, body)) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index dc68e064634..9114c31d298 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -30,7 +30,7 @@ use ast::{NodeId, PatKind}; use ast; use attr; use attr::AttrMetaMethods; -use codemap::CodeMap; +use codemap::{CodeMap, Spanned}; use syntax_pos::Span; use errors::Handler; use visit::{self, FnKind, Visitor}; @@ -1046,7 +1046,7 @@ impl<'a> Visitor for PostExpansionVisitor<'a> { _node_id: NodeId) { // check for const fn declarations match fn_kind { - FnKind::ItemFn(_, _, _, ast::Constness::Const, _, _) => { + FnKind::ItemFn(_, _, _, Spanned { node: ast::Constness::Const, .. }, _, _) => { gate_feature_post!(&self, const_fn, span, "const fn is unstable"); } _ => { @@ -1078,7 +1078,7 @@ impl<'a> Visitor for PostExpansionVisitor<'a> { if block.is_none() { self.check_abi(sig.abi, ti.span); } - if sig.constness == ast::Constness::Const { + if sig.constness.node == ast::Constness::Const { gate_feature_post!(&self, const_fn, ti.span, "const fn is unstable"); } } @@ -1105,7 +1105,7 @@ impl<'a> Visitor for PostExpansionVisitor<'a> { "associated constants are experimental") } ast::ImplItemKind::Method(ref sig, _) => { - if sig.constness == ast::Constness::Const { + if sig.constness.node == ast::Constness::Const { gate_feature_post!(&self, const_fn, ii.span, "const fn is unstable"); } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index cd1fdcfe9d1..a89dc80df4b 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -937,7 +937,10 @@ mod tests { variadic: false }), ast::Unsafety::Normal, - ast::Constness::NotConst, + Spanned { + span: sp(0,2), + node: ast::Constness::NotConst, + }, Abi::Rust, ast::Generics{ // no idea on either of these: lifetimes: Vec::new(), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1646246069e..757c0779e35 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -39,7 +39,7 @@ use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; use ast::{Visibility, WhereClause}; use ast::{BinOpKind, UnOp}; use ast; -use codemap::{self, CodeMap, Spanned, spanned}; +use codemap::{self, CodeMap, Spanned, spanned, respan}; use syntax_pos::{self, Span, BytePos, mk_sp}; use errors::{self, DiagnosticBuilder}; use ext::tt::macro_parser; @@ -4768,7 +4768,7 @@ impl<'a> Parser<'a> { /// Parse an item-position function declaration. fn parse_item_fn(&mut self, unsafety: Unsafety, - constness: Constness, + constness: Spanned, abi: abi::Abi) -> PResult<'a, ItemInfo> { let (ident, mut generics) = self.parse_fn_header()?; @@ -4794,18 +4794,21 @@ impl<'a> Parser<'a> { /// - `extern fn` /// - etc pub fn parse_fn_front_matter(&mut self) - -> PResult<'a, (ast::Constness, ast::Unsafety, abi::Abi)> { + -> PResult<'a, (Spanned, + ast::Unsafety, + abi::Abi)> { let is_const_fn = self.eat_keyword(keywords::Const); + let const_span = self.last_span; let unsafety = self.parse_unsafety()?; let (constness, unsafety, abi) = if is_const_fn { - (Constness::Const, unsafety, Abi::Rust) + (respan(const_span, Constness::Const), unsafety, Abi::Rust) } else { let abi = if self.eat_keyword(keywords::Extern) { self.parse_opt_abi()?.unwrap_or(Abi::C) } else { Abi::Rust }; - (Constness::NotConst, unsafety, abi) + (respan(self.last_span, Constness::NotConst), unsafety, abi) }; self.expect_keyword(keywords::Fn)?; Ok((constness, unsafety, abi)) @@ -5704,9 +5707,12 @@ impl<'a> Parser<'a> { if self.eat_keyword(keywords::Fn) { // EXTERN FUNCTION ITEM + let fn_span = self.last_span; let abi = opt_abi.unwrap_or(Abi::C); let (ident, item_, extra_attrs) = - self.parse_item_fn(Unsafety::Normal, Constness::NotConst, abi)?; + self.parse_item_fn(Unsafety::Normal, + respan(fn_span, Constness::NotConst), + abi)?; let last_span = self.last_span; let item = self.mk_item(lo, last_span.hi, @@ -5740,6 +5746,7 @@ impl<'a> Parser<'a> { return Ok(Some(item)); } if self.eat_keyword(keywords::Const) { + let const_span = self.last_span; if self.check_keyword(keywords::Fn) || (self.check_keyword(keywords::Unsafe) && self.look_ahead(1, |t| t.is_keyword(keywords::Fn))) { @@ -5751,7 +5758,9 @@ impl<'a> Parser<'a> { }; self.bump(); let (ident, item_, extra_attrs) = - self.parse_item_fn(unsafety, Constness::Const, Abi::Rust)?; + self.parse_item_fn(unsafety, + respan(const_span, Constness::Const), + Abi::Rust)?; let last_span = self.last_span; let item = self.mk_item(lo, last_span.hi, @@ -5815,8 +5824,11 @@ impl<'a> Parser<'a> { if self.check_keyword(keywords::Fn) { // FUNCTION ITEM self.bump(); + let fn_span = self.last_span; let (ident, item_, extra_attrs) = - self.parse_item_fn(Unsafety::Normal, Constness::NotConst, Abi::Rust)?; + self.parse_item_fn(Unsafety::Normal, + respan(fn_span, Constness::NotConst), + Abi::Rust)?; let last_span = self.last_span; let item = self.mk_item(lo, last_span.hi, @@ -5836,8 +5848,11 @@ impl<'a> Parser<'a> { Abi::Rust }; self.expect_keyword(keywords::Fn)?; + let fn_span = self.last_span; let (ident, item_, extra_attrs) = - self.parse_item_fn(Unsafety::Unsafe, Constness::NotConst, abi)?; + self.parse_item_fn(Unsafety::Unsafe, + respan(fn_span, Constness::NotConst), + abi)?; let last_span = self.last_span; let item = self.mk_item(lo, last_span.hi, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a77c678248b..4c834403063 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1184,7 +1184,7 @@ impl<'a> State<'a> { try!(self.print_fn( decl, unsafety, - constness, + constness.node, abi, Some(item.ident), typarams, @@ -1518,7 +1518,7 @@ impl<'a> State<'a> { -> io::Result<()> { self.print_fn(&m.decl, m.unsafety, - m.constness, + m.constness.node, m.abi, Some(ident), &m.generics, diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index faf6a17a150..cbf9aa8c6c1 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -24,7 +24,7 @@ use attr; use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos}; use std::rc::Rc; -use codemap::{self, CodeMap, ExpnInfo, NameAndSpan, MacroAttribute}; +use codemap::{self, CodeMap, ExpnInfo, NameAndSpan, MacroAttribute, dummy_spanned}; use errors; use errors::snippet::{SnippetData}; use config; @@ -485,7 +485,7 @@ fn mk_main(cx: &mut TestCtxt) -> P { let main_body = ecx.block(sp, vec![call_test_main]); let main = ast::ItemKind::Fn(ecx.fn_decl(vec![], main_ret_ty), ast::Unsafety::Normal, - ast::Constness::NotConst, + dummy_spanned(ast::Constness::NotConst), ::abi::Abi::Rust, ast::Generics::default(), main_body); let main = P(ast::Item { ident: token::str_to_ident("main"), diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 582412119ca..d75110b2654 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -31,7 +31,7 @@ use codemap::Spanned; #[derive(Copy, Clone, PartialEq, Eq)] pub enum FnKind<'a> { /// fn foo() or extern "Abi" fn foo() - ItemFn(Ident, &'a Generics, Unsafety, Constness, Abi, &'a Visibility), + ItemFn(Ident, &'a Generics, Unsafety, Spanned, Abi, &'a Visibility), /// fn foo(&self) Method(Ident, &'a MethodSig, Option<&'a Visibility>), diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index cd49e7ec9d2..809f444b993 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -197,7 +197,7 @@ use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::ext::build::AstBuilder; -use syntax::codemap::{self, respan}; +use syntax::codemap::{self, dummy_spanned, respan}; use syntax::util::move_map::MoveMap; use syntax::parse::token::{InternedString, keywords}; use syntax::ptr::P; @@ -901,7 +901,8 @@ impl<'a> MethodDef<'a> { generics: fn_generics, abi: abi, unsafety: unsafety, - constness: ast::Constness::NotConst, + constness: + dummy_spanned(ast::Constness::NotConst), decl: fn_decl, }, body_block), -- cgit 1.4.1-3-g733a5