From 4d7c0b68cf2df93158747180bef0c7c6724e4dd3 Mon Sep 17 00:00:00 2001 From: achernyak Date: Wed, 3 May 2017 08:17:54 -0500 Subject: [PATCH 01/17] all queries use dep nodes --- src/librustc/dep_graph/dep_node.rs | 6 ++++++ src/librustc/ty/maps.rs | 10 +++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 37b8a56d9166b..1c71079e94b27 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -154,6 +154,9 @@ pub enum DepNode { DefSpan(D), Stability(D), Deprecation(D), + ItemBodyNestedBodies(D), + ConstIsRvaluePromotableToStatic(D), + IsMirAvailable(D), } impl DepNode { @@ -264,6 +267,9 @@ impl DepNode { DefSpan(ref d) => op(d).map(DefSpan), Stability(ref d) => op(d).map(Stability), Deprecation(ref d) => op(d).map(Deprecation), + ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies), + ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic), + IsMirAvailable(ref d) => op(d).map(IsMirAvailable), } } } diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 66df8dc050a24..513240a4ec345 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -783,9 +783,9 @@ define_maps! { <'tcx> [] def_span: DefSpan(DefId) -> Span, [] stability: Stability(DefId) -> Option, [] deprecation: Deprecation(DefId) -> Option, - [] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc>, - [] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool, - [] is_mir_available: metadata_dep_node(DefId) -> bool, + [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc>, + [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool, + [] is_mir_available: IsMirAvailable(DefId) -> bool, } fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode { @@ -800,10 +800,6 @@ fn reachability_dep_node(_: CrateNum) -> DepNode { DepNode::Reachability } -fn metadata_dep_node(def_id: DefId) -> DepNode { - DepNode::MetaData(def_id) -} - fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode { instance.dep_node() } From a12a55f519baea94c049fcda6d14dcd56110f39d Mon Sep 17 00:00:00 2001 From: achernyak Date: Wed, 3 May 2017 08:40:32 -0500 Subject: [PATCH 02/17] item_attrs --- src/librustc/dep_graph/dep_node.rs | 2 ++ src/librustc/middle/cstore.rs | 2 -- src/librustc/ty/maps.rs | 8 ++++++++ src/librustc/ty/mod.rs | 2 +- src/librustc_metadata/cstore_impl.rs | 7 +------ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 1c71079e94b27..fb8678ce93eae 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -157,6 +157,7 @@ pub enum DepNode { ItemBodyNestedBodies(D), ConstIsRvaluePromotableToStatic(D), IsMirAvailable(D), + ItemAttrs(D), } impl DepNode { @@ -267,6 +268,7 @@ impl DepNode { DefSpan(ref d) => op(d).map(DefSpan), Stability(ref d) => op(d).map(Stability), Deprecation(ref d) => op(d).map(Deprecation), + ItemAttrs(ref d) => op(d).map(ItemAttrs), ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies), ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic), IsMirAvailable(ref d) => op(d).map(IsMirAvailable), diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 303c5059e7cf3..e30b4b2818e5e 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -182,7 +182,6 @@ pub trait CrateStore { fn visibility(&self, def: DefId) -> ty::Visibility; fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap>; fn item_generics_cloned(&self, def: DefId) -> ty::Generics; - fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>; fn fn_arg_names(&self, did: DefId) -> Vec; // trait info @@ -309,7 +308,6 @@ impl CrateStore for DummyCrateStore { } fn item_generics_cloned(&self, def: DefId) -> ty::Generics { bug!("item_generics_cloned") } - fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]> { bug!("item_attrs") } fn fn_arg_names(&self, did: DefId) -> Vec { bug!("fn_arg_names") } // trait info diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 513240a4ec345..948df61786751 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -34,6 +34,7 @@ use std::ops::Deref; use std::rc::Rc; use syntax_pos::{Span, DUMMY_SP}; use syntax::attr; +use syntax::ast; use syntax::symbol::Symbol; pub trait Key: Clone + Hash + Eq + Debug { @@ -334,6 +335,12 @@ impl<'tcx> QueryDescription for queries::deprecation<'tcx> { } } +impl<'tcx> QueryDescription for queries::item_attrs<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("item_attrs") + } +} + impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> { fn describe(tcx: TyCtxt, def_id: DefId) -> String { format!("nested item bodies of `{}`", tcx.item_path_str(def_id)) @@ -783,6 +790,7 @@ define_maps! { <'tcx> [] def_span: DefSpan(DefId) -> Span, [] stability: Stability(DefId) -> Option, [] deprecation: Deprecation(DefId) -> Option, + [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>, [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc>, [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool, [] is_mir_available: IsMirAvailable(DefId) -> bool, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 55466b1f36dac..3cc250f0814ef 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2357,7 +2357,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { if let Some(id) = self.hir.as_local_node_id(did) { Attributes::Borrowed(self.hir.attrs(id)) } else { - Attributes::Owned(self.sess.cstore.item_attrs(did)) + Attributes::Owned(self.item_attrs(did)) } } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index a1794ec2d82ca..c7a52922e2a09 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -113,6 +113,7 @@ provide! { <'tcx> tcx, def_id, cdata def_span => { cdata.get_span(def_id.index, &tcx.sess) } stability => { cdata.get_stability(def_id.index) } deprecation => { cdata.get_deprecation(def_id.index) } + item_attrs => { cdata.get_item_attrs(def_id.index) } item_body_nested_bodies => { let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| { ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body)) @@ -145,12 +146,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(def.krate).get_generics(def.index) } - fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]> - { - self.dep_graph.read(DepNode::MetaData(def_id)); - self.get_crate_data(def_id.krate).get_item_attrs(def_id.index) - } - fn fn_arg_names(&self, did: DefId) -> Vec { // FIXME(#38501) We've skipped a `read` on the `HirBody` of From c72a16b8e2e1febb300cab5b97fc3265a463e775 Mon Sep 17 00:00:00 2001 From: achernyak Date: Wed, 3 May 2017 09:01:49 -0500 Subject: [PATCH 03/17] fn_arg_names --- src/librustc/dep_graph/dep_node.rs | 2 ++ src/librustc/middle/cstore.rs | 2 -- src/librustc/ty/maps.rs | 7 +++++++ src/librustc_metadata/cstore_impl.rs | 15 +++++---------- src/librustdoc/clean/mod.rs | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index fb8678ce93eae..591c128a16559 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -158,6 +158,7 @@ pub enum DepNode { ConstIsRvaluePromotableToStatic(D), IsMirAvailable(D), ItemAttrs(D), + FnArgNames(D), } impl DepNode { @@ -269,6 +270,7 @@ impl DepNode { Stability(ref d) => op(d).map(Stability), Deprecation(ref d) => op(d).map(Deprecation), ItemAttrs(ref d) => op(d).map(ItemAttrs), + FnArgNames(ref d) => op(d).map(FnArgNames), ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies), ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic), IsMirAvailable(ref d) => op(d).map(IsMirAvailable), diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index e30b4b2818e5e..00904f5406172 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -182,7 +182,6 @@ pub trait CrateStore { fn visibility(&self, def: DefId) -> ty::Visibility; fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap>; fn item_generics_cloned(&self, def: DefId) -> ty::Generics; - fn fn_arg_names(&self, did: DefId) -> Vec; // trait info fn implementations_of_trait(&self, filter: Option) -> Vec; @@ -308,7 +307,6 @@ impl CrateStore for DummyCrateStore { } fn item_generics_cloned(&self, def: DefId) -> ty::Generics { bug!("item_generics_cloned") } - fn fn_arg_names(&self, did: DefId) -> Vec { bug!("fn_arg_names") } // trait info fn implementations_of_trait(&self, filter: Option) -> Vec { vec![] } diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 948df61786751..43f6c94b8b095 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -341,6 +341,12 @@ impl<'tcx> QueryDescription for queries::item_attrs<'tcx> { } } +impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("fn_arg_names") + } +} + impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> { fn describe(tcx: TyCtxt, def_id: DefId) -> String { format!("nested item bodies of `{}`", tcx.item_path_str(def_id)) @@ -791,6 +797,7 @@ define_maps! { <'tcx> [] stability: Stability(DefId) -> Option, [] deprecation: Deprecation(DefId) -> Option, [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>, + [] fn_arg_names: FnArgNames(DefId) -> Vec, [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc>, [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool, [] is_mir_available: IsMirAvailable(DefId) -> bool, diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index c7a52922e2a09..325ba14da9c8a 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -114,6 +114,11 @@ provide! { <'tcx> tcx, def_id, cdata stability => { cdata.get_stability(def_id.index) } deprecation => { cdata.get_deprecation(def_id.index) } item_attrs => { cdata.get_item_attrs(def_id.index) } + // FIXME(#38501) We've skipped a `read` on the `HirBody` of + // a `fn` when encoding, so the dep-tracking wouldn't work. + // This is only used by rustdoc anyway, which shouldn't have + // incremental recompilation ever enabled. + fn_arg_names => { cdata.get_fn_arg_names(def_id.index) } item_body_nested_bodies => { let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| { ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body)) @@ -146,16 +151,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(def.krate).get_generics(def.index) } - fn fn_arg_names(&self, did: DefId) -> Vec - { - // FIXME(#38501) We've skipped a `read` on the `HirBody` of - // a `fn` when encoding, so the dep-tracking wouldn't work. - // This is only used by rustdoc anyway, which shouldn't have - // incremental recompilation ever enabled. - assert!(!self.dep_graph.is_fully_enabled()); - self.get_crate_data(did.krate).get_fn_arg_names(did.index) - } - fn implementations_of_trait(&self, filter: Option) -> Vec { if let Some(def_id) = filter { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 0a74848724432..78b96e1833b6d 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1179,7 +1179,7 @@ impl<'a, 'tcx> Clean for (DefId, ty::PolyFnSig<'tcx>) { let mut names = if cx.tcx.hir.as_local_node_id(did).is_some() { vec![].into_iter() } else { - cx.tcx.sess.cstore.fn_arg_names(did).into_iter() + cx.tcx.fn_arg_names(did).into_iter() }.peekable(); FnDecl { output: Return(sig.skip_binder().output().clean(cx)), From aa5a5320466d4a6ac7125cb01956307e63d9918b Mon Sep 17 00:00:00 2001 From: achernyak Date: Thu, 4 May 2017 08:27:48 -0500 Subject: [PATCH 04/17] trait_of_item --- src/librustc/dep_graph/dep_node.rs | 2 ++ src/librustc/middle/cstore.rs | 2 -- src/librustc/ty/maps.rs | 7 ++++++ src/librustc/ty/mod.rs | 34 +++++++++++++++------------- src/librustc_const_eval/eval.rs | 2 +- src/librustc_metadata/cstore_impl.rs | 6 +---- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 591c128a16559..0e462b95d820e 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -156,6 +156,7 @@ pub enum DepNode { Deprecation(D), ItemBodyNestedBodies(D), ConstIsRvaluePromotableToStatic(D), + TraitOfItem(D), IsMirAvailable(D), ItemAttrs(D), FnArgNames(D), @@ -271,6 +272,7 @@ impl DepNode { Deprecation(ref d) => op(d).map(Deprecation), ItemAttrs(ref d) => op(d).map(ItemAttrs), FnArgNames(ref d) => op(d).map(FnArgNames), + TraitOfItem(ref d) => op(d).map(TraitOfItem), ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies), ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic), IsMirAvailable(ref d) => op(d).map(IsMirAvailable), diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 00904f5406172..11a2dfc6685a1 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -191,7 +191,6 @@ pub trait CrateStore { fn impl_parent(&self, impl_def_id: DefId) -> Option; // trait/impl-item info - fn trait_of_item(&self, def_id: DefId) -> Option; fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem; // flags @@ -316,7 +315,6 @@ impl CrateStore for DummyCrateStore { fn impl_parent(&self, def: DefId) -> Option { bug!("impl_parent") } // trait/impl-item info - fn trait_of_item(&self, def_id: DefId) -> Option { bug!("trait_of_item") } fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem { bug!("associated_item_cloned") } diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 43f6c94b8b095..5d1b16c3d2e1c 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -347,6 +347,12 @@ impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> { } } +impl<'tcx> QueryDescription for queries::trait_of_item<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("trait_of_item") + } +} + impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> { fn describe(tcx: TyCtxt, def_id: DefId) -> String { format!("nested item bodies of `{}`", tcx.item_path_str(def_id)) @@ -798,6 +804,7 @@ define_maps! { <'tcx> [] deprecation: Deprecation(DefId) -> Option, [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>, [] fn_arg_names: FnArgNames(DefId) -> Vec, + [] trait_of_item: TraitOfItem(DefId) -> Option, [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc>, [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool, [] is_mir_available: IsMirAvailable(DefId) -> bool, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 3cc250f0814ef..00f81c9dcf7bc 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2430,22 +2430,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - /// If the given def ID describes an item belonging to a trait, - /// return the ID of the trait that the trait item belongs to. - /// Otherwise, return `None`. - pub fn trait_of_item(self, def_id: DefId) -> Option { - if def_id.krate != LOCAL_CRATE { - return self.sess.cstore.trait_of_item(def_id); - } - self.opt_associated_item(def_id) - .and_then(|associated_item| { - match associated_item.container { - TraitContainer(def_id) => Some(def_id), - ImplContainer(_) => None - } - }) - } - /// Construct a parameter environment suitable for static contexts or other contexts where there /// are no free type/lifetime parameters in scope. pub fn empty_parameter_environment(self) -> ParameterEnvironment<'tcx> { @@ -2693,6 +2677,23 @@ fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span { tcx.hir.span_if_local(def_id).unwrap() } +/// If the given def ID describes an item belonging to a trait, +/// return the ID of the trait that the trait item belongs to. +/// Otherwise, return `None`. +fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option { + if def_id.krate != LOCAL_CRATE { + return None + } + tcx.opt_associated_item(def_id) + .and_then(|associated_item| { + match associated_item.container { + TraitContainer(def_id) => Some(def_id), + ImplContainer(_) => None + } + }) +} + + pub fn provide(providers: &mut ty::maps::Providers) { *providers = ty::maps::Providers { associated_item, @@ -2700,6 +2701,7 @@ pub fn provide(providers: &mut ty::maps::Providers) { adt_sized_constraint, adt_dtorck_constraint, def_span, + trait_of_item, ..*providers }; } diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 8b1aa0708807b..e79f23aee1145 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -74,7 +74,7 @@ pub fn lookup_const_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // constants, we only try to find the expression for a // trait-associated const if the caller gives us the // substitutions for the reference to it. - if tcx.sess.cstore.trait_of_item(def_id).is_some() { + if tcx.trait_of_item(def_id).is_some() { resolve_trait_associated_const(tcx, def_id, substs) } else { Some((def_id, substs)) diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 325ba14da9c8a..b07dd1ec7b0b8 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -119,6 +119,7 @@ provide! { <'tcx> tcx, def_id, cdata // This is only used by rustdoc anyway, which shouldn't have // incremental recompilation ever enabled. fn_arg_names => { cdata.get_fn_arg_names(def_id.index) } + trait_of_item => { cdata.get_trait_of_item(def_id.index) } item_body_nested_bodies => { let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| { ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body)) @@ -174,11 +175,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(impl_def.krate).get_parent_impl(impl_def.index) } - fn trait_of_item(&self, def_id: DefId) -> Option { - self.dep_graph.read(DepNode::MetaData(def_id)); - self.get_crate_data(def_id.krate).get_trait_of_item(def_id.index) - } - fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem { self.dep_graph.read(DepNode::MetaData(def)); From 03fe10d91d3361144ab5c8a142daf63bc0ff143e Mon Sep 17 00:00:00 2001 From: achernyak Date: Thu, 4 May 2017 09:37:34 -0500 Subject: [PATCH 05/17] impl_parent --- src/librustc/dep_graph/dep_node.rs | 2 ++ src/librustc/middle/cstore.rs | 2 -- src/librustc/ty/maps.rs | 7 +++++++ src/librustc/ty/mod.rs | 2 +- src/librustc_metadata/cstore_impl.rs | 6 +----- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 0e462b95d820e..de1531bbd54d3 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -156,6 +156,7 @@ pub enum DepNode { Deprecation(D), ItemBodyNestedBodies(D), ConstIsRvaluePromotableToStatic(D), + ImplParent(D), TraitOfItem(D), IsMirAvailable(D), ItemAttrs(D), @@ -272,6 +273,7 @@ impl DepNode { Deprecation(ref d) => op(d).map(Deprecation), ItemAttrs(ref d) => op(d).map(ItemAttrs), FnArgNames(ref d) => op(d).map(FnArgNames), + ImplParent(ref d) => op(d).map(ImplParent), TraitOfItem(ref d) => op(d).map(TraitOfItem), ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies), ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic), diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 11a2dfc6685a1..e50072043d5f7 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -188,7 +188,6 @@ pub trait CrateStore { // impl info fn impl_defaultness(&self, def: DefId) -> hir::Defaultness; - fn impl_parent(&self, impl_def_id: DefId) -> Option; // trait/impl-item info fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem; @@ -312,7 +311,6 @@ impl CrateStore for DummyCrateStore { // impl info fn impl_defaultness(&self, def: DefId) -> hir::Defaultness { bug!("impl_defaultness") } - fn impl_parent(&self, def: DefId) -> Option { bug!("impl_parent") } // trait/impl-item info fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 5d1b16c3d2e1c..1dfd7bc976082 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -347,6 +347,12 @@ impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> { } } +impl<'tcx> QueryDescription for queries::impl_parent<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("impl_parent") + } +} + impl<'tcx> QueryDescription for queries::trait_of_item<'tcx> { fn describe(_: TyCtxt, _: DefId) -> String { bug!("trait_of_item") @@ -804,6 +810,7 @@ define_maps! { <'tcx> [] deprecation: Deprecation(DefId) -> Option, [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>, [] fn_arg_names: FnArgNames(DefId) -> Vec, + [] impl_parent: ImplParent(DefId) -> Option, [] trait_of_item: TraitOfItem(DefId) -> Option, [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc>, [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 00f81c9dcf7bc..1c3e74d4fb965 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2393,7 +2393,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let trait_ref = self.impl_trait_ref(impl_def_id).unwrap(); // Record the trait->implementation mapping. - let parent = self.sess.cstore.impl_parent(impl_def_id).unwrap_or(trait_id); + let parent = self.impl_parent(impl_def_id).unwrap_or(trait_id); def.record_remote_impl(self, impl_def_id, trait_ref, parent); } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index b07dd1ec7b0b8..b54db55c0e12a 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -119,6 +119,7 @@ provide! { <'tcx> tcx, def_id, cdata // This is only used by rustdoc anyway, which shouldn't have // incremental recompilation ever enabled. fn_arg_names => { cdata.get_fn_arg_names(def_id.index) } + impl_parent => { cdata.get_parent_impl(def_id.index) } trait_of_item => { cdata.get_trait_of_item(def_id.index) } item_body_nested_bodies => { let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| { @@ -170,11 +171,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(def.krate).get_impl_defaultness(def.index) } - fn impl_parent(&self, impl_def: DefId) -> Option { - self.dep_graph.read(DepNode::MetaData(impl_def)); - self.get_crate_data(impl_def.krate).get_parent_impl(impl_def.index) - } - fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem { self.dep_graph.read(DepNode::MetaData(def)); From 5b71d769ffe751399b538fb0fdb51ec88345061b Mon Sep 17 00:00:00 2001 From: achernyak Date: Thu, 4 May 2017 12:45:56 -0500 Subject: [PATCH 06/17] moved metadata provider impls to decoder --- src/librustc_metadata/cstore_impl.rs | 18 +++--------------- src/librustc_metadata/decoder.rs | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index b54db55c0e12a..a0c887e95d6c7 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -41,8 +41,6 @@ use rustc::hir::svh::Svh; use rustc_back::target::Target; use rustc::hir; -use std::collections::BTreeMap; - macro_rules! provide { (<$lt:tt> $tcx:ident, $def_id:ident, $cdata:ident $($name:ident => $compute:block)*) => { pub fn provide<$lt>(providers: &mut Providers<$lt>) { @@ -121,21 +119,11 @@ provide! { <'tcx> tcx, def_id, cdata fn_arg_names => { cdata.get_fn_arg_names(def_id.index) } impl_parent => { cdata.get_parent_impl(def_id.index) } trait_of_item => { cdata.get_trait_of_item(def_id.index) } - item_body_nested_bodies => { - let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| { - ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body)) - }).collect(); - - Rc::new(map) - } + item_body_nested_bodies => { Rc::new(cdata.item_body_nested_bodies(def_id.index)) } const_is_rvalue_promotable_to_static => { - cdata.entry(def_id.index).ast.expect("const item missing `ast`") - .decode(cdata).rvalue_promotable_to_static - } - is_mir_available => { - !cdata.is_proc_macro(def_id.index) && - cdata.maybe_entry(def_id.index).and_then(|item| item.decode(cdata).mir).is_some() + cdata.const_is_rvalue_promotable_to_static(def_id.index) } + is_mir_available => { cdata.is_item_mir_available(def_id.index) } } impl CrateStore for cstore::CStore { diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index ae755adcf5fbb..b89b5181e7bb7 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -29,6 +29,7 @@ use rustc::mir::Mir; use std::borrow::Cow; use std::cell::Ref; +use std::collections::BTreeMap; use std::io; use std::mem; use std::rc::Rc; @@ -448,16 +449,16 @@ impl<'tcx> EntryKind<'tcx> { } impl<'a, 'tcx> CrateMetadata { - pub fn is_proc_macro(&self, id: DefIndex) -> bool { + fn is_proc_macro(&self, id: DefIndex) -> bool { self.proc_macros.is_some() && id != CRATE_DEF_INDEX } - pub fn maybe_entry(&self, item_id: DefIndex) -> Option>> { + fn maybe_entry(&self, item_id: DefIndex) -> Option>> { assert!(!self.is_proc_macro(item_id)); self.root.index.lookup(self.blob.raw_bytes(), item_id) } - pub fn entry(&self, item_id: DefIndex) -> Entry<'tcx> { + fn entry(&self, item_id: DefIndex) -> Entry<'tcx> { match self.maybe_entry(item_id) { None => { bug!("entry: id not found: {:?} in crate {:?} with number {}", @@ -779,6 +780,22 @@ impl<'a, 'tcx> CrateMetadata { tcx.alloc_tables(ast.tables.decode((self, tcx))) } + pub fn item_body_nested_bodies(&self, id: DefIndex) -> BTreeMap { + self.entry(id).ast.into_iter().flat_map(|ast| { + ast.decode(self).nested_bodies.decode(self).map(|body| (body.id(), body)) + }).collect() + } + + pub fn const_is_rvalue_promotable_to_static(&self, id: DefIndex) -> bool { + self.entry(id).ast.expect("const item missing `ast`") + .decode(self).rvalue_promotable_to_static + } + + pub fn is_item_mir_available(&self, id: DefIndex) -> bool { + !self.is_proc_macro(id) && + self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some() + } + pub fn maybe_get_optimized_mir(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefIndex) From 5a7946df703f2d9149adc0ca5c7e0b116e82a98d Mon Sep 17 00:00:00 2001 From: achernyak Date: Fri, 5 May 2017 08:15:08 -0500 Subject: [PATCH 07/17] is_foreign_item --- src/librustc/middle/cstore.rs | 2 -- src/librustc/middle/effect.rs | 2 +- src/librustc_metadata/cstore_impl.rs | 4 ---- src/librustc_trans/back/symbol_names.rs | 2 +- src/librustc_trans/collector.rs | 2 +- src/librustc_trans/consts.rs | 2 +- 6 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index e50072043d5f7..d9ce40a0d7de2 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -195,7 +195,6 @@ pub trait CrateStore { // flags fn is_const_fn(&self, did: DefId) -> bool; fn is_default_impl(&self, impl_did: DefId) -> bool; - fn is_foreign_item(&self, did: DefId) -> bool; fn is_dllimport_foreign_item(&self, def: DefId) -> bool; fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool; fn is_exported_symbol(&self, def_id: DefId) -> bool; @@ -319,7 +318,6 @@ impl CrateStore for DummyCrateStore { // flags fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") } fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") } - fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") } fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false } fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false } fn is_exported_symbol(&self, def_id: DefId) -> bool { false } diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index d2b8ed8c29707..4bbf37b21edbf 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -205,7 +205,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> { } else if match self.tcx.hir.get_if_local(def_id) { Some(hir::map::NodeForeignItem(..)) => true, Some(..) => false, - None => self.tcx.sess.cstore.is_foreign_item(def_id), + None => self.tcx.is_foreign_item(def_id), } { self.require_unsafe_ext(expr.id, expr.span, "use of extern static", true); } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index a0c887e95d6c7..7bd431ff44621 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -176,10 +176,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(impl_did.krate).is_default_impl(impl_did.index) } - fn is_foreign_item(&self, did: DefId) -> bool { - self.get_crate_data(did.krate).is_foreign_item(did.index) - } - fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { self.do_is_statically_included_foreign_item(def_id) diff --git a/src/librustc_trans/back/symbol_names.rs b/src/librustc_trans/back/symbol_names.rs index aef9140ba4556..1aed293294802 100644 --- a/src/librustc_trans/back/symbol_names.rs +++ b/src/librustc_trans/back/symbol_names.rs @@ -223,7 +223,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance _ => false } } else { - tcx.sess.cstore.is_foreign_item(def_id) + tcx.is_foreign_item(def_id) }; if let Some(name) = weak_lang_items::link_name(&attrs) { diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 6d7d95f548721..f0be0941ccf36 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -653,7 +653,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan Some(_) => true, None => { if tcx.sess.cstore.is_exported_symbol(def_id) || - tcx.sess.cstore.is_foreign_item(def_id) + tcx.is_foreign_item(def_id) { // We can link to the item in question, no instance needed // in this crate diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 6afb340107d66..eac0a06256719 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -186,7 +186,7 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef { llvm::set_thread_local(g, true); } } - if ccx.use_dll_storage_attrs() && !ccx.sess().cstore.is_foreign_item(def_id) { + if ccx.use_dll_storage_attrs() && !ccx.tcx().is_foreign_item(def_id) { // This item is external but not foreign, i.e. it originates from an external Rust // crate. Since we don't know whether this crate will be linked dynamically or // statically in the final application, we always mark such symbols as 'dllimport'. From d561d4c9eb808cbca28fd641934825fdf96fb762 Mon Sep 17 00:00:00 2001 From: achernyak Date: Fri, 5 May 2017 14:40:26 -0500 Subject: [PATCH 08/17] propper trait of item impl --- src/librustc/ty/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 1c3e74d4fb965..9f43ed9bf5bb5 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2682,7 +2682,7 @@ fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span { /// Otherwise, return `None`. fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option { if def_id.krate != LOCAL_CRATE { - return None + return tcx.trait_of_item(def_id) } tcx.opt_associated_item(def_id) .and_then(|associated_item| { From 1f532bfed5e0a80bf145f5db504601dc037367a1 Mon Sep 17 00:00:00 2001 From: achernyak Date: Sun, 7 May 2017 21:05:31 -0500 Subject: [PATCH 09/17] is_exported_symbol --- src/librustc/dep_graph/dep_node.rs | 2 ++ src/librustc/middle/cstore.rs | 2 -- src/librustc/ty/maps.rs | 7 +++++++ src/librustc_metadata/cstore_impl.rs | 5 +---- src/librustc_trans/collector.rs | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index de1531bbd54d3..712ada4ec65bb 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -158,6 +158,7 @@ pub enum DepNode { ConstIsRvaluePromotableToStatic(D), ImplParent(D), TraitOfItem(D), + IsExportedSymbol(D), IsMirAvailable(D), ItemAttrs(D), FnArgNames(D), @@ -275,6 +276,7 @@ impl DepNode { FnArgNames(ref d) => op(d).map(FnArgNames), ImplParent(ref d) => op(d).map(ImplParent), TraitOfItem(ref d) => op(d).map(TraitOfItem), + IsExportedSymbol(ref d) => op(d).map(IsExportedSymbol), ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies), ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic), IsMirAvailable(ref d) => op(d).map(IsMirAvailable), diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index d9ce40a0d7de2..6f0a990ca4126 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -197,7 +197,6 @@ pub trait CrateStore { fn is_default_impl(&self, impl_did: DefId) -> bool; fn is_dllimport_foreign_item(&self, def: DefId) -> bool; fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool; - fn is_exported_symbol(&self, def_id: DefId) -> bool; // crate metadata fn dylib_dependency_formats(&self, cnum: CrateNum) @@ -320,7 +319,6 @@ impl CrateStore for DummyCrateStore { fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") } fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false } fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false } - fn is_exported_symbol(&self, def_id: DefId) -> bool { false } // crate metadata fn dylib_dependency_formats(&self, cnum: CrateNum) diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 1dfd7bc976082..80783a547bf42 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -341,6 +341,12 @@ impl<'tcx> QueryDescription for queries::item_attrs<'tcx> { } } +impl<'tcx> QueryDescription for queries::is_exported_symbol<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("is_exported_symbol") + } +} + impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> { fn describe(_: TyCtxt, _: DefId) -> String { bug!("fn_arg_names") @@ -812,6 +818,7 @@ define_maps! { <'tcx> [] fn_arg_names: FnArgNames(DefId) -> Vec, [] impl_parent: ImplParent(DefId) -> Option, [] trait_of_item: TraitOfItem(DefId) -> Option, + [] is_exported_symbol: IsExportedSymbol(DefId) -> bool, [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc>, [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool, [] is_mir_available: IsMirAvailable(DefId) -> bool, diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 7bd431ff44621..d29fa8f081497 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -119,6 +119,7 @@ provide! { <'tcx> tcx, def_id, cdata fn_arg_names => { cdata.get_fn_arg_names(def_id.index) } impl_parent => { cdata.get_parent_impl(def_id.index) } trait_of_item => { cdata.get_trait_of_item(def_id.index) } + is_exported_symbol => { cdata.exported_symbols.contains(&def_id.index) } item_body_nested_bodies => { Rc::new(cdata.item_body_nested_bodies(def_id.index)) } const_is_rvalue_promotable_to_static => { cdata.const_is_rvalue_promotable_to_static(def_id.index) @@ -181,10 +182,6 @@ impl CrateStore for cstore::CStore { self.do_is_statically_included_foreign_item(def_id) } - fn is_exported_symbol(&self, def_id: DefId) -> bool { - self.get_crate_data(def_id.krate).exported_symbols.contains(&def_id.index) - } - fn is_dllimport_foreign_item(&self, def_id: DefId) -> bool { if def_id.krate == LOCAL_CRATE { self.dllimport_foreign_items.borrow().contains(&def_id.index) diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index f0be0941ccf36..5f8b79a994a55 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -652,7 +652,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan } Some(_) => true, None => { - if tcx.sess.cstore.is_exported_symbol(def_id) || + if tcx.is_exported_symbol(def_id) || tcx.is_foreign_item(def_id) { // We can link to the item in question, no instance needed From dfb740f83ca1d6f2056f5cf8de1adbe81b973438 Mon Sep 17 00:00:00 2001 From: achernyak Date: Mon, 8 May 2017 14:30:30 -0500 Subject: [PATCH 10/17] removed unnecessary if --- src/librustc/ty/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 9f43ed9bf5bb5..a065dd6a592f2 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2681,9 +2681,6 @@ fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span { /// return the ID of the trait that the trait item belongs to. /// Otherwise, return `None`. fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option { - if def_id.krate != LOCAL_CRATE { - return tcx.trait_of_item(def_id) - } tcx.opt_associated_item(def_id) .and_then(|associated_item| { match associated_item.container { From 84a40c14430566b94a238d5399929bc16867f519 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 10 May 2017 11:00:08 +0200 Subject: [PATCH 11/17] ICH: Handle case of removed FileMaps. --- src/librustc_incremental/persist/hash.rs | 6 +++- .../remove_source_file/auxiliary/mod.rs | 13 ++++++++ .../incremental/remove_source_file/main.rs | 31 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/test/incremental/remove_source_file/auxiliary/mod.rs create mode 100644 src/test/incremental/remove_source_file/main.rs diff --git a/src/librustc_incremental/persist/hash.rs b/src/librustc_incremental/persist/hash.rs index 5bc442deafa2b..2f727a80f016e 100644 --- a/src/librustc_incremental/persist/hash.rs +++ b/src/librustc_incremental/persist/hash.rs @@ -79,7 +79,11 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> { DepNode::FileMap(def_id, ref name) => { if def_id.is_local() { - Some(self.incremental_hashes_map[dep_node]) + // We will have been able to retrace the DefId (which is + // always the local CRATE_DEF_INDEX), but the file with the + // given name might have been removed, so we use get() in + // order to allow for that case. + self.incremental_hashes_map.get(dep_node).map(|x| *x) } else { Some(self.metadata_hash(DepNode::FileMap(def_id, name.clone()), def_id.krate, diff --git a/src/test/incremental/remove_source_file/auxiliary/mod.rs b/src/test/incremental/remove_source_file/auxiliary/mod.rs new file mode 100644 index 0000000000000..a2cea65a309ce --- /dev/null +++ b/src/test/incremental/remove_source_file/auxiliary/mod.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn print_hello() { + println!("hello"); +} diff --git a/src/test/incremental/remove_source_file/main.rs b/src/test/incremental/remove_source_file/main.rs new file mode 100644 index 0000000000000..4ba33f3bb3d62 --- /dev/null +++ b/src/test/incremental/remove_source_file/main.rs @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test case makes sure that the compiler doesn't crash due to a failing +// table lookup when a source file is removed. + +// revisions:rpass1 rpass2 + +// Note that we specify -g so that the FileMaps actually get referenced by the +// incr. comp. cache: +// compile-flags: -Z query-dep-graph -g + +#[cfg(rpass1)] +mod auxiliary; + +#[cfg(rpass1)] +fn main() { + auxiliary::print_hello(); +} + +#[cfg(rpass2)] +fn main() { + println!("hello"); +} From d23a65077add9da538e7ba2c2d3c3baae7a8597e Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 10 May 2017 14:37:29 +0300 Subject: [PATCH 12/17] compiletest: force GDB to print values in the Rust format. --- src/tools/compiletest/src/runtest.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a044282666da0..461cb59bf7dfa 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -647,6 +647,11 @@ actual:\n\ exe_file.to_str().unwrap() .replace(r"\", r"\\"))); + // Force GDB to print values in the Rust format. + if self.config.gdb_native_rust { + script_str.push_str("set language rust\n"); + } + // Add line breakpoints for line in &breakpoint_lines { script_str.push_str(&format!("break '{}':{}\n", From 76127275a09d970169952bcf616f966faa9ed6db Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Sat, 21 Jan 2017 13:38:11 -0500 Subject: [PATCH 13/17] Add `eprint!` and `eprintln!` macros to the prelude. These are exactly the same as `print!` and `println!` except that they write to stderr instead of stdout. Issue #39228. --- src/libstd/io/mod.rs | 2 + src/libstd/io/stdio.rs | 36 +++++++++++++++ src/libstd/macros.rs | 45 +++++++++++++++++++ .../run-pass/print-stdout-eprint-stderr.rs | 40 +++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 src/test/run-pass/print-stdout-eprint-stderr.rs diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index e2832873e2e67..b6d3c920fb942 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -290,6 +290,8 @@ pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +#[unstable(feature = "eprint", issue="39228")] +pub use self::stdio::_eprint; #[unstable(feature = "libstd_io_internals", issue = "0")] #[doc(no_inline, hidden)] pub use self::stdio::{set_panic, set_print}; diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 38ad23e14b3eb..de80cb4980421 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -694,6 +694,42 @@ pub fn _print(args: fmt::Arguments) { } } +#[unstable(feature = "eprint_internal", + reason = "implementation detail which may disappear or be replaced at any time", + issue = "0")] +#[doc(hidden)] +pub fn _eprint(args: fmt::Arguments) { + // As an implementation of the `eprintln!` macro, we want to try our best to + // not panic wherever possible and get the output somewhere. There are + // currently two possible vectors for panics we take care of here: + // + // 1. If the TLS key for the local stderr has been destroyed, accessing it + // would cause a panic. Note that we just lump in the uninitialized case + // here for convenience, we're not trying to avoid a panic. + // 2. If the local stderr is currently in use (e.g. we're in the middle of + // already printing) then accessing again would cause a panic. + // + // If, however, the actual I/O causes an error, we do indeed panic. + use panicking::LOCAL_STDERR; + let result = match LOCAL_STDERR.state() { + LocalKeyState::Uninitialized | + LocalKeyState::Destroyed => stderr().write_fmt(args), + LocalKeyState::Valid => { + LOCAL_STDERR.with(|s| { + if let Ok(mut borrowed) = s.try_borrow_mut() { + if let Some(w) = borrowed.as_mut() { + return w.write_fmt(args); + } + } + stderr().write_fmt(args) + }) + } + }; + if let Err(e) = result { + panic!("failed printing to stderr: {}", e); + } +} + #[cfg(test)] mod tests { use thread; diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index a1f092621cb44..d1c304ec46e79 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -68,6 +68,9 @@ macro_rules! panic { /// necessary to use `io::stdout().flush()` to ensure the output is emitted /// immediately. /// +/// Use `print!` only for the primary output of your program. Use +/// `eprint!` instead to print error and progress messages. +/// /// # Panics /// /// Panics if writing to `io::stdout()` fails. @@ -105,6 +108,9 @@ macro_rules! print { /// Use the `format!` syntax to write data to the standard output. /// See `std::fmt` for more information. /// +/// Use `println!` only for the primary output of your program. Use +/// `eprintln!` instead to print error and progress messages. +/// /// # Panics /// /// Panics if writing to `io::stdout()` fails. @@ -124,6 +130,45 @@ macro_rules! println { ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); } +/// Macro for printing to the standard error. +/// +/// Equivalent to the `print!` macro, except that output goes to +/// `io::stderr()` instead of `io::stdout()`. See `print!` for +/// example usage. +/// +/// Use `eprint!` only for error and progress messages. Use `print!` +/// instead for the primary output of your program. +/// +/// # Panics +/// +/// Panics if writing to `io::stderr()` fails. +#[macro_export] +#[unstable(feature = "eprint", issue="39228")] +#[allow_internal_unstable] +macro_rules! eprint { + ($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*))); +} + +/// Macro for printing to the standard error, with a newline. +/// +/// Equivalent to the `println!` macro, except that output goes to +/// `io::stderr()` instead of `io::stdout()`. See `println!` for +/// example usage. +/// +/// Use `eprintln!` only for error and progress messages. Use `println!` +/// instead for the primary output of your program. +/// +/// # Panics +/// +/// Panics if writing to `io::stderr()` fails. +#[macro_export] +#[unstable(feature = "eprint", issue="39228")] +macro_rules! eprintln { + () => (eprint!("\n")); + ($fmt:expr) => (eprint!(concat!($fmt, "\n"))); + ($fmt:expr, $($arg:tt)*) => (eprint!(concat!($fmt, "\n"), $($arg)*)); +} + /// A macro to select an event from a number of receivers. /// /// This macro is used to wait for the first event to occur on a number of diff --git a/src/test/run-pass/print-stdout-eprint-stderr.rs b/src/test/run-pass/print-stdout-eprint-stderr.rs new file mode 100644 index 0000000000000..8ca6e1c63567e --- /dev/null +++ b/src/test/run-pass/print-stdout-eprint-stderr.rs @@ -0,0 +1,40 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(eprint)] + +use std::{env, process}; + +fn child() { + print!("[stdout 0]"); + print!("[stdout {}]", 1); + println!("[stdout {}]", 2); + println!(); + eprint!("[stderr 0]"); + eprint!("[stderr {}]", 1); + eprintln!("[stderr {}]", 2); + eprintln!(); +} + +fn parent() { + let this = env::args().next().unwrap(); + let output = process::Command::new(this).arg("-").output().unwrap(); + assert!(output.status.success()); + + let stdout = String::from_utf8(output.stdout).unwrap(); + let stderr = String::from_utf8(output.stderr).unwrap(); + + assert_eq!(stdout, "[stdout 0][stdout 1][stdout 2]\n\n"); + assert_eq!(stderr, "[stderr 0][stderr 1][stderr 2]\n\n"); +} + +fn main() { + if env::args().count() == 2 { child() } else { parent() } +} From 07766f675caaabc1d64ef59db6ddfa43e72e6d4f Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Thu, 13 Apr 2017 10:48:09 -0400 Subject: [PATCH 14/17] Revise the eprint(ln)! feature. * Factor out the nigh-identical bodies of `_print` and `_eprint` to a helper function `print_to` (I was sorely tempted to call it `_doprnt`). * Update the issue number for the unstable `eprint` feature. * Add entries to the "unstable book" for `eprint` and `eprint_internal`. * Style corrections to the documentation. --- src/doc/unstable-book/src/SUMMARY.md | 2 + .../src/library-features/eprint-internal.md | 5 ++ .../src/library-features/eprint.md | 13 +++ src/libstd/io/mod.rs | 2 +- src/libstd/io/stdio.rs | 79 +++++++------------ src/libstd/macros.rs | 14 ++-- 6 files changed, 57 insertions(+), 58 deletions(-) create mode 100644 src/doc/unstable-book/src/library-features/eprint-internal.md create mode 100644 src/doc/unstable-book/src/library-features/eprint.md diff --git a/src/doc/unstable-book/src/SUMMARY.md b/src/doc/unstable-book/src/SUMMARY.md index 3d9e7c7fd860d..9229f445297df 100644 --- a/src/doc/unstable-book/src/SUMMARY.md +++ b/src/doc/unstable-book/src/SUMMARY.md @@ -130,6 +130,8 @@ - [derive_eq](library-features/derive-eq.md) - [discriminant_value](library-features/discriminant-value.md) - [error_type_id](library-features/error-type-id.md) + - [eprint](library-features/eprint.md) + - [eprint_internal](library-features/eprint-internal.md) - [exact_size_is_empty](library-features/exact-size-is-empty.md) - [fd](library-features/fd.md) - [fd_read](library-features/fd-read.md) diff --git a/src/doc/unstable-book/src/library-features/eprint-internal.md b/src/doc/unstable-book/src/library-features/eprint-internal.md new file mode 100644 index 0000000000000..d3230d8bfa83e --- /dev/null +++ b/src/doc/unstable-book/src/library-features/eprint-internal.md @@ -0,0 +1,5 @@ +# `eprint_internal` + +This feature is internal to the Rust compiler and is not intended for general use. + +------------------------ diff --git a/src/doc/unstable-book/src/library-features/eprint.md b/src/doc/unstable-book/src/library-features/eprint.md new file mode 100644 index 0000000000000..69f781b224167 --- /dev/null +++ b/src/doc/unstable-book/src/library-features/eprint.md @@ -0,0 +1,13 @@ +# `eprint` + +The tracking issue for this feature is: [#40528] + +[#40528]: https://github.com/rust-lang/rust/issues/40528 + +------------------------ + +This feature enables the `eprint!` and `eprintln!` global macros, +which are just like `print!` and `println!`, respectively, except that +they send output to the standard _error_ stream, rather than standard +output. (`panic!` messages have always been written to standard error.) + diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index b6d3c920fb942..9320bfe9abee5 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -290,7 +290,7 @@ pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; -#[unstable(feature = "eprint", issue="39228")] +#[unstable(feature = "eprint", issue="40528")] pub use self::stdio::_eprint; #[unstable(feature = "libstd_io_internals", issue = "0")] #[doc(no_inline, hidden)] diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index de80cb4980421..363c99c666e3a 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -17,7 +17,7 @@ use io::{self, BufReader, LineWriter}; use sync::{Arc, Mutex, MutexGuard}; use sys::stdio; use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; -use thread::LocalKeyState; +use thread::{LocalKey, LocalKeyState}; /// Stdout used by print! and println! macros thread_local! { @@ -659,75 +659,54 @@ pub fn set_print(sink: Option>) -> Option> { }) } -#[unstable(feature = "print", - reason = "implementation detail which may disappear or be replaced at any time", - issue = "0")] -#[doc(hidden)] -pub fn _print(args: fmt::Arguments) { - // As an implementation of the `println!` macro, we want to try our best to - // not panic wherever possible and get the output somewhere. There are - // currently two possible vectors for panics we take care of here: - // - // 1. If the TLS key for the local stdout has been destroyed, accessing it - // would cause a panic. Note that we just lump in the uninitialized case - // here for convenience, we're not trying to avoid a panic. - // 2. If the local stdout is currently in use (e.g. we're in the middle of - // already printing) then accessing again would cause a panic. - // - // If, however, the actual I/O causes an error, we do indeed panic. - let result = match LOCAL_STDOUT.state() { +/// Write `args` to output stream `local_s` if possible, `global_s` +/// otherwise. `label` identifies the stream in a panic message. +/// +/// This function is used to print error messages, so it takes extra +/// care to avoid causing a panic when `local_stream` is unusable. +/// For instance, if the TLS key for the local stream is uninitialized +/// or already destroyed, or if the local stream is locked by another +/// thread, it will just fall back to the global stream. +/// +/// However, if the actual I/O causes an error, this function does panic. +fn print_to(args: fmt::Arguments, + local_s: &'static LocalKey>>>, + global_s: fn() -> T, + label: &str) where T: Write { + let result = match local_s.state() { LocalKeyState::Uninitialized | - LocalKeyState::Destroyed => stdout().write_fmt(args), + LocalKeyState::Destroyed => global_s().write_fmt(args), LocalKeyState::Valid => { - LOCAL_STDOUT.with(|s| { + local_s.with(|s| { if let Ok(mut borrowed) = s.try_borrow_mut() { if let Some(w) = borrowed.as_mut() { return w.write_fmt(args); } } - stdout().write_fmt(args) + global_s().write_fmt(args) }) } }; if let Err(e) = result { - panic!("failed printing to stdout: {}", e); + panic!("failed printing to {}: {}", label, e); } } +#[unstable(feature = "print", + reason = "implementation detail which may disappear or be replaced at any time", + issue = "0")] +#[doc(hidden)] +pub fn _print(args: fmt::Arguments) { + print_to(args, &LOCAL_STDOUT, stdout, "stdout"); +} + #[unstable(feature = "eprint_internal", reason = "implementation detail which may disappear or be replaced at any time", issue = "0")] #[doc(hidden)] pub fn _eprint(args: fmt::Arguments) { - // As an implementation of the `eprintln!` macro, we want to try our best to - // not panic wherever possible and get the output somewhere. There are - // currently two possible vectors for panics we take care of here: - // - // 1. If the TLS key for the local stderr has been destroyed, accessing it - // would cause a panic. Note that we just lump in the uninitialized case - // here for convenience, we're not trying to avoid a panic. - // 2. If the local stderr is currently in use (e.g. we're in the middle of - // already printing) then accessing again would cause a panic. - // - // If, however, the actual I/O causes an error, we do indeed panic. use panicking::LOCAL_STDERR; - let result = match LOCAL_STDERR.state() { - LocalKeyState::Uninitialized | - LocalKeyState::Destroyed => stderr().write_fmt(args), - LocalKeyState::Valid => { - LOCAL_STDERR.with(|s| { - if let Ok(mut borrowed) = s.try_borrow_mut() { - if let Some(w) = borrowed.as_mut() { - return w.write_fmt(args); - } - } - stderr().write_fmt(args) - }) - } - }; - if let Err(e) = result { - panic!("failed printing to stderr: {}", e); - } + print_to(args, &LOCAL_STDERR, stderr, "stderr"); } #[cfg(test)] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index d1c304ec46e79..98c635d127f7d 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -113,7 +113,7 @@ macro_rules! print { /// /// # Panics /// -/// Panics if writing to `io::stdout()` fails. +/// Panics if writing to `io::stdout` fails. /// /// # Examples /// @@ -133,7 +133,7 @@ macro_rules! println { /// Macro for printing to the standard error. /// /// Equivalent to the `print!` macro, except that output goes to -/// `io::stderr()` instead of `io::stdout()`. See `print!` for +/// `io::stderr` instead of `io::stdout`. See `print!` for /// example usage. /// /// Use `eprint!` only for error and progress messages. Use `print!` @@ -141,9 +141,9 @@ macro_rules! println { /// /// # Panics /// -/// Panics if writing to `io::stderr()` fails. +/// Panics if writing to `io::stderr` fails. #[macro_export] -#[unstable(feature = "eprint", issue="39228")] +#[unstable(feature = "eprint", issue="40528")] #[allow_internal_unstable] macro_rules! eprint { ($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*))); @@ -152,7 +152,7 @@ macro_rules! eprint { /// Macro for printing to the standard error, with a newline. /// /// Equivalent to the `println!` macro, except that output goes to -/// `io::stderr()` instead of `io::stdout()`. See `println!` for +/// `io::stderr` instead of `io::stdout`. See `println!` for /// example usage. /// /// Use `eprintln!` only for error and progress messages. Use `println!` @@ -160,9 +160,9 @@ macro_rules! eprint { /// /// # Panics /// -/// Panics if writing to `io::stderr()` fails. +/// Panics if writing to `io::stderr` fails. #[macro_export] -#[unstable(feature = "eprint", issue="39228")] +#[unstable(feature = "eprint", issue="40528")] macro_rules! eprintln { () => (eprint!("\n")); ($fmt:expr) => (eprint!(concat!($fmt, "\n"))); From 4ab3bcb9ca137ad6e6ee4ae4a70a234d92b6d4ab Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Thu, 20 Apr 2017 17:37:12 -0400 Subject: [PATCH 15/17] Fix up stability annotations per feedback. --- src/doc/unstable-book/src/SUMMARY.md | 4 +--- .../unstable-book/src/library-features/eprint.md | 13 ------------- .../{eprint-internal.md => print-internals.md} | 2 +- src/doc/unstable-book/src/library-features/print.md | 5 ----- src/libstd/io/mod.rs | 6 +++--- src/libstd/io/stdio.rs | 4 ++-- src/libstd/macros.rs | 4 ++-- src/test/run-pass/print-stdout-eprint-stderr.rs | 2 -- 8 files changed, 9 insertions(+), 31 deletions(-) delete mode 100644 src/doc/unstable-book/src/library-features/eprint.md rename src/doc/unstable-book/src/library-features/{eprint-internal.md => print-internals.md} (84%) delete mode 100644 src/doc/unstable-book/src/library-features/print.md diff --git a/src/doc/unstable-book/src/SUMMARY.md b/src/doc/unstable-book/src/SUMMARY.md index 9229f445297df..8f26e4d36cda2 100644 --- a/src/doc/unstable-book/src/SUMMARY.md +++ b/src/doc/unstable-book/src/SUMMARY.md @@ -130,8 +130,6 @@ - [derive_eq](library-features/derive-eq.md) - [discriminant_value](library-features/discriminant-value.md) - [error_type_id](library-features/error-type-id.md) - - [eprint](library-features/eprint.md) - - [eprint_internal](library-features/eprint-internal.md) - [exact_size_is_empty](library-features/exact-size-is-empty.md) - [fd](library-features/fd.md) - [fd_read](library-features/fd-read.md) @@ -180,7 +178,7 @@ - [peek](library-features/peek.md) - [placement_in](library-features/placement-in.md) - [placement_new_protocol](library-features/placement-new-protocol.md) - - [print](library-features/print.md) + - [print_internals](library-features/print-internals.md) - [proc_macro_internals](library-features/proc-macro-internals.md) - [process_try_wait](library-features/process-try-wait.md) - [question_mark_carrier](library-features/question-mark-carrier.md) diff --git a/src/doc/unstable-book/src/library-features/eprint.md b/src/doc/unstable-book/src/library-features/eprint.md deleted file mode 100644 index 69f781b224167..0000000000000 --- a/src/doc/unstable-book/src/library-features/eprint.md +++ /dev/null @@ -1,13 +0,0 @@ -# `eprint` - -The tracking issue for this feature is: [#40528] - -[#40528]: https://github.com/rust-lang/rust/issues/40528 - ------------------------- - -This feature enables the `eprint!` and `eprintln!` global macros, -which are just like `print!` and `println!`, respectively, except that -they send output to the standard _error_ stream, rather than standard -output. (`panic!` messages have always been written to standard error.) - diff --git a/src/doc/unstable-book/src/library-features/eprint-internal.md b/src/doc/unstable-book/src/library-features/print-internals.md similarity index 84% rename from src/doc/unstable-book/src/library-features/eprint-internal.md rename to src/doc/unstable-book/src/library-features/print-internals.md index d3230d8bfa83e..a68557872af55 100644 --- a/src/doc/unstable-book/src/library-features/eprint-internal.md +++ b/src/doc/unstable-book/src/library-features/print-internals.md @@ -1,4 +1,4 @@ -# `eprint_internal` +# `print_internals` This feature is internal to the Rust compiler and is not intended for general use. diff --git a/src/doc/unstable-book/src/library-features/print.md b/src/doc/unstable-book/src/library-features/print.md deleted file mode 100644 index dc25cb237e3b5..0000000000000 --- a/src/doc/unstable-book/src/library-features/print.md +++ /dev/null @@ -1,5 +0,0 @@ -# `print` - -This feature is internal to the Rust compiler and is not intended for general use. - ------------------------- diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 9320bfe9abee5..c872a8e526114 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -287,11 +287,11 @@ pub use self::error::{Result, Error, ErrorKind}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; #[stable(feature = "rust1", since = "1.0.0")] -pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr}; +pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; -#[unstable(feature = "eprint", issue="40528")] -pub use self::stdio::_eprint; +#[unstable(feature = "print_internals", issue = "0")] +pub use self::stdio::{_print, _eprint}; #[unstable(feature = "libstd_io_internals", issue = "0")] #[doc(no_inline, hidden)] pub use self::stdio::{set_panic, set_print}; diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 363c99c666e3a..a8b0bf0071a22 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -692,7 +692,7 @@ fn print_to(args: fmt::Arguments, } } -#[unstable(feature = "print", +#[unstable(feature = "print_internals", reason = "implementation detail which may disappear or be replaced at any time", issue = "0")] #[doc(hidden)] @@ -700,7 +700,7 @@ pub fn _print(args: fmt::Arguments) { print_to(args, &LOCAL_STDOUT, stdout, "stdout"); } -#[unstable(feature = "eprint_internal", +#[unstable(feature = "print_internals", reason = "implementation detail which may disappear or be replaced at any time", issue = "0")] #[doc(hidden)] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 98c635d127f7d..ef78ea6dfe8ee 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -143,7 +143,7 @@ macro_rules! println { /// /// Panics if writing to `io::stderr` fails. #[macro_export] -#[unstable(feature = "eprint", issue="40528")] +#[stable(feature = "eprint", since="1.18.0")] #[allow_internal_unstable] macro_rules! eprint { ($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*))); @@ -162,7 +162,7 @@ macro_rules! eprint { /// /// Panics if writing to `io::stderr` fails. #[macro_export] -#[unstable(feature = "eprint", issue="40528")] +#[stable(feature = "eprint", since="1.18.0")] macro_rules! eprintln { () => (eprint!("\n")); ($fmt:expr) => (eprint!(concat!($fmt, "\n"))); diff --git a/src/test/run-pass/print-stdout-eprint-stderr.rs b/src/test/run-pass/print-stdout-eprint-stderr.rs index 8ca6e1c63567e..f65d841700efa 100644 --- a/src/test/run-pass/print-stdout-eprint-stderr.rs +++ b/src/test/run-pass/print-stdout-eprint-stderr.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(eprint)] - use std::{env, process}; fn child() { From a06f9a66dff42965a47e9c8d99b059707347b998 Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 10 May 2017 18:20:23 +0200 Subject: [PATCH 16/17] Remove debug message --- src/librustc_lint/builtin.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 715a769158bc3..3b6516af35a05 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -718,7 +718,6 @@ fn fl_lit_check_expr(cx: &EarlyContext, expr: &ast::Expr) { cx.span_lint(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, l.span, "floating-point literals cannot be used in patterns"); - error!("span mc spanspam"); }, _ => (), } From 72588a2b2a1af655b81fcd3c1c467707d9c237c2 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Wed, 10 May 2017 15:28:25 -0400 Subject: [PATCH 17/17] Skip print-stdout-eprint-stderr test on emscripten --- src/test/run-pass/print-stdout-eprint-stderr.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/run-pass/print-stdout-eprint-stderr.rs b/src/test/run-pass/print-stdout-eprint-stderr.rs index f65d841700efa..0a0f30aba72c2 100644 --- a/src/test/run-pass/print-stdout-eprint-stderr.rs +++ b/src/test/run-pass/print-stdout-eprint-stderr.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-emscripten spawning processes is not supported + use std::{env, process}; fn child() {