From 03d3ba7667ed9599f46b742ac314a43297d76b19 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 30 Mar 2015 17:46:34 -0400 Subject: Implement the changes to coherence such that we consider a type to be local only if matches `FUNDAMENTAL(LocalType)`, where `FUNDAMENTAL` includes `&T` and types marked as fundamental (which includes `Box`). Also apply these tests to negative reasoning. --- src/libsyntax/feature_gate.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index f88381fb36f..113827a3b40 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -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), -- cgit 1.4.1-3-g733a5 From 15b58fedcacba7d10a9f7d460a83da645a09ad3e Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 30 Mar 2015 17:51:26 -0400 Subject: Fallout in libsyntax/librustc: use newtype'd options for linked lists, since `Option` is not fundamental and hence the old impls run afoul of the orphan rules. --- src/librustc/metadata/encoder.rs | 7 +++---- src/libsyntax/ast_map/mod.rs | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index a8f83bee7f6..862ced78c08 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -34,8 +34,7 @@ use std::io::prelude::*; use std::io::{Cursor, SeekFrom}; use syntax::abi; use syntax::ast::{self, DefId, NodeId}; -use syntax::ast_map::{PathElem, PathElems}; -use syntax::ast_map; +use syntax::ast_map::{self, LinkedPath, PathElem, PathElems}; use syntax::ast_util::*; use syntax::ast_util; use syntax::attr; @@ -1513,7 +1512,7 @@ fn encode_info_for_items(ecx: &EncodeContext, &krate.module, &[], ast::CRATE_NODE_ID, - [].iter().cloned().chain(None), + [].iter().cloned().chain(LinkedPath::empty()), syntax::parse::token::special_idents::invalid, ast::Public); @@ -1874,7 +1873,7 @@ fn encode_misc_info(ecx: &EncodeContext, } // Encode reexports for the root module. - encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(None)); + encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(LinkedPath::empty())); rbml_w.end_tag(); rbml_w.end_tag(); 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 { - 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(&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) -- cgit 1.4.1-3-g733a5