X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fmiddle%2Fstability.rs;h=d496272ae3477fd81117c633a48046e2e7037749;hb=30c669819342dc09d6bd29dc72d0ff85381b71d2;hp=73a55265f009ac017844f2de1aa755f83ca36104;hpb=1e21c9a297a9fe668d62887a3a6a4add8e717b17;p=rust.git diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 73a55265f00..d496272ae34 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -134,11 +134,11 @@ fn annotate(&mut self, id: NodeId, attrs: &[Attribute], if self.tcx.features().staged_api { // This crate explicitly wants staged API. debug!("annotate(id = {:?}, attrs = {:?})", id, attrs); - if let Some(..) = attr::find_deprecation(self.tcx.sess.diagnostic(), attrs, item_sp) { + if let Some(..) = attr::find_deprecation(&self.tcx.sess.parse_sess, attrs, item_sp) { self.tcx.sess.span_err(item_sp, "`#[deprecated]` cannot be used in staged api, \ use `#[rustc_deprecated]` instead"); } - if let Some(mut stab) = attr::find_stability(self.tcx.sess.diagnostic(), + if let Some(mut stab) = attr::find_stability(&self.tcx.sess.parse_sess, attrs, item_sp) { // Error if prohibited, or can't inherit anything from a container if kind == AnnotationKind::Prohibited || @@ -164,8 +164,10 @@ fn annotate(&mut self, id: NodeId, attrs: &[Attribute], if let (&Some(attr::RustcDeprecation {since: dep_since, ..}), &attr::Stable {since: stab_since}) = (&stab.rustc_depr, &stab.level) { // Explicit version of iter::order::lt to handle parse errors properly - for (dep_v, stab_v) in - dep_since.as_str().split('.').zip(stab_since.as_str().split('.')) { + for (dep_v, stab_v) in dep_since.as_str() + .split('.') + .zip(stab_since.as_str().split('.')) + { if let (Ok(dep_v), Ok(stab_v)) = (dep_v.parse::(), stab_v.parse()) { match dep_v.cmp(&stab_v) { Ordering::Less => { @@ -222,7 +224,7 @@ fn annotate(&mut self, id: NodeId, attrs: &[Attribute], } } - if let Some(depr) = attr::find_deprecation(self.tcx.sess.diagnostic(), attrs, item_sp) { + if let Some(depr) = attr::find_deprecation(&self.tcx.sess.parse_sess, attrs, item_sp) { if kind == AnnotationKind::Prohibited { self.tcx.sess.span_err(item_sp, "This deprecation annotation is useless"); } @@ -441,6 +443,7 @@ pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Index<'tcx> { feature: Symbol::intern("rustc_private"), rustc_depr: None, const_stability: None, + promotable: false, }); annotator.parent_stab = Some(stability); } @@ -522,15 +525,12 @@ fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool { Some(Def::Method(_)) | Some(Def::AssociatedTy(_)) | Some(Def::AssociatedConst(_)) => { - match self.associated_item(def_id).container { - ty::TraitContainer(trait_def_id) => { - // Trait methods do not declare visibility (even - // for visibility info in cstore). Use containing - // trait instead, so methods of pub traits are - // themselves considered pub. - def_id = trait_def_id; - } - _ => {} + if let ty::TraitContainer(trait_def_id) = self.associated_item(def_id).container { + // Trait methods do not declare visibility (even + // for visibility info in cstore). Use containing + // trait instead, so methods of pub traits are + // themselves considered pub. + def_id = trait_def_id; } } _ => {} @@ -560,8 +560,7 @@ fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool { /// `id`. pub fn eval_stability(self, def_id: DefId, id: Option, span: Span) -> EvalResult { if span.allows_unstable() { - debug!("stability: \ - skipping span={:?} since it is internal", span); + debug!("stability: skipping span={:?} since it is internal", span); return EvalResult::Allow; } @@ -769,8 +768,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item) { let param_env = self.tcx.param_env(def_id); if !param_env.can_type_implement_copy(self.tcx, ty).is_ok() { emit_feature_err(&self.tcx.sess.parse_sess, - "untagged_unions", item.span, GateIssue::Language, - "unions with non-`Copy` fields are unstable"); + "untagged_unions", item.span, GateIssue::Language, + "unions with non-`Copy` fields are unstable"); } } }