diff options
| author | bors <bors@rust-lang.org> | 2015-04-01 22:41:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-01 22:41:08 +0000 |
| commit | 2e3b0c051dca9880bf66b5366dccd2e0bb424b99 (patch) | |
| tree | 2e8b8ea5a0daf51f819acaab9b9e2572459e2a60 /src/libsyntax | |
| parent | d528aa9960cb9b937d8ef6c09905a6a8076d5f3a (diff) | |
| parent | 0304e15e5c39654346e827c2bb25ca41ed310c86 (diff) | |
| download | rust-2e3b0c051dca9880bf66b5366dccd2e0bb424b99.tar.gz rust-2e3b0c051dca9880bf66b5366dccd2e0bb424b99.zip | |
Auto merge of #23955 - alexcrichton:rollup, r=alexcrichton
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map/mod.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 19 |
3 files changed, 43 insertions, 15 deletions
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 48bb044cb18..2b5cb7076f4 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -53,18 +53,29 @@ impl fmt::Display for PathElem { } #[derive(Clone)] -struct LinkedPathNode<'a> { +pub struct LinkedPathNode<'a> { node: PathElem, next: LinkedPath<'a>, } -type LinkedPath<'a> = Option<&'a LinkedPathNode<'a>>; +#[derive(Copy, Clone)] +pub struct LinkedPath<'a>(Option<&'a LinkedPathNode<'a>>); + +impl<'a> LinkedPath<'a> { + pub fn empty() -> LinkedPath<'a> { + LinkedPath(None) + } + + pub fn from(node: &'a LinkedPathNode) -> LinkedPath<'a> { + LinkedPath(Some(node)) + } +} impl<'a> Iterator for LinkedPath<'a> { type Item = PathElem; fn next(&mut self) -> Option<PathElem> { - match *self { + match self.0 { Some(node) => { *self = node.next; Some(node.node) @@ -384,7 +395,7 @@ impl<'ast> Map<'ast> { pub fn with_path<T, F>(&self, id: NodeId, f: F) -> T where F: FnOnce(PathElems) -> T, { - self.with_path_next(id, None, f) + self.with_path_next(id, LinkedPath::empty(), f) } pub fn path_to_string(&self, id: NodeId) -> String { @@ -422,7 +433,7 @@ impl<'ast> Map<'ast> { _ => f([].iter().cloned().chain(next)) } } else { - self.with_path_next(parent, Some(&LinkedPathNode { + self.with_path_next(parent, LinkedPath::from(&LinkedPathNode { node: self.get_path_elem(id), next: next }), f) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index f88381fb36f..4c01cecc67c 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -25,7 +25,7 @@ use self::Status::*; use self::AttributeType::*; -use abi::RustIntrinsic; +use abi::Abi; use ast::NodeId; use ast; use attr; @@ -91,6 +91,8 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ ("start", "1.0.0", Active), ("main", "1.0.0", Active), + ("fundamental", "1.0.0", Active), + // Deprecate after snapshot // SNAP 5520801 ("unsafe_destructor", "1.0.0", Active), @@ -237,6 +239,10 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[ ("allow_internal_unstable", Gated("allow_internal_unstable", EXPLAIN_ALLOW_INTERNAL_UNSTABLE)), + ("fundamental", Gated("fundamental", + "the `#[fundamental]` attribute \ + is an experimental feature")), + // FIXME: #14408 whitelist docs since rustdoc looks at them ("doc", Whitelisted), @@ -511,7 +517,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { across platforms, it is recommended to \ use `#[link(name = \"foo\")]` instead") } - if foreign_module.abi == RustIntrinsic { + if foreign_module.abi == Abi::RustIntrinsic { self.gate_feature("intrinsics", i.span, "intrinsics are subject to change") @@ -627,11 +633,17 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { span: Span, _node_id: NodeId) { match fn_kind { - visit::FkItemFn(_, _, _, abi) if abi == RustIntrinsic => { + visit::FkItemFn(_, _, _, abi) if abi == Abi::RustIntrinsic => { self.gate_feature("intrinsics", span, "intrinsics are subject to change") } + visit::FkItemFn(_, _, _, abi) | + visit::FkMethod(_, &ast::MethodSig { abi, .. }) if abi == Abi::RustCall => { + self.gate_feature("unboxed_closures", + span, + "rust-call ABI is subject to change") + } _ => {} } visit::walk_fn(self, fn_kind, fn_decl, block, span); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index da1b7a7bdde..c2f323f98af 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -37,6 +37,7 @@ pub enum AnnNode<'a> { NodeName(&'a ast::Name), NodeBlock(&'a ast::Block), NodeItem(&'a ast::Item), + NodeSubItem(ast::NodeId), NodeExpr(&'a ast::Expr), NodePat(&'a ast::Pat), } @@ -1264,6 +1265,7 @@ impl<'a> State<'a> { pub fn print_trait_item(&mut self, ti: &ast::TraitItem) -> io::Result<()> { + try!(self.ann.pre(self, NodeSubItem(ti.id))); try!(self.hardbreak_if_not_bol()); try!(self.maybe_print_comment(ti.span.lo)); try!(self.print_outer_attributes(&ti.attrs)); @@ -1275,19 +1277,21 @@ impl<'a> State<'a> { try!(self.print_method_sig(ti.ident, sig, ast::Inherited)); if let Some(ref body) = *body { try!(self.nbsp()); - self.print_block_with_attrs(body, &ti.attrs) + try!(self.print_block_with_attrs(body, &ti.attrs)); } else { - word(&mut self.s, ";") + try!(word(&mut self.s, ";")); } } ast::TypeTraitItem(ref bounds, ref default) => { - self.print_associated_type(ti.ident, Some(bounds), - default.as_ref().map(|ty| &**ty)) + try!(self.print_associated_type(ti.ident, Some(bounds), + default.as_ref().map(|ty| &**ty))); } } + self.ann.post(self, NodeSubItem(ti.id)) } pub fn print_impl_item(&mut self, ii: &ast::ImplItem) -> io::Result<()> { + try!(self.ann.pre(self, NodeSubItem(ii.id))); try!(self.hardbreak_if_not_bol()); try!(self.maybe_print_comment(ii.span.lo)); try!(self.print_outer_attributes(&ii.attrs)); @@ -1296,10 +1300,10 @@ impl<'a> State<'a> { try!(self.head("")); try!(self.print_method_sig(ii.ident, sig, ii.vis)); try!(self.nbsp()); - self.print_block_with_attrs(body, &ii.attrs) + try!(self.print_block_with_attrs(body, &ii.attrs)); } ast::TypeImplItem(ref ty) => { - self.print_associated_type(ii.ident, None, Some(ty)) + try!(self.print_associated_type(ii.ident, None, Some(ty))); } ast::MacImplItem(codemap::Spanned { node: ast::MacInvocTT(ref pth, ref tts, _), ..}) => { @@ -1311,9 +1315,10 @@ impl<'a> State<'a> { try!(self.print_tts(&tts[..])); try!(self.pclose()); try!(word(&mut self.s, ";")); - self.end() + try!(self.end()) } } + self.ann.post(self, NodeSubItem(ii.id)) } pub fn print_outer_attributes(&mut self, |
