From ac9dfc3e7785c9bba96ebac4fd51726189e1bf91 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 11 Apr 2020 00:50:02 -0400 Subject: [PATCH 01/71] Normalize opaque types when converting `ParamEnv` to `Reveal::All` Fixes #65918 --- src/librustc_middle/mir/interpret/queries.rs | 2 +- src/librustc_middle/mir/interpret/value.rs | 2 +- src/librustc_middle/query/mod.rs | 12 +- src/librustc_middle/ty/layout.rs | 4 +- src/librustc_middle/ty/mod.rs | 15 +- src/librustc_middle/ty/query/keys.rs | 11 ++ src/librustc_middle/ty/util.rs | 156 ++++++++++-------- src/librustc_mir/shim.rs | 2 +- src/librustc_mir/transform/const_prop.rs | 2 +- src/librustc_mir/transform/elaborate_drops.rs | 2 +- src/librustc_mir/transform/inline.rs | 2 +- src/librustc_mir_build/hair/pattern/mod.rs | 2 +- src/librustc_symbol_mangling/v0.rs | 2 +- src/librustc_ty/instance.rs | 2 +- src/librustc_ty/ty.rs | 5 + 15 files changed, 139 insertions(+), 82 deletions(-) diff --git a/src/librustc_middle/mir/interpret/queries.rs b/src/librustc_middle/mir/interpret/queries.rs index d7c0be058599f..442e7f6b0f45e 100644 --- a/src/librustc_middle/mir/interpret/queries.rs +++ b/src/librustc_middle/mir/interpret/queries.rs @@ -18,7 +18,7 @@ impl<'tcx> TyCtxt<'tcx> { let substs = InternalSubsts::identity_for_item(self, def_id); let instance = ty::Instance::new(def_id, substs); let cid = GlobalId { instance, promoted: None }; - let param_env = self.param_env(def_id).with_reveal_all(); + let param_env = self.param_env(def_id).with_reveal_all_normalized(self); self.const_eval_global_id(param_env, cid, None) } diff --git a/src/librustc_middle/mir/interpret/value.rs b/src/librustc_middle/mir/interpret/value.rs index ba2a2bd8a026f..a560c2aa0be11 100644 --- a/src/librustc_middle/mir/interpret/value.rs +++ b/src/librustc_middle/mir/interpret/value.rs @@ -78,7 +78,7 @@ impl<'tcx> ConstValue<'tcx> { param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> Option { - let size = tcx.layout_of(param_env.with_reveal_all().and(ty)).ok()?.size; + let size = tcx.layout_of(param_env.with_reveal_all_normalized(tcx).and(ty)).ok()?.size; self.try_to_bits(size) } diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index f857af28622d1..69f1366abf8ec 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -864,11 +864,17 @@ rustc_queries! { /// type-checking etc, and it does not normalize specializable /// associated types. This is almost always what you want, /// unless you are doing MIR optimizations, in which case you - /// might want to use `reveal_all()` method to change modes. query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> { desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) } } + /// Like `param_env`, but returns the `ParamEnv in `Reveal::All` mode. + /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`, + /// as this method is more efficient. + query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> { + desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) } + } + /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`, /// `ty.is_copy()`, etc, since that will prune the environment where possible. query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { @@ -1527,5 +1533,9 @@ rustc_queries! { ty::Instance::new(key.value.0.to_def_id(), key.value.2), } } + + query normalize_opaque_types(key: &'tcx ty::List>) -> &'tcx ty::List> { + desc { "normalizing opaque types in {:?}", key } + } } } diff --git a/src/librustc_middle/ty/layout.rs b/src/librustc_middle/ty/layout.rs index cb937bf0112ae..06dd2eee50567 100644 --- a/src/librustc_middle/ty/layout.rs +++ b/src/librustc_middle/ty/layout.rs @@ -1921,7 +1921,7 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> { /// Computes the layout of a type. Note that this implicitly /// executes in "reveal all" mode. fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout { - let param_env = self.param_env.with_reveal_all(); + let param_env = self.param_env.with_reveal_all_normalized(self.tcx); let ty = self.tcx.normalize_erasing_regions(param_env, ty); let layout = self.tcx.layout_raw(param_env.and(ty))?; let layout = TyAndLayout { ty, layout }; @@ -1945,7 +1945,7 @@ impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> { /// Computes the layout of a type. Note that this implicitly /// executes in "reveal all" mode. fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout { - let param_env = self.param_env.with_reveal_all(); + let param_env = self.param_env.with_reveal_all_normalized(*self.tcx); let ty = self.tcx.normalize_erasing_regions(param_env, ty); let layout = self.tcx.layout_raw(param_env.and(ty))?; let layout = TyAndLayout { ty, layout }; diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 51a353c013241..ef0cf929dcd4d 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -1,5 +1,5 @@ // ignore-tidy-filelength -pub use self::fold::{TypeFoldable, TypeVisitor}; +pub use self::fold::{TypeFoldable, TypeFolder, TypeVisitor}; pub use self::AssocItemContainer::*; pub use self::BorrowKind::*; pub use self::IntVarValue::*; @@ -1819,9 +1819,15 @@ impl<'tcx> ParamEnv<'tcx> { /// the desired behavior during codegen and certain other special /// contexts; normally though we want to use `Reveal::UserFacing`, /// which is the default. - pub fn with_reveal_all(mut self) -> Self { - self.packed_data |= 1; - self + /// All opaque types in the caller_bounds of the `ParamEnv` + /// will be normalized to their underlying types. + /// See PR #65989 and issue #65918 for more details + pub fn with_reveal_all_normalized(mut self) -> Self { + if self.packed_data & 1 == 1 { + return self; + } + + ParamEnv::new(tcx.normalize_opaque_types(self.caller_bounds()), Reveal::All, self.def_id) } /// Returns this same environment but with no caller bounds. @@ -3067,6 +3073,7 @@ pub fn provide(providers: &mut ty::query::Providers) { context::provide(providers); erase_regions::provide(providers); layout::provide(providers); + util::provide(providers); super::util::bug::provide(providers); *providers = ty::query::Providers { trait_impls_of: trait_def::trait_impls_of_provider, diff --git a/src/librustc_middle/ty/query/keys.rs b/src/librustc_middle/ty/query/keys.rs index cb2b7a662cb4c..3f7a20bba2b9a 100644 --- a/src/librustc_middle/ty/query/keys.rs +++ b/src/librustc_middle/ty/query/keys.rs @@ -270,6 +270,17 @@ impl<'tcx> Key for Ty<'tcx> { } } +impl<'tcx> Key for &'tcx ty::List> { + type CacheSelector = DefaultCacheSelector; + + fn query_crate(&self) -> CrateNum { + LOCAL_CRATE + } + fn default_span(&self, _: TyCtxt<'_>) -> Span { + DUMMY_SP + } +} + impl<'tcx> Key for ty::ParamEnv<'tcx> { type CacheSelector = DefaultCacheSelector; diff --git a/src/librustc_middle/ty/util.rs b/src/librustc_middle/ty/util.rs index adba45facc9b4..35b684316fd87 100644 --- a/src/librustc_middle/ty/util.rs +++ b/src/librustc_middle/ty/util.rs @@ -3,11 +3,12 @@ use crate::ich::NodeIdHashingMode; use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::mir::interpret::{sign_extend, truncate}; +use crate::ty::fold::TypeFolder; use crate::ty::layout::IntegerExt; use crate::ty::query::TyCtxtAt; use crate::ty::subst::{GenericArgKind, InternalSubsts, Subst, SubstsRef}; use crate::ty::TyKind::*; -use crate::ty::{self, DefIdTree, GenericParamDefKind, Ty, TyCtxt, TypeFoldable}; +use crate::ty::{self, DefIdTree, GenericParamDefKind, List, Ty, TyCtxt, TypeFoldable}; use rustc_apfloat::Float as _; use rustc_ast::ast; use rustc_attr::{self as attr, SignedInt, UnsignedInt}; @@ -557,82 +558,84 @@ impl<'tcx> TyCtxt<'tcx> { def_id: DefId, substs: SubstsRef<'tcx>, ) -> Result, Ty<'tcx>> { - use crate::ty::fold::TypeFolder; - - struct OpaqueTypeExpander<'tcx> { - // Contains the DefIds of the opaque types that are currently being - // expanded. When we expand an opaque type we insert the DefId of - // that type, and when we finish expanding that type we remove the - // its DefId. - seen_opaque_tys: FxHashSet, - // Cache of all expansions we've seen so far. This is a critical - // optimization for some large types produced by async fn trees. - expanded_cache: FxHashMap<(DefId, SubstsRef<'tcx>), Ty<'tcx>>, - primary_def_id: DefId, - found_recursion: bool, - tcx: TyCtxt<'tcx>, - } - - impl<'tcx> OpaqueTypeExpander<'tcx> { - fn expand_opaque_ty( - &mut self, - def_id: DefId, - substs: SubstsRef<'tcx>, - ) -> Option> { - if self.found_recursion { - return None; - } - let substs = substs.fold_with(self); - if self.seen_opaque_tys.insert(def_id) { - let expanded_ty = match self.expanded_cache.get(&(def_id, substs)) { - Some(expanded_ty) => expanded_ty, - None => { - let generic_ty = self.tcx.type_of(def_id); - let concrete_ty = generic_ty.subst(self.tcx, substs); - let expanded_ty = self.fold_ty(concrete_ty); - self.expanded_cache.insert((def_id, substs), expanded_ty); - expanded_ty - } - }; - self.seen_opaque_tys.remove(&def_id); - Some(expanded_ty) - } else { - // If another opaque type that we contain is recursive, then it - // will report the error, so we don't have to. - self.found_recursion = def_id == self.primary_def_id; - None - } - } - } - - impl<'tcx> TypeFolder<'tcx> for OpaqueTypeExpander<'tcx> { - fn tcx(&self) -> TyCtxt<'tcx> { - self.tcx - } - - fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - if let ty::Opaque(def_id, substs) = t.kind { - self.expand_opaque_ty(def_id, substs).unwrap_or(t) - } else if t.has_opaque_types() { - t.super_fold_with(self) - } else { - t - } - } - } - let mut visitor = OpaqueTypeExpander { seen_opaque_tys: FxHashSet::default(), expanded_cache: FxHashMap::default(), - primary_def_id: def_id, + primary_def_id: Some(def_id), found_recursion: false, + check_recursion: true, tcx: self, }; + let expanded_type = visitor.expand_opaque_ty(def_id, substs).unwrap(); if visitor.found_recursion { Err(expanded_type) } else { Ok(expanded_type) } } } +struct OpaqueTypeExpander<'tcx> { + // Contains the DefIds of the opaque types that are currently being + // expanded. When we expand an opaque type we insert the DefId of + // that type, and when we finish expanding that type we remove the + // its DefId. + seen_opaque_tys: FxHashSet, + // Cache of all expansions we've seen so far. This is a critical + // optimization for some large types produced by async fn trees. + expanded_cache: FxHashMap<(DefId, SubstsRef<'tcx>), Ty<'tcx>>, + primary_def_id: Option, + found_recursion: bool, + /// Whether or not to check for recursive opaque types. + /// This is `true` when we're explicitly checking for opaque type + /// recursion, and 'false' otherwise to avoid unecessary work. + check_recursion: bool, + tcx: TyCtxt<'tcx>, +} + +impl<'tcx> OpaqueTypeExpander<'tcx> { + fn expand_opaque_ty(&mut self, def_id: DefId, substs: SubstsRef<'tcx>) -> Option> { + if self.found_recursion { + return None; + } + let substs = substs.fold_with(self); + if !self.check_recursion || self.seen_opaque_tys.insert(def_id) { + let expanded_ty = match self.expanded_cache.get(&(def_id, substs)) { + Some(expanded_ty) => expanded_ty, + None => { + let generic_ty = self.tcx.type_of(def_id); + let concrete_ty = generic_ty.subst(self.tcx, substs); + let expanded_ty = self.fold_ty(concrete_ty); + self.expanded_cache.insert((def_id, substs), expanded_ty); + expanded_ty + } + }; + if self.check_recursion { + self.seen_opaque_tys.remove(&def_id); + } + Some(expanded_ty) + } else { + // If another opaque type that we contain is recursive, then it + // will report the error, so we don't have to. + self.found_recursion = def_id == *self.primary_def_id.as_ref().unwrap(); + None + } + } +} + +impl<'tcx> TypeFolder<'tcx> for OpaqueTypeExpander<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { + self.tcx + } + + fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { + if let ty::Opaque(def_id, substs) = t.kind { + self.expand_opaque_ty(def_id, substs).unwrap_or(t) + } else if t.has_opaque_types() { + t.super_fold_with(self) + } else { + t + } + } +} + impl<'tcx> ty::TyS<'tcx> { /// Returns the maximum value for the given numeric type (including `char`s) /// or returns `None` if the type is not numeric. @@ -1142,3 +1145,24 @@ pub fn needs_drop_components( #[derive(Copy, Clone, Debug, HashStable, RustcEncodable, RustcDecodable)] pub struct AlwaysRequiresDrop; + +/// Normalizes all opaque types in the given value, replacing them +/// with their underlying types. +pub fn normalize_opaque_types( + tcx: TyCtxt<'tcx>, + val: &'tcx List>, +) -> &'tcx List> { + let mut visitor = OpaqueTypeExpander { + seen_opaque_tys: FxHashSet::default(), + expanded_cache: FxHashMap::default(), + primary_def_id: None, + found_recursion: false, + check_recursion: false, + tcx, + }; + val.fold_with(&mut visitor) +} + +pub fn provide(providers: &mut ty::query::Providers<'_>) { + *providers = ty::query::Providers { normalize_opaque_types, ..*providers } +} diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index bfa9bb9e0f0e1..6a7653b60752d 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -193,7 +193,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option>) ); } let patch = { - let param_env = tcx.param_env(def_id).with_reveal_all(); + let param_env = tcx.param_env_reveal_all_normalized(def_id); let mut elaborator = DropShimElaborator { body: &body, patch: MirPatch::new(&body), tcx, param_env }; let dropee = tcx.mk_place_deref(dropee_ptr); diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 3073bf53afd78..80fc37207171a 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -328,7 +328,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { ) -> ConstPropagator<'mir, 'tcx> { let def_id = source.def_id(); let substs = &InternalSubsts::identity_for_item(tcx, def_id); - let param_env = tcx.param_env(def_id).with_reveal_all(); + let param_env = tcx.param_env_reveal_all_normalized(def_id); let span = tcx.def_span(def_id); let can_const_prop = CanConstProp::check(body); diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index d3bfd872d16c2..ad49090bfc50c 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -25,7 +25,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops { debug!("elaborate_drops({:?} @ {:?})", src, body.span); let def_id = src.def_id(); - let param_env = tcx.param_env(src.def_id()).with_reveal_all(); + let param_env = tcx.param_env_reveal_all_normalized(src.def_id()); let move_data = match MoveData::gather_moves(body, tcx, param_env) { Ok(move_data) => move_data, Err((move_data, _)) => { diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index c03be2a8fcd69..92ea162e419db 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -72,7 +72,7 @@ impl Inliner<'tcx> { let mut callsites = VecDeque::new(); - let param_env = self.tcx.param_env(self.source.def_id()).with_reveal_all(); + let param_env = self.tcx.param_env_reveal_all_normalized(self.source.def_id()); // Only do inlining into fn bodies. let id = self.tcx.hir().as_local_hir_id(self.source.def_id().expect_local()); diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/hair/pattern/mod.rs index 4fa23906a3568..1c7e8c3c2e8b2 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/hair/pattern/mod.rs @@ -781,7 +781,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { // Use `Reveal::All` here because patterns are always monomorphic even if their function // isn't. - let param_env_reveal_all = self.param_env.with_reveal_all(); + let param_env_reveal_all = self.param_env.with_reveal_all_normalized(self.tcx); let substs = self.typeck_results.node_substs(id); let instance = match ty::Instance::resolve(self.tcx, param_env_reveal_all, def_id, substs) { Ok(Some(i)) => i, diff --git a/src/librustc_symbol_mangling/v0.rs b/src/librustc_symbol_mangling/v0.rs index ecf27fbf54220..8cfab7b9833ba 100644 --- a/src/librustc_symbol_mangling/v0.rs +++ b/src/librustc_symbol_mangling/v0.rs @@ -271,7 +271,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { let key = self.tcx.def_key(impl_def_id); let parent_def_id = DefId { index: key.parent.unwrap(), ..impl_def_id }; - let mut param_env = self.tcx.param_env(impl_def_id).with_reveal_all(); + let mut param_env = self.tcx.param_env_reveal_all_normalized(impl_def_id); if !substs.is_empty() { param_env = param_env.subst(self.tcx, substs); } diff --git a/src/librustc_ty/instance.rs b/src/librustc_ty/instance.rs index 324ae4ec29e9b..1e0c4055af3c5 100644 --- a/src/librustc_ty/instance.rs +++ b/src/librustc_ty/instance.rs @@ -137,7 +137,7 @@ fn resolve_associated_item<'tcx>( }); let substs = tcx.infer_ctxt().enter(|infcx| { - let param_env = param_env.with_reveal_all(); + let param_env = param_env.with_reveal_all_normalized(tcx); let substs = rcvr_substs.rebase_onto(tcx, trait_def_id, impl_data.substs); let substs = translate_substs( &infcx, diff --git a/src/librustc_ty/ty.rs b/src/librustc_ty/ty.rs index c99bc8a47e33b..c508fc5f89bae 100644 --- a/src/librustc_ty/ty.rs +++ b/src/librustc_ty/ty.rs @@ -276,6 +276,10 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause) } +fn param_env_reveal_all_normalized(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { + tcx.param_env(def_id).with_reveal_all_normalized(tcx) +} + fn crate_disambiguator(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateDisambiguator { assert_eq!(crate_num, LOCAL_CRATE); tcx.sess.local_crate_disambiguator() @@ -503,6 +507,7 @@ pub fn provide(providers: &mut ty::query::Providers) { adt_sized_constraint, def_span, param_env, + param_env_reveal_all_normalized, trait_of_item, crate_disambiguator, original_crate_name, From 117a60e1f5045e317d3f76ce60be28d18c694608 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 11 Jun 2020 15:27:49 -0400 Subject: [PATCH 02/71] Erase regions in try_eval_bits --- src/librustc_middle/ty/sty.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_middle/ty/sty.rs b/src/librustc_middle/ty/sty.rs index 03bf51c95c5a3..3e705a2a29717 100644 --- a/src/librustc_middle/ty/sty.rs +++ b/src/librustc_middle/ty/sty.rs @@ -2225,3 +2225,4 @@ impl<'tcx> TyS<'tcx> { tcx.layout_of(tcx.param_env(did).and(self)).map(|layout| layout.is_zst()).unwrap_or(false) } } + From 90aee14eb95ac0b9ddb7cf5db6d003155e94800c Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 12 Jun 2020 20:44:19 -0400 Subject: [PATCH 03/71] Skip computing param_env and size if not needed --- src/librustc_middle/ty/sty.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_middle/ty/sty.rs b/src/librustc_middle/ty/sty.rs index 3e705a2a29717..03bf51c95c5a3 100644 --- a/src/librustc_middle/ty/sty.rs +++ b/src/librustc_middle/ty/sty.rs @@ -2225,4 +2225,3 @@ impl<'tcx> TyS<'tcx> { tcx.layout_of(tcx.param_env(did).and(self)).map(|layout| layout.is_zst()).unwrap_or(false) } } - From 5e2e927e0107916b825b164c82be44877ac6ab54 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 22 Jul 2020 01:13:42 -0400 Subject: [PATCH 04/71] Fix rebase fallout --- src/librustc_middle/ty/consts.rs | 2 +- src/librustc_middle/ty/consts/kind.rs | 10 +++++++--- src/librustc_middle/ty/mod.rs | 2 +- src/librustc_middle/ty/util.rs | 2 +- src/librustc_mir/transform/validate.rs | 2 +- src/librustc_passes/layout_test.rs | 6 ++++-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/librustc_middle/ty/consts.rs b/src/librustc_middle/ty/consts.rs index f3a863c3fce62..c0b5693dc594e 100644 --- a/src/librustc_middle/ty/consts.rs +++ b/src/librustc_middle/ty/consts.rs @@ -158,7 +158,7 @@ impl<'tcx> Const<'tcx> { ty: Ty<'tcx>, ) -> Option { assert_eq!(self.ty, ty); - let size = tcx.layout_of(param_env.with_reveal_all().and(ty)).ok()?.size; + let size = tcx.layout_of(param_env.with_reveal_all_normalized(tcx).and(ty)).ok()?.size; // if `ty` does not depend on generic parameters, use an empty param_env self.val.eval(tcx, param_env).try_to_bits(size) } diff --git a/src/librustc_middle/ty/consts/kind.rs b/src/librustc_middle/ty/consts/kind.rs index 75287ff7dace3..e8a1e714a8f43 100644 --- a/src/librustc_middle/ty/consts/kind.rs +++ b/src/librustc_middle/ty/consts/kind.rs @@ -96,12 +96,16 @@ impl<'tcx> ConstKind<'tcx> { if let ConstKind::Unevaluated(def, substs, promoted) = self { use crate::mir::interpret::ErrorHandled; - let param_env_and_substs = param_env.with_reveal_all().and(substs); - // HACK(eddyb) this erases lifetimes even though `const_eval_resolve` // also does later, but we want to do it before checking for // inference variables. - let param_env_and_substs = tcx.erase_regions(¶m_env_and_substs); + // Note that we erase regions *before* calling `with_reveal_all_normalized`, + // so that we don't try to invoke this query with + // any region variables. + let param_env_and_substs = tcx + .erase_regions(¶m_env) + .with_reveal_all_normalized(tcx) + .and(tcx.erase_regions(&substs)); // HACK(eddyb) when the query key would contain inference variables, // attempt using identity substs and `ParamEnv` instead, that will succeed diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index ef0cf929dcd4d..16471364b822e 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -1822,7 +1822,7 @@ impl<'tcx> ParamEnv<'tcx> { /// All opaque types in the caller_bounds of the `ParamEnv` /// will be normalized to their underlying types. /// See PR #65989 and issue #65918 for more details - pub fn with_reveal_all_normalized(mut self) -> Self { + pub fn with_reveal_all_normalized(self, tcx: TyCtxt<'tcx>) -> Self { if self.packed_data & 1 == 1 { return self; } diff --git a/src/librustc_middle/ty/util.rs b/src/librustc_middle/ty/util.rs index 35b684316fd87..db78fa535cf42 100644 --- a/src/librustc_middle/ty/util.rs +++ b/src/librustc_middle/ty/util.rs @@ -1163,6 +1163,6 @@ pub fn normalize_opaque_types( val.fold_with(&mut visitor) } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { normalize_opaque_types, ..*providers } } diff --git a/src/librustc_mir/transform/validate.rs b/src/librustc_mir/transform/validate.rs index e794a6949d2f0..b8a74f09409ca 100644 --- a/src/librustc_mir/transform/validate.rs +++ b/src/librustc_mir/transform/validate.rs @@ -189,7 +189,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // Normalize projections and things like that. // FIXME: We need to reveal_all, as some optimizations change types in ways // that require unfolding opaque types. - let param_env = self.param_env.with_reveal_all(); + let param_env = self.param_env.with_reveal_all_normalized(self.tcx); let src = self.tcx.normalize_erasing_regions(param_env, src); let dest = self.tcx.normalize_erasing_regions(param_env, dest); diff --git a/src/librustc_passes/layout_test.rs b/src/librustc_passes/layout_test.rs index 2419e6965968e..55a6d3f76457e 100644 --- a/src/librustc_passes/layout_test.rs +++ b/src/librustc_passes/layout_test.rs @@ -82,8 +82,10 @@ impl LayoutTest<'tcx> { } sym::debug => { - let normalized_ty = - self.tcx.normalize_erasing_regions(param_env.with_reveal_all(), ty); + let normalized_ty = self.tcx.normalize_erasing_regions( + param_env.with_reveal_all_normalized(self.tcx), + ty, + ); self.tcx.sess.span_err( item.span, &format!("layout_of({:?}) = {:#?}", normalized_ty, *ty_layout), From 1d2e3fff69b654c3dfd6a810e193db29bb1868fa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 25 Jul 2020 18:57:42 +0200 Subject: [PATCH 05/71] Clean up E0730 explanation --- src/librustc_error_codes/error_codes/E0730.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0730.md b/src/librustc_error_codes/error_codes/E0730.md index c2a71ca5669a1..d385009063f78 100644 --- a/src/librustc_error_codes/error_codes/E0730.md +++ b/src/librustc_error_codes/error_codes/E0730.md @@ -1,6 +1,6 @@ An array without a fixed length was pattern-matched. -Example of erroneous code: +Erroneous code example: ```compile_fail,E0730 #![feature(const_generics)] @@ -14,8 +14,8 @@ fn is_123(x: [u32; N]) -> bool { } ``` -Ensure that the pattern is consistent with the size of the matched -array. Additional elements can be matched with `..`: +Ensure that the pattern is consistent with the size of the matched array. +Additional elements can be matched with `..`: ``` let r = &[1, 2, 3, 4]; From f22a34e84d4dba9b17bb3e68051ee82bd85f3c94 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Jul 2020 20:55:30 +0200 Subject: [PATCH 06/71] Clean up E0734 explanation --- src/librustc_error_codes/error_codes/E0734.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0734.md b/src/librustc_error_codes/error_codes/E0734.md index 7506c8e693ed8..4b8e89a70604d 100644 --- a/src/librustc_error_codes/error_codes/E0734.md +++ b/src/librustc_error_codes/error_codes/E0734.md @@ -1,6 +1,6 @@ A stability attribute has been used outside of the standard library. -Erroneous code examples: +Erroneous code example: ```compile_fail,E0734 #[rustc_deprecated(since = "b", reason = "text")] // invalid From 013e1a6e9f73125734cb919d9b6220b3a4710d67 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 27 Jul 2020 15:17:15 -0600 Subject: [PATCH 07/71] Enable the profiler on FreeBSD FreeBSD has been doing this in our own package builds for two months now. https://svnweb.freebsd.org/ports?view=revision&revision=535771 --- src/ci/docker/host-x86_64/dist-i686-freebsd/Dockerfile | 2 +- src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-i686-freebsd/Dockerfile b/src/ci/docker/host-x86_64/dist-i686-freebsd/Dockerfile index 7978bb7086965..14af9b9efe815 100644 --- a/src/ci/docker/host-x86_64/dist-i686-freebsd/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-i686-freebsd/Dockerfile @@ -29,5 +29,5 @@ ENV \ ENV HOSTS=i686-unknown-freebsd -ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs +ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --disable-docs ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile index 12170a3661487..2372c0dad0abf 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile @@ -29,5 +29,5 @@ ENV \ ENV HOSTS=x86_64-unknown-freebsd -ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs +ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --disable-docs ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS From ad6d63ef01e37a1a05acdba50985b01d178d7c11 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Sun, 26 Jul 2020 15:31:58 +0200 Subject: [PATCH 08/71] Don't use "weak count" around Weak::from_raw_ptr As `Rc/Arc::weak_count` returns 0 when having no strong counts, this could be confusing and it's better to avoid using that completely. Closes #73840. --- library/alloc/src/rc.rs | 20 +++++++++++--------- library/alloc/src/sync.rs | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 96dfc2f42519b..431672865dcc1 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1715,8 +1715,9 @@ impl Weak { /// Consumes the `Weak` and turns it into a raw pointer. /// - /// This converts the weak pointer into a raw pointer, preserving the original weak count. It - /// can be turned back into the `Weak` with [`from_raw`]. + /// This converts the weak pointer into a raw pointer, while still preserving the ownership of + /// one weak reference (the weak count is not modified by this operation). It can be turned + /// back into the `Weak` with [`from_raw`]. /// /// The same restrictions of accessing the target of the pointer as with /// [`as_ptr`] apply. @@ -1751,17 +1752,18 @@ impl Weak { /// This can be used to safely get a strong reference (by calling [`upgrade`] /// later) or to deallocate the weak count by dropping the `Weak`. /// - /// It takes ownership of one weak count (with the exception of pointers created by [`new`], - /// as these don't have any corresponding weak count). + /// It takes ownership of one weak reference (with the exception of pointers created by [`new`], + /// as these don't own anything; the method still works on them). /// /// # Safety /// - /// The pointer must have originated from the [`into_raw`] and must still own its potential - /// weak reference count. + /// The pointer must have originated from the [`into_raw`] and must still own its potential + /// weak reference. /// - /// It is allowed for the strong count to be 0 at the time of calling this, but the weak count - /// must be non-zero or the pointer must have originated from a dangling `Weak` (one created - /// by [`new`]). + /// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this + /// takes ownership of one weak reference currently represented as a raw pointer (the weak + /// count is not modified by this operation) and therefore it must be paired with a previous + /// call to [`into_raw`]. /// /// # Examples /// diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 8a5f1ee5076b9..a06dad77c4422 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1485,8 +1485,9 @@ impl Weak { /// Consumes the `Weak` and turns it into a raw pointer. /// - /// This converts the weak pointer into a raw pointer, preserving the original weak count. It - /// can be turned back into the `Weak` with [`from_raw`]. + /// This converts the weak pointer into a raw pointer, while still preserving the ownership of + /// one weak reference (the weak count is not modified by this operation). It can be turned + /// back into the `Weak` with [`from_raw`]. /// /// The same restrictions of accessing the target of the pointer as with /// [`as_ptr`] apply. @@ -1516,24 +1517,23 @@ impl Weak { result } - /// Converts a raw pointer previously created by [`into_raw`] back into - /// `Weak`. + /// Converts a raw pointer previously created by [`into_raw`] back into `Weak`. /// /// This can be used to safely get a strong reference (by calling [`upgrade`] /// later) or to deallocate the weak count by dropping the `Weak`. /// - /// It takes ownership of one weak count (with the exception of pointers created by [`new`], - /// as these don't have any corresponding weak count). + /// It takes ownership of one weak reference (with the exception of pointers created by [`new`], + /// as these don't own anything; the method still works on them). /// /// # Safety /// /// The pointer must have originated from the [`into_raw`] and must still own its potential - /// weak reference count. - /// - /// It is allowed for the strong count to be 0 at the time of calling this, but the weak count - /// must be non-zero or the pointer must have originated from a dangling `Weak` (one created - /// by [`new`]). + /// weak reference. /// + /// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this + /// takes ownership of one weak reference currently represented as a raw pointer (the weak + /// count is not modified by this operation) and therefore it must be paired with a previous + /// call to [`into_raw`]. /// # Examples /// /// ``` From b5d143b126cd73c873fc8feff7dee0a0b077cc84 Mon Sep 17 00:00:00 2001 From: David Sonder Date: Tue, 28 Jul 2020 13:28:43 +0200 Subject: [PATCH 09/71] Enable docs on dist-x86_64-musl Add the rust-docs component to toolchain x86_64-unknown-linux-musl, which allows people using rustup on their musl-based linux distribution to download the rust-docs. --- src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile index c026506b10661..ab6515cd1fa95 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile @@ -33,7 +33,6 @@ ENV HOSTS=x86_64-unknown-linux-musl ENV RUST_CONFIGURE_ARGS \ --musl-root-x86_64=/usr/local/x86_64-linux-musl \ --enable-extended \ - --disable-docs \ --enable-lld \ --set target.x86_64-unknown-linux-musl.crt-static=false \ --build $HOSTS From 06d565c967bfb7c6ff52a991bbe47b4a2a25de3e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 13 May 2020 14:22:37 -0700 Subject: [PATCH 10/71] std: Switch from libbacktrace to gimli This commit is a proof-of-concept for switching the standard library's backtrace symbolication mechanism on most platforms from libbacktrace to gimli. The standard library's support for `RUST_BACKTRACE=1` requires in-process parsing of object files and DWARF debug information to interpret it and print the filename/line number of stack frames as part of a backtrace. Historically this support in the standard library has come from a library called "libbacktrace". The libbacktrace library seems to have been extracted from gcc at some point and is written in C. We've had a lot of issues with libbacktrace over time, unfortunately, though. The library does not appear to be actively maintained since we've had patches sit for months-to-years without comments. We have discovered a good number of soundness issues with the library itself, both when parsing valid DWARF as well as invalid DWARF. This is enough of an issue that the libs team has previously decided that we cannot feed untrusted inputs to libbacktrace. This also doesn't take into account the portability of libbacktrace which has been difficult to manage and maintain over time. While possible there are lots of exceptions and it's the main C dependency of the standard library right now. For years it's been the desire to switch over to a Rust-based solution for symbolicating backtraces. It's been assumed that we'll be using the Gimli family of crates for this purpose, which are targeted at safely and efficiently parsing DWARF debug information. I've been working recently to shore up the Gimli support in the `backtrace` crate. As of a few weeks ago the `backtrace` crate, by default, uses Gimli when loaded from crates.io. This transition has gone well enough that I figured it was time to start talking seriously about this change to the standard library. This commit is a preview of what's probably the best way to integrate the `backtrace` crate into the standard library with the Gimli feature turned on. While today it's used as a crates.io dependency, this commit switches the `backtrace` crate to a submodule of this repository which will need to be updated manually. This is not done lightly, but is thought to be the best solution. The primary reason for this is that the `backtrace` crate needs to do some pretty nontrivial filesystem interactions to locate debug information. Working without `std::fs` is not an option, and while it might be possible to do some sort of trait-based solution when prototyped it was found to be too unergonomic. Using a submodule allows the `backtrace` crate to build as a submodule of the `std` crate itself, enabling it to use `std::fs` and such. Otherwise this adds new dependencies to the standard library. This step requires extra attention because this means that these crates are now going to be included with all Rust programs by default. It's important to note, however, that we're already shipping libbacktrace with all Rust programs by default and it has a bunch of C code implementing all of this internally anyway, so we're basically already switching already-shipping functionality to Rust from C. * `object` - this crate is used to parse object file headers and contents. Very low-level support is used from this crate and almost all of it is disabled. Largely we're just using struct definitions as well as convenience methods internally to read bytes and such. * `addr2line` - this is the main meat of the implementation for symbolication. This crate depends on `gimli` for DWARF parsing and then provides interfaces needed by the `backtrace` crate to turn an address into a filename / line number. This crate is actually pretty small (fits in a single file almost!) and mirrors most of what `dwarf.c` does for libbacktrace. * `miniz_oxide` - the libbacktrace crate transparently handles compressed debug information which is compressed with zlib. This crate is used to decompress compressed debug sections. * `gimli` - not actually used directly, but a dependency of `addr2line`. * `adler32`- not used directly either, but a dependency of `miniz_oxide`. The goal of this change is to improve the safety of backtrace symbolication in the standard library, especially in the face of possibly malformed DWARF debug information. Even to this day we're still seeing segfaults in libbacktrace which could possibly become security vulnerabilities. This change should almost entirely eliminate this possibility whilc also paving the way forward to adding more features like split debug information. Some references for those interested are: * Original addition of libbacktrace - #12602 * OOM with libbacktrace - #24231 * Backtrace failure due to use of uninitialized value - #28447 * Possibility to feed untrusted data to libbacktrace - #21889 * Soundness fix for libbacktrace - #33729 * Crash in libbacktrace - #39468 * Support for macOS, never merged - ianlancetaylor/libbacktrace#2 * Performance issues with libbacktrace - #29293, #37477 * Update procedure is quite complicated due to how many patches we need to carry - #50955 * Libbacktrace doesn't work on MinGW with dynamic libs - #71060 * Segfault in libbacktrace on macOS - #71397 Switching to Rust will not make us immune to all of these issues. The crashes are expected to go away, but correctness and performance may still have bugs arise. The gimli and `backtrace` crates, however, are actively maintained unlike libbacktrace, so this should enable us to at least efficiently apply fixes as situations come up. --- .gitmodules | 3 + Cargo.lock | 88 +++++++++++++++++-------- Cargo.toml | 18 +++++ library/backtrace | 1 + library/std/Cargo.toml | 23 ++++--- library/std/build.rs | 1 + library/std/src/backtrace.rs | 21 +++--- library/std/src/lib.rs | 4 ++ library/std/src/panicking.rs | 2 +- library/std/src/sys_common/backtrace.rs | 3 +- rustfmt.toml | 1 + src/bootstrap/dist.rs | 12 +++- src/tools/tidy/src/deps.rs | 8 ++- src/tools/tidy/src/lib.rs | 1 + 14 files changed, 130 insertions(+), 56 deletions(-) create mode 160000 library/backtrace diff --git a/.gitmodules b/.gitmodules index 2eae52b2eac54..a327aaa8d5a34 100644 --- a/.gitmodules +++ b/.gitmodules @@ -44,3 +44,6 @@ [submodule "src/tools/rust-analyzer"] path = src/tools/rust-analyzer url = https://github.com/rust-analyzer/rust-analyzer.git +[submodule "library/backtrace"] + path = library/backtrace + url = https://github.com/rust-lang/backtrace-rs.git diff --git a/Cargo.lock b/Cargo.lock index d0ce581343f0b..8e0621ad96fcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,10 +1,26 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "adler32" -version = "1.0.3" +name = "addr2line" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" +checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +dependencies = [ + "compiler_builtins", + "gimli", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] [[package]] name = "aho-corasick" @@ -125,28 +141,14 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" [[package]] name = "backtrace" -version = "0.3.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e" +version = "0.3.50" dependencies = [ - "backtrace-sys", + "addr2line", "cfg-if", - "compiler_builtins", "libc", + "miniz_oxide", + "object", "rustc-demangle", - "rustc-std-workspace-core", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" -dependencies = [ - "cc", - "compiler_builtins", - "libc", - "rustc-std-workspace-core", ] [[package]] @@ -688,9 +690,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91d5240c6975ef33aeb5f148f35275c25eda8e8a5f95abe421978b05b8bf192" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" dependencies = [ "cfg-if", ] @@ -1023,9 +1025,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" [[package]] name = "flate2" -version = "1.0.12" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" +checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e" dependencies = [ "cfg-if", "crc32fast", @@ -1159,6 +1161,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + [[package]] name = "git2" version = "0.13.5" @@ -1819,11 +1832,14 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" +checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" dependencies = [ - "adler32", + "adler", + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", ] [[package]] @@ -1955,6 +1971,17 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + [[package]] name = "once_cell" version = "1.1.0" @@ -4347,8 +4374,8 @@ dependencies = [ name = "std" version = "0.0.0" dependencies = [ + "addr2line", "alloc", - "backtrace", "cfg-if", "compiler_builtins", "core", @@ -4357,10 +4384,13 @@ dependencies = [ "hashbrown", "hermit-abi", "libc", + "miniz_oxide", + "object", "panic_abort", "panic_unwind", "profiler_builtins", "rand 0.7.3", + "rustc-demangle", "unwind", "wasi", ] diff --git a/Cargo.toml b/Cargo.toml index 4e49d697be1fb..1936e35aa4c5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,18 @@ overflow-checks = false # per-crate configuration isn't specifiable in the environment. codegen-units = 10000 +# These dependencies of the standard library implement symbolication for +# backtraces on most platforms. Their debuginfo causes both linking to be slower +# (more data to chew through) and binaries to be larger without really all that +# much benefit. This section turns them all to down to have no debuginfo which +# helps to improve link times a little bit. +[profile.release.package] +addr2line.debug = 0 +adler.debug = 0 +gimli.debug = 0 +miniz_oxide.debug = 0 +object.debug = 0 + # We want the RLS to use the version of Cargo that we've got vendored in this # repository to ensure that the same exact version of Cargo is used by both the # RLS and the Cargo binary itself. The RLS depends on Cargo as a git repository @@ -80,5 +92,11 @@ rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' } rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' } rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' } +# This crate's integration with libstd is a bit wonky, so we use a submodule +# instead of a crates.io dependency. Make sure everything else in the repo is +# also using the submodule, however, so we can avoid duplicate copies of the +# source code for this crate. +backtrace = { path = "library/backtrace" } + [patch."https://github.com/rust-lang/rust-clippy"] clippy_lints = { path = "src/tools/clippy/clippy_lints" } diff --git a/library/backtrace b/library/backtrace new file mode 160000 index 0000000000000..4083a90168d60 --- /dev/null +++ b/library/backtrace @@ -0,0 +1 @@ +Subproject commit 4083a90168d605b682ba166a0c01f86b3384e474 diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index b4951488fd86c..474765d863811 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -22,11 +22,15 @@ profiler_builtins = { path = "../profiler_builtins", optional = true } unwind = { path = "../unwind" } hashbrown = { version = "0.6.2", default-features = false, features = ['rustc-dep-of-std'] } -[dependencies.backtrace_rs] -package = "backtrace" -version = "0.3.46" -default-features = false # without the libstd `backtrace` feature, stub out everything -features = [ "rustc-dep-of-std" ] # enable build support for integrating into libstd +# Dependencies of the `backtrace` crate +addr2line = { version = "0.13.0", optional = true, default-features = false } +rustc-demangle = { version = "0.1.4", features = ['rustc-dep-of-std'] } +miniz_oxide = { version = "0.4.0", optional = true, default-features = false } +[dependencies.object] +version = "0.20" +optional = true +default-features = false +features = ['read_core', 'elf', 'macho', 'pe'] [dev-dependencies] rand = "0.7" @@ -45,11 +49,12 @@ wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = [features] backtrace = [ - "backtrace_rs/dbghelp", # backtrace/symbolize on MSVC - "backtrace_rs/libbacktrace", # symbolize on most platforms - "backtrace_rs/libunwind", # backtrace on most platforms - "backtrace_rs/dladdr", # symbolize on platforms w/o libbacktrace + "gimli-symbolize", + 'addr2line/rustc-dep-of-std', + 'object/rustc-dep-of-std', + 'miniz_oxide/rustc-dep-of-std', ] +gimli-symbolize = [] panic-unwind = ["panic_unwind"] profiler = ["profiler_builtins"] diff --git a/library/std/build.rs b/library/std/build.rs index 43a3327d84b61..83073cc77dd1a 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -88,4 +88,5 @@ fn main() { println!("cargo:rustc-cfg=feature=\"restricted-std\""); } println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap()); + println!("cargo:rustc-cfg=backtrace_in_libstd"); } diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 02e6811bc3f43..09f83ea5fca81 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -91,6 +91,7 @@ // `Backtrace`, but that's a relatively small price to pay relative to capturing // a backtrace or actually symbolizing it. +use crate::backtrace_rs::{self, BytesOrWideString}; use crate::env; use crate::ffi::c_void; use crate::fmt; @@ -98,8 +99,6 @@ use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst}; use crate::sync::Mutex; use crate::sys_common::backtrace::{lock, output_filename}; use crate::vec::Vec; -use backtrace::BytesOrWideString; -use backtrace_rs as backtrace; /// A captured OS thread stack backtrace. /// @@ -150,7 +149,7 @@ struct BacktraceFrame { } enum RawFrame { - Actual(backtrace::Frame), + Actual(backtrace_rs::Frame), #[cfg(test)] Fake, } @@ -197,7 +196,7 @@ impl fmt::Debug for BacktraceSymbol { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{{ ")?; - if let Some(fn_name) = self.name.as_ref().map(|b| backtrace::SymbolName::new(b)) { + if let Some(fn_name) = self.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)) { write!(fmt, "fn: \"{:#}\"", fn_name)?; } else { write!(fmt, "fn: ")?; @@ -223,7 +222,7 @@ impl fmt::Debug for BytesOrWide { BytesOrWide::Bytes(w) => BytesOrWideString::Bytes(w), BytesOrWide::Wide(w) => BytesOrWideString::Wide(w), }, - backtrace::PrintFmt::Short, + backtrace_rs::PrintFmt::Short, crate::env::current_dir().as_ref().ok(), ) } @@ -305,7 +304,7 @@ impl Backtrace { let mut frames = Vec::new(); let mut actual_start = None; unsafe { - backtrace::trace_unsynchronized(|frame| { + backtrace_rs::trace_unsynchronized(|frame| { frames.push(BacktraceFrame { frame: RawFrame::Actual(frame.clone()), symbols: Vec::new(), @@ -356,9 +355,9 @@ impl fmt::Display for Backtrace { let full = fmt.alternate(); let (frames, style) = if full { - (&capture.frames[..], backtrace::PrintFmt::Full) + (&capture.frames[..], backtrace_rs::PrintFmt::Full) } else { - (&capture.frames[capture.actual_start..], backtrace::PrintFmt::Short) + (&capture.frames[capture.actual_start..], backtrace_rs::PrintFmt::Short) }; // When printing paths we try to strip the cwd if it exists, otherwise @@ -370,7 +369,7 @@ impl fmt::Display for Backtrace { output_filename(fmt, path, style, cwd.as_ref().ok()) }; - let mut f = backtrace::BacktraceFmt::new(fmt, style, &mut print_path); + let mut f = backtrace_rs::BacktraceFmt::new(fmt, style, &mut print_path); f.add_context()?; for frame in frames { let mut f = f.frame(); @@ -380,7 +379,7 @@ impl fmt::Display for Backtrace { for symbol in frame.symbols.iter() { f.print_raw( frame.frame.ip(), - symbol.name.as_ref().map(|b| backtrace::SymbolName::new(b)), + symbol.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)), symbol.filename.as_ref().map(|b| match b { BytesOrWide::Bytes(w) => BytesOrWideString::Bytes(w), BytesOrWide::Wide(w) => BytesOrWideString::Wide(w), @@ -415,7 +414,7 @@ impl Capture { RawFrame::Fake => unimplemented!(), }; unsafe { - backtrace::resolve_frame_unsynchronized(frame, |symbol| { + backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| { symbols.push(BacktraceSymbol { name: symbol.name().map(|m| m.as_bytes().to_vec()), filename: symbol.filename_raw().map(|b| match b { diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index c6e5b0a492ac8..30e1514a8b830 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -511,6 +511,10 @@ mod panicking; // compiler pub mod rt; +#[path = "../../backtrace/src/lib.rs"] +#[allow(dead_code, unused_attributes)] +mod backtrace_rs; + // Pull in the `std_detect` crate directly into libstd. The contents of // `std_detect` are in a different repository: rust-lang/stdarch. // diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 9542e7209b4cf..ab2a60103069d 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -171,7 +171,7 @@ fn default_hook(info: &PanicInfo<'_>) { // If this is a double panic, make sure that we print a backtrace // for this panic. Otherwise only print it if logging is enabled. let backtrace_env = if panic_count::get() >= 2 { - RustBacktrace::Print(backtrace_rs::PrintFmt::Full) + RustBacktrace::Print(crate::backtrace_rs::PrintFmt::Full) } else { backtrace::rust_backtrace_env() }; diff --git a/library/std/src/sys_common/backtrace.rs b/library/std/src/sys_common/backtrace.rs index e9b1e86d7ae49..d386a656e4ffd 100644 --- a/library/std/src/sys_common/backtrace.rs +++ b/library/std/src/sys_common/backtrace.rs @@ -1,3 +1,4 @@ +use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt}; use crate::borrow::Cow; /// Common code for printing the backtrace in the same way across the different /// supported platforms. @@ -9,8 +10,6 @@ use crate::path::{self, Path, PathBuf}; use crate::sync::atomic::{self, Ordering}; use crate::sys::mutex::Mutex; -use backtrace_rs::{BacktraceFmt, BytesOrWideString, PrintFmt}; - /// Max number of frames to print. const MAX_NB_FRAMES: usize = 100; diff --git a/rustfmt.toml b/rustfmt.toml index cb689098f8989..26cdcfff2a316 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -14,6 +14,7 @@ ignore = [ "src/test", # do not format submodules + "library/backtrace", "library/stdarch", "src/doc/book", "src/doc/edition-guide", diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 7f10d7895a5e7..a4a1d5193b9b9 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1016,7 +1016,17 @@ impl Step for Src { let src_files = ["Cargo.lock"]; // This is the reduced set of paths which will become the rust-src component // (essentially libstd and all of its path dependencies). - copy_src_dirs(builder, &builder.src, &["library"], &[], &dst_src); + copy_src_dirs( + builder, + &builder.src, + &["library"], + &[ + // not needed and contains symlinks which rustup currently + // chokes on when unpacking. + "library/backtrace/crates", + ], + &dst_src, + ); for file in src_files.iter() { builder.copy(&builder.src.join(file), &dst_src.join(file)); } diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 56d2717c30477..8769d5e17bb3e 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -17,6 +17,7 @@ const LICENSES: &[&str] = &[ "MIT", "Unlicense/MIT", "Unlicense OR MIT", + "0BSD OR MIT OR Apache-2.0", // adler license ]; /// These are exceptions to Rust's permissive licensing policy, and @@ -36,7 +37,6 @@ const EXCEPTIONS: &[(&str, &str)] = &[ ("ryu", "Apache-2.0 OR BSL-1.0"), // rls/cargo/... (because of serde) ("bytesize", "Apache-2.0"), // cargo ("im-rc", "MPL-2.0+"), // cargo - ("adler32", "BSD-3-Clause AND Zlib"), // cargo dep that isn't used ("constant_time_eq", "CC0-1.0"), // rustfmt ("sized-chunks", "MPL-2.0+"), // cargo via im-rc ("bitmaps", "MPL-2.0+"), // cargo via im-rc @@ -57,7 +57,8 @@ const RESTRICTED_DEPENDENCY_CRATES: &[&str] = &["rustc_middle", "rustc_codegen_l /// This list is here to provide a speed-bump to adding a new dependency to /// rustc. Please check with the compiler team before adding an entry. const PERMITTED_DEPENDENCIES: &[&str] = &[ - "adler32", + "addr2line", + "adler", "aho-corasick", "annotate-snippets", "ansi_term", @@ -65,7 +66,6 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "atty", "autocfg", "backtrace", - "backtrace-sys", "bitflags", "block-buffer", "block-padding", @@ -98,6 +98,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "generic-array", "getopts", "getrandom", + "gimli", "hashbrown", "hermit-abi", "humantime", @@ -119,6 +120,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "miniz_oxide", "nodrop", "num_cpus", + "object", "once_cell", "opaque-debug", "parking_lot", diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 08b2fccd73f5c..19218cbd66a8a 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -51,6 +51,7 @@ pub mod unstable_book; fn filter_dirs(path: &Path) -> bool { let skip = [ "src/llvm-project", + "library/backtrace", "library/stdarch", "src/tools/cargo", "src/tools/clippy", From d8bcf75206e88e07cabd95b87418fe98c5fa2b95 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 21 Jul 2020 23:06:23 +0200 Subject: [PATCH 11/71] Make `Vec::leak` a method instead of an associated function. The reason for `Box::leak` not to be a method (`Deref` to an arbitrary `T` which might have its own, different `leak` method) does not apply. --- library/alloc/src/vec.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index f5a3d0cd4af87..3414060a55687 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -1513,17 +1513,17 @@ impl Vec { /// #![feature(vec_leak)] /// /// let x = vec![1, 2, 3]; - /// let static_ref: &'static mut [usize] = Vec::leak(x); + /// let static_ref: &'static mut [usize] = x.leak(); /// static_ref[0] += 1; /// assert_eq!(static_ref, &[2, 2, 3]); /// ``` #[unstable(feature = "vec_leak", issue = "62195")] #[inline] - pub fn leak<'a>(vec: Vec) -> &'a mut [T] + pub fn leak<'a>(self) -> &'a mut [T] where T: 'a, // Technically not needed, but kept to be explicit. { - Box::leak(vec.into_boxed_slice()) + Box::leak(self.into_boxed_slice()) } } From 7d759f539f363125511f1edd9ad30934367f409b Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 21 Jul 2020 23:08:27 +0200 Subject: [PATCH 12/71] Stabilize `Vec::leak` --- library/alloc/src/vec.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index 3414060a55687..9eb37bf473fed 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -1510,14 +1510,12 @@ impl Vec { /// Simple usage: /// /// ``` - /// #![feature(vec_leak)] - /// /// let x = vec![1, 2, 3]; /// let static_ref: &'static mut [usize] = x.leak(); /// static_ref[0] += 1; /// assert_eq!(static_ref, &[2, 2, 3]); /// ``` - #[unstable(feature = "vec_leak", issue = "62195")] + #[stable(feature = "vec_leak", since = "1.47.0")] #[inline] pub fn leak<'a>(self) -> &'a mut [T] where From 0374006d79114824d8eec020a9d771ca8cf712ff Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 29 Jul 2020 10:48:00 +0000 Subject: [PATCH 13/71] Avoid bool-like naming --- src/etc/test-float-parse/runtests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/etc/test-float-parse/runtests.py b/src/etc/test-float-parse/runtests.py index 7106078f897cf..4d2902e986f56 100644 --- a/src/etc/test-float-parse/runtests.py +++ b/src/etc/test-float-parse/runtests.py @@ -195,9 +195,8 @@ def main(): global MAILBOX tests = [os.path.splitext(f)[0] for f in glob('*.rs') if not f.startswith('_')] - listed = sys.argv[1:] - if listed: - tests = [test for test in tests if test in listed] + args = sys.argv[1:] + tests = [test for test in tests if test in args] if not tests: print("Error: No tests to run") sys.exit(1) From 759de11f534b940f090ff94cf1829935c1eb4e7d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 29 Jul 2020 14:06:29 +0200 Subject: [PATCH 14/71] Clean up E0740 explanation --- src/librustc_error_codes/error_codes/E0740.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0740.md b/src/librustc_error_codes/error_codes/E0740.md index 3777678518964..6240099a99f67 100644 --- a/src/librustc_error_codes/error_codes/E0740.md +++ b/src/librustc_error_codes/error_codes/E0740.md @@ -1,4 +1,4 @@ -A `union` cannot have fields with destructors. +A `union` was declared with fields with destructors. Erroneous code example: @@ -14,3 +14,5 @@ impl Drop for A { fn drop(&mut self) { println!("A"); } } ``` + +A `union` cannot have fields with destructors. From abaf38ccb08d64a2a2c6b5d66dca2b58c2427664 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 29 Jul 2020 15:22:13 -0700 Subject: [PATCH 15/71] Rename intra_doc_link_resolution_failure -> intra_doc_link_resolution_failures --- src/librustc_lint/lib.rs | 4 ++-- src/librustc_session/lint/builtin.rs | 4 ++-- src/librustdoc/core.rs | 2 +- src/librustdoc/passes/collect_intra_doc_links.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index ab30d545edfc3..ee5ea6a9a192e 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -62,7 +62,7 @@ use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::{ BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, - INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, + INTRA_DOC_LINK_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, }; use rustc_span::symbol::{Ident, Symbol}; @@ -303,7 +303,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { add_lint_group!( "rustdoc", - INTRA_DOC_LINK_RESOLUTION_FAILURE, + INTRA_DOC_LINK_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS diff --git a/src/librustc_session/lint/builtin.rs b/src/librustc_session/lint/builtin.rs index aa2a133952f8f..3e93c430c1f53 100644 --- a/src/librustc_session/lint/builtin.rs +++ b/src/librustc_session/lint/builtin.rs @@ -398,7 +398,7 @@ declare_lint! { } declare_lint! { - pub INTRA_DOC_LINK_RESOLUTION_FAILURE, + pub INTRA_DOC_LINK_RESOLUTION_FAILURES, Warn, "failures in resolving intra-doc link targets" } @@ -601,7 +601,7 @@ declare_lint_pass! { ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, UNSTABLE_NAME_COLLISIONS, IRREFUTABLE_LET_PATTERNS, - INTRA_DOC_LINK_RESOLUTION_FAILURE, + INTRA_DOC_LINK_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_CRATE_LEVEL_DOCS, MISSING_DOC_CODE_EXAMPLES, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 263909d5559d1..ecd6a28bcecf9 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -315,7 +315,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let cpath = Some(input.clone()); let input = Input::File(input); - let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE.name; + let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURES.name; let missing_docs = rustc_lint::builtin::MISSING_DOCS.name; let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name; let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 418238181e9b8..c65905ade31f1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -868,7 +868,7 @@ fn report_diagnostic( let sp = span_of_attrs(attrs).unwrap_or(item.source.span()); cx.tcx.struct_span_lint_hir( - lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE, + lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURES, hir_id, sp, |lint| { From 48de8ac0416853aaf76fcbe721efe9f11e27bd9d Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 29 Jul 2020 15:21:26 -0700 Subject: [PATCH 16/71] Rename usage of intra_doc_link_resolution_failure --- src/doc/rustdoc/src/lints.md | 2 +- src/test/run-make-fulldeps/exit-code/lint-failure.rs | 2 +- src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs | 2 +- src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr | 2 +- src/test/rustdoc-ui/intra-doc-alias-ice.rs | 2 +- src/test/rustdoc-ui/intra-doc-alias-ice.stderr | 2 +- src/test/rustdoc-ui/intra-link-span-ice-55723.rs | 2 +- src/test/rustdoc-ui/intra-link-span-ice-55723.stderr | 2 +- src/test/rustdoc-ui/intra-links-ambiguity.rs | 2 +- src/test/rustdoc-ui/intra-links-ambiguity.stderr | 2 +- src/test/rustdoc-ui/intra-links-anchors.rs | 2 +- src/test/rustdoc-ui/intra-links-anchors.stderr | 2 +- src/test/rustdoc-ui/intra-links-private.private.stderr | 2 +- src/test/rustdoc-ui/intra-links-private.public.stderr | 2 +- src/test/rustdoc-ui/intra-links-warning-crlf.stderr | 2 +- src/test/rustdoc-ui/intra-links-warning.stderr | 2 +- src/test/rustdoc-ui/issue-74134.private.stderr | 2 +- src/test/rustdoc-ui/issue-74134.public.stderr | 2 +- src/test/rustdoc-ui/lint-group.stderr | 2 +- src/test/rustdoc-ui/reference-link-has-one-warning.stderr | 2 +- src/test/rustdoc/intra-doc-crate/additional_doc.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/module.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs | 2 +- src/test/rustdoc/intra-doc-crate/basic.rs | 2 +- src/test/rustdoc/intra-doc-crate/hidden.rs | 2 +- src/test/rustdoc/intra-doc-crate/macro.rs | 2 +- src/test/rustdoc/intra-doc-crate/module.rs | 2 +- src/test/rustdoc/intra-doc-crate/submodule-inner.rs | 2 +- src/test/rustdoc/intra-doc-crate/submodule-outer.rs | 2 +- src/test/rustdoc/intra-doc-crate/traits.rs | 2 +- src/test/rustdoc/intra-doc-link-mod-ambiguity.rs | 2 +- src/test/rustdoc/intra-link-extern-crate.rs | 2 +- src/test/rustdoc/intra-link-in-bodies.rs | 2 +- src/test/rustdoc/intra-link-libstd-re-export.rs | 2 +- src/test/rustdoc/intra-link-prim-methods-external-core.rs | 2 +- src/test/rustdoc/intra-link-prim-methods-local.rs | 2 +- src/test/rustdoc/intra-link-prim-methods.rs | 2 +- src/test/rustdoc/intra-link-prim-precedence.rs | 2 +- src/test/rustdoc/intra-link-private.rs | 2 +- src/test/rustdoc/intra-link-proc-macro.rs | 2 +- src/test/rustdoc/intra-links-external-traits.rs | 2 +- src/test/rustdoc/through-proc-macro.rs | 2 +- 47 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/doc/rustdoc/src/lints.md b/src/doc/rustdoc/src/lints.md index beb2556872df7..0766e7b87ea07 100644 --- a/src/doc/rustdoc/src/lints.md +++ b/src/doc/rustdoc/src/lints.md @@ -11,7 +11,7 @@ can use them like any other lints by doing this: Here is the list of the lints provided by `rustdoc`: -## intra_doc_link_resolution_failure +## intra_doc_link_resolution_failures This lint **warns by default** and is **nightly-only**. This lint detects when an intra-doc link fails to get resolved. For example: diff --git a/src/test/run-make-fulldeps/exit-code/lint-failure.rs b/src/test/run-make-fulldeps/exit-code/lint-failure.rs index 70bdddc6246bd..97c95a2672fc8 100644 --- a/src/test/run-make-fulldeps/exit-code/lint-failure.rs +++ b/src/test/run-make-fulldeps/exit-code/lint-failure.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] /// [intradoc::failure] pub fn main() { diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs index 9e64e6eb3999b..c443350031737 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] /// [v2] //~ ERROR pub fn foo() {} diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr index 894518faa3168..8263ffe9f4d82 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -7,7 +7,7 @@ LL | /// [v2] note: the lint level is defined here --> $DIR/deny-intra-link-resolution-failure.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failure)] +LL | #![deny(intra_doc_link_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.rs b/src/test/rustdoc-ui/intra-doc-alias-ice.rs index 9657d573d5016..aaf09a78093b6 100644 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.rs +++ b/src/test/rustdoc-ui/intra-doc-alias-ice.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub type TypeAlias = usize; diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr index d2b2b90a4e50d..d692dc76d6af3 100644 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr +++ b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr @@ -7,7 +7,7 @@ LL | /// [broken cross-reference](TypeAlias::hoge) note: the lint level is defined here --> $DIR/intra-doc-alias-ice.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failure)] +LL | #![deny(intra_doc_link_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs index 95388003f8470..89d271bb911a2 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] // An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to // attempt to slice in the middle of a multibyte character. See diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr index 156e214a79ff0..c0c49c027f624 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr @@ -7,7 +7,7 @@ LL | /// (arr[i]) note: the lint level is defined here --> $DIR/intra-link-span-ice-55723.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failure)] +LL | #![deny(intra_doc_link_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.rs b/src/test/rustdoc-ui/intra-links-ambiguity.rs index 7316fcdad6772..dd7b8eee384da 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.rs +++ b/src/test/rustdoc-ui/intra-links-ambiguity.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.stderr b/src/test/rustdoc-ui/intra-links-ambiguity.stderr index 7b9821b3d047a..a0c6dbd44b290 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.stderr +++ b/src/test/rustdoc-ui/intra-links-ambiguity.stderr @@ -7,7 +7,7 @@ LL | /// [`ambiguous`] is ambiguous. note: the lint level is defined here --> $DIR/intra-links-ambiguity.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failure)] +LL | #![deny(intra_doc_link_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to link to the struct, prefix with the item type | diff --git a/src/test/rustdoc-ui/intra-links-anchors.rs b/src/test/rustdoc-ui/intra-links-anchors.rs index 7e61bd725359a..fbf99fdba34b7 100644 --- a/src/test/rustdoc-ui/intra-links-anchors.rs +++ b/src/test/rustdoc-ui/intra-links-anchors.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] // A few tests on anchors. diff --git a/src/test/rustdoc-ui/intra-links-anchors.stderr b/src/test/rustdoc-ui/intra-links-anchors.stderr index ef33d8f3e06fe..d7c47f1ed122a 100644 --- a/src/test/rustdoc-ui/intra-links-anchors.stderr +++ b/src/test/rustdoc-ui/intra-links-anchors.stderr @@ -7,7 +7,7 @@ LL | /// Or maybe [Foo::f#hola]. note: the lint level is defined here --> $DIR/intra-links-anchors.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failure)] +LL | #![deny(intra_doc_link_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `hello#people#!` contains multiple anchors diff --git a/src/test/rustdoc-ui/intra-links-private.private.stderr b/src/test/rustdoc-ui/intra-links-private.private.stderr index a2148b82f819a..0cd3470851331 100644 --- a/src/test/rustdoc-ui/intra-links-private.private.stderr +++ b/src/test/rustdoc-ui/intra-links-private.private.stderr @@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe` LL | /// docs [DontDocMe] | ^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_link_resolution_failure)]` on by default + = note: `#[warn(intra_doc_link_resolution_failures)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/intra-links-private.public.stderr b/src/test/rustdoc-ui/intra-links-private.public.stderr index 56742406992fc..dc09270a2e150 100644 --- a/src/test/rustdoc-ui/intra-links-private.public.stderr +++ b/src/test/rustdoc-ui/intra-links-private.public.stderr @@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe` LL | /// docs [DontDocMe] | ^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_link_resolution_failure)]` on by default + = note: `#[warn(intra_doc_link_resolution_failures)]` on by default = note: this link will resolve properly if you pass `--document-private-items` warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/intra-links-warning-crlf.stderr b/src/test/rustdoc-ui/intra-links-warning-crlf.stderr index bc31264c170ea..cc6f51ef15571 100644 --- a/src/test/rustdoc-ui/intra-links-warning-crlf.stderr +++ b/src/test/rustdoc-ui/intra-links-warning-crlf.stderr @@ -4,7 +4,7 @@ warning: unresolved link to `error` LL | /// [error] | ^^^^^ unresolved link | - = note: `#[warn(intra_doc_link_resolution_failure)]` on by default + = note: `#[warn(intra_doc_link_resolution_failures)]` on by default = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `error1` diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr index 81931399c240a..28a92bd150b0b 100644 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ b/src/test/rustdoc-ui/intra-links-warning.stderr @@ -4,7 +4,7 @@ warning: unresolved link to `Foo::baz` LL | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ unresolved link | - = note: `#[warn(intra_doc_link_resolution_failure)]` on by default + = note: `#[warn(intra_doc_link_resolution_failures)]` on by default = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `Bar::foo` diff --git a/src/test/rustdoc-ui/issue-74134.private.stderr b/src/test/rustdoc-ui/issue-74134.private.stderr index 9c5cdf0117cab..349d567dc3b2b 100644 --- a/src/test/rustdoc-ui/issue-74134.private.stderr +++ b/src/test/rustdoc-ui/issue-74134.private.stderr @@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy LL | /// [`PrivateType`] | ^^^^^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_link_resolution_failure)]` on by default + = note: `#[warn(intra_doc_link_resolution_failures)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/issue-74134.public.stderr b/src/test/rustdoc-ui/issue-74134.public.stderr index ff2951d864e64..6a73d4a32498d 100644 --- a/src/test/rustdoc-ui/issue-74134.public.stderr +++ b/src/test/rustdoc-ui/issue-74134.public.stderr @@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy LL | /// [`PrivateType`] | ^^^^^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_link_resolution_failure)]` on by default + = note: `#[warn(intra_doc_link_resolution_failures)]` on by default = note: this link will resolve properly if you pass `--document-private-items` warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/lint-group.stderr b/src/test/rustdoc-ui/lint-group.stderr index ad923c714da4d..203ca83884936 100644 --- a/src/test/rustdoc-ui/lint-group.stderr +++ b/src/test/rustdoc-ui/lint-group.stderr @@ -39,7 +39,7 @@ note: the lint level is defined here | LL | #![deny(rustdoc)] | ^^^^^^^ - = note: `#[deny(intra_doc_link_resolution_failure)]` implied by `#[deny(rustdoc)]` + = note: `#[deny(intra_doc_link_resolution_failures)]` implied by `#[deny(rustdoc)]` = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to 3 previous errors diff --git a/src/test/rustdoc-ui/reference-link-has-one-warning.stderr b/src/test/rustdoc-ui/reference-link-has-one-warning.stderr index 5bbc62b76dd04..02b53eb710958 100644 --- a/src/test/rustdoc-ui/reference-link-has-one-warning.stderr +++ b/src/test/rustdoc-ui/reference-link-has-one-warning.stderr @@ -4,7 +4,7 @@ warning: `[with#anchor#error]` has an issue with the link anchor. LL | /// docs [label][with#anchor#error] | ^^^^^^^^^^^^^^^^^ only one `#` is allowed in a link | - = note: `#[warn(intra_doc_link_resolution_failure)]` on by default + = note: `#[warn(intra_doc_link_resolution_failures)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc/intra-doc-crate/additional_doc.rs b/src/test/rustdoc/intra-doc-crate/additional_doc.rs index adfa7f5754eb9..f5ab6ce2101de 100644 --- a/src/test/rustdoc/intra-doc-crate/additional_doc.rs +++ b/src/test/rustdoc/intra-doc-crate/additional_doc.rs @@ -1,6 +1,6 @@ // aux-build:additional_doc.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] extern crate my_rand; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs index 8b8793e75ed59..59f59dc3919dd 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs @@ -1,5 +1,5 @@ #![crate_name = "my_rand"] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub trait RngCore {} /// Rng extends [`RngCore`]. diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs index 23e38523a4f91..e4019dad3b6eb 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs @@ -1,5 +1,5 @@ #![crate_name = "hidden_dep"] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] #[doc(hidden)] pub mod __reexport { diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs index 2ee5835a7df84..7ffb622a740c6 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs @@ -1,5 +1,5 @@ #![crate_name = "a"] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub struct Foo; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs index abd41fec13016..9907f569e8b83 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs @@ -1,5 +1,5 @@ #![crate_name = "macro_inner"] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub struct Foo; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs index 5d63d7e37b64d..a000cea07a28e 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs @@ -1,5 +1,5 @@ #![crate_name = "module_inner"] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] /// [SomeType] links to [bar] pub struct SomeType; pub trait SomeTrait {} diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs index 3a22d13e673ac..e13e4b0ed2262 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs @@ -1,5 +1,5 @@ #![crate_name = "a"] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub mod bar { pub struct Bar; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs index b8ca4e44e1f16..770ccc9ada88f 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs @@ -1,5 +1,5 @@ #![crate_name = "bar"] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub trait Foo { /// [`Bar`] [`Baz`] diff --git a/src/test/rustdoc/intra-doc-crate/basic.rs b/src/test/rustdoc/intra-doc-crate/basic.rs index a245a0f84539c..db20ef296fa91 100644 --- a/src/test/rustdoc/intra-doc-crate/basic.rs +++ b/src/test/rustdoc/intra-doc-crate/basic.rs @@ -1,6 +1,6 @@ // aux-build:intra-doc-basic.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] // from https://github.com/rust-lang/rust/issues/65983 extern crate a; diff --git a/src/test/rustdoc/intra-doc-crate/hidden.rs b/src/test/rustdoc/intra-doc-crate/hidden.rs index e3d2af16db19c..45ca15f71d094 100644 --- a/src/test/rustdoc/intra-doc-crate/hidden.rs +++ b/src/test/rustdoc/intra-doc-crate/hidden.rs @@ -1,6 +1,6 @@ // aux-build:hidden.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] // tests https://github.com/rust-lang/rust/issues/73363 diff --git a/src/test/rustdoc/intra-doc-crate/macro.rs b/src/test/rustdoc/intra-doc-crate/macro.rs index 72fd57b6b0c7f..f219d99c681d2 100644 --- a/src/test/rustdoc/intra-doc-crate/macro.rs +++ b/src/test/rustdoc/intra-doc-crate/macro.rs @@ -2,7 +2,7 @@ // aux-build:macro_inner.rs // aux-build:proc_macro.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] extern crate macro_inner; extern crate proc_macro_inner; diff --git a/src/test/rustdoc/intra-doc-crate/module.rs b/src/test/rustdoc/intra-doc-crate/module.rs index 67fa7293f37fb..658b3219681ef 100644 --- a/src/test/rustdoc/intra-doc-crate/module.rs +++ b/src/test/rustdoc/intra-doc-crate/module.rs @@ -1,7 +1,7 @@ // outer.rs // aux-build: module.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] extern crate module_inner; // @has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait' // @has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType' diff --git a/src/test/rustdoc/intra-doc-crate/submodule-inner.rs b/src/test/rustdoc/intra-doc-crate/submodule-inner.rs index b4b615bf9edad..166dc073fe346 100644 --- a/src/test/rustdoc/intra-doc-crate/submodule-inner.rs +++ b/src/test/rustdoc/intra-doc-crate/submodule-inner.rs @@ -1,6 +1,6 @@ // aux-build:submodule-inner.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] extern crate a; diff --git a/src/test/rustdoc/intra-doc-crate/submodule-outer.rs b/src/test/rustdoc/intra-doc-crate/submodule-outer.rs index 6b30ef8b3dec8..f849cc25531ab 100644 --- a/src/test/rustdoc/intra-doc-crate/submodule-outer.rs +++ b/src/test/rustdoc/intra-doc-crate/submodule-outer.rs @@ -1,6 +1,6 @@ // aux-build:submodule-outer.rs // edition:2018 -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] extern crate bar as bar_; diff --git a/src/test/rustdoc/intra-doc-crate/traits.rs b/src/test/rustdoc/intra-doc-crate/traits.rs index 617331236902d..8a3b20d175b20 100644 --- a/src/test/rustdoc/intra-doc-crate/traits.rs +++ b/src/test/rustdoc/intra-doc-crate/traits.rs @@ -3,7 +3,7 @@ // aux-build:traits.rs // build-aux-docs // ignore-tidy-line-length -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] extern crate inner; use inner::SomeTrait; diff --git a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs index 65187f48539a4..b64817662b60b 100644 --- a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs +++ b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub fn foo() { diff --git a/src/test/rustdoc/intra-link-extern-crate.rs b/src/test/rustdoc/intra-link-extern-crate.rs index bbe3edaea8cb2..8066d57e571e7 100644 --- a/src/test/rustdoc/intra-link-extern-crate.rs +++ b/src/test/rustdoc/intra-link-extern-crate.rs @@ -4,6 +4,6 @@ // though they would never actually get displayed. This tripped intra-doc-link resolution failures, // for items that aren't under our control, and not actually getting documented! -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] extern crate inner; diff --git a/src/test/rustdoc/intra-link-in-bodies.rs b/src/test/rustdoc/intra-link-in-bodies.rs index 4c693907226ad..4f299dec996c4 100644 --- a/src/test/rustdoc/intra-link-in-bodies.rs +++ b/src/test/rustdoc/intra-link-in-bodies.rs @@ -1,6 +1,6 @@ // we need to make sure that intra-doc links on trait impls get resolved in the right scope -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub mod inner { pub struct SomethingOutOfScope; diff --git a/src/test/rustdoc/intra-link-libstd-re-export.rs b/src/test/rustdoc/intra-link-libstd-re-export.rs index 6f239292ec200..95c3a33bfb19a 100644 --- a/src/test/rustdoc/intra-link-libstd-re-export.rs +++ b/src/test/rustdoc/intra-link-libstd-re-export.rs @@ -1,3 +1,3 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub use std::*; diff --git a/src/test/rustdoc/intra-link-prim-methods-external-core.rs b/src/test/rustdoc/intra-link-prim-methods-external-core.rs index e09d36594edf9..6205a10b6709d 100644 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -4,7 +4,7 @@ // ignore-windows // ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] #![feature(no_core, lang_items)] #![no_core] #![crate_type = "rlib"] diff --git a/src/test/rustdoc/intra-link-prim-methods-local.rs b/src/test/rustdoc/intra-link-prim-methods-local.rs index d24cd2cbb5e20..6f9712edb1925 100644 --- a/src/test/rustdoc/intra-link-prim-methods-local.rs +++ b/src/test/rustdoc/intra-link-prim-methods-local.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] #![feature(no_core, lang_items)] #![no_core] #![crate_type = "rlib"] diff --git a/src/test/rustdoc/intra-link-prim-methods.rs b/src/test/rustdoc/intra-link-prim-methods.rs index 76636b80b5eb5..770e0e99d8b62 100644 --- a/src/test/rustdoc/intra-link-prim-methods.rs +++ b/src/test/rustdoc/intra-link-prim-methods.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] // ignore-tidy-linelength diff --git a/src/test/rustdoc/intra-link-prim-precedence.rs b/src/test/rustdoc/intra-link-prim-precedence.rs index d7ebb73b3be7d..c149e15c81c0c 100644 --- a/src/test/rustdoc/intra-link-prim-precedence.rs +++ b/src/test/rustdoc/intra-link-prim-precedence.rs @@ -1,5 +1,5 @@ // ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] pub mod char {} diff --git a/src/test/rustdoc/intra-link-private.rs b/src/test/rustdoc/intra-link-private.rs index c99b4d70684aa..24a9fda034157 100644 --- a/src/test/rustdoc/intra-link-private.rs +++ b/src/test/rustdoc/intra-link-private.rs @@ -2,7 +2,7 @@ // These failures were legitimate, but not truly relevant - the docs in question couldn't be // checked for accuracy anyway. -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] /// ooh, i'm a [rebel] just for kicks struct SomeStruct; diff --git a/src/test/rustdoc/intra-link-proc-macro.rs b/src/test/rustdoc/intra-link-proc-macro.rs index 7b6ea5d60f853..d22a4cfbf389d 100644 --- a/src/test/rustdoc/intra-link-proc-macro.rs +++ b/src/test/rustdoc/intra-link-proc-macro.rs @@ -1,6 +1,6 @@ // aux-build:intra-link-proc-macro-macro.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] extern crate intra_link_proc_macro_macro; diff --git a/src/test/rustdoc/intra-links-external-traits.rs b/src/test/rustdoc/intra-links-external-traits.rs index d6b4a8ad58ad7..dd6f0e780f948 100644 --- a/src/test/rustdoc/intra-links-external-traits.rs +++ b/src/test/rustdoc/intra-links-external-traits.rs @@ -2,7 +2,7 @@ // ignore-cross-compile #![crate_name = "outer"] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failures)] // using a trait that has intra-doc links on it from another crate (whether re-exporting or just // implementing it) used to give spurious resolution failure warnings diff --git a/src/test/rustdoc/through-proc-macro.rs b/src/test/rustdoc/through-proc-macro.rs index 348c9eea2dcbf..6c650146df130 100644 --- a/src/test/rustdoc/through-proc-macro.rs +++ b/src/test/rustdoc/through-proc-macro.rs @@ -1,6 +1,6 @@ // aux-build:through-proc-macro-aux.rs // build-aux-docs -#![warn(intra_doc_link_resolution_failure)] +#![warn(intra_doc_link_resolution_failures)] extern crate some_macros; #[some_macros::second] From da0b10c4fb2ff230fd68e3096c467da5dd82e89e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 29 Jul 2020 15:23:07 -0700 Subject: [PATCH 17/71] Register renamed lint --- src/librustc_lint/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index ee5ea6a9a192e..4fb47a7363d8a 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -318,6 +318,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { store.register_renamed("async_idents", "keyword_idents"); store.register_renamed("exceeding_bitshifts", "arithmetic_overflow"); store.register_renamed("redundant_semicolon", "redundant_semicolons"); + store.register_renamed("intra_doc_link_resolution_failure", "intra_doc_link_resolution_failures"); store.register_removed("unknown_features", "replaced by an error"); store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); store.register_removed("negate_unsigned", "cast a signed value instead"); From 8046fea62263d50fc196ce07ccdc4534af321441 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Thu, 30 Jul 2020 06:17:18 +0100 Subject: [PATCH 18/71] Improve diagnostics when constant pattern is too generic --- src/librustc_mir_build/hair/pattern/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/hair/pattern/mod.rs index a5c87bc963f49..f813ba0c077ca 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/hair/pattern/mod.rs @@ -16,7 +16,7 @@ use rustc_hir::pat_util::EnumerateAndAdjustIterator; use rustc_hir::RangeEnd; use rustc_index::vec::Idx; use rustc_middle::mir::interpret::{get_slice_bytes, sign_extend, ConstValue}; -use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput}; +use rustc_middle::mir::interpret::{ErrorHandled, LitToConstError, LitToConstInput}; use rustc_middle::mir::UserTypeProjection; use rustc_middle::mir::{BorrowKind, Field, Mutability}; use rustc_middle::ty::subst::{GenericArg, SubstsRef}; @@ -834,6 +834,12 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { pattern } } + Err(ErrorHandled::TooGeneric) => { + // While `Reported | Linted` cases will have diagnostics emitted already + // it is not true for TooGeneric case, so we need to give user more information. + self.tcx.sess.span_err(span, "constant pattern depends on a generic parameter"); + pat_from_kind(PatKind::Wild) + } Err(_) => { self.tcx.sess.span_err(span, "could not evaluate constant pattern"); pat_from_kind(PatKind::Wild) From 4e963d58c7d94270697c2765f23993e40757292f Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Thu, 30 Jul 2020 06:34:16 +0100 Subject: [PATCH 19/71] Fix ui tests --- src/test/ui/consts/issue-73976-polymorphic.rs | 8 ++++---- src/test/ui/consts/issue-73976-polymorphic.stderr | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/ui/consts/issue-73976-polymorphic.rs b/src/test/ui/consts/issue-73976-polymorphic.rs index 7cf20296062ab..518036c9dbeec 100644 --- a/src/test/ui/consts/issue-73976-polymorphic.rs +++ b/src/test/ui/consts/issue-73976-polymorphic.rs @@ -17,8 +17,8 @@ impl GetTypeId { const fn check_type_id() -> bool { matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) - //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern + //~^ ERROR constant pattern depends on a generic parameter + //~| ERROR constant pattern depends on a generic parameter } pub struct GetTypeNameLen(T); @@ -29,8 +29,8 @@ impl GetTypeNameLen { const fn check_type_name_len() -> bool { matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) - //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern + //~^ ERROR constant pattern depends on a generic parameter + //~| ERROR constant pattern depends on a generic parameter } fn main() { diff --git a/src/test/ui/consts/issue-73976-polymorphic.stderr b/src/test/ui/consts/issue-73976-polymorphic.stderr index 971573e14aad8..250f1536d85fc 100644 --- a/src/test/ui/consts/issue-73976-polymorphic.stderr +++ b/src/test/ui/consts/issue-73976-polymorphic.stderr @@ -1,22 +1,22 @@ -error: could not evaluate constant pattern +error: constant pattern depends on a generic parameter --> $DIR/issue-73976-polymorphic.rs:19:37 | LL | matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^ -error: could not evaluate constant pattern +error: constant pattern depends on a generic parameter --> $DIR/issue-73976-polymorphic.rs:31:42 | LL | matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: could not evaluate constant pattern +error: constant pattern depends on a generic parameter --> $DIR/issue-73976-polymorphic.rs:19:37 | LL | matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^ -error: could not evaluate constant pattern +error: constant pattern depends on a generic parameter --> $DIR/issue-73976-polymorphic.rs:31:42 | LL | matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) From 870b7cbb11d799bcabc6eb5a919a27821c981bc1 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 18 May 2020 20:06:00 +0200 Subject: [PATCH 20/71] improve chunks + windows err on size 0 --- library/core/src/slice/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 9ed5a1f962215..77fe379feeebe 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -680,7 +680,7 @@ impl [T] { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn windows(&self, size: usize) -> Windows<'_, T> { - assert!(size != 0); + assert_ne!(size, 0); Windows { v: self, size } } @@ -714,7 +714,7 @@ impl [T] { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> { - assert!(chunk_size != 0); + assert_ne!(chunk_size, 0); Chunks { v: self, chunk_size } } @@ -752,7 +752,7 @@ impl [T] { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> { - assert!(chunk_size != 0); + assert_ne!(chunk_size, 0); ChunksMut { v: self, chunk_size } } @@ -789,7 +789,7 @@ impl [T] { #[stable(feature = "chunks_exact", since = "1.31.0")] #[inline] pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T> { - assert!(chunk_size != 0); + assert_ne!(chunk_size, 0); let rem = self.len() % chunk_size; let len = self.len() - rem; let (fst, snd) = self.split_at(len); @@ -834,7 +834,7 @@ impl [T] { #[stable(feature = "chunks_exact", since = "1.31.0")] #[inline] pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T> { - assert!(chunk_size != 0); + assert_ne!(chunk_size, 0); let rem = self.len() % chunk_size; let len = self.len() - rem; let (fst, snd) = self.split_at_mut(len); From d405347f095a20d832261bbf777c8214d7e61dc9 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 18 May 2020 20:40:37 +0200 Subject: [PATCH 21/71] adds `slice::array_chunks` --- library/core/src/slice/mod.rs | 180 ++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 77fe379feeebe..a7d24492facd1 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -841,6 +841,41 @@ impl [T] { ChunksExactMut { v: fst, rem: snd, chunk_size } } + /// Returns an iterator over `N` elements of the slice at a time, starting at the + /// beginning of the slice. + /// + /// The chunks are slices and do not overlap. If `N` does not divide the length of the + /// slice, then the last up to `N-1` elements will be omitted and can be retrieved + /// from the `remainder` function of the iterator. + /// + /// # Panics + /// + /// Panics if `N` is 0. + /// + /// # Examples + /// + /// ``` + /// #![feature(array_chunks)] + /// let slice = ['l', 'o', 'r', 'e', 'm']; + /// let mut iter = slice.array_chunks(); + /// assert_eq!(iter.next().unwrap(), &['l', 'o']); + /// assert_eq!(iter.next().unwrap(), &['r', 'e']); + /// assert!(iter.next().is_none()); + /// assert_eq!(iter.remainder(), &['m']); + /// ``` + /// + /// [`chunks`]: #method.chunks + /// [`rchunks_exact`]: #method.rchunks_exact + #[unstable(feature = "array_chunks", issue = "none")] + #[inline] + pub fn array_chunks(&self) -> ArrayChunks<'_, T, N> { + assert_ne!(N, 0); + let rem = self.len() % N; + let len = self.len() - rem; + let (fst, snd) = self.split_at(len); + ArrayChunks { v: fst, rem: snd } + } + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end /// of the slice. /// @@ -5432,6 +5467,151 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> { } } +/// An iterator over a slice in (non-overlapping) chunks (`N` elements at a +/// time), starting at the beginning of the slice. +/// +/// When the slice len is not evenly divided by the chunk size, the last +/// up to `chunk_size-1` elements will be omitted but can be retrieved from +/// the [`remainder`] function from the iterator. +/// +/// This struct is created by the [`array_chunks`] method on [slices]. +/// +/// [`array_chunks`]: ../../std/primitive.slice.html#method.array_chunks +/// [`remainder`]: ../../std/slice/struct.ArrayChunks.html#method.remainder +/// [slices]: ../../std/primitive.slice.html +#[derive(Debug)] +#[unstable(feature = "array_chunks", issue = "none")] +pub struct ArrayChunks<'a, T: 'a, const N: usize> { + v: &'a [T], + rem: &'a [T], +} + +impl<'a, T, const N: usize> ArrayChunks<'a, T, N> { + /// Returns the remainder of the original slice that is not going to be + /// returned by the iterator. The returned slice has at most `chunk_size-1` + /// elements. + #[unstable(feature = "array_chunks", issue = "none")] + pub fn remainder(&self) -> &'a [T] { + self.rem + } +} + +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +#[unstable(feature = "array_chunks", issue = "none")] +impl Clone for ArrayChunks<'_, T, N> { + fn clone(&self) -> Self { + ArrayChunks { v: self.v, rem: self.rem } + } +} + +#[unstable(feature = "array_chunks", issue = "none")] +impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> { + type Item = &'a [T; N]; + + #[inline] + fn next(&mut self) -> Option<&'a [T; N]> { + if self.v.len() < N { + None + } else { + let (fst, snd) = self.v.split_at(N); + self.v = snd; + // SAFETY: This is safe as fst is exactly N elements long. + let ptr = fst.as_ptr() as *const [T; N]; + unsafe { Some(&*ptr) } + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + let n = self.v.len() / N; + (n, Some(n)) + } + + #[inline] + fn count(self) -> usize { + self.len() + } + + #[inline] + fn nth(&mut self, n: usize) -> Option { + let (start, overflow) = n.overflowing_mul(N); + if start >= self.v.len() || overflow { + self.v = &[]; + None + } else { + let (_, snd) = self.v.split_at(start); + self.v = snd; + self.next() + } + } + + #[inline] + fn last(mut self) -> Option { + self.next_back() + } +} + +#[unstable(feature = "array_chunks", issue = "none")] +impl<'a, T, const N: usize> DoubleEndedIterator for ArrayChunks<'a, T, N> { + #[inline] + fn next_back(&mut self) -> Option<&'a [T; N]> { + if self.v.len() < N { + None + } else { + let (fst, snd) = self.v.split_at(self.v.len() - N); + self.v = fst; + // SAFETY: This is safe as snd is exactly N elements long. + let ptr = snd.as_ptr() as *const [T; N]; + unsafe { Some(&*ptr) } + } + } + + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + let len = self.len(); + if n >= len { + self.v = &[]; + None + } else { + let start = (len - 1 - n) * N; + let end = start + N; + let nth_back = &self.v[start..end]; + self.v = &self.v[..start]; + // SAFETY: This is safe as snd is exactly N elements long. + let ptr = nth_back.as_ptr() as *const [T; N]; + unsafe { Some(&*ptr) } + } + } +} + +#[unstable(feature = "array_chunks", issue = "none")] +impl ExactSizeIterator for ArrayChunks<'_, T, N> { + fn is_empty(&self) -> bool { + self.v.is_empty() + } +} + +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl TrustedLen for ArrayChunks<'_, T, N> {} + +#[unstable(feature = "array_chunks", issue = "none")] +impl FusedIterator for ArrayChunks<'_, T, N> {} + +#[doc(hidden)] +#[unstable(feature = "array_chunks", issue = "none")] +unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunks<'a, T, N> { + unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T; N] { + let start = i * N; + // SAFETY: This is safe as `i` must be less than `self.size_hint`. + let segment = unsafe { from_raw_parts(self.v.as_ptr().add(start), N) }; + // SAFETY: This is safe as segment is exactly `N` elements long. + unsafe { &*(segment.as_ptr() as *const [T; N]) } + } + fn may_have_side_effect() -> bool { + false + } +} + /// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a /// time), starting at the end of the slice. /// From d27007fd6d41a8e9f16228d036c1fedaf0449efd Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 18 May 2020 21:24:37 +0200 Subject: [PATCH 22/71] add tests for array_chunks --- library/core/src/slice/mod.rs | 1 - library/core/tests/lib.rs | 1 + library/core/tests/slice.rs | 91 +++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index a7d24492facd1..e33dad38d4b0d 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -865,7 +865,6 @@ impl [T] { /// ``` /// /// [`chunks`]: #method.chunks - /// [`rchunks_exact`]: #method.rchunks_exact #[unstable(feature = "array_chunks", issue = "none")] #[inline] pub fn array_chunks(&self) -> ArrayChunks<'_, T, N> { diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 47ed6db6c677b..6b28a815f033a 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -1,4 +1,5 @@ #![feature(alloc_layout_extra)] +#![feature(array_chunks)] #![feature(bool_to_option)] #![feature(bound_cloned)] #![feature(box_syntax)] diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 8e240832c13b8..27cc7fce1daa3 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -473,6 +473,97 @@ fn test_chunks_exact_mut_zip() { assert_eq!(v1, [13, 14, 19, 20, 4]); } +#[test] +fn test_array_chunks_infer() { + let v: &[i32] = &[0, 1, 2, 3, 4, -4]; + let c = v.array_chunks(); + for &[a, b, c] in c { + assert_eq!(a + b + c, 3); + } + + let v2: &[i32] = &[0, 1, 2, 3, 4, 5, 6]; + let total = v2.array_chunks().map(|&[a, b]| a * b).sum::(); + assert_eq!(total, 2 * 3 + 4 * 5); +} + +#[test] +fn test_array_chunks_count() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.array_chunks::<3>(); + assert_eq!(c.count(), 2); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.array_chunks::<2>(); + assert_eq!(c2.count(), 2); + + let v3: &[i32] = &[]; + let c3 = v3.array_chunks::<2>(); + assert_eq!(c3.count(), 0); +} + +#[test] +fn test_array_chunks_nth() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.array_chunks::<2>(); + assert_eq!(c.nth(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[4, 5]); + + let v2: &[i32] = &[0, 1, 2, 3, 4, 5, 6]; + let mut c2 = v2.array_chunks::<3>(); + assert_eq!(c2.nth(1).unwrap(), &[3, 4, 5]); + assert_eq!(c2.next(), None); +} + +#[test] +fn test_array_chunks_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.array_chunks::<2>(); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + assert_eq!(c.next(), None); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.array_chunks::<3>(); + assert_eq!(c2.nth_back(0).unwrap(), &[0, 1, 2]); + assert_eq!(c2.next(), None); + assert_eq!(c2.next_back(), None); + + let v3: &[i32] = &[0, 1, 2, 3, 4]; + let mut c3 = v3.array_chunks::<10>(); + assert_eq!(c3.nth_back(0), None); +} + +#[test] +fn test_array_chunks_last() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.array_chunks::<2>(); + assert_eq!(c.last().unwrap(), &[4, 5]); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.array_chunks::<2>(); + assert_eq!(c2.last().unwrap(), &[2, 3]); +} + +#[test] +fn test_array_chunks_remainder() { + let v: &[i32] = &[0, 1, 2, 3, 4]; + let c = v.array_chunks::<2>(); + assert_eq!(c.remainder(), &[4]); +} + +#[test] +fn test_array_chunks_zip() { + let v1: &[i32] = &[0, 1, 2, 3, 4]; + let v2: &[i32] = &[6, 7, 8, 9, 10]; + + let res = v1 + .array_chunks::<2>() + .zip(v2.array_chunks::<2>()) + .map(|(a, b)| a.iter().sum::() + b.iter().sum::()) + .collect::>(); + assert_eq!(res, vec![14, 22]); +} + #[test] fn test_rchunks_count() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; From 95fa63e63f21ba3270870920d67836016b4c9711 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 18 May 2020 23:14:55 +0200 Subject: [PATCH 23/71] liballoc export ArrayChunks --- library/alloc/src/lib.rs | 1 + library/alloc/src/slice.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 90e2d2531c552..fe91cceed697a 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -76,6 +76,7 @@ #![cfg_attr(not(test), feature(generator_trait))] #![cfg_attr(test, feature(test))] #![feature(allocator_api)] +#![feature(array_chunks)] #![feature(allow_internal_unstable)] #![feature(arbitrary_self_types)] #![feature(box_patterns)] diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index 3d51115fe01d3..0bb64d6bb6f02 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -95,6 +95,8 @@ use crate::borrow::ToOwned; use crate::boxed::Box; use crate::vec::Vec; +#[unstable(feature = "array_chunks", issue = "none")] +pub use core::slice::ArrayChunks; #[stable(feature = "slice_get_slice", since = "1.28.0")] pub use core::slice::SliceIndex; #[stable(feature = "from_ref", since = "1.28.0")] From 89e4fe33130a17888a2add6baadd850653263242 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 30 Jul 2020 13:51:22 +0200 Subject: [PATCH 24/71] Improve E0730 explanation --- src/librustc_error_codes/error_codes/E0730.md | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0730.md b/src/librustc_error_codes/error_codes/E0730.md index d385009063f78..016b3f38aa310 100644 --- a/src/librustc_error_codes/error_codes/E0730.md +++ b/src/librustc_error_codes/error_codes/E0730.md @@ -14,14 +14,28 @@ fn is_123(x: [u32; N]) -> bool { } ``` -Ensure that the pattern is consistent with the size of the matched array. -Additional elements can be matched with `..`: +To fix this error, you have two solutions: + 1. Use an array with a fixed length. + 2. Use a slice. +Example with an array with a fixed length: + +``` +fn is_123(x: [u32; 3]) -> bool { // We use an array with a fixed size + match x { + [1, 2, ..] => true, // ok! + _ => false + } +} ``` -let r = &[1, 2, 3, 4]; -match r { - &[a, b, ..] => { // ok! - println!("a={}, b={}", a, b); + +Example with a slice: + +``` +fn is_123(x: &[u32]) -> bool { // We use a slice + match x { + [1, 2, ..] => true, // ok! + _ => false } } ``` From ddbe69a5b2f268042d7d68b0bb5d2cac0055519b Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Thu, 30 Jul 2020 18:33:34 +0800 Subject: [PATCH 25/71] Special treatment for dereferencing a borrow to a static definition --- src/librustc_mir/transform/promote_consts.rs | 28 ++++++++++++++++++-- src/test/ui/statics/static-promotion.rs | 15 +++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/statics/static-promotion.rs diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 59a8415ef96f0..5f62e19938b83 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -502,9 +502,33 @@ impl<'tcx> Validator<'_, 'tcx> { fn validate_place(&self, place: PlaceRef<'tcx>) -> Result<(), Unpromotable> { match place { PlaceRef { local, projection: [] } => self.validate_local(local), - PlaceRef { local: _, projection: [proj_base @ .., elem] } => { + PlaceRef { local, projection: [proj_base @ .., elem] } => { match *elem { - ProjectionElem::Deref | ProjectionElem::Downcast(..) => { + ProjectionElem::Deref => { + let mut not_promotable = true; + if let TempState::Defined { location, .. } = self.temps[local] { + let def_stmt = + self.body[location.block].statements.get(location.statement_index); + if let Some(Statement { + kind: + StatementKind::Assign(box (_, Rvalue::Use(Operand::Constant(c)))), + .. + }) = def_stmt + { + if let Some(did) = c.check_static_ptr(self.tcx) { + if let Some(hir::ConstContext::Static(..)) = self.const_kind { + if !self.tcx.is_thread_local_static(did) { + not_promotable = false; + } + } + } + } + } + if not_promotable { + return Err(Unpromotable); + } + } + ProjectionElem::Downcast(..) => { return Err(Unpromotable); } diff --git a/src/test/ui/statics/static-promotion.rs b/src/test/ui/statics/static-promotion.rs new file mode 100644 index 0000000000000..2d9237d11c929 --- /dev/null +++ b/src/test/ui/statics/static-promotion.rs @@ -0,0 +1,15 @@ +// run-pass + +struct A(&'static T); +struct B { + x: &'static T, +} +static C: A>> = { + A(&B { + x: &B { x: b"hi" as &[u8] }, + }) +}; + +fn main() { + assert_eq!(b"hi", C.0.x.x); +} From 4df76f0f90fc0aa4cb3ed4c2c812c6f505f3e21e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 29 Jul 2020 16:26:32 -0700 Subject: [PATCH 26/71] Rename to intra_doc_resolution_failures --- src/doc/rustdoc/src/lints.md | 2 +- src/librustc_lint/lib.rs | 6 +- src/librustc_session/lint/builtin.rs | 4 +- src/librustdoc/core.rs | 2 +- .../passes/collect_intra_doc_links.rs | 66 +++++++++---------- .../exit-code/lint-failure.rs | 2 +- .../deny-intra-link-resolution-failure.rs | 2 +- .../deny-intra-link-resolution-failure.stderr | 2 +- src/test/rustdoc-ui/intra-doc-alias-ice.rs | 2 +- .../rustdoc-ui/intra-doc-alias-ice.stderr | 2 +- .../rustdoc-ui/intra-link-span-ice-55723.rs | 2 +- .../intra-link-span-ice-55723.stderr | 2 +- src/test/rustdoc-ui/intra-links-ambiguity.rs | 2 +- .../rustdoc-ui/intra-links-ambiguity.stderr | 2 +- src/test/rustdoc-ui/intra-links-anchors.rs | 2 +- .../rustdoc-ui/intra-links-anchors.stderr | 2 +- .../intra-links-private.private.stderr | 2 +- .../intra-links-private.public.stderr | 2 +- .../intra-links-warning-crlf.stderr | 2 +- .../rustdoc-ui/intra-links-warning.stderr | 2 +- .../rustdoc-ui/issue-74134.private.stderr | 2 +- src/test/rustdoc-ui/issue-74134.public.stderr | 2 +- src/test/rustdoc-ui/lint-group.stderr | 2 +- .../reference-link-has-one-warning.stderr | 2 +- .../rustdoc/intra-doc-crate/additional_doc.rs | 2 +- .../auxiliary/additional_doc.rs | 2 +- .../intra-doc-crate/auxiliary/hidden.rs | 2 +- .../auxiliary/intra-doc-basic.rs | 2 +- .../intra-doc-crate/auxiliary/macro_inner.rs | 2 +- .../intra-doc-crate/auxiliary/module.rs | 2 +- .../auxiliary/submodule-inner.rs | 2 +- .../auxiliary/submodule-outer.rs | 2 +- src/test/rustdoc/intra-doc-crate/basic.rs | 2 +- src/test/rustdoc/intra-doc-crate/hidden.rs | 2 +- src/test/rustdoc/intra-doc-crate/macro.rs | 2 +- src/test/rustdoc/intra-doc-crate/module.rs | 2 +- .../intra-doc-crate/submodule-inner.rs | 2 +- .../intra-doc-crate/submodule-outer.rs | 2 +- src/test/rustdoc/intra-doc-crate/traits.rs | 2 +- .../rustdoc/intra-doc-link-mod-ambiguity.rs | 2 +- src/test/rustdoc/intra-link-extern-crate.rs | 2 +- src/test/rustdoc/intra-link-in-bodies.rs | 2 +- .../rustdoc/intra-link-libstd-re-export.rs | 2 +- .../intra-link-prim-methods-external-core.rs | 2 +- .../rustdoc/intra-link-prim-methods-local.rs | 2 +- src/test/rustdoc/intra-link-prim-methods.rs | 2 +- .../rustdoc/intra-link-prim-precedence.rs | 2 +- src/test/rustdoc/intra-link-private.rs | 2 +- src/test/rustdoc/intra-link-proc-macro.rs | 2 +- .../rustdoc/intra-links-external-traits.rs | 2 +- src/test/rustdoc/through-proc-macro.rs | 2 +- 51 files changed, 83 insertions(+), 89 deletions(-) diff --git a/src/doc/rustdoc/src/lints.md b/src/doc/rustdoc/src/lints.md index 0766e7b87ea07..275cadb65252b 100644 --- a/src/doc/rustdoc/src/lints.md +++ b/src/doc/rustdoc/src/lints.md @@ -11,7 +11,7 @@ can use them like any other lints by doing this: Here is the list of the lints provided by `rustdoc`: -## intra_doc_link_resolution_failures +## intra_doc_resolution_failures This lint **warns by default** and is **nightly-only**. This lint detects when an intra-doc link fails to get resolved. For example: diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 4fb47a7363d8a..a542f5c96fa7e 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -62,7 +62,7 @@ use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::{ BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, - INTRA_DOC_LINK_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, + INTRA_DOC_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, }; use rustc_span::symbol::{Ident, Symbol}; @@ -303,7 +303,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { add_lint_group!( "rustdoc", - INTRA_DOC_LINK_RESOLUTION_FAILURES, + INTRA_DOC_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS @@ -318,7 +318,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { store.register_renamed("async_idents", "keyword_idents"); store.register_renamed("exceeding_bitshifts", "arithmetic_overflow"); store.register_renamed("redundant_semicolon", "redundant_semicolons"); - store.register_renamed("intra_doc_link_resolution_failure", "intra_doc_link_resolution_failures"); + store.register_renamed("intra_doc_link_resolution_failure", "intra_doc_resolution_failures"); store.register_removed("unknown_features", "replaced by an error"); store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); store.register_removed("negate_unsigned", "cast a signed value instead"); diff --git a/src/librustc_session/lint/builtin.rs b/src/librustc_session/lint/builtin.rs index 3e93c430c1f53..f2a5289c8c445 100644 --- a/src/librustc_session/lint/builtin.rs +++ b/src/librustc_session/lint/builtin.rs @@ -398,7 +398,7 @@ declare_lint! { } declare_lint! { - pub INTRA_DOC_LINK_RESOLUTION_FAILURES, + pub INTRA_DOC_RESOLUTION_FAILURES, Warn, "failures in resolving intra-doc link targets" } @@ -601,7 +601,7 @@ declare_lint_pass! { ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, UNSTABLE_NAME_COLLISIONS, IRREFUTABLE_LET_PATTERNS, - INTRA_DOC_LINK_RESOLUTION_FAILURES, + INTRA_DOC_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_CRATE_LEVEL_DOCS, MISSING_DOC_CODE_EXAMPLES, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index ecd6a28bcecf9..35c340bf251d9 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -315,7 +315,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let cpath = Some(input.clone()); let input = Input::File(input); - let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURES.name; + let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_RESOLUTION_FAILURES.name; let missing_docs = rustc_lint::builtin::MISSING_DOCS.name; let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name; let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index c65905ade31f1..02a9483f9293a 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -867,46 +867,40 @@ fn report_diagnostic( let attrs = &item.attrs; let sp = span_of_attrs(attrs).unwrap_or(item.source.span()); - cx.tcx.struct_span_lint_hir( - lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURES, - hir_id, - sp, - |lint| { - let mut diag = lint.build(msg); - - let span = link_range - .as_ref() - .and_then(|range| super::source_span_for_markdown_range(cx, dox, range, attrs)); - - if let Some(link_range) = link_range { - if let Some(sp) = span { - diag.set_span(sp); - } else { - // blah blah blah\nblah\nblah [blah] blah blah\nblah blah - // ^ ~~~~ - // | link_range - // last_new_line_offset - let last_new_line_offset = - dox[..link_range.start].rfind('\n').map_or(0, |n| n + 1); - let line = dox[last_new_line_offset..].lines().next().unwrap_or(""); - - // Print the line containing the `link_range` and manually mark it with '^'s. - diag.note(&format!( - "the link appears in this line:\n\n{line}\n\ + cx.tcx.struct_span_lint_hir(lint::builtin::INTRA_DOC_RESOLUTION_FAILURES, hir_id, sp, |lint| { + let mut diag = lint.build(msg); + + let span = link_range + .as_ref() + .and_then(|range| super::source_span_for_markdown_range(cx, dox, range, attrs)); + + if let Some(link_range) = link_range { + if let Some(sp) = span { + diag.set_span(sp); + } else { + // blah blah blah\nblah\nblah [blah] blah blah\nblah blah + // ^ ~~~~ + // | link_range + // last_new_line_offset + let last_new_line_offset = dox[..link_range.start].rfind('\n').map_or(0, |n| n + 1); + let line = dox[last_new_line_offset..].lines().next().unwrap_or(""); + + // Print the line containing the `link_range` and manually mark it with '^'s. + diag.note(&format!( + "the link appears in this line:\n\n{line}\n\ {indicator: $DIR/deny-intra-link-resolution-failure.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failures)] +LL | #![deny(intra_doc_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.rs b/src/test/rustdoc-ui/intra-doc-alias-ice.rs index aaf09a78093b6..5729ebb4cc017 100644 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.rs +++ b/src/test/rustdoc-ui/intra-doc-alias-ice.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub type TypeAlias = usize; diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr index d692dc76d6af3..5ba34dd1d54af 100644 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr +++ b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr @@ -7,7 +7,7 @@ LL | /// [broken cross-reference](TypeAlias::hoge) note: the lint level is defined here --> $DIR/intra-doc-alias-ice.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failures)] +LL | #![deny(intra_doc_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs index 89d271bb911a2..efd492406342a 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] // An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to // attempt to slice in the middle of a multibyte character. See diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr index c0c49c027f624..5c0ab62c6a13b 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr @@ -7,7 +7,7 @@ LL | /// (arr[i]) note: the lint level is defined here --> $DIR/intra-link-span-ice-55723.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failures)] +LL | #![deny(intra_doc_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.rs b/src/test/rustdoc-ui/intra-links-ambiguity.rs index dd7b8eee384da..7b2ca4f48d57b 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.rs +++ b/src/test/rustdoc-ui/intra-links-ambiguity.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.stderr b/src/test/rustdoc-ui/intra-links-ambiguity.stderr index a0c6dbd44b290..94b9258bdeeac 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.stderr +++ b/src/test/rustdoc-ui/intra-links-ambiguity.stderr @@ -7,7 +7,7 @@ LL | /// [`ambiguous`] is ambiguous. note: the lint level is defined here --> $DIR/intra-links-ambiguity.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failures)] +LL | #![deny(intra_doc_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to link to the struct, prefix with the item type | diff --git a/src/test/rustdoc-ui/intra-links-anchors.rs b/src/test/rustdoc-ui/intra-links-anchors.rs index fbf99fdba34b7..24e3bf1832aef 100644 --- a/src/test/rustdoc-ui/intra-links-anchors.rs +++ b/src/test/rustdoc-ui/intra-links-anchors.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] // A few tests on anchors. diff --git a/src/test/rustdoc-ui/intra-links-anchors.stderr b/src/test/rustdoc-ui/intra-links-anchors.stderr index d7c47f1ed122a..29a632273fa73 100644 --- a/src/test/rustdoc-ui/intra-links-anchors.stderr +++ b/src/test/rustdoc-ui/intra-links-anchors.stderr @@ -7,7 +7,7 @@ LL | /// Or maybe [Foo::f#hola]. note: the lint level is defined here --> $DIR/intra-links-anchors.rs:1:9 | -LL | #![deny(intra_doc_link_resolution_failures)] +LL | #![deny(intra_doc_resolution_failures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `hello#people#!` contains multiple anchors diff --git a/src/test/rustdoc-ui/intra-links-private.private.stderr b/src/test/rustdoc-ui/intra-links-private.private.stderr index 0cd3470851331..5c40fcd826b10 100644 --- a/src/test/rustdoc-ui/intra-links-private.private.stderr +++ b/src/test/rustdoc-ui/intra-links-private.private.stderr @@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe` LL | /// docs [DontDocMe] | ^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_link_resolution_failures)]` on by default + = note: `#[warn(intra_doc_resolution_failures)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/intra-links-private.public.stderr b/src/test/rustdoc-ui/intra-links-private.public.stderr index dc09270a2e150..93ba3229038b8 100644 --- a/src/test/rustdoc-ui/intra-links-private.public.stderr +++ b/src/test/rustdoc-ui/intra-links-private.public.stderr @@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe` LL | /// docs [DontDocMe] | ^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_link_resolution_failures)]` on by default + = note: `#[warn(intra_doc_resolution_failures)]` on by default = note: this link will resolve properly if you pass `--document-private-items` warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/intra-links-warning-crlf.stderr b/src/test/rustdoc-ui/intra-links-warning-crlf.stderr index cc6f51ef15571..0cf440c1fad2f 100644 --- a/src/test/rustdoc-ui/intra-links-warning-crlf.stderr +++ b/src/test/rustdoc-ui/intra-links-warning-crlf.stderr @@ -4,7 +4,7 @@ warning: unresolved link to `error` LL | /// [error] | ^^^^^ unresolved link | - = note: `#[warn(intra_doc_link_resolution_failures)]` on by default + = note: `#[warn(intra_doc_resolution_failures)]` on by default = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `error1` diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr index 28a92bd150b0b..c0091cefb4f33 100644 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ b/src/test/rustdoc-ui/intra-links-warning.stderr @@ -4,7 +4,7 @@ warning: unresolved link to `Foo::baz` LL | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ unresolved link | - = note: `#[warn(intra_doc_link_resolution_failures)]` on by default + = note: `#[warn(intra_doc_resolution_failures)]` on by default = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `Bar::foo` diff --git a/src/test/rustdoc-ui/issue-74134.private.stderr b/src/test/rustdoc-ui/issue-74134.private.stderr index 349d567dc3b2b..16d7c27230c2d 100644 --- a/src/test/rustdoc-ui/issue-74134.private.stderr +++ b/src/test/rustdoc-ui/issue-74134.private.stderr @@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy LL | /// [`PrivateType`] | ^^^^^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_link_resolution_failures)]` on by default + = note: `#[warn(intra_doc_resolution_failures)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/issue-74134.public.stderr b/src/test/rustdoc-ui/issue-74134.public.stderr index 6a73d4a32498d..a9ca83f810ad1 100644 --- a/src/test/rustdoc-ui/issue-74134.public.stderr +++ b/src/test/rustdoc-ui/issue-74134.public.stderr @@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy LL | /// [`PrivateType`] | ^^^^^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_link_resolution_failures)]` on by default + = note: `#[warn(intra_doc_resolution_failures)]` on by default = note: this link will resolve properly if you pass `--document-private-items` warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/lint-group.stderr b/src/test/rustdoc-ui/lint-group.stderr index 203ca83884936..471bb71fe5d8c 100644 --- a/src/test/rustdoc-ui/lint-group.stderr +++ b/src/test/rustdoc-ui/lint-group.stderr @@ -39,7 +39,7 @@ note: the lint level is defined here | LL | #![deny(rustdoc)] | ^^^^^^^ - = note: `#[deny(intra_doc_link_resolution_failures)]` implied by `#[deny(rustdoc)]` + = note: `#[deny(intra_doc_resolution_failures)]` implied by `#[deny(rustdoc)]` = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to 3 previous errors diff --git a/src/test/rustdoc-ui/reference-link-has-one-warning.stderr b/src/test/rustdoc-ui/reference-link-has-one-warning.stderr index 02b53eb710958..e5276a2b4aa84 100644 --- a/src/test/rustdoc-ui/reference-link-has-one-warning.stderr +++ b/src/test/rustdoc-ui/reference-link-has-one-warning.stderr @@ -4,7 +4,7 @@ warning: `[with#anchor#error]` has an issue with the link anchor. LL | /// docs [label][with#anchor#error] | ^^^^^^^^^^^^^^^^^ only one `#` is allowed in a link | - = note: `#[warn(intra_doc_link_resolution_failures)]` on by default + = note: `#[warn(intra_doc_resolution_failures)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc/intra-doc-crate/additional_doc.rs b/src/test/rustdoc/intra-doc-crate/additional_doc.rs index f5ab6ce2101de..ca30895e3ce2d 100644 --- a/src/test/rustdoc/intra-doc-crate/additional_doc.rs +++ b/src/test/rustdoc/intra-doc-crate/additional_doc.rs @@ -1,6 +1,6 @@ // aux-build:additional_doc.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] extern crate my_rand; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs index 59f59dc3919dd..b0f6dda865b63 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs @@ -1,5 +1,5 @@ #![crate_name = "my_rand"] -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub trait RngCore {} /// Rng extends [`RngCore`]. diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs index e4019dad3b6eb..f2bc8f470b87f 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs @@ -1,5 +1,5 @@ #![crate_name = "hidden_dep"] -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] #[doc(hidden)] pub mod __reexport { diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs index 7ffb622a740c6..a98fec734d70e 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs @@ -1,5 +1,5 @@ #![crate_name = "a"] -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub struct Foo; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs index 9907f569e8b83..59c4d7e00702c 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs @@ -1,5 +1,5 @@ #![crate_name = "macro_inner"] -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub struct Foo; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs index a000cea07a28e..2dc70211262f5 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs @@ -1,5 +1,5 @@ #![crate_name = "module_inner"] -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] /// [SomeType] links to [bar] pub struct SomeType; pub trait SomeTrait {} diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs index e13e4b0ed2262..d79a1b1b12e65 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs @@ -1,5 +1,5 @@ #![crate_name = "a"] -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub mod bar { pub struct Bar; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs index 770ccc9ada88f..e1f0bd9c6dd56 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs @@ -1,5 +1,5 @@ #![crate_name = "bar"] -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub trait Foo { /// [`Bar`] [`Baz`] diff --git a/src/test/rustdoc/intra-doc-crate/basic.rs b/src/test/rustdoc/intra-doc-crate/basic.rs index db20ef296fa91..88b18ed539bd2 100644 --- a/src/test/rustdoc/intra-doc-crate/basic.rs +++ b/src/test/rustdoc/intra-doc-crate/basic.rs @@ -1,6 +1,6 @@ // aux-build:intra-doc-basic.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] // from https://github.com/rust-lang/rust/issues/65983 extern crate a; diff --git a/src/test/rustdoc/intra-doc-crate/hidden.rs b/src/test/rustdoc/intra-doc-crate/hidden.rs index 45ca15f71d094..6d832b5a5f7ea 100644 --- a/src/test/rustdoc/intra-doc-crate/hidden.rs +++ b/src/test/rustdoc/intra-doc-crate/hidden.rs @@ -1,6 +1,6 @@ // aux-build:hidden.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] // tests https://github.com/rust-lang/rust/issues/73363 diff --git a/src/test/rustdoc/intra-doc-crate/macro.rs b/src/test/rustdoc/intra-doc-crate/macro.rs index f219d99c681d2..dd5dbec144da2 100644 --- a/src/test/rustdoc/intra-doc-crate/macro.rs +++ b/src/test/rustdoc/intra-doc-crate/macro.rs @@ -2,7 +2,7 @@ // aux-build:macro_inner.rs // aux-build:proc_macro.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] extern crate macro_inner; extern crate proc_macro_inner; diff --git a/src/test/rustdoc/intra-doc-crate/module.rs b/src/test/rustdoc/intra-doc-crate/module.rs index 658b3219681ef..0a6cc27f4a045 100644 --- a/src/test/rustdoc/intra-doc-crate/module.rs +++ b/src/test/rustdoc/intra-doc-crate/module.rs @@ -1,7 +1,7 @@ // outer.rs // aux-build: module.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] extern crate module_inner; // @has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait' // @has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType' diff --git a/src/test/rustdoc/intra-doc-crate/submodule-inner.rs b/src/test/rustdoc/intra-doc-crate/submodule-inner.rs index 166dc073fe346..f86547f90e112 100644 --- a/src/test/rustdoc/intra-doc-crate/submodule-inner.rs +++ b/src/test/rustdoc/intra-doc-crate/submodule-inner.rs @@ -1,6 +1,6 @@ // aux-build:submodule-inner.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] extern crate a; diff --git a/src/test/rustdoc/intra-doc-crate/submodule-outer.rs b/src/test/rustdoc/intra-doc-crate/submodule-outer.rs index f849cc25531ab..62781da479ffb 100644 --- a/src/test/rustdoc/intra-doc-crate/submodule-outer.rs +++ b/src/test/rustdoc/intra-doc-crate/submodule-outer.rs @@ -1,6 +1,6 @@ // aux-build:submodule-outer.rs // edition:2018 -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] extern crate bar as bar_; diff --git a/src/test/rustdoc/intra-doc-crate/traits.rs b/src/test/rustdoc/intra-doc-crate/traits.rs index 8a3b20d175b20..f12ba5b21fc36 100644 --- a/src/test/rustdoc/intra-doc-crate/traits.rs +++ b/src/test/rustdoc/intra-doc-crate/traits.rs @@ -3,7 +3,7 @@ // aux-build:traits.rs // build-aux-docs // ignore-tidy-line-length -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] extern crate inner; use inner::SomeTrait; diff --git a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs index b64817662b60b..38fa3d0c7dbac 100644 --- a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs +++ b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub fn foo() { diff --git a/src/test/rustdoc/intra-link-extern-crate.rs b/src/test/rustdoc/intra-link-extern-crate.rs index 8066d57e571e7..2af6880c6328e 100644 --- a/src/test/rustdoc/intra-link-extern-crate.rs +++ b/src/test/rustdoc/intra-link-extern-crate.rs @@ -4,6 +4,6 @@ // though they would never actually get displayed. This tripped intra-doc-link resolution failures, // for items that aren't under our control, and not actually getting documented! -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] extern crate inner; diff --git a/src/test/rustdoc/intra-link-in-bodies.rs b/src/test/rustdoc/intra-link-in-bodies.rs index 4f299dec996c4..48244aa2ac792 100644 --- a/src/test/rustdoc/intra-link-in-bodies.rs +++ b/src/test/rustdoc/intra-link-in-bodies.rs @@ -1,6 +1,6 @@ // we need to make sure that intra-doc links on trait impls get resolved in the right scope -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub mod inner { pub struct SomethingOutOfScope; diff --git a/src/test/rustdoc/intra-link-libstd-re-export.rs b/src/test/rustdoc/intra-link-libstd-re-export.rs index 95c3a33bfb19a..07623da50171d 100644 --- a/src/test/rustdoc/intra-link-libstd-re-export.rs +++ b/src/test/rustdoc/intra-link-libstd-re-export.rs @@ -1,3 +1,3 @@ -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub use std::*; diff --git a/src/test/rustdoc/intra-link-prim-methods-external-core.rs b/src/test/rustdoc/intra-link-prim-methods-external-core.rs index 6205a10b6709d..8166489c7a62b 100644 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -4,7 +4,7 @@ // ignore-windows // ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] #![feature(no_core, lang_items)] #![no_core] #![crate_type = "rlib"] diff --git a/src/test/rustdoc/intra-link-prim-methods-local.rs b/src/test/rustdoc/intra-link-prim-methods-local.rs index 6f9712edb1925..c42c6986233c5 100644 --- a/src/test/rustdoc/intra-link-prim-methods-local.rs +++ b/src/test/rustdoc/intra-link-prim-methods-local.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] #![feature(no_core, lang_items)] #![no_core] #![crate_type = "rlib"] diff --git a/src/test/rustdoc/intra-link-prim-methods.rs b/src/test/rustdoc/intra-link-prim-methods.rs index 770e0e99d8b62..bfb974d95b365 100644 --- a/src/test/rustdoc/intra-link-prim-methods.rs +++ b/src/test/rustdoc/intra-link-prim-methods.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] // ignore-tidy-linelength diff --git a/src/test/rustdoc/intra-link-prim-precedence.rs b/src/test/rustdoc/intra-link-prim-precedence.rs index c149e15c81c0c..ee0ef743a1e93 100644 --- a/src/test/rustdoc/intra-link-prim-precedence.rs +++ b/src/test/rustdoc/intra-link-prim-precedence.rs @@ -1,5 +1,5 @@ // ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] pub mod char {} diff --git a/src/test/rustdoc/intra-link-private.rs b/src/test/rustdoc/intra-link-private.rs index 24a9fda034157..08a2a8070cb86 100644 --- a/src/test/rustdoc/intra-link-private.rs +++ b/src/test/rustdoc/intra-link-private.rs @@ -2,7 +2,7 @@ // These failures were legitimate, but not truly relevant - the docs in question couldn't be // checked for accuracy anyway. -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] /// ooh, i'm a [rebel] just for kicks struct SomeStruct; diff --git a/src/test/rustdoc/intra-link-proc-macro.rs b/src/test/rustdoc/intra-link-proc-macro.rs index d22a4cfbf389d..eef82c4ac192c 100644 --- a/src/test/rustdoc/intra-link-proc-macro.rs +++ b/src/test/rustdoc/intra-link-proc-macro.rs @@ -1,6 +1,6 @@ // aux-build:intra-link-proc-macro-macro.rs // build-aux-docs -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] extern crate intra_link_proc_macro_macro; diff --git a/src/test/rustdoc/intra-links-external-traits.rs b/src/test/rustdoc/intra-links-external-traits.rs index dd6f0e780f948..de00f787bd292 100644 --- a/src/test/rustdoc/intra-links-external-traits.rs +++ b/src/test/rustdoc/intra-links-external-traits.rs @@ -2,7 +2,7 @@ // ignore-cross-compile #![crate_name = "outer"] -#![deny(intra_doc_link_resolution_failures)] +#![deny(intra_doc_resolution_failures)] // using a trait that has intra-doc links on it from another crate (whether re-exporting or just // implementing it) used to give spurious resolution failure warnings diff --git a/src/test/rustdoc/through-proc-macro.rs b/src/test/rustdoc/through-proc-macro.rs index 6c650146df130..fb84ef614744c 100644 --- a/src/test/rustdoc/through-proc-macro.rs +++ b/src/test/rustdoc/through-proc-macro.rs @@ -1,6 +1,6 @@ // aux-build:through-proc-macro-aux.rs // build-aux-docs -#![warn(intra_doc_link_resolution_failures)] +#![warn(intra_doc_resolution_failures)] extern crate some_macros; #[some_macros::second] From 7b7b5a7a129a640e4c652fbe91dd4113b0b5e06c Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 29 Jul 2020 17:06:44 -0700 Subject: [PATCH 27/71] Rename in library --- library/alloc/src/lib.rs | 2 +- library/core/src/lib.rs | 4 ++-- library/std/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 90e2d2531c552..479e0a955090f 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -69,7 +69,7 @@ #![warn(deprecated_in_future)] #![warn(missing_docs)] #![warn(missing_debug_implementations)] -#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings +#![deny(intra_doc_resolution_failures)] // rustdoc is run without -D warnings #![allow(explicit_outlives_requirements)] #![allow(incomplete_features)] #![deny(unsafe_op_in_unsafe_fn)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index c2bd5d16088fd..7c9dd92ffa0ee 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -61,7 +61,7 @@ #![warn(deprecated_in_future)] #![warn(missing_docs)] #![warn(missing_debug_implementations)] -#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings +#![deny(intra_doc_resolution_failures)] // rustdoc is run without -D warnings #![allow(explicit_outlives_requirements)] #![allow(incomplete_features)] #![feature(allow_internal_unstable)] @@ -149,7 +149,7 @@ #![feature(slice_ptr_get)] #![feature(no_niche)] // rust-lang/rust#68303 #![feature(unsafe_block_in_unsafe_fn)] -#![deny(intra_doc_link_resolution_failure)] +#![deny(intra_doc_resolution_failures)] #![deny(unsafe_op_in_unsafe_fn)] #[prelude_import] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index c6e5b0a492ac8..edd677b2ae086 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -212,7 +212,7 @@ #![warn(deprecated_in_future)] #![warn(missing_docs)] #![warn(missing_debug_implementations)] -#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings +#![deny(intra_doc_resolution_failures)] // rustdoc is run without -D warnings #![allow(explicit_outlives_requirements)] #![allow(unused_lifetimes)] // Tell the compiler to link to either panic_abort or panic_unwind From 522ef2e9811139e80e39cd1d5da2514cf9b7a8b4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 29 Jul 2020 23:19:12 -0700 Subject: [PATCH 28/71] Remove deny for intra doc link failures from library code, it's no longer necessary --- library/alloc/src/lib.rs | 1 - library/core/src/lib.rs | 2 -- library/std/src/lib.rs | 1 - 3 files changed, 4 deletions(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 479e0a955090f..6350e38554647 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -69,7 +69,6 @@ #![warn(deprecated_in_future)] #![warn(missing_docs)] #![warn(missing_debug_implementations)] -#![deny(intra_doc_resolution_failures)] // rustdoc is run without -D warnings #![allow(explicit_outlives_requirements)] #![allow(incomplete_features)] #![deny(unsafe_op_in_unsafe_fn)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 7c9dd92ffa0ee..de440a8261e90 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -61,7 +61,6 @@ #![warn(deprecated_in_future)] #![warn(missing_docs)] #![warn(missing_debug_implementations)] -#![deny(intra_doc_resolution_failures)] // rustdoc is run without -D warnings #![allow(explicit_outlives_requirements)] #![allow(incomplete_features)] #![feature(allow_internal_unstable)] @@ -149,7 +148,6 @@ #![feature(slice_ptr_get)] #![feature(no_niche)] // rust-lang/rust#68303 #![feature(unsafe_block_in_unsafe_fn)] -#![deny(intra_doc_resolution_failures)] #![deny(unsafe_op_in_unsafe_fn)] #[prelude_import] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index edd677b2ae086..74661d3456b8f 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -212,7 +212,6 @@ #![warn(deprecated_in_future)] #![warn(missing_docs)] #![warn(missing_debug_implementations)] -#![deny(intra_doc_resolution_failures)] // rustdoc is run without -D warnings #![allow(explicit_outlives_requirements)] #![allow(unused_lifetimes)] // Tell the compiler to link to either panic_abort or panic_unwind From cd8bdb5eb9a7440fa64500218f43b04429e64fc1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 29 Jul 2020 09:10:07 -0700 Subject: [PATCH 29/71] rustc: Ignore fs::canonicalize errors in metadata This commit updates the metadata location logic to ignore errors when calling `fs::canonicalize`. Canonicalization was added historically so multiple `-L` paths to the same directory don't print errors about multiple candidates (since rustc can deduplicate same-named paths), but canonicalization doesn't work on all filesystems. Cargo, for example, always uses this sort of fallback where it will opportunitistically try to canonicalize but fall back to using the input path if it otherwise doesn't work. If rustc is run on a filesystem that doesn't support canonicalization then the effect of this change will be that `-L` paths which logically point to the same directory will cause errors, but that's a rare enough occurrence it shouldn't cause much issue in practice. Otherwise rustc doesn't work at all today on those sorts of filesystem where canonicalization isn't supported! --- src/librustc_metadata/creader.rs | 6 +++--- src/librustc_metadata/locator.rs | 32 ++++++++++++++---------------- src/librustc_session/filesearch.rs | 32 ++++++++++++------------------ 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 724b4123fab6c..8dc842cc9d496 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -236,9 +236,9 @@ impl<'a> CrateLoader<'a> { // Only use `--extern crate_name=path` here, not `--extern crate_name`. if let Some(mut files) = entry.files() { if files.any(|l| { - let l = fs::canonicalize(l).ok(); - source.dylib.as_ref().map(|p| &p.0) == l.as_ref() - || source.rlib.as_ref().map(|p| &p.0) == l.as_ref() + let l = fs::canonicalize(l).unwrap_or(l.clone().into()); + source.dylib.as_ref().map(|p| &p.0) == Some(&l) + || source.rlib.as_ref().map(|p| &p.0) == Some(&l) }) { ret = Some(cnum); } diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 371ec4cd91148..8828b318d1ea6 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -426,20 +426,17 @@ impl<'a> CrateLocator<'a> { info!("lib candidate: {}", spf.path.display()); let (rlibs, rmetas, dylibs) = candidates.entry(hash.to_string()).or_default(); - fs::canonicalize(&spf.path) - .map(|p| { - if seen_paths.contains(&p) { - return FileDoesntMatch; - }; - seen_paths.insert(p.clone()); - match found_kind { - CrateFlavor::Rlib => rlibs.insert(p, kind), - CrateFlavor::Rmeta => rmetas.insert(p, kind), - CrateFlavor::Dylib => dylibs.insert(p, kind), - }; - FileMatches - }) - .unwrap_or(FileDoesntMatch) + let path = fs::canonicalize(&spf.path).unwrap_or_else(|_| spf.path.clone()); + if seen_paths.contains(&path) { + return FileDoesntMatch; + }; + seen_paths.insert(path.clone()); + match found_kind { + CrateFlavor::Rlib => rlibs.insert(path, kind), + CrateFlavor::Rmeta => rmetas.insert(path, kind), + CrateFlavor::Dylib => dylibs.insert(path, kind), + }; + FileMatches }); self.rejected_via_kind.extend(staticlibs); @@ -688,12 +685,13 @@ impl<'a> CrateLocator<'a> { && file.ends_with(&self.target.options.dll_suffix) { // Make sure there's at most one rlib and at most one dylib. + let loc = fs::canonicalize(&loc).unwrap_or_else(|_| loc.clone()); if loc.file_name().unwrap().to_str().unwrap().ends_with(".rlib") { - rlibs.insert(fs::canonicalize(&loc).unwrap(), PathKind::ExternFlag); + rlibs.insert(loc, PathKind::ExternFlag); } else if loc.file_name().unwrap().to_str().unwrap().ends_with(".rmeta") { - rmetas.insert(fs::canonicalize(&loc).unwrap(), PathKind::ExternFlag); + rmetas.insert(loc, PathKind::ExternFlag); } else { - dylibs.insert(fs::canonicalize(&loc).unwrap(), PathKind::ExternFlag); + dylibs.insert(loc, PathKind::ExternFlag); } } else { self.rejected_via_filename diff --git a/src/librustc_session/filesearch.rs b/src/librustc_session/filesearch.rs index 27396c524f4e6..504490d938cfa 100644 --- a/src/librustc_session/filesearch.rs +++ b/src/librustc_session/filesearch.rs @@ -117,28 +117,22 @@ pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf { pub fn get_or_default_sysroot() -> PathBuf { // Follow symlinks. If the resolved path is relative, make it absolute. - fn canonicalize(path: Option) -> Option { - path.and_then(|path| { - match fs::canonicalize(&path) { - // See comments on this target function, but the gist is that - // gcc chokes on verbatim paths which fs::canonicalize generates - // so we try to avoid those kinds of paths. - Ok(canon) => Some(fix_windows_verbatim_for_gcc(&canon)), - Err(e) => panic!("failed to get realpath: {}", e), - } - }) + fn canonicalize(path: PathBuf) -> PathBuf { + let path = fs::canonicalize(&path).unwrap_or(path); + // See comments on this target function, but the gist is that + // gcc chokes on verbatim paths which fs::canonicalize generates + // so we try to avoid those kinds of paths. + fix_windows_verbatim_for_gcc(&path) } match env::current_exe() { - Ok(exe) => match canonicalize(Some(exe)) { - Some(mut p) => { - p.pop(); - p.pop(); - p - } - None => panic!("can't determine value for sysroot"), - }, - Err(ref e) => panic!(format!("failed to get current_exe: {}", e)), + Ok(exe) => { + let mut p = canonicalize(exe); + p.pop(); + p.pop(); + p + } + Err(e) => panic!("failed to get current_exe: {}", e), } } From 1a2208afc5ef525649b12a9a0a01425390ca44a5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 30 Jul 2020 19:05:21 +0200 Subject: [PATCH 30/71] update Miri --- src/bootstrap/test.rs | 2 +- src/tools/miri | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 05af7210b1c68..2ead5d0a37f9c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -393,7 +393,7 @@ impl Step for Miri { cargo.arg("--").arg("miri").arg("setup"); // Tell `cargo miri setup` where to find the sources. - cargo.env("XARGO_RUST_SRC", builder.src.join("src")); + cargo.env("XARGO_RUST_SRC", builder.src.join("library")); // Tell it where to find Miri. cargo.env("MIRI", &miri); // Debug things. diff --git a/src/tools/miri b/src/tools/miri index 515287f114b54..55bdb31746530 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 515287f114b546a72d4a1fe8ffe1dbc20dedf13d +Subproject commit 55bdb3174653039f47362742f8dc941bfc086e8f From bcb2813e01313f78f580e0e7af263c27cc77a825 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 30 Jul 2020 10:22:57 -0700 Subject: [PATCH 31/71] Update uitest expectations --- src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr | 2 +- src/test/rustdoc-ui/intra-doc-alias-ice.stderr | 2 +- src/test/rustdoc-ui/intra-link-span-ice-55723.stderr | 2 +- src/test/rustdoc-ui/intra-links-ambiguity.stderr | 2 +- src/test/rustdoc-ui/intra-links-anchors.stderr | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr index 33c391855278f..68096f5fb6900 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/deny-intra-link-resolution-failure.rs:1:9 | LL | #![deny(intra_doc_resolution_failures)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr index 5ba34dd1d54af..dfd4f2dd45181 100644 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr +++ b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/intra-doc-alias-ice.rs:1:9 | LL | #![deny(intra_doc_resolution_failures)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr index 5c0ab62c6a13b..a202759e8d018 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/intra-link-span-ice-55723.rs:1:9 | LL | #![deny(intra_doc_resolution_failures)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.stderr b/src/test/rustdoc-ui/intra-links-ambiguity.stderr index 94b9258bdeeac..548bb9c296baa 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.stderr +++ b/src/test/rustdoc-ui/intra-links-ambiguity.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/intra-links-ambiguity.rs:1:9 | LL | #![deny(intra_doc_resolution_failures)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to link to the struct, prefix with the item type | LL | /// [`struct@ambiguous`] is ambiguous. diff --git a/src/test/rustdoc-ui/intra-links-anchors.stderr b/src/test/rustdoc-ui/intra-links-anchors.stderr index 29a632273fa73..8f16b9a8fc44b 100644 --- a/src/test/rustdoc-ui/intra-links-anchors.stderr +++ b/src/test/rustdoc-ui/intra-links-anchors.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/intra-links-anchors.rs:1:9 | LL | #![deny(intra_doc_resolution_failures)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `hello#people#!` contains multiple anchors --> $DIR/intra-links-anchors.rs:31:28 From 8fe438e632c0fe6a6d99f5096e21d9ab5d16fe3c Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 30 Jul 2020 10:38:55 -0700 Subject: [PATCH 32/71] intra_doc_resolution_failures -> broken_intra_doc_links --- src/doc/rustdoc/src/lints.md | 2 +- src/librustc_lint/lib.rs | 2 +- src/test/run-make-fulldeps/exit-code/lint-failure.rs | 2 +- src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs | 2 +- src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr | 2 +- src/test/rustdoc-ui/intra-doc-alias-ice.rs | 2 +- src/test/rustdoc-ui/intra-doc-alias-ice.stderr | 2 +- src/test/rustdoc-ui/intra-link-span-ice-55723.rs | 2 +- src/test/rustdoc-ui/intra-link-span-ice-55723.stderr | 2 +- src/test/rustdoc-ui/intra-links-ambiguity.rs | 2 +- src/test/rustdoc-ui/intra-links-ambiguity.stderr | 2 +- src/test/rustdoc-ui/intra-links-anchors.rs | 2 +- src/test/rustdoc-ui/intra-links-anchors.stderr | 2 +- src/test/rustdoc-ui/intra-links-private.private.stderr | 2 +- src/test/rustdoc-ui/intra-links-private.public.stderr | 2 +- src/test/rustdoc-ui/intra-links-warning-crlf.stderr | 2 +- src/test/rustdoc-ui/intra-links-warning.stderr | 2 +- src/test/rustdoc-ui/issue-74134.private.stderr | 2 +- src/test/rustdoc-ui/issue-74134.public.stderr | 2 +- src/test/rustdoc-ui/lint-group.stderr | 2 +- src/test/rustdoc-ui/reference-link-has-one-warning.stderr | 2 +- src/test/rustdoc/intra-doc-crate/additional_doc.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/module.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs | 2 +- src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs | 2 +- src/test/rustdoc/intra-doc-crate/basic.rs | 2 +- src/test/rustdoc/intra-doc-crate/hidden.rs | 2 +- src/test/rustdoc/intra-doc-crate/macro.rs | 2 +- src/test/rustdoc/intra-doc-crate/module.rs | 2 +- src/test/rustdoc/intra-doc-crate/submodule-inner.rs | 2 +- src/test/rustdoc/intra-doc-crate/submodule-outer.rs | 2 +- src/test/rustdoc/intra-doc-crate/traits.rs | 2 +- src/test/rustdoc/intra-doc-link-mod-ambiguity.rs | 2 +- src/test/rustdoc/intra-link-extern-crate.rs | 2 +- src/test/rustdoc/intra-link-in-bodies.rs | 2 +- src/test/rustdoc/intra-link-libstd-re-export.rs | 2 +- src/test/rustdoc/intra-link-prim-methods-external-core.rs | 2 +- src/test/rustdoc/intra-link-prim-methods-local.rs | 2 +- src/test/rustdoc/intra-link-prim-methods.rs | 2 +- src/test/rustdoc/intra-link-prim-precedence.rs | 2 +- src/test/rustdoc/intra-link-private.rs | 2 +- src/test/rustdoc/intra-link-proc-macro.rs | 2 +- src/test/rustdoc/intra-links-external-traits.rs | 2 +- src/test/rustdoc/through-proc-macro.rs | 2 +- 48 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/doc/rustdoc/src/lints.md b/src/doc/rustdoc/src/lints.md index 275cadb65252b..d1d6bc1c1fe69 100644 --- a/src/doc/rustdoc/src/lints.md +++ b/src/doc/rustdoc/src/lints.md @@ -11,7 +11,7 @@ can use them like any other lints by doing this: Here is the list of the lints provided by `rustdoc`: -## intra_doc_resolution_failures +## broken_intra_doc_links This lint **warns by default** and is **nightly-only**. This lint detects when an intra-doc link fails to get resolved. For example: diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index a542f5c96fa7e..8ba79efa7c9de 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -318,7 +318,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { store.register_renamed("async_idents", "keyword_idents"); store.register_renamed("exceeding_bitshifts", "arithmetic_overflow"); store.register_renamed("redundant_semicolon", "redundant_semicolons"); - store.register_renamed("intra_doc_link_resolution_failure", "intra_doc_resolution_failures"); + store.register_renamed("intra_doc_link_resolution_failure", "broken_intra_doc_links"); store.register_removed("unknown_features", "replaced by an error"); store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); store.register_removed("negate_unsigned", "cast a signed value instead"); diff --git a/src/test/run-make-fulldeps/exit-code/lint-failure.rs b/src/test/run-make-fulldeps/exit-code/lint-failure.rs index 423edeecb0ed9..df876ec237ff3 100644 --- a/src/test/run-make-fulldeps/exit-code/lint-failure.rs +++ b/src/test/run-make-fulldeps/exit-code/lint-failure.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] /// [intradoc::failure] pub fn main() { diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs index 1ef2ac105f37d..54e7689f3163f 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] /// [v2] //~ ERROR pub fn foo() {} diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr index 68096f5fb6900..c60c400c1d387 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -7,7 +7,7 @@ LL | /// [v2] note: the lint level is defined here --> $DIR/deny-intra-link-resolution-failure.rs:1:9 | -LL | #![deny(intra_doc_resolution_failures)] +LL | #![deny(broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.rs b/src/test/rustdoc-ui/intra-doc-alias-ice.rs index 5729ebb4cc017..c053e378e7147 100644 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.rs +++ b/src/test/rustdoc-ui/intra-doc-alias-ice.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub type TypeAlias = usize; diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr index dfd4f2dd45181..e4ba4d1484637 100644 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr +++ b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr @@ -7,7 +7,7 @@ LL | /// [broken cross-reference](TypeAlias::hoge) note: the lint level is defined here --> $DIR/intra-doc-alias-ice.rs:1:9 | -LL | #![deny(intra_doc_resolution_failures)] +LL | #![deny(broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs index efd492406342a..7764a6df6ee77 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] // An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to // attempt to slice in the middle of a multibyte character. See diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr index a202759e8d018..90798fdc79fb9 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr @@ -7,7 +7,7 @@ LL | /// (arr[i]) note: the lint level is defined here --> $DIR/intra-link-span-ice-55723.rs:1:9 | -LL | #![deny(intra_doc_resolution_failures)] +LL | #![deny(broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.rs b/src/test/rustdoc-ui/intra-links-ambiguity.rs index 7b2ca4f48d57b..d1597cdca66ab 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.rs +++ b/src/test/rustdoc-ui/intra-links-ambiguity.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.stderr b/src/test/rustdoc-ui/intra-links-ambiguity.stderr index 548bb9c296baa..a84c7d4d6e447 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.stderr +++ b/src/test/rustdoc-ui/intra-links-ambiguity.stderr @@ -7,7 +7,7 @@ LL | /// [`ambiguous`] is ambiguous. note: the lint level is defined here --> $DIR/intra-links-ambiguity.rs:1:9 | -LL | #![deny(intra_doc_resolution_failures)] +LL | #![deny(broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to link to the struct, prefix with the item type | diff --git a/src/test/rustdoc-ui/intra-links-anchors.rs b/src/test/rustdoc-ui/intra-links-anchors.rs index 24e3bf1832aef..ccefd2e6fabb5 100644 --- a/src/test/rustdoc-ui/intra-links-anchors.rs +++ b/src/test/rustdoc-ui/intra-links-anchors.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] // A few tests on anchors. diff --git a/src/test/rustdoc-ui/intra-links-anchors.stderr b/src/test/rustdoc-ui/intra-links-anchors.stderr index 8f16b9a8fc44b..e3327ebcb3f27 100644 --- a/src/test/rustdoc-ui/intra-links-anchors.stderr +++ b/src/test/rustdoc-ui/intra-links-anchors.stderr @@ -7,7 +7,7 @@ LL | /// Or maybe [Foo::f#hola]. note: the lint level is defined here --> $DIR/intra-links-anchors.rs:1:9 | -LL | #![deny(intra_doc_resolution_failures)] +LL | #![deny(broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `hello#people#!` contains multiple anchors diff --git a/src/test/rustdoc-ui/intra-links-private.private.stderr b/src/test/rustdoc-ui/intra-links-private.private.stderr index 5c40fcd826b10..77c4b67a6528f 100644 --- a/src/test/rustdoc-ui/intra-links-private.private.stderr +++ b/src/test/rustdoc-ui/intra-links-private.private.stderr @@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe` LL | /// docs [DontDocMe] | ^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_resolution_failures)]` on by default + = note: `#[warn(broken_intra_doc_links)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/intra-links-private.public.stderr b/src/test/rustdoc-ui/intra-links-private.public.stderr index 93ba3229038b8..312a78e8c3ec7 100644 --- a/src/test/rustdoc-ui/intra-links-private.public.stderr +++ b/src/test/rustdoc-ui/intra-links-private.public.stderr @@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe` LL | /// docs [DontDocMe] | ^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_resolution_failures)]` on by default + = note: `#[warn(broken_intra_doc_links)]` on by default = note: this link will resolve properly if you pass `--document-private-items` warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/intra-links-warning-crlf.stderr b/src/test/rustdoc-ui/intra-links-warning-crlf.stderr index 0cf440c1fad2f..1e3a26fadfa9f 100644 --- a/src/test/rustdoc-ui/intra-links-warning-crlf.stderr +++ b/src/test/rustdoc-ui/intra-links-warning-crlf.stderr @@ -4,7 +4,7 @@ warning: unresolved link to `error` LL | /// [error] | ^^^^^ unresolved link | - = note: `#[warn(intra_doc_resolution_failures)]` on by default + = note: `#[warn(broken_intra_doc_links)]` on by default = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `error1` diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr index c0091cefb4f33..53f2476295ebb 100644 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ b/src/test/rustdoc-ui/intra-links-warning.stderr @@ -4,7 +4,7 @@ warning: unresolved link to `Foo::baz` LL | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ unresolved link | - = note: `#[warn(intra_doc_resolution_failures)]` on by default + = note: `#[warn(broken_intra_doc_links)]` on by default = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `Bar::foo` diff --git a/src/test/rustdoc-ui/issue-74134.private.stderr b/src/test/rustdoc-ui/issue-74134.private.stderr index 16d7c27230c2d..58772109140ca 100644 --- a/src/test/rustdoc-ui/issue-74134.private.stderr +++ b/src/test/rustdoc-ui/issue-74134.private.stderr @@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy LL | /// [`PrivateType`] | ^^^^^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_resolution_failures)]` on by default + = note: `#[warn(broken_intra_doc_links)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/issue-74134.public.stderr b/src/test/rustdoc-ui/issue-74134.public.stderr index a9ca83f810ad1..b5bea190941e6 100644 --- a/src/test/rustdoc-ui/issue-74134.public.stderr +++ b/src/test/rustdoc-ui/issue-74134.public.stderr @@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy LL | /// [`PrivateType`] | ^^^^^^^^^^^^^ this item is private | - = note: `#[warn(intra_doc_resolution_failures)]` on by default + = note: `#[warn(broken_intra_doc_links)]` on by default = note: this link will resolve properly if you pass `--document-private-items` warning: 1 warning emitted diff --git a/src/test/rustdoc-ui/lint-group.stderr b/src/test/rustdoc-ui/lint-group.stderr index 471bb71fe5d8c..04296d2e44a7c 100644 --- a/src/test/rustdoc-ui/lint-group.stderr +++ b/src/test/rustdoc-ui/lint-group.stderr @@ -39,7 +39,7 @@ note: the lint level is defined here | LL | #![deny(rustdoc)] | ^^^^^^^ - = note: `#[deny(intra_doc_resolution_failures)]` implied by `#[deny(rustdoc)]` + = note: `#[deny(broken_intra_doc_links)]` implied by `#[deny(rustdoc)]` = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to 3 previous errors diff --git a/src/test/rustdoc-ui/reference-link-has-one-warning.stderr b/src/test/rustdoc-ui/reference-link-has-one-warning.stderr index e5276a2b4aa84..a1eeb60f1785a 100644 --- a/src/test/rustdoc-ui/reference-link-has-one-warning.stderr +++ b/src/test/rustdoc-ui/reference-link-has-one-warning.stderr @@ -4,7 +4,7 @@ warning: `[with#anchor#error]` has an issue with the link anchor. LL | /// docs [label][with#anchor#error] | ^^^^^^^^^^^^^^^^^ only one `#` is allowed in a link | - = note: `#[warn(intra_doc_resolution_failures)]` on by default + = note: `#[warn(broken_intra_doc_links)]` on by default warning: 1 warning emitted diff --git a/src/test/rustdoc/intra-doc-crate/additional_doc.rs b/src/test/rustdoc/intra-doc-crate/additional_doc.rs index ca30895e3ce2d..837390b3c7161 100644 --- a/src/test/rustdoc/intra-doc-crate/additional_doc.rs +++ b/src/test/rustdoc/intra-doc-crate/additional_doc.rs @@ -1,6 +1,6 @@ // aux-build:additional_doc.rs // build-aux-docs -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] extern crate my_rand; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs index b0f6dda865b63..849d25687337b 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs @@ -1,5 +1,5 @@ #![crate_name = "my_rand"] -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub trait RngCore {} /// Rng extends [`RngCore`]. diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs index f2bc8f470b87f..b543ae764c05b 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs @@ -1,5 +1,5 @@ #![crate_name = "hidden_dep"] -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] #[doc(hidden)] pub mod __reexport { diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs index a98fec734d70e..5342baecbc4b8 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs @@ -1,5 +1,5 @@ #![crate_name = "a"] -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub struct Foo; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs index 59c4d7e00702c..a94f9e5dcca2e 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs @@ -1,5 +1,5 @@ #![crate_name = "macro_inner"] -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub struct Foo; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs index 2dc70211262f5..b7e3913f108f7 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs @@ -1,5 +1,5 @@ #![crate_name = "module_inner"] -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] /// [SomeType] links to [bar] pub struct SomeType; pub trait SomeTrait {} diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs index d79a1b1b12e65..8ae0f6c16b3d8 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs @@ -1,5 +1,5 @@ #![crate_name = "a"] -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub mod bar { pub struct Bar; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs index e1f0bd9c6dd56..d90c529e38552 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs @@ -1,5 +1,5 @@ #![crate_name = "bar"] -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub trait Foo { /// [`Bar`] [`Baz`] diff --git a/src/test/rustdoc/intra-doc-crate/basic.rs b/src/test/rustdoc/intra-doc-crate/basic.rs index 88b18ed539bd2..6ab9140c3c385 100644 --- a/src/test/rustdoc/intra-doc-crate/basic.rs +++ b/src/test/rustdoc/intra-doc-crate/basic.rs @@ -1,6 +1,6 @@ // aux-build:intra-doc-basic.rs // build-aux-docs -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] // from https://github.com/rust-lang/rust/issues/65983 extern crate a; diff --git a/src/test/rustdoc/intra-doc-crate/hidden.rs b/src/test/rustdoc/intra-doc-crate/hidden.rs index 6d832b5a5f7ea..9c9d4c649455e 100644 --- a/src/test/rustdoc/intra-doc-crate/hidden.rs +++ b/src/test/rustdoc/intra-doc-crate/hidden.rs @@ -1,6 +1,6 @@ // aux-build:hidden.rs // build-aux-docs -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] // tests https://github.com/rust-lang/rust/issues/73363 diff --git a/src/test/rustdoc/intra-doc-crate/macro.rs b/src/test/rustdoc/intra-doc-crate/macro.rs index dd5dbec144da2..311b16dff13bc 100644 --- a/src/test/rustdoc/intra-doc-crate/macro.rs +++ b/src/test/rustdoc/intra-doc-crate/macro.rs @@ -2,7 +2,7 @@ // aux-build:macro_inner.rs // aux-build:proc_macro.rs // build-aux-docs -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] extern crate macro_inner; extern crate proc_macro_inner; diff --git a/src/test/rustdoc/intra-doc-crate/module.rs b/src/test/rustdoc/intra-doc-crate/module.rs index 0a6cc27f4a045..9039e344f7b00 100644 --- a/src/test/rustdoc/intra-doc-crate/module.rs +++ b/src/test/rustdoc/intra-doc-crate/module.rs @@ -1,7 +1,7 @@ // outer.rs // aux-build: module.rs // build-aux-docs -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] extern crate module_inner; // @has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait' // @has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType' diff --git a/src/test/rustdoc/intra-doc-crate/submodule-inner.rs b/src/test/rustdoc/intra-doc-crate/submodule-inner.rs index f86547f90e112..e1465816368bf 100644 --- a/src/test/rustdoc/intra-doc-crate/submodule-inner.rs +++ b/src/test/rustdoc/intra-doc-crate/submodule-inner.rs @@ -1,6 +1,6 @@ // aux-build:submodule-inner.rs // build-aux-docs -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] extern crate a; diff --git a/src/test/rustdoc/intra-doc-crate/submodule-outer.rs b/src/test/rustdoc/intra-doc-crate/submodule-outer.rs index 62781da479ffb..45f561328f279 100644 --- a/src/test/rustdoc/intra-doc-crate/submodule-outer.rs +++ b/src/test/rustdoc/intra-doc-crate/submodule-outer.rs @@ -1,6 +1,6 @@ // aux-build:submodule-outer.rs // edition:2018 -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] extern crate bar as bar_; diff --git a/src/test/rustdoc/intra-doc-crate/traits.rs b/src/test/rustdoc/intra-doc-crate/traits.rs index f12ba5b21fc36..07f9fb6331333 100644 --- a/src/test/rustdoc/intra-doc-crate/traits.rs +++ b/src/test/rustdoc/intra-doc-crate/traits.rs @@ -3,7 +3,7 @@ // aux-build:traits.rs // build-aux-docs // ignore-tidy-line-length -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] extern crate inner; use inner::SomeTrait; diff --git a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs index 38fa3d0c7dbac..bd733e1023033 100644 --- a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs +++ b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub fn foo() { diff --git a/src/test/rustdoc/intra-link-extern-crate.rs b/src/test/rustdoc/intra-link-extern-crate.rs index 2af6880c6328e..193bca704bfbd 100644 --- a/src/test/rustdoc/intra-link-extern-crate.rs +++ b/src/test/rustdoc/intra-link-extern-crate.rs @@ -4,6 +4,6 @@ // though they would never actually get displayed. This tripped intra-doc-link resolution failures, // for items that aren't under our control, and not actually getting documented! -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] extern crate inner; diff --git a/src/test/rustdoc/intra-link-in-bodies.rs b/src/test/rustdoc/intra-link-in-bodies.rs index 48244aa2ac792..ec965a99dc240 100644 --- a/src/test/rustdoc/intra-link-in-bodies.rs +++ b/src/test/rustdoc/intra-link-in-bodies.rs @@ -1,6 +1,6 @@ // we need to make sure that intra-doc links on trait impls get resolved in the right scope -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub mod inner { pub struct SomethingOutOfScope; diff --git a/src/test/rustdoc/intra-link-libstd-re-export.rs b/src/test/rustdoc/intra-link-libstd-re-export.rs index 07623da50171d..d0af3aec66097 100644 --- a/src/test/rustdoc/intra-link-libstd-re-export.rs +++ b/src/test/rustdoc/intra-link-libstd-re-export.rs @@ -1,3 +1,3 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub use std::*; diff --git a/src/test/rustdoc/intra-link-prim-methods-external-core.rs b/src/test/rustdoc/intra-link-prim-methods-external-core.rs index 8166489c7a62b..c8ef4c015997b 100644 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -4,7 +4,7 @@ // ignore-windows // ignore-tidy-linelength -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] #![feature(no_core, lang_items)] #![no_core] #![crate_type = "rlib"] diff --git a/src/test/rustdoc/intra-link-prim-methods-local.rs b/src/test/rustdoc/intra-link-prim-methods-local.rs index c42c6986233c5..d448acf7f9682 100644 --- a/src/test/rustdoc/intra-link-prim-methods-local.rs +++ b/src/test/rustdoc/intra-link-prim-methods-local.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] #![feature(no_core, lang_items)] #![no_core] #![crate_type = "rlib"] diff --git a/src/test/rustdoc/intra-link-prim-methods.rs b/src/test/rustdoc/intra-link-prim-methods.rs index bfb974d95b365..94c80c996c1e0 100644 --- a/src/test/rustdoc/intra-link-prim-methods.rs +++ b/src/test/rustdoc/intra-link-prim-methods.rs @@ -1,4 +1,4 @@ -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] // ignore-tidy-linelength diff --git a/src/test/rustdoc/intra-link-prim-precedence.rs b/src/test/rustdoc/intra-link-prim-precedence.rs index ee0ef743a1e93..5f10c1ec4a75c 100644 --- a/src/test/rustdoc/intra-link-prim-precedence.rs +++ b/src/test/rustdoc/intra-link-prim-precedence.rs @@ -1,5 +1,5 @@ // ignore-tidy-linelength -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] pub mod char {} diff --git a/src/test/rustdoc/intra-link-private.rs b/src/test/rustdoc/intra-link-private.rs index 08a2a8070cb86..cf8bc0b15869f 100644 --- a/src/test/rustdoc/intra-link-private.rs +++ b/src/test/rustdoc/intra-link-private.rs @@ -2,7 +2,7 @@ // These failures were legitimate, but not truly relevant - the docs in question couldn't be // checked for accuracy anyway. -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] /// ooh, i'm a [rebel] just for kicks struct SomeStruct; diff --git a/src/test/rustdoc/intra-link-proc-macro.rs b/src/test/rustdoc/intra-link-proc-macro.rs index eef82c4ac192c..7a8403255edb6 100644 --- a/src/test/rustdoc/intra-link-proc-macro.rs +++ b/src/test/rustdoc/intra-link-proc-macro.rs @@ -1,6 +1,6 @@ // aux-build:intra-link-proc-macro-macro.rs // build-aux-docs -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] extern crate intra_link_proc_macro_macro; diff --git a/src/test/rustdoc/intra-links-external-traits.rs b/src/test/rustdoc/intra-links-external-traits.rs index de00f787bd292..de76f29476c66 100644 --- a/src/test/rustdoc/intra-links-external-traits.rs +++ b/src/test/rustdoc/intra-links-external-traits.rs @@ -2,7 +2,7 @@ // ignore-cross-compile #![crate_name = "outer"] -#![deny(intra_doc_resolution_failures)] +#![deny(broken_intra_doc_links)] // using a trait that has intra-doc links on it from another crate (whether re-exporting or just // implementing it) used to give spurious resolution failure warnings diff --git a/src/test/rustdoc/through-proc-macro.rs b/src/test/rustdoc/through-proc-macro.rs index fb84ef614744c..613410871f0d1 100644 --- a/src/test/rustdoc/through-proc-macro.rs +++ b/src/test/rustdoc/through-proc-macro.rs @@ -1,6 +1,6 @@ // aux-build:through-proc-macro-aux.rs // build-aux-docs -#![warn(intra_doc_resolution_failures)] +#![warn(broken_intra_doc_links)] extern crate some_macros; #[some_macros::second] From e25a67fa6cbfacea80f5579149299f842775be79 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 30 Jul 2020 10:39:16 -0700 Subject: [PATCH 33/71] Rename the lint again --- src/librustc_lint/lib.rs | 6 +++--- src/librustc_session/lint/builtin.rs | 4 ++-- src/librustdoc/core.rs | 2 +- src/librustdoc/passes/collect_intra_doc_links.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 8ba79efa7c9de..15a9affbff7e9 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -61,8 +61,8 @@ use rustc_hir::def_id::LocalDefId; use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::{ - BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, - INTRA_DOC_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, + BARE_TRAIT_OBJECTS, BROKEN_INTRA_DOC_LINKS, ELIDED_LIFETIMES_IN_PATHS, + EXPLICIT_OUTLIVES_REQUIREMENTS, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, }; use rustc_span::symbol::{Ident, Symbol}; @@ -303,7 +303,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { add_lint_group!( "rustdoc", - INTRA_DOC_RESOLUTION_FAILURES, + BROKEN_INTRA_DOC_LINKS, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS diff --git a/src/librustc_session/lint/builtin.rs b/src/librustc_session/lint/builtin.rs index f2a5289c8c445..144a06a4916bd 100644 --- a/src/librustc_session/lint/builtin.rs +++ b/src/librustc_session/lint/builtin.rs @@ -398,7 +398,7 @@ declare_lint! { } declare_lint! { - pub INTRA_DOC_RESOLUTION_FAILURES, + pub BROKEN_INTRA_DOC_LINKS, Warn, "failures in resolving intra-doc link targets" } @@ -601,7 +601,7 @@ declare_lint_pass! { ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, UNSTABLE_NAME_COLLISIONS, IRREFUTABLE_LET_PATTERNS, - INTRA_DOC_RESOLUTION_FAILURES, + BROKEN_INTRA_DOC_LINKS, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_CRATE_LEVEL_DOCS, MISSING_DOC_CODE_EXAMPLES, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 35c340bf251d9..338aba36d0479 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -315,7 +315,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let cpath = Some(input.clone()); let input = Input::File(input); - let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_RESOLUTION_FAILURES.name; + let intra_link_resolution_failure_name = lint::builtin::BROKEN_INTRA_DOC_LINKS.name; let missing_docs = rustc_lint::builtin::MISSING_DOCS.name; let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name; let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 02a9483f9293a..bf7a43236e061 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -867,7 +867,7 @@ fn report_diagnostic( let attrs = &item.attrs; let sp = span_of_attrs(attrs).unwrap_or(item.source.span()); - cx.tcx.struct_span_lint_hir(lint::builtin::INTRA_DOC_RESOLUTION_FAILURES, hir_id, sp, |lint| { + cx.tcx.struct_span_lint_hir(lint::builtin::BROKEN_INTRA_DOC_LINKS, hir_id, sp, |lint| { let mut diag = lint.build(msg); let span = link_range From c17eb566c20bb4c98a1e74f7f0461483ff175310 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 30 Jul 2020 10:40:17 -0700 Subject: [PATCH 34/71] Fix uitests --- src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr | 2 +- src/test/rustdoc-ui/intra-doc-alias-ice.stderr | 2 +- src/test/rustdoc-ui/intra-link-span-ice-55723.stderr | 2 +- src/test/rustdoc-ui/intra-links-ambiguity.stderr | 2 +- src/test/rustdoc-ui/intra-links-anchors.stderr | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr index c60c400c1d387..7530e3ad0f551 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/deny-intra-link-resolution-failure.rs:1:9 | LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr index e4ba4d1484637..f1c07e31cd753 100644 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr +++ b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/intra-doc-alias-ice.rs:1:9 | LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr index 90798fdc79fb9..6b0ff8f116295 100644 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr +++ b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/intra-link-span-ice-55723.rs:1:9 | LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.stderr b/src/test/rustdoc-ui/intra-links-ambiguity.stderr index a84c7d4d6e447..35262c1b6122e 100644 --- a/src/test/rustdoc-ui/intra-links-ambiguity.stderr +++ b/src/test/rustdoc-ui/intra-links-ambiguity.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/intra-links-ambiguity.rs:1:9 | LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ help: to link to the struct, prefix with the item type | LL | /// [`struct@ambiguous`] is ambiguous. diff --git a/src/test/rustdoc-ui/intra-links-anchors.stderr b/src/test/rustdoc-ui/intra-links-anchors.stderr index e3327ebcb3f27..e737b84320d94 100644 --- a/src/test/rustdoc-ui/intra-links-anchors.stderr +++ b/src/test/rustdoc-ui/intra-links-anchors.stderr @@ -8,7 +8,7 @@ note: the lint level is defined here --> $DIR/intra-links-anchors.rs:1:9 | LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ error: `hello#people#!` contains multiple anchors --> $DIR/intra-links-anchors.rs:31:28 From 3b2642ffa7eceb9d04113d34e8136bd4b4e429d5 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Fri, 31 Jul 2020 02:16:42 +0800 Subject: [PATCH 35/71] Add comments to explain the test case and the special treatment --- src/librustc_mir/transform/promote_consts.rs | 14 +++++++++++++- src/test/ui/statics/static-promotion.rs | 10 +++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 5f62e19938b83..688f48f32b120 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -506,6 +506,10 @@ impl<'tcx> Validator<'_, 'tcx> { match *elem { ProjectionElem::Deref => { let mut not_promotable = true; + // This is a special treatment for cases like *&STATIC where STATIC is a + // global static variable. + // This pattern is generated only when global static variables are directly + // accessed and is qualified for promotion safely. if let TempState::Defined { location, .. } = self.temps[local] { let def_stmt = self.body[location.block].statements.get(location.statement_index); @@ -517,7 +521,15 @@ impl<'tcx> Validator<'_, 'tcx> { { if let Some(did) = c.check_static_ptr(self.tcx) { if let Some(hir::ConstContext::Static(..)) = self.const_kind { - if !self.tcx.is_thread_local_static(did) { + // The `is_empty` predicate is introduced to exclude the case + // where the projection operations are [ .field, * ]. + // The reason is because promotion will be illegal if field + // accesses preceed the dereferencing. + // Discussion can be found at + // https://github.com/rust-lang/rust/pull/74945#discussion_r463063247 + // There may be opportunity for generalization, but this needs to be + // accounted for. + if proj_base.is_empty() && !self.tcx.is_thread_local_static(did) { not_promotable = false; } } diff --git a/src/test/ui/statics/static-promotion.rs b/src/test/ui/statics/static-promotion.rs index 2d9237d11c929..500af1e15e12e 100644 --- a/src/test/ui/statics/static-promotion.rs +++ b/src/test/ui/statics/static-promotion.rs @@ -1,4 +1,12 @@ -// run-pass +// check-pass + +// Use of global static variables in literal values should be allowed for +// promotion. +// This test is to demonstrate the issue raised in +// https://github.com/rust-lang/rust/issues/70584 + +// Literal values were previously promoted into local static values when +// other global static variables are used. struct A(&'static T); struct B { From e1e01f72a5e5f4ebcf455a2df72781aa1cbb2016 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 20 Jul 2020 08:58:10 -0400 Subject: [PATCH 36/71] 1.45.1 release (cherry picked from commit 9e5fb40807f97fe47d2eaca99daeb1f1f6ff07a7) --- RELEASES.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index f36cdee0975a0..fec48b043612a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,14 @@ +Version 1.45.1 (2020-07-30) +========================== + +* [rustfmt accepts rustfmt_skip in cfg_attr again.][73078] +* [Avoid spurious implicit region bound.][74509] +* [Install clippy on x.py install][74457] + +[73078]: https://github.com/rust-lang/rust/issues/73078 +[74509]: https://github.com/rust-lang/rust/pull/74509 +[74457]: https://github.com/rust-lang/rust/pull/74457 + Version 1.45.0 (2020-07-16) ========================== From 19d191bb02d1566096493a26904826d4e81beeda Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 25 Jul 2020 11:01:44 -0400 Subject: [PATCH 37/71] Update release notes (cherry picked from commit 32166ab1ebec2e5e5454221f0d3238c21382de9f) --- RELEASES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index fec48b043612a..b47f64d2fafc9 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,10 +1,12 @@ Version 1.45.1 (2020-07-30) ========================== +* [Fix const propagation with references.][73613] * [rustfmt accepts rustfmt_skip in cfg_attr again.][73078] * [Avoid spurious implicit region bound.][74509] * [Install clippy on x.py install][74457] +[73613]: https://github.com/rust-lang/rust/pull/73613 [73078]: https://github.com/rust-lang/rust/issues/73078 [74509]: https://github.com/rust-lang/rust/pull/74509 [74457]: https://github.com/rust-lang/rust/pull/74457 From 48c6f05662b0bf58cce0e867e60c2d86b5e6fcfb Mon Sep 17 00:00:00 2001 From: Joseph Ryan Date: Thu, 30 Jul 2020 13:54:26 -0500 Subject: [PATCH 38/71] Update driver to add json backend --- src/librustdoc/config.rs | 6 +++-- src/librustdoc/json/mod.rs | 47 ++++++++++++++++++++++++++++++++++++++ src/librustdoc/lib.rs | 44 +++++++++++++++++++++++------------ 3 files changed, 81 insertions(+), 16 deletions(-) create mode 100644 src/librustdoc/json/mod.rs diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 3547b45dfa71f..4f751decc8090 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -508,7 +508,7 @@ impl Options { let output_format = match matches.opt_str("output-format") { Some(s) => match OutputFormat::try_from(s.as_str()) { Ok(o) => { - if o.is_json() && !show_coverage { + if o.is_json() && !(show_coverage || nightly_options::is_nightly_build()) { diag.struct_err("json output format isn't supported for doc generation") .emit(); return Err(1); @@ -626,7 +626,9 @@ fn check_deprecated_options(matches: &getopts::Matches, diag: &rustc_errors::Han for flag in deprecated_flags.iter() { if matches.opt_present(flag) { - if *flag == "output-format" && matches.opt_present("show-coverage") { + if *flag == "output-format" + && (matches.opt_present("show-coverage") || nightly_options::is_nightly_build()) + { continue; } let mut err = diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs new file mode 100644 index 0000000000000..14f87ec2aa9bb --- /dev/null +++ b/src/librustdoc/json/mod.rs @@ -0,0 +1,47 @@ +use crate::clean; +use crate::config::{RenderInfo, RenderOptions}; +use crate::error::Error; +use crate::formats::cache::Cache; +use crate::formats::FormatRenderer; + +use rustc_span::edition::Edition; + +#[derive(Clone)] +pub struct JsonRenderer {} + +impl FormatRenderer for JsonRenderer { + fn init( + _krate: clean::Crate, + _options: RenderOptions, + _render_info: RenderInfo, + _edition: Edition, + _cache: &mut Cache, + ) -> Result<(Self, clean::Crate), Error> { + unimplemented!() + } + + fn item(&mut self, _item: clean::Item, _cache: &Cache) -> Result<(), Error> { + unimplemented!() + } + + fn mod_item_in( + &mut self, + _item: &clean::Item, + _item_name: &str, + _cache: &Cache, + ) -> Result<(), Error> { + unimplemented!() + } + + fn mod_item_out(&mut self, _item_name: &str) -> Result<(), Error> { + unimplemented!() + } + + fn after_krate(&mut self, _krate: &clean::Crate, _cache: &Cache) -> Result<(), Error> { + unimplemented!() + } + + fn after_run(&mut self, _diag: &rustc_errors::Handler) -> Result<(), Error> { + unimplemented!() + } +} diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 65bc089faf428..62780878fd5af 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -68,6 +68,7 @@ mod error; mod fold; crate mod formats; pub mod html; +mod json; mod markdown; mod passes; mod test; @@ -450,6 +451,28 @@ fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> i32 { } } +fn run_renderer( + krate: clean::Crate, + renderopts: config::RenderOptions, + render_info: config::RenderInfo, + diag: &rustc_errors::Handler, + edition: rustc_span::edition::Edition, +) -> i32 { + match formats::run_format::(krate, renderopts, render_info, &diag, edition) { + Ok(_) => rustc_driver::EXIT_SUCCESS, + Err(e) => { + let mut msg = diag.struct_err(&format!("couldn't generate documentation: {}", e.error)); + let file = e.file.display().to_string(); + if file.is_empty() { + msg.emit() + } else { + msg.note(&format!("failed to create or modify \"{}\"", file)).emit() + } + rustc_driver::EXIT_FAILURE + } + } +} + fn main_options(options: config::Options) -> i32 { let diag = core::new_handler(options.error_format, None, &options.debugging_options); @@ -480,6 +503,7 @@ fn main_options(options: config::Options) -> i32 { let result = rustc_driver::catch_fatal_errors(move || { let crate_name = options.crate_name.clone(); let crate_version = options.crate_version.clone(); + let output_format = options.output_format; let (mut krate, renderinfo, renderopts) = core::run_core(options); info!("finished with rustc"); @@ -502,20 +526,12 @@ fn main_options(options: config::Options) -> i32 { info!("going to format"); let (error_format, edition, debugging_options) = diag_opts; let diag = core::new_handler(error_format, None, &debugging_options); - match formats::run_format::( - krate, renderopts, renderinfo, &diag, edition, - ) { - Ok(_) => rustc_driver::EXIT_SUCCESS, - Err(e) => { - let mut msg = - diag.struct_err(&format!("couldn't generate documentation: {}", e.error)); - let file = e.file.display().to_string(); - if file.is_empty() { - msg.emit() - } else { - msg.note(&format!("failed to create or modify \"{}\"", file)).emit() - } - rustc_driver::EXIT_FAILURE + match output_format { + None | Some(config::OutputFormat::Html) => { + run_renderer::(krate, renderopts, renderinfo, &diag, edition) + } + Some(config::OutputFormat::Json) => { + run_renderer::(krate, renderopts, renderinfo, &diag, edition) } } }); From 34b26d6a77c45776cbbef182b4c1b0b96ac326fe Mon Sep 17 00:00:00 2001 From: Rich Kadel Date: Thu, 30 Jul 2020 12:25:39 -0700 Subject: [PATCH 39/71] Rust function-level coverage now works on external crates Fixed a known issue in the coverage map where some regions had nonsensical source code locations. External crate functions are already included in their own coverage maps, per library, and don't need to also be added to the importing crate's coverage map. (In fact, their source start and end byte positions are not relevant to the importing crate's SourceMap.) The fix was to simply skip trying to add imported coverage info to the coverage map if the instrumented function is not "local". The injected counters are still relevant, however, and the LLVM `instrprof.increment` intrinsic call parameters will map those counters to the external crates' coverage maps, when generating runtime coverage data. --- src/librustc_codegen_llvm/intrinsic.rs | 109 ++++++++++--------- src/librustc_codegen_ssa/coverageinfo/map.rs | 6 +- 2 files changed, 62 insertions(+), 53 deletions(-) diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 236f7f696533d..728af7b0a8cd1 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -90,64 +90,69 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> { args: &Vec>, caller_instance: ty::Instance<'tcx>, ) -> bool { + let mut is_codegen_intrinsic = true; + // Set `is_codegen_intrinsic` to `false` to bypass `codegen_intrinsic_call()`. + if self.tcx.sess.opts.debugging_opts.instrument_coverage { - // Add the coverage information from the MIR to the Codegen context. Some coverage - // intrinsics are used only to pass along the coverage information (returns `false` - // for `is_codegen_intrinsic()`), but `count_code_region` is also converted into an - // LLVM intrinsic to increment a coverage counter. - match intrinsic { - sym::count_code_region => { - use coverage::count_code_region_args::*; - self.add_counter_region( - caller_instance, - op_to_u64(&args[FUNCTION_SOURCE_HASH]), - op_to_u32(&args[COUNTER_ID]), - op_to_u32(&args[START_BYTE_POS]), - op_to_u32(&args[END_BYTE_POS]), - ); - return true; // Also inject the counter increment in the backend - } - sym::coverage_counter_add | sym::coverage_counter_subtract => { - use coverage::coverage_counter_expression_args::*; - self.add_counter_expression_region( - caller_instance, - op_to_u32(&args[EXPRESSION_ID]), - op_to_u32(&args[LEFT_ID]), - if intrinsic == sym::coverage_counter_add { - ExprKind::Add - } else { - ExprKind::Subtract - }, - op_to_u32(&args[RIGHT_ID]), - op_to_u32(&args[START_BYTE_POS]), - op_to_u32(&args[END_BYTE_POS]), - ); - return false; // Does not inject backend code + // If the intrinsic is from the local MIR, add the coverage information to the Codegen + // context, to be encoded into the local crate's coverage map. + if caller_instance.def_id().is_local() { + // FIXME(richkadel): Make sure to add coverage analysis tests on a crate with + // external crate dependencies, where: + // 1. Both binary and dependent crates are compiled with `-Zinstrument-coverage` + // 2. Only binary is compiled with `-Zinstrument-coverage` + // 3. Only dependent crates are compiled with `-Zinstrument-coverage` + match intrinsic { + sym::count_code_region => { + use coverage::count_code_region_args::*; + self.add_counter_region( + caller_instance, + op_to_u64(&args[FUNCTION_SOURCE_HASH]), + op_to_u32(&args[COUNTER_ID]), + op_to_u32(&args[START_BYTE_POS]), + op_to_u32(&args[END_BYTE_POS]), + ); + } + sym::coverage_counter_add | sym::coverage_counter_subtract => { + use coverage::coverage_counter_expression_args::*; + self.add_counter_expression_region( + caller_instance, + op_to_u32(&args[EXPRESSION_ID]), + op_to_u32(&args[LEFT_ID]), + if intrinsic == sym::coverage_counter_add { + ExprKind::Add + } else { + ExprKind::Subtract + }, + op_to_u32(&args[RIGHT_ID]), + op_to_u32(&args[START_BYTE_POS]), + op_to_u32(&args[END_BYTE_POS]), + ); + } + sym::coverage_unreachable => { + use coverage::coverage_unreachable_args::*; + self.add_unreachable_region( + caller_instance, + op_to_u32(&args[START_BYTE_POS]), + op_to_u32(&args[END_BYTE_POS]), + ); + } + _ => {} } - sym::coverage_unreachable => { - use coverage::coverage_unreachable_args::*; - self.add_unreachable_region( - caller_instance, - op_to_u32(&args[START_BYTE_POS]), - op_to_u32(&args[END_BYTE_POS]), - ); - return false; // Does not inject backend code + } + + // Only the `count_code_region` coverage intrinsic is translated into an actual LLVM + // intrinsic call (local or not); otherwise, set `is_codegen_intrinsic` to `false`. + match intrinsic { + sym::coverage_counter_add + | sym::coverage_counter_subtract + | sym::coverage_unreachable => { + is_codegen_intrinsic = false; } _ => {} } - } else { - // NOT self.tcx.sess.opts.debugging_opts.instrument_coverage - if intrinsic == sym::count_code_region { - // An external crate may have been pre-compiled with coverage instrumentation, and - // some references from the current crate to the external crate might carry along - // the call terminators to coverage intrinsics, like `count_code_region` (for - // example, when instantiating a generic function). If the current crate has - // `instrument_coverage` disabled, the `count_code_region` call terminators should - // be ignored. - return false; // Do not inject coverage counters inlined from external crates - } } - true // Unhandled intrinsics should be passed to `codegen_intrinsic_call()` + is_codegen_intrinsic } fn codegen_intrinsic_call( diff --git a/src/librustc_codegen_ssa/coverageinfo/map.rs b/src/librustc_codegen_ssa/coverageinfo/map.rs index 1e36c90baafdf..72138065a90ba 100644 --- a/src/librustc_codegen_ssa/coverageinfo/map.rs +++ b/src/librustc_codegen_ssa/coverageinfo/map.rs @@ -86,7 +86,11 @@ impl Region { pub fn new(source_map: &SourceMap, start_byte_pos: u32, end_byte_pos: u32) -> Self { let start = source_map.lookup_char_pos(BytePos::from_u32(start_byte_pos)); let end = source_map.lookup_char_pos(BytePos::from_u32(end_byte_pos)); - assert_eq!(start.file.name, end.file.name); + assert_eq!( + start.file.name, end.file.name, + "Region start ({} -> {:?}) and end ({} -> {:?}) don't come from the same source file!", + start_byte_pos, start, end_byte_pos, end + ); Self { start, end } } From fc2c1f8ddc9a460c558741ae44b894faf3967f7c Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Thu, 30 Jul 2020 12:30:56 -0700 Subject: [PATCH 40/71] Make `Option::unwrap` unstably const `Result::unwrap` is not eligible becuase it formats the contents of the `Err` variant. `unwrap_or`, `unwrap_or_else` and friends are not eligible because they drop things or invoke closures. --- library/core/src/lib.rs | 1 + library/core/src/option.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 550e07f9d5710..46a6ec09962bc 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -82,6 +82,7 @@ #![feature(const_fn_union)] #![feature(const_generics)] #![feature(const_option)] +#![feature(const_precise_live_drops)] #![feature(const_ptr_offset)] #![feature(const_ptr_offset_from)] #![feature(const_raw_ptr_comparison)] diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 5932f8e5856a7..3c7211fe040dc 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -380,7 +380,8 @@ impl Option { #[inline] #[track_caller] #[stable(feature = "rust1", since = "1.0.0")] - pub fn unwrap(self) -> T { + #[rustc_const_unstable(feature = "const_option", issue = "67441")] + pub const fn unwrap(self) -> T { match self { Some(val) => val, None => panic!("called `Option::unwrap()` on a `None` value"), From 96c84ac3cbc4f2c81580893dacf263d00306649c Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Thu, 30 Jul 2020 12:32:20 -0700 Subject: [PATCH 41/71] Test `Option::unwrap` in a const context --- src/test/ui/consts/const-unwrap.rs | 14 ++++++++++++++ src/test/ui/consts/const-unwrap.stderr | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/test/ui/consts/const-unwrap.rs create mode 100644 src/test/ui/consts/const-unwrap.stderr diff --git a/src/test/ui/consts/const-unwrap.rs b/src/test/ui/consts/const-unwrap.rs new file mode 100644 index 0000000000000..6ed60ed87bf76 --- /dev/null +++ b/src/test/ui/consts/const-unwrap.rs @@ -0,0 +1,14 @@ +// check-fail + +#![feature(const_option)] + +const FOO: i32 = Some(42i32).unwrap(); + +// This causes an error, but it is attributed to the `panic` *inside* `Option::unwrap` (maybe due +// to `track_caller`?). A note points to the originating `const`. +const BAR: i32 = Option::::None.unwrap(); //~ NOTE + +fn main() { + println!("{}", FOO); + println!("{}", BAR); +} diff --git a/src/test/ui/consts/const-unwrap.stderr b/src/test/ui/consts/const-unwrap.stderr new file mode 100644 index 0000000000000..7f2c1f4151097 --- /dev/null +++ b/src/test/ui/consts/const-unwrap.stderr @@ -0,0 +1,20 @@ +error: any use of this value will cause an error + --> $SRC_DIR/core/src/option.rs:LL:COL + | +LL | None => panic!("called `Option::unwrap()` on a `None` value"), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the evaluated program panicked at 'called `Option::unwrap()` on a `None` value', $DIR/const-unwrap.rs:9:38 + | inside `std::option::Option::::unwrap` at $SRC_DIR/core/src/macros/mod.rs:LL:COL + | inside `BAR` at $DIR/const-unwrap.rs:9:18 + | + ::: $DIR/const-unwrap.rs:9:1 + | +LL | const BAR: i32 = Option::::None.unwrap(); + | ---------------------------------------------- + | + = note: `#[deny(const_err)]` on by default + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + From 1629fed4c0bdc6d3246ea63a91f600bcb8874626 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 31 Jul 2020 09:03:14 +0900 Subject: [PATCH 42/71] Presort restrictions to make output consistent --- src/librustc_typeck/check/method/suggest.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index ae2cf6daf5350..e69102d1995d3 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -678,6 +678,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .collect::>(); for ((span, empty_where), obligations) in type_params.into_iter() { restrict_type_params = true; + // #74886: Sort here so that the output is always the same. + let mut obligations = obligations.into_iter().collect::>(); + obligations.sort(); err.span_suggestion_verbose( span, &format!( @@ -688,7 +691,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { format!( "{} {}", if empty_where { " where" } else { "," }, - obligations.into_iter().collect::>().join(", ") + obligations.join(", ") ), Applicability::MaybeIncorrect, ); From db071746323029c634f246a50156192d16ab182e Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Fri, 31 Jul 2020 11:46:05 +0800 Subject: [PATCH 43/71] Remove a trailing space --- src/librustc_mir/transform/promote_consts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 688f48f32b120..ca79cb3cc0a9c 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -526,7 +526,7 @@ impl<'tcx> Validator<'_, 'tcx> { // The reason is because promotion will be illegal if field // accesses preceed the dereferencing. // Discussion can be found at - // https://github.com/rust-lang/rust/pull/74945#discussion_r463063247 + // https://github.com/rust-lang/rust/pull/74945#discussion_r463063247 // There may be opportunity for generalization, but this needs to be // accounted for. if proj_base.is_empty() && !self.tcx.is_thread_local_static(did) { From 4631579b000b006ed3eba7d3f80bbfece02579bc Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Fri, 31 Jul 2020 11:58:49 +0800 Subject: [PATCH 44/71] rustfmt --- src/librustc_mir/transform/promote_consts.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index ca79cb3cc0a9c..f68473480630b 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -529,7 +529,9 @@ impl<'tcx> Validator<'_, 'tcx> { // https://github.com/rust-lang/rust/pull/74945#discussion_r463063247 // There may be opportunity for generalization, but this needs to be // accounted for. - if proj_base.is_empty() && !self.tcx.is_thread_local_static(did) { + if proj_base.is_empty() + && !self.tcx.is_thread_local_static(did) + { not_promotable = false; } } From a4757225d72b9c7f46bc90630126eb000974ffaf Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 31 Jul 2020 04:20:27 +0000 Subject: [PATCH 45/71] Run all tests if have no specified tests --- src/etc/test-float-parse/runtests.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/etc/test-float-parse/runtests.py b/src/etc/test-float-parse/runtests.py index 4d2902e986f56..218552a45972d 100644 --- a/src/etc/test-float-parse/runtests.py +++ b/src/etc/test-float-parse/runtests.py @@ -193,10 +193,12 @@ def interact(proc, queue): def main(): global MAILBOX - tests = [os.path.splitext(f)[0] for f in glob('*.rs') - if not f.startswith('_')] + all_tests = [os.path.splitext(f)[0] for f in glob('*.rs') if not f.startswith('_')] args = sys.argv[1:] - tests = [test for test in tests if test in args] + if args: + tests = [test for test in all_tests if test in args] + else + tests = all_tests if not tests: print("Error: No tests to run") sys.exit(1) From a410ebc5ea44c0cea23a8e6d05aab2fe66b17203 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 20 Jul 2020 23:33:22 +0200 Subject: [PATCH 46/71] add note to array_chunks --- library/core/src/slice/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index e33dad38d4b0d..fdf3c7b3f637e 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -848,6 +848,8 @@ impl [T] { /// slice, then the last up to `N-1` elements will be omitted and can be retrieved /// from the `remainder` function of the iterator. /// + /// This method is the const generic equivalent of [`chunks_exact`]. + /// /// # Panics /// /// Panics if `N` is 0. @@ -864,7 +866,7 @@ impl [T] { /// assert_eq!(iter.remainder(), &['m']); /// ``` /// - /// [`chunks`]: #method.chunks + /// [`chunks_exact`]: #method.chunks_exact #[unstable(feature = "array_chunks", issue = "none")] #[inline] pub fn array_chunks(&self) -> ArrayChunks<'_, T, N> { From e75ffb0f1c566e11011b72ac04c3afcad3bf2b13 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Fri, 31 Jul 2020 08:24:39 +0200 Subject: [PATCH 47/71] use Iter<'_, [T; N]> in array_chunks --- library/core/src/slice/mod.rs | 78 +++++++++-------------------------- 1 file changed, 20 insertions(+), 58 deletions(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index fdf3c7b3f637e..d2d42d4be4b57 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -852,7 +852,8 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is 0. + /// Panics if `N` is 0. This check will most probably get changed to a compile time + /// error before this method gets stabilized. /// /// # Examples /// @@ -871,10 +872,12 @@ impl [T] { #[inline] pub fn array_chunks(&self) -> ArrayChunks<'_, T, N> { assert_ne!(N, 0); - let rem = self.len() % N; - let len = self.len() - rem; - let (fst, snd) = self.split_at(len); - ArrayChunks { v: fst, rem: snd } + let len = self.len() / N; + let (fst, snd) = self.split_at(len * N); + // SAFETY: We cast a slice of `len * N` elements into + // a slice of `len` many `N` elements chunks. + let array_slice: &[[T; N]] = unsafe { from_raw_parts(fst.as_ptr().cast(), len) }; + ArrayChunks { iter: array_slice.iter(), rem: snd } } /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end @@ -5483,7 +5486,7 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> { #[derive(Debug)] #[unstable(feature = "array_chunks", issue = "none")] pub struct ArrayChunks<'a, T: 'a, const N: usize> { - v: &'a [T], + iter: Iter<'a, [T; N]>, rem: &'a [T], } @@ -5501,7 +5504,7 @@ impl<'a, T, const N: usize> ArrayChunks<'a, T, N> { #[unstable(feature = "array_chunks", issue = "none")] impl Clone for ArrayChunks<'_, T, N> { fn clone(&self) -> Self { - ArrayChunks { v: self.v, rem: self.rem } + ArrayChunks { iter: self.iter.clone(), rem: self.rem } } } @@ -5511,44 +5514,27 @@ impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> { #[inline] fn next(&mut self) -> Option<&'a [T; N]> { - if self.v.len() < N { - None - } else { - let (fst, snd) = self.v.split_at(N); - self.v = snd; - // SAFETY: This is safe as fst is exactly N elements long. - let ptr = fst.as_ptr() as *const [T; N]; - unsafe { Some(&*ptr) } - } + self.iter.next() } #[inline] fn size_hint(&self) -> (usize, Option) { - let n = self.v.len() / N; - (n, Some(n)) + self.iter.size_hint() } #[inline] fn count(self) -> usize { - self.len() + self.iter.count() } #[inline] fn nth(&mut self, n: usize) -> Option { - let (start, overflow) = n.overflowing_mul(N); - if start >= self.v.len() || overflow { - self.v = &[]; - None - } else { - let (_, snd) = self.v.split_at(start); - self.v = snd; - self.next() - } + self.iter.nth(n) } #[inline] - fn last(mut self) -> Option { - self.next_back() + fn last(self) -> Option { + self.iter.last() } } @@ -5556,39 +5542,19 @@ impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> { impl<'a, T, const N: usize> DoubleEndedIterator for ArrayChunks<'a, T, N> { #[inline] fn next_back(&mut self) -> Option<&'a [T; N]> { - if self.v.len() < N { - None - } else { - let (fst, snd) = self.v.split_at(self.v.len() - N); - self.v = fst; - // SAFETY: This is safe as snd is exactly N elements long. - let ptr = snd.as_ptr() as *const [T; N]; - unsafe { Some(&*ptr) } - } + self.iter.next_back() } #[inline] fn nth_back(&mut self, n: usize) -> Option { - let len = self.len(); - if n >= len { - self.v = &[]; - None - } else { - let start = (len - 1 - n) * N; - let end = start + N; - let nth_back = &self.v[start..end]; - self.v = &self.v[..start]; - // SAFETY: This is safe as snd is exactly N elements long. - let ptr = nth_back.as_ptr() as *const [T; N]; - unsafe { Some(&*ptr) } - } + self.iter.nth_back(n) } } #[unstable(feature = "array_chunks", issue = "none")] impl ExactSizeIterator for ArrayChunks<'_, T, N> { fn is_empty(&self) -> bool { - self.v.is_empty() + self.iter.is_empty() } } @@ -5602,11 +5568,7 @@ impl FusedIterator for ArrayChunks<'_, T, N> {} #[unstable(feature = "array_chunks", issue = "none")] unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunks<'a, T, N> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T; N] { - let start = i * N; - // SAFETY: This is safe as `i` must be less than `self.size_hint`. - let segment = unsafe { from_raw_parts(self.v.as_ptr().add(start), N) }; - // SAFETY: This is safe as segment is exactly `N` elements long. - unsafe { &*(segment.as_ptr() as *const [T; N]) } + unsafe { self.iter.get_unchecked(i) } } fn may_have_side_effect() -> bool { false From c5114549d74f6092517af6ea630ec5a26317ae93 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Fri, 31 Jul 2020 18:04:13 +0800 Subject: [PATCH 48/71] Add the proper tests --- src/test/ui/statics/static-promotion.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/ui/statics/static-promotion.rs b/src/test/ui/statics/static-promotion.rs index 500af1e15e12e..bd8910bdb3f3f 100644 --- a/src/test/ui/statics/static-promotion.rs +++ b/src/test/ui/statics/static-promotion.rs @@ -12,12 +12,23 @@ struct A(&'static T); struct B { x: &'static T, } +static STR: &'static [u8] = b"hi"; static C: A>> = { A(&B { - x: &B { x: b"hi" as &[u8] }, + x: &B { x: STR }, }) }; +pub struct Slice(&'static [i32]); + +static CONTENT: i32 = 42; +pub static CONTENT_MAP: Slice = Slice(&[CONTENT]); + +pub static FOO: (i32, i32) = (42, 43); +pub static CONTENT_MAP2: Slice = Slice(&[FOO.0]); + fn main() { assert_eq!(b"hi", C.0.x.x); + assert_eq!(&[42], CONTENT_MAP.0); + assert_eq!(&[42], CONTENT_MAP2.0); } From 1a6730e31ced3a7264c80c0bbdd9f42c54f1534b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 31 Jul 2020 13:15:47 +0200 Subject: [PATCH 49/71] Clean up E0741 error explanation --- src/librustc_error_codes/error_codes/E0741.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0741.md b/src/librustc_error_codes/error_codes/E0741.md index 0a8650282a374..91379bfe05c65 100644 --- a/src/librustc_error_codes/error_codes/E0741.md +++ b/src/librustc_error_codes/error_codes/E0741.md @@ -1,5 +1,6 @@ -Only structural-match types (that is, types that derive `PartialEq` and `Eq`) -may be used as the types of const generic parameters. +A non-structural-match type was used as the type of a const generic parameter. + +Erroneous code example: ```compile_fail,E0741 #![feature(const_generics)] @@ -9,12 +10,15 @@ struct A; struct B; // error! ``` -To fix this example, we derive `PartialEq` and `Eq`. +Only structural-match types (that is, types that derive `PartialEq` and `Eq`) +may be used as the types of const generic parameters. + +To fix the previous code example, we derive `PartialEq` and `Eq`: ``` #![feature(const_generics)] -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq)] // We derive both traits here. struct A; struct B; // ok! From 3e48848538a49c66e3447a46346b96e8dc972531 Mon Sep 17 00:00:00 2001 From: Takayuki Nakata Date: Fri, 31 Jul 2020 23:53:05 +0900 Subject: [PATCH 50/71] Some fixes for `plugin.md` in unstable-book - sample codes not working - broken link --- .../src/language-features/plugin.md | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/doc/unstable-book/src/language-features/plugin.md b/src/doc/unstable-book/src/language-features/plugin.md index 1f010656bb854..3835113152762 100644 --- a/src/doc/unstable-book/src/language-features/plugin.md +++ b/src/doc/unstable-book/src/language-features/plugin.md @@ -45,42 +45,40 @@ that warns about any item named `lintme`. extern crate rustc_ast; // Load rustc as a plugin to get macros -#[macro_use] -extern crate rustc; extern crate rustc_driver; +#[macro_use] +extern crate rustc_lint; +#[macro_use] +extern crate rustc_session; -use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, - EarlyLintPassObject, LintArray}; use rustc_driver::plugin::Registry; +use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; use rustc_ast::ast; - declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); -struct Pass; - -impl LintPass for Pass { - fn get_lints(&self) -> LintArray { - lint_array!(TEST_LINT) - } -} +declare_lint_pass!(Pass => [TEST_LINT]); impl EarlyLintPass for Pass { fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { - if it.ident.as_str() == "lintme" { - cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"); + if it.ident.name.as_str() == "lintme" { + cx.lint(TEST_LINT, |lint| { + lint.build("item is named 'lintme'").set_span(it.span).emit() + }); } } } #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { - reg.register_early_lint_pass(box Pass as EarlyLintPassObject); + reg.lint_store.register_lints(&[&TEST_LINT]); + reg.lint_store.register_early_pass(|| box Pass); } ``` Then code like ```rust,ignore +#![feature(plugin)] #![plugin(lint_plugin_test)] fn lintme() { } @@ -107,7 +105,7 @@ The components of a lint plugin are: Lint passes are syntax traversals, but they run at a late stage of compilation where type information is available. `rustc`'s [built-in -lints](https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs) +lints](https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs) mostly use the same infrastructure as lint plugins, and provide examples of how to access type information. From 59e621c1969fb03c5d367e9c713c0279461e772f Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 24 Jul 2020 13:16:54 +0100 Subject: [PATCH 51/71] interp: needs_subst -> ensure_monomorphic_enough This commit adds a `ensure_monomorphic_enough` utility function which checks whether a type needs substitution, but only for parameters that the `unused_generic_params` query considers used. `ensure_monomorphic_enough` is then used throughout interpret where `needs_subst` checks previously existed (in particular, for some pointer casts and for reflection intrinsics more precise). Signed-off-by: David Wood --- src/librustc_mir/interpret/cast.rs | 15 ++--- src/librustc_mir/interpret/intrinsics.rs | 14 ++-- src/librustc_mir/interpret/mod.rs | 1 + src/librustc_mir/interpret/traits.rs | 8 +-- src/librustc_mir/interpret/util.rs | 73 +++++++++++++++++++++ src/test/ui/issues/issue-74614.rs | 1 + src/test/ui/polymorphization/issue-74636.rs | 16 +++++ 7 files changed, 108 insertions(+), 20 deletions(-) create mode 100644 src/librustc_mir/interpret/util.rs create mode 100644 src/test/ui/polymorphization/issue-74636.rs diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index 60cf21552e9e9..78f149f6451e6 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -8,11 +8,14 @@ use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar}; use rustc_middle::mir::CastKind; use rustc_middle::ty::adjustment::PointerCast; use rustc_middle::ty::layout::{IntegerExt, TyAndLayout}; -use rustc_middle::ty::{self, Ty, TypeAndMut, TypeFoldable}; +use rustc_middle::ty::{self, Ty, TypeAndMut}; use rustc_span::symbol::sym; use rustc_target::abi::{Integer, LayoutOf, Variants}; -use super::{truncate, FnVal, ImmTy, Immediate, InterpCx, Machine, OpTy, PlaceTy}; +use super::{ + truncate, util::ensure_monomorphic_enough, FnVal, ImmTy, Immediate, InterpCx, Machine, OpTy, + PlaceTy, +}; impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { pub fn cast( @@ -47,9 +50,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { match src.layout.ty.kind { ty::FnDef(def_id, substs) => { // All reifications must be monomorphic, bail out otherwise. - if src.layout.ty.needs_subst() { - throw_inval!(TooGeneric); - } + ensure_monomorphic_enough(*self.tcx, src.layout.ty)?; if self.tcx.has_attr(def_id, sym::rustc_args_required_const) { span_bug!( @@ -89,9 +90,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { match src.layout.ty.kind { ty::Closure(def_id, substs) => { // All reifications must be monomorphic, bail out otherwise. - if src.layout.ty.needs_subst() { - throw_inval!(TooGeneric); - } + ensure_monomorphic_enough(*self.tcx, src.layout.ty)?; let instance = ty::Instance::resolve_closure( *self.tcx, diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index 29549041d258c..072a926b31100 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -12,11 +12,13 @@ use rustc_middle::mir::{ }; use rustc_middle::ty; use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{Ty, TyCtxt}; use rustc_span::symbol::{sym, Symbol}; use rustc_target::abi::{Abi, LayoutOf as _, Primitive, Size}; -use super::{CheckInAllocMsg, ImmTy, InterpCx, Machine, OpTy, PlaceTy}; +use super::{ + util::ensure_monomorphic_enough, CheckInAllocMsg, ImmTy, InterpCx, Machine, OpTy, PlaceTy, +}; mod caller_location; mod type_name; @@ -54,9 +56,7 @@ crate fn eval_nullary_intrinsic<'tcx>( let name = tcx.item_name(def_id); Ok(match name { sym::type_name => { - if tp_ty.needs_subst() { - throw_inval!(TooGeneric); - } + ensure_monomorphic_enough(tcx, tp_ty)?; let alloc = type_name::alloc_type_name(tcx, tp_ty); ConstValue::Slice { data: alloc, start: 0, end: alloc.len() } } @@ -72,9 +72,7 @@ crate fn eval_nullary_intrinsic<'tcx>( ConstValue::from_machine_usize(n, &tcx) } sym::type_id => { - if tp_ty.needs_subst() { - throw_inval!(TooGeneric); - } + ensure_monomorphic_enough(tcx, tp_ty)?; ConstValue::from_u64(tcx.type_id_hash(tp_ty)) } sym::variant_count => { diff --git a/src/librustc_mir/interpret/mod.rs b/src/librustc_mir/interpret/mod.rs index d46010d98a5aa..8a186dc372fef 100644 --- a/src/librustc_mir/interpret/mod.rs +++ b/src/librustc_mir/interpret/mod.rs @@ -12,6 +12,7 @@ mod place; mod step; mod terminator; mod traits; +mod util; mod validity; mod visitor; diff --git a/src/librustc_mir/interpret/traits.rs b/src/librustc_mir/interpret/traits.rs index 49a80ca13457d..5c01345475c30 100644 --- a/src/librustc_mir/interpret/traits.rs +++ b/src/librustc_mir/interpret/traits.rs @@ -1,9 +1,10 @@ use std::convert::TryFrom; use rustc_middle::mir::interpret::{InterpResult, Pointer, PointerArithmetic, Scalar}; -use rustc_middle::ty::{self, Instance, Ty, TypeFoldable}; +use rustc_middle::ty::{self, Instance, Ty}; use rustc_target::abi::{Align, LayoutOf, Size}; +use super::util::ensure_monomorphic_enough; use super::{FnVal, InterpCx, Machine, MemoryKind}; impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { @@ -23,9 +24,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let (ty, poly_trait_ref) = self.tcx.erase_regions(&(ty, poly_trait_ref)); // All vtables must be monomorphic, bail out otherwise. - if ty.needs_subst() || poly_trait_ref.needs_subst() { - throw_inval!(TooGeneric); - } + ensure_monomorphic_enough(*self.tcx, ty)?; + ensure_monomorphic_enough(*self.tcx, poly_trait_ref)?; if let Some(&vtable) = self.vtables.get(&(ty, poly_trait_ref)) { // This means we guarantee that there are no duplicate vtables, we will diff --git a/src/librustc_mir/interpret/util.rs b/src/librustc_mir/interpret/util.rs new file mode 100644 index 0000000000000..c0eac8a9305ee --- /dev/null +++ b/src/librustc_mir/interpret/util.rs @@ -0,0 +1,73 @@ +use rustc_middle::mir::interpret::InterpResult; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeVisitor}; +use std::convert::TryInto; + +/// Returns `true` if a used generic parameter requires substitution. +crate fn ensure_monomorphic_enough<'tcx, T>(tcx: TyCtxt<'tcx>, ty: T) -> InterpResult<'tcx> +where + T: TypeFoldable<'tcx>, +{ + debug!("ensure_monomorphic_enough: ty={:?}", ty); + if !ty.needs_subst() { + return Ok(()); + } + + struct UsedParamsNeedSubstVisitor<'tcx> { + tcx: TyCtxt<'tcx>, + }; + + impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> { + fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool { + if !c.needs_subst() { + return false; + } + + match c.val { + ty::ConstKind::Param(..) => true, + _ => c.super_visit_with(self), + } + } + + fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { + if !ty.needs_subst() { + return false; + } + + match ty.kind { + ty::Param(_) => true, + ty::Closure(def_id, substs) + | ty::Generator(def_id, substs, ..) + | ty::FnDef(def_id, substs) => { + let unused_params = self.tcx.unused_generic_params(def_id); + for (index, subst) in substs.into_iter().enumerate() { + let index = index + .try_into() + .expect("more generic parameters than can fit into a `u32`"); + let is_used = + unused_params.contains(index).map(|unused| !unused).unwrap_or(true); + // Only recurse when generic parameters in fns, closures and generators + // are used and require substitution. + if is_used && subst.needs_subst() { + // Just in case there are closures or generators within this subst, + // recurse. + if subst.super_visit_with(self) { + // Only return when we find a parameter so the remaining substs + // are not skipped. + return true; + } + } + } + false + } + _ => ty.super_visit_with(self), + } + } + } + + let mut vis = UsedParamsNeedSubstVisitor { tcx }; + if ty.visit_with(&mut vis) { + throw_inval!(TooGeneric); + } else { + Ok(()) + } +} diff --git a/src/test/ui/issues/issue-74614.rs b/src/test/ui/issues/issue-74614.rs index f5e8deb29fbc8..8b0c00b135519 100644 --- a/src/test/ui/issues/issue-74614.rs +++ b/src/test/ui/issues/issue-74614.rs @@ -1,3 +1,4 @@ +// compile-flags:-Zpolymorphize=on // build-pass fn test() { diff --git a/src/test/ui/polymorphization/issue-74636.rs b/src/test/ui/polymorphization/issue-74636.rs new file mode 100644 index 0000000000000..4c532f451e373 --- /dev/null +++ b/src/test/ui/polymorphization/issue-74636.rs @@ -0,0 +1,16 @@ +// compile-flags:-Zpolymorphize=on +// build-pass + +use std::any::TypeId; + +pub fn foo(_: T) -> TypeId { + TypeId::of::() +} + +fn outer() { + foo(|| ()); +} + +fn main() { + outer::(); +} From f173a4b8ecb1f7673e9f5df19dd2f9287f461364 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 30 Jul 2020 16:12:02 -0400 Subject: [PATCH 52/71] 1.45.2 release notes --- RELEASES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index b47f64d2fafc9..4859532f7a1f7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,12 @@ +Version 1.45.2 (2020-08-03) +========================== + +* [Fix bindings in tuple struct patterns][74954] +* [Fix track_caller integration with trait objects][74784] + +[74954]: https://github.com/rust-lang/rust/issues/74954 +[74784]: https://github.com/rust-lang/rust/issues/74784 + Version 1.45.1 (2020-07-30) ========================== From dc21178830a0ae6e70101ffff8ef4843990cd902 Mon Sep 17 00:00:00 2001 From: Charles Lew Date: Thu, 23 Jul 2020 01:30:54 +0800 Subject: [PATCH 53/71] Remove `linked_list_extras` methods. --- library/alloc/src/collections/linked_list.rs | 45 +++++-------------- .../src/collections/linked_list/tests.rs | 27 ----------- 2 files changed, 10 insertions(+), 62 deletions(-) diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 1f875f6c5217f..02a746f0e2488 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -1110,32 +1110,17 @@ impl IterMut<'_, T> { /// Inserts the given element just after the element most recently returned by `.next()`. /// The inserted element does not appear in the iteration. /// - /// # Examples - /// - /// ``` - /// #![feature(linked_list_extras)] - /// - /// use std::collections::LinkedList; - /// - /// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect(); - /// - /// { - /// let mut it = list.iter_mut(); - /// assert_eq!(it.next().unwrap(), &1); - /// // insert `2` after `1` - /// it.insert_next(2); - /// } - /// { - /// let vec: Vec<_> = list.into_iter().collect(); - /// assert_eq!(vec, [1, 2, 3, 4]); - /// } - /// ``` + /// This method will be removed soon. #[inline] #[unstable( feature = "linked_list_extras", reason = "this is probably better handled by a cursor type -- we'll see", issue = "27794" )] + #[rustc_deprecated( + reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.", + since = "1.47.0" + )] pub fn insert_next(&mut self, element: T) { match self.head { // `push_back` is okay with aliasing `element` references @@ -1163,27 +1148,17 @@ impl IterMut<'_, T> { /// Provides a reference to the next element, without changing the iterator. /// - /// # Examples - /// - /// ``` - /// #![feature(linked_list_extras)] - /// - /// use std::collections::LinkedList; - /// - /// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect(); - /// - /// let mut it = list.iter_mut(); - /// assert_eq!(it.next().unwrap(), &1); - /// assert_eq!(it.peek_next().unwrap(), &2); - /// // We just peeked at 2, so it was not consumed from the iterator. - /// assert_eq!(it.next().unwrap(), &2); - /// ``` + /// This method will be removed soon. #[inline] #[unstable( feature = "linked_list_extras", reason = "this is probably better handled by a cursor type -- we'll see", issue = "27794" )] + #[rustc_deprecated( + reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.", + since = "1.47.0" + )] pub fn peek_next(&mut self) -> Option<&mut T> { if self.len == 0 { None diff --git a/library/alloc/src/collections/linked_list/tests.rs b/library/alloc/src/collections/linked_list/tests.rs index b8c93a28bba81..ad643a7bdf194 100644 --- a/library/alloc/src/collections/linked_list/tests.rs +++ b/library/alloc/src/collections/linked_list/tests.rs @@ -153,33 +153,6 @@ fn test_clone_from() { } } -#[test] -fn test_insert_prev() { - let mut m = list_from(&[0, 2, 4, 6, 8]); - let len = m.len(); - { - let mut it = m.iter_mut(); - it.insert_next(-2); - loop { - match it.next() { - None => break, - Some(elt) => { - it.insert_next(*elt + 1); - match it.peek_next() { - Some(x) => assert_eq!(*x, *elt + 2), - None => assert_eq!(8, *elt), - } - } - } - } - it.insert_next(0); - it.insert_next(1); - } - check_links(&m); - assert_eq!(m.len(), 3 + len * 2); - assert_eq!(m.into_iter().collect::>(), [-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]); -} - #[test] #[cfg_attr(target_os = "emscripten", ignore)] fn test_send() { From 73ba4e7abe0ada4c187aee4576bffe6024b5098a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 20:46:05 +0200 Subject: [PATCH 54/71] Miri: fix ICE when unwinding past topmost stack frame --- src/librustc_mir/interpret/eval_context.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 630b2890835da..65736710fce1b 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -718,6 +718,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } ); + if unwinding && self.frame_idx() == 0 { + throw_ub_format!("unwinding past the topmost frame of the stack"); + } + ::log_settings::settings().indentation -= 1; let frame = self.stack_mut().pop().expect("tried to pop a stack frame, but there were none"); From 8a5654f53c434466d913e18f50e661098e0c3e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 31 Jul 2020 21:23:39 +0200 Subject: [PATCH 55/71] fix part of comparison that would always evaluate to "true", probably an oversight --- src/librustc_lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 06e7c2b6f3625..e32c8fbee6852 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -2209,7 +2209,7 @@ impl ClashingExternDeclarations { } (Slice(a_ty), Slice(b_ty)) => Self::structurally_same_type(cx, a_ty, b_ty, ckind), (RawPtr(a_tymut), RawPtr(b_tymut)) => { - a_tymut.mutbl == a_tymut.mutbl + a_tymut.mutbl == b_tymut.mutbl && Self::structurally_same_type(cx, &a_tymut.ty, &b_tymut.ty, ckind) } (Ref(_a_region, a_ty, a_mut), Ref(_b_region, b_ty, b_mut)) => { From ec7230fea2f4a96a1993c54bf2b17892d2e978b4 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 24 Jul 2020 20:42:00 +0200 Subject: [PATCH 56/71] Move from `log` to `tracing` --- Cargo.lock | 168 +++++++++++++++------ src/librustc_ast/Cargo.toml | 2 +- src/librustc_ast_lowering/Cargo.toml | 2 +- src/librustc_ast_passes/Cargo.toml | 2 +- src/librustc_ast_pretty/Cargo.toml | 2 +- src/librustc_builtin_macros/Cargo.toml | 2 +- src/librustc_codegen_llvm/Cargo.toml | 2 +- src/librustc_codegen_ssa/Cargo.toml | 2 +- src/librustc_data_structures/Cargo.toml | 2 +- src/librustc_driver/Cargo.toml | 4 +- src/librustc_driver/lib.rs | 6 +- src/librustc_errors/Cargo.toml | 2 +- src/librustc_expand/Cargo.toml | 2 +- src/librustc_hir/Cargo.toml | 2 +- src/librustc_incremental/Cargo.toml | 2 +- src/librustc_infer/Cargo.toml | 2 +- src/librustc_interface/Cargo.toml | 2 +- src/librustc_lint/Cargo.toml | 2 +- src/librustc_metadata/Cargo.toml | 2 +- src/librustc_middle/Cargo.toml | 2 +- src/librustc_mir/Cargo.toml | 2 +- src/librustc_mir/interpret/eval_context.rs | 3 +- src/librustc_mir_build/Cargo.toml | 2 +- src/librustc_parse/Cargo.toml | 2 +- src/librustc_passes/Cargo.toml | 2 +- src/librustc_privacy/Cargo.toml | 2 +- src/librustc_query_system/Cargo.toml | 2 +- src/librustc_resolve/Cargo.toml | 2 +- src/librustc_save_analysis/Cargo.toml | 2 +- src/librustc_session/Cargo.toml | 2 +- src/librustc_span/Cargo.toml | 2 +- src/librustc_symbol_mangling/Cargo.toml | 2 +- src/librustc_target/Cargo.toml | 2 +- src/librustc_trait_selection/Cargo.toml | 2 +- src/librustc_traits/Cargo.toml | 2 +- src/librustc_ty/Cargo.toml | 2 +- src/librustc_typeck/Cargo.toml | 2 +- src/tools/compiletest/Cargo.toml | 2 +- 38 files changed, 165 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6f2468055a1f..367bf2ff0d923 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,7 +61,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7021ce4924a3f25f802b2cccd1af585e39ea1a363a1aa2e72afe54b67a3a7a7" dependencies = [ - "ansi_term", + "ansi_term 0.11.0", ] [[package]] @@ -79,6 +79,15 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "anyhow" version = "1.0.31" @@ -496,7 +505,7 @@ version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" dependencies = [ - "ansi_term", + "ansi_term 0.11.0", "atty", "bitflags", "strsim", @@ -616,12 +625,12 @@ dependencies = [ "glob", "lazy_static", "libc", - "log", "miow 0.3.3", "regex", "rustfix", "serde", "serde_json", + "tracing", "walkdir", "winapi 0.3.8", ] @@ -1741,6 +1750,15 @@ dependencies = [ "tendril", ] +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + [[package]] name = "matches" version = "0.1.8" @@ -2314,7 +2332,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" dependencies = [ - "ansi_term", + "ansi_term 0.11.0", "ctor", "difference", "output_vt100", @@ -2678,6 +2696,16 @@ dependencies = [ "thread_local", ] +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.17" @@ -3228,7 +3256,6 @@ name = "rustc_ast" version = "0.0.0" dependencies = [ "bitflags", - "log", "rustc_data_structures", "rustc_index", "rustc_lexer", @@ -3237,13 +3264,13 @@ dependencies = [ "rustc_span", "scoped-tls", "smallvec 1.4.0", + "tracing", ] [[package]] name = "rustc_ast_lowering" version = "0.0.0" dependencies = [ - "log", "rustc_arena", "rustc_ast", "rustc_ast_pretty", @@ -3255,6 +3282,7 @@ dependencies = [ "rustc_span", "rustc_target", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3262,7 +3290,6 @@ name = "rustc_ast_passes" version = "0.0.0" dependencies = [ "itertools 0.8.0", - "log", "rustc_ast", "rustc_ast_pretty", "rustc_attr", @@ -3272,16 +3299,17 @@ dependencies = [ "rustc_parse", "rustc_session", "rustc_span", + "tracing", ] [[package]] name = "rustc_ast_pretty" version = "0.0.0" dependencies = [ - "log", "rustc_ast", "rustc_span", "rustc_target", + "tracing", ] [[package]] @@ -3304,7 +3332,6 @@ dependencies = [ name = "rustc_builtin_macros" version = "0.0.0" dependencies = [ - "log", "rustc_ast", "rustc_ast_pretty", "rustc_attr", @@ -3318,6 +3345,7 @@ dependencies = [ "rustc_span", "rustc_target", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3327,7 +3355,6 @@ dependencies = [ "bitflags", "flate2", "libc", - "log", "measureme", "rustc-demangle", "rustc_ast", @@ -3347,6 +3374,7 @@ dependencies = [ "rustc_span", "rustc_target", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3357,7 +3385,6 @@ dependencies = [ "cc", "jobserver", "libc", - "log", "memmap", "num_cpus", "pathdiff", @@ -3377,6 +3404,7 @@ dependencies = [ "rustc_symbol_mangling", "rustc_target", "tempfile", + "tracing", ] [[package]] @@ -3391,7 +3419,6 @@ dependencies = [ "jobserver", "lazy_static", "libc", - "log", "measureme", "once_cell", "parking_lot 0.10.2", @@ -3404,6 +3431,7 @@ dependencies = [ "smallvec 1.4.0", "stable_deref_trait", "stacker", + "tracing", "winapi 0.3.8", ] @@ -3411,10 +3439,8 @@ dependencies = [ name = "rustc_driver" version = "0.0.0" dependencies = [ - "env_logger 0.7.1", "lazy_static", "libc", - "log", "rustc_ast", "rustc_ast_pretty", "rustc_codegen_ssa", @@ -3436,6 +3462,8 @@ dependencies = [ "rustc_session", "rustc_span", "rustc_target", + "tracing", + "tracing-subscriber", "winapi 0.3.8", ] @@ -3449,12 +3477,12 @@ version = "0.0.0" dependencies = [ "annotate-snippets 0.8.0", "atty", - "log", "rustc_data_structures", "rustc_serialize", "rustc_span", "termcolor", "termize", + "tracing", "unicode-width", "winapi 0.3.8", ] @@ -3463,7 +3491,6 @@ dependencies = [ name = "rustc_expand" version = "0.0.0" dependencies = [ - "log", "rustc_ast", "rustc_ast_passes", "rustc_ast_pretty", @@ -3477,6 +3504,7 @@ dependencies = [ "rustc_session", "rustc_span", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3501,7 +3529,6 @@ name = "rustc_hir" version = "0.0.0" dependencies = [ "lazy_static", - "log", "rustc_ast", "rustc_data_structures", "rustc_index", @@ -3510,6 +3537,7 @@ dependencies = [ "rustc_span", "rustc_target", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3527,7 +3555,6 @@ dependencies = [ name = "rustc_incremental" version = "0.0.0" dependencies = [ - "log", "rand 0.7.3", "rustc_ast", "rustc_data_structures", @@ -3538,6 +3565,7 @@ dependencies = [ "rustc_serialize", "rustc_session", "rustc_span", + "tracing", ] [[package]] @@ -3552,7 +3580,6 @@ dependencies = [ name = "rustc_infer" version = "0.0.0" dependencies = [ - "log", "rustc_ast", "rustc_data_structures", "rustc_errors", @@ -3566,6 +3593,7 @@ dependencies = [ "rustc_span", "rustc_target", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3573,7 +3601,6 @@ name = "rustc_interface" version = "0.0.0" dependencies = [ "libc", - "log", "once_cell", "rustc-rayon", "rustc_ast", @@ -3609,6 +3636,7 @@ dependencies = [ "rustc_typeck", "smallvec 1.4.0", "tempfile", + "tracing", "winapi 0.3.8", ] @@ -3623,7 +3651,6 @@ dependencies = [ name = "rustc_lint" version = "0.0.0" dependencies = [ - "log", "rustc_ast", "rustc_ast_pretty", "rustc_attr", @@ -3637,6 +3664,7 @@ dependencies = [ "rustc_span", "rustc_target", "rustc_trait_selection", + "tracing", "unicode-security", ] @@ -3665,7 +3693,6 @@ version = "0.0.0" dependencies = [ "flate2", "libc", - "log", "memmap", "rustc_ast", "rustc_attr", @@ -3682,6 +3709,7 @@ dependencies = [ "rustc_target", "smallvec 1.4.0", "stable_deref_trait", + "tracing", "winapi 0.3.8", ] @@ -3692,7 +3720,6 @@ dependencies = [ "bitflags", "byteorder", "chalk-ir", - "log", "measureme", "polonius-engine", "rustc-rayon-core", @@ -3713,6 +3740,7 @@ dependencies = [ "rustc_target", "scoped-tls", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3721,7 +3749,6 @@ version = "0.0.0" dependencies = [ "either", "itertools 0.8.0", - "log", "log_settings", "polonius-engine", "rustc_apfloat", @@ -3742,13 +3769,13 @@ dependencies = [ "rustc_target", "rustc_trait_selection", "smallvec 1.4.0", + "tracing", ] [[package]] name = "rustc_mir_build" version = "0.0.0" dependencies = [ - "log", "rustc_apfloat", "rustc_arena", "rustc_ast", @@ -3765,6 +3792,7 @@ dependencies = [ "rustc_target", "rustc_trait_selection", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3772,7 +3800,6 @@ name = "rustc_parse" version = "0.0.0" dependencies = [ "bitflags", - "log", "rustc_ast", "rustc_ast_pretty", "rustc_data_structures", @@ -3781,6 +3808,7 @@ dependencies = [ "rustc_lexer", "rustc_session", "rustc_span", + "tracing", "unicode-normalization", ] @@ -3796,7 +3824,6 @@ dependencies = [ name = "rustc_passes" version = "0.0.0" dependencies = [ - "log", "rustc_ast", "rustc_attr", "rustc_data_structures", @@ -3808,6 +3835,7 @@ dependencies = [ "rustc_span", "rustc_target", "rustc_trait_selection", + "tracing", ] [[package]] @@ -3828,7 +3856,6 @@ dependencies = [ name = "rustc_privacy" version = "0.0.0" dependencies = [ - "log", "rustc_attr", "rustc_data_structures", "rustc_errors", @@ -3837,13 +3864,13 @@ dependencies = [ "rustc_session", "rustc_span", "rustc_typeck", + "tracing", ] [[package]] name = "rustc_query_system" version = "0.0.0" dependencies = [ - "log", "parking_lot 0.10.2", "rustc-rayon-core", "rustc_arena", @@ -3853,6 +3880,7 @@ dependencies = [ "rustc_serialize", "rustc_span", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -3860,7 +3888,6 @@ name = "rustc_resolve" version = "0.0.0" dependencies = [ "bitflags", - "log", "rustc_arena", "rustc_ast", "rustc_ast_lowering", @@ -3877,13 +3904,13 @@ dependencies = [ "rustc_session", "rustc_span", "smallvec 1.4.0", + "tracing", ] [[package]] name = "rustc_save_analysis" version = "0.0.0" dependencies = [ - "log", "rls-data", "rls-span", "rustc_ast", @@ -3896,6 +3923,7 @@ dependencies = [ "rustc_session", "rustc_span", "serde_json", + "tracing", ] [[package]] @@ -3912,7 +3940,6 @@ version = "0.0.0" dependencies = [ "bitflags", "getopts", - "log", "num_cpus", "rustc_ast", "rustc_data_structures", @@ -3922,6 +3949,7 @@ dependencies = [ "rustc_serialize", "rustc_span", "rustc_target", + "tracing", ] [[package]] @@ -3929,7 +3957,6 @@ name = "rustc_span" version = "0.0.0" dependencies = [ "cfg-if", - "log", "md-5", "rustc_arena", "rustc_data_structures", @@ -3938,6 +3965,7 @@ dependencies = [ "rustc_serialize", "scoped-tls", "sha-1", + "tracing", "unicode-width", ] @@ -3945,7 +3973,6 @@ dependencies = [ name = "rustc_symbol_mangling" version = "0.0.0" dependencies = [ - "log", "punycode", "rustc-demangle", "rustc_ast", @@ -3955,6 +3982,7 @@ dependencies = [ "rustc_session", "rustc_span", "rustc_target", + "tracing", ] [[package]] @@ -3962,12 +3990,12 @@ name = "rustc_target" version = "0.0.0" dependencies = [ "bitflags", - "log", "rustc_data_structures", "rustc_index", "rustc_macros", "rustc_serialize", "rustc_span", + "tracing", ] [[package]] @@ -3984,7 +4012,6 @@ checksum = "b725dadae9fabc488df69a287f5a99c5eaf5d10853842a8a3dfac52476f544ee" name = "rustc_trait_selection" version = "0.0.0" dependencies = [ - "log", "rustc_ast", "rustc_attr", "rustc_data_structures", @@ -3999,6 +4026,7 @@ dependencies = [ "rustc_span", "rustc_target", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -4007,7 +4035,6 @@ version = "0.0.0" dependencies = [ "chalk-ir", "chalk-solve", - "log", "rustc_ast", "rustc_data_structures", "rustc_hir", @@ -4017,13 +4044,13 @@ dependencies = [ "rustc_span", "rustc_trait_selection", "smallvec 1.4.0", + "tracing", ] [[package]] name = "rustc_ty" version = "0.0.0" dependencies = [ - "log", "rustc_data_structures", "rustc_errors", "rustc_hir", @@ -4033,13 +4060,13 @@ dependencies = [ "rustc_span", "rustc_target", "rustc_trait_selection", + "tracing", ] [[package]] name = "rustc_typeck" version = "0.0.0" dependencies = [ - "log", "rustc_arena", "rustc_ast", "rustc_attr", @@ -4055,6 +4082,7 @@ dependencies = [ "rustc_target", "rustc_trait_selection", "smallvec 1.4.0", + "tracing", ] [[package]] @@ -4284,6 +4312,15 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sharded-slab" +version = "0.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" +dependencies = [ + "lazy_static", +] + [[package]] name = "shell-escape" version = "0.1.4" @@ -4931,9 +4968,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.15" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41f40ed0e162c911ac6fcb53ecdc8134c46905fdbbae8c50add462a538b495f" +checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178" dependencies = [ "cfg-if", "tracing-attributes", @@ -4942,9 +4979,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99bbad0de3fd923c9c3232ead88510b783e5a4d16a6154adffa3d53308de984c" +checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" dependencies = [ "proc-macro2 1.0.3", "quote 1.0.2", @@ -4953,13 +4990,54 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aa83a9a47081cd522c09c81b31aec2c9273424976f922ad61c053b58350b715" +checksum = "b2734b5a028fa697686f16c6d18c2c6a3c7e41513f9a213abb6754c4acb3c8d7" dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-log" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6ccba2f8f16e0ed268fc765d9b7ff22e965e7185d32f8f1ec8294fe17d86e79" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b33f8b2ef2ab0c3778c12646d9c42a24f7772bee4cdafc72199644a9f58fdc" +dependencies = [ + "ansi_term 0.12.1", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec 1.4.0", + "tracing-core", + "tracing-log", + "tracing-serde", +] + [[package]] name = "typenum" version = "1.12.0" diff --git a/src/librustc_ast/Cargo.toml b/src/librustc_ast/Cargo.toml index 6bd65fd5f96c7..a36f49bd4146b 100644 --- a/src/librustc_ast/Cargo.toml +++ b/src/librustc_ast/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_serialize = { path = "../librustc_serialize" } -log = "0.4" +log = { package = "tracing", version = "0.1" } scoped-tls = "1.0" rustc_span = { path = "../librustc_span" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_ast_lowering/Cargo.toml b/src/librustc_ast_lowering/Cargo.toml index d71eb4fcd5c27..51f34a1b78e97 100644 --- a/src/librustc_ast_lowering/Cargo.toml +++ b/src/librustc_ast_lowering/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_arena = { path = "../librustc_arena" } -log = { version = "0.4", features = ["release_max_level_info", "std"] } +log = { package = "tracing", version = "0.1" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_hir = { path = "../librustc_hir" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_ast_passes/Cargo.toml b/src/librustc_ast_passes/Cargo.toml index e4d1d79abb2d6..c53089a4afc5c 100644 --- a/src/librustc_ast_passes/Cargo.toml +++ b/src/librustc_ast_passes/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" [dependencies] itertools = "0.8" -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_ast_pretty/Cargo.toml b/src/librustc_ast_pretty/Cargo.toml index 6c076d2c5b866..4035346d35446 100644 --- a/src/librustc_ast_pretty/Cargo.toml +++ b/src/librustc_ast_pretty/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" doctest = false [dependencies] -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_span = { path = "../librustc_span" } rustc_ast = { path = "../librustc_ast" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_builtin_macros/Cargo.toml b/src/librustc_builtin_macros/Cargo.toml index fdb6c359052d0..c612781153e8f 100644 --- a/src/librustc_builtin_macros/Cargo.toml +++ b/src/librustc_builtin_macros/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_parse_format = { path = "../librustc_parse_format" } -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_codegen_llvm/Cargo.toml b/src/librustc_codegen_llvm/Cargo.toml index bedefcc30ed8c..ec4dfabdcc2f0 100644 --- a/src/librustc_codegen_llvm/Cargo.toml +++ b/src/librustc_codegen_llvm/Cargo.toml @@ -15,7 +15,7 @@ bitflags = "1.0" flate2 = "1.0" libc = "0.2" measureme = "0.7.1" -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_middle = { path = "../librustc_middle" } rustc-demangle = "0.1" rustc_attr = { path = "../librustc_attr" } diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml index e100e0095c92a..8fa0de37648f3 100644 --- a/src/librustc_codegen_ssa/Cargo.toml +++ b/src/librustc_codegen_ssa/Cargo.toml @@ -14,7 +14,7 @@ bitflags = "1.2.1" cc = "1.0.1" num_cpus = "1.0" memmap = "0.7" -log = "0.4.5" +log = { package = "tracing", version = "0.1" } libc = "0.2.50" jobserver = "0.1.11" tempfile = "3.1" diff --git a/src/librustc_data_structures/Cargo.toml b/src/librustc_data_structures/Cargo.toml index 1c2fb90b2d8b4..811d1e49626c4 100644 --- a/src/librustc_data_structures/Cargo.toml +++ b/src/librustc_data_structures/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] ena = "0.14" indexmap = "1" -log = "0.4" +log = { package = "tracing", version = "0.1" } jobserver_crate = { version = "0.1.13", package = "jobserver" } lazy_static = "1" once_cell = { version = "1", features = ["parking_lot"] } diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index 75d6592076655..69dd221ef969d 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -12,8 +12,8 @@ crate-type = ["dylib"] [dependencies] lazy_static = "1.0" libc = "0.2" -log = "0.4" -env_logger = { version = "0.7", default-features = false } +log = { package = "tracing", version = "0.1.18", features = ["release_max_level_info"] } +tracing-subscriber = { version = "0.2.10", features = ["fmt", "env-filter"] } rustc_middle = { path = "../librustc_middle" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index ab4eac9440b41..6faffae305d18 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1226,7 +1226,11 @@ pub fn install_ice_hook() { /// This allows tools to enable rust logging without having to magically match rustc's /// log crate version pub fn init_rustc_env_logger() { - env_logger::init_from_env("RUSTC_LOG"); + let builder = tracing_subscriber::FmtSubscriber::builder(); + + let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env("RUSTC_LOG")); + + builder.init() } pub fn main() -> ! { diff --git a/src/librustc_errors/Cargo.toml b/src/librustc_errors/Cargo.toml index 7f72161aff826..d0f04c3fe7647 100644 --- a/src/librustc_errors/Cargo.toml +++ b/src/librustc_errors/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" doctest = false [dependencies] -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_serialize = { path = "../librustc_serialize" } rustc_span = { path = "../librustc_span" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_expand/Cargo.toml b/src/librustc_expand/Cargo.toml index ef617acfe1314..bdf039c36abf6 100644 --- a/src/librustc_expand/Cargo.toml +++ b/src/librustc_expand/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] rustc_serialize = { path = "../librustc_serialize" } -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_span = { path = "../librustc_span" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_ast_passes = { path = "../librustc_ast_passes" } diff --git a/src/librustc_hir/Cargo.toml b/src/librustc_hir/Cargo.toml index 1b91d769c7047..4a404e176e148 100644 --- a/src/librustc_hir/Cargo.toml +++ b/src/librustc_hir/Cargo.toml @@ -18,5 +18,5 @@ rustc_span = { path = "../librustc_span" } rustc_serialize = { path = "../librustc_serialize" } rustc_ast = { path = "../librustc_ast" } lazy_static = "1" -log = { version = "0.4", features = ["release_max_level_info", "std"] } +log = { package = "tracing", version = "0.1" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index 7b3030fa1d9c1..60a87078d63cf 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_graphviz = { path = "../librustc_graphviz" } -log = "0.4" +log = { package = "tracing", version = "0.1" } rand = "0.7" rustc_middle = { path = "../librustc_middle" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_infer/Cargo.toml b/src/librustc_infer/Cargo.toml index 06fc7ecf95f26..9d56fa223a9cb 100644 --- a/src/librustc_infer/Cargo.toml +++ b/src/librustc_infer/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_graphviz = { path = "../librustc_graphviz" } -log = { version = "0.4", features = ["release_max_level_info", "std"] } +log = { package = "tracing", version = "0.1" } rustc_middle = { path = "../librustc_middle" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index 112dc7037f588..5c7edc10dd5c7 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] libc = "0.2" -log = "0.4" +log = { package = "tracing", version = "0.1" } rayon = { version = "0.3.0", package = "rustc-rayon" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_ast = { path = "../librustc_ast" } diff --git a/src/librustc_lint/Cargo.toml b/src/librustc_lint/Cargo.toml index 58c15257326ae..3ba1566023d28 100644 --- a/src/librustc_lint/Cargo.toml +++ b/src/librustc_lint/Cargo.toml @@ -9,7 +9,7 @@ name = "rustc_lint" path = "lib.rs" [dependencies] -log = "0.4" +log = { package = "tracing", version = "0.1" } unicode-security = "0.0.5" rustc_middle = { path = "../librustc_middle" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 7bbe7567d2924..2c0e2aa39fd59 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] flate2 = "1.0" libc = "0.2" -log = "0.4" +log = { package = "tracing", version = "0.1" } memmap = "0.7" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_middle = { path = "../librustc_middle" } diff --git a/src/librustc_middle/Cargo.toml b/src/librustc_middle/Cargo.toml index 02d82c6793386..678fcfe65394b 100644 --- a/src/librustc_middle/Cargo.toml +++ b/src/librustc_middle/Cargo.toml @@ -13,7 +13,7 @@ doctest = false rustc_arena = { path = "../librustc_arena" } bitflags = "1.2.1" scoped-tls = "1.0" -log = { version = "0.4", features = ["release_max_level_info", "std"] } +log = { package = "tracing", version = "0.1" } rustc-rayon-core = "0.3.0" polonius-engine = "0.12.0" rustc_apfloat = { path = "../librustc_apfloat" } diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index aebce78e4018b..f05c47e0ed626 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -13,7 +13,7 @@ doctest = false either = "1.5.0" rustc_graphviz = { path = "../librustc_graphviz" } itertools = "0.8" -log = "0.4" +log = { package = "tracing", version = "0.1" } log_settings = "0.1.1" polonius-engine = "0.12.0" rustc_middle = { path = "../librustc_middle" } diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 630b2890835da..879a8e644907d 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -818,11 +818,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ) -> InterpResult<'tcx> { // FIXME: should we tell the user that there was a local which was never written to? if let LocalValue::Live(Operand::Indirect(MemPlace { ptr, .. })) = local { - trace!("deallocating local"); // All locals have a backing allocation, even if the allocation is empty // due to the local having ZST type. let ptr = ptr.assert_ptr(); - trace!("{:?}", self.memory.dump_alloc(ptr.alloc_id)); + trace!("deallocating local: {:?}", self.memory.dump_alloc(ptr.alloc_id)); self.memory.deallocate_local(ptr)?; }; Ok(()) diff --git a/src/librustc_mir_build/Cargo.toml b/src/librustc_mir_build/Cargo.toml index 401a5009e3cf7..96059fa43e521 100644 --- a/src/librustc_mir_build/Cargo.toml +++ b/src/librustc_mir_build/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_arena = { path = "../librustc_arena" } -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_middle = { path = "../librustc_middle" } rustc_apfloat = { path = "../librustc_apfloat" } rustc_attr = { path = "../librustc_attr" } diff --git a/src/librustc_parse/Cargo.toml b/src/librustc_parse/Cargo.toml index 7164c67880863..f214ec020cbec 100644 --- a/src/librustc_parse/Cargo.toml +++ b/src/librustc_parse/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] bitflags = "1.0" -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_feature = { path = "../librustc_feature" } diff --git a/src/librustc_passes/Cargo.toml b/src/librustc_passes/Cargo.toml index 69048cbf24a30..d9fa435e3ad68 100644 --- a/src/librustc_passes/Cargo.toml +++ b/src/librustc_passes/Cargo.toml @@ -9,7 +9,7 @@ name = "rustc_passes" path = "lib.rs" [dependencies] -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_middle = { path = "../librustc_middle" } rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_privacy/Cargo.toml b/src/librustc_privacy/Cargo.toml index 6110d2ef7fc9a..6f543e71b4281 100644 --- a/src/librustc_privacy/Cargo.toml +++ b/src/librustc_privacy/Cargo.toml @@ -17,4 +17,4 @@ rustc_typeck = { path = "../librustc_typeck" } rustc_session = { path = "../librustc_session" } rustc_span = { path = "../librustc_span" } rustc_data_structures = { path = "../librustc_data_structures" } -log = "0.4" +log = { package = "tracing", version = "0.1" } diff --git a/src/librustc_query_system/Cargo.toml b/src/librustc_query_system/Cargo.toml index 73d50f84fe836..64af9c5f1a152 100644 --- a/src/librustc_query_system/Cargo.toml +++ b/src/librustc_query_system/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_arena = { path = "../librustc_arena" } -log = { version = "0.4", features = ["release_max_level_info", "std"] } +log = { package = "tracing", version = "0.1" } rustc-rayon-core = "0.3.0" rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml index 6f6104c3d6932..1cb49132ead9c 100644 --- a/src/librustc_resolve/Cargo.toml +++ b/src/librustc_resolve/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] bitflags = "1.2.1" -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_ast = { path = "../librustc_ast" } rustc_arena = { path = "../librustc_arena" } rustc_middle = { path = "../librustc_middle" } diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index 5948c88054ded..7a5ae0ace3ae6 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -9,7 +9,7 @@ name = "rustc_save_analysis" path = "lib.rs" [dependencies] -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_middle = { path = "../librustc_middle" } rustc_ast = { path = "../librustc_ast" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } diff --git a/src/librustc_session/Cargo.toml b/src/librustc_session/Cargo.toml index abce7359c0ed7..35c227df8500a 100644 --- a/src/librustc_session/Cargo.toml +++ b/src/librustc_session/Cargo.toml @@ -11,7 +11,7 @@ path = "lib.rs" [dependencies] bitflags = "1.2.1" getopts = "0.2" -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_errors = { path = "../librustc_errors" } rustc_feature = { path = "../librustc_feature" } rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_span/Cargo.toml b/src/librustc_span/Cargo.toml index 2a7a774872525..2db417ce0e129 100644 --- a/src/librustc_span/Cargo.toml +++ b/src/librustc_span/Cargo.toml @@ -18,6 +18,6 @@ rustc_arena = { path = "../librustc_arena" } scoped-tls = "1.0" unicode-width = "0.1.4" cfg-if = "0.1.2" -log = "0.4" +log = { package = "tracing", version = "0.1" } sha-1 = "0.8" md-5 = "0.8" diff --git a/src/librustc_symbol_mangling/Cargo.toml b/src/librustc_symbol_mangling/Cargo.toml index d670ababe9f12..757d86bd95afd 100644 --- a/src/librustc_symbol_mangling/Cargo.toml +++ b/src/librustc_symbol_mangling/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" doctest = false [dependencies] -log = "0.4" +log = { package = "tracing", version = "0.1" } punycode = "0.4.0" rustc-demangle = "0.1.16" diff --git a/src/librustc_target/Cargo.toml b/src/librustc_target/Cargo.toml index c73490e451320..21796e8498568 100644 --- a/src/librustc_target/Cargo.toml +++ b/src/librustc_target/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" [dependencies] bitflags = "1.2.1" -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_macros = { path = "../librustc_macros" } rustc_serialize = { path = "../librustc_serialize" } diff --git a/src/librustc_trait_selection/Cargo.toml b/src/librustc_trait_selection/Cargo.toml index fd11a85a9c406..c43fe3f2c0c89 100644 --- a/src/librustc_trait_selection/Cargo.toml +++ b/src/librustc_trait_selection/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc_parse_format = { path = "../librustc_parse_format" } -log = { version = "0.4", features = ["release_max_level_info", "std"] } +log = { package = "tracing", version = "0.1" } rustc_attr = { path = "../librustc_attr" } rustc_middle = { path = "../librustc_middle" } rustc_ast = { path = "../librustc_ast" } diff --git a/src/librustc_traits/Cargo.toml b/src/librustc_traits/Cargo.toml index 079b9b10fd090..f8487982e3d49 100644 --- a/src/librustc_traits/Cargo.toml +++ b/src/librustc_traits/Cargo.toml @@ -9,7 +9,7 @@ name = "rustc_traits" path = "lib.rs" [dependencies] -log = { version = "0.4" } +log = { package = "tracing", version = "0.1" } rustc_middle = { path = "../librustc_middle" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_hir = { path = "../librustc_hir" } diff --git a/src/librustc_ty/Cargo.toml b/src/librustc_ty/Cargo.toml index b6db75e44f971..6cdb353000278 100644 --- a/src/librustc_ty/Cargo.toml +++ b/src/librustc_ty/Cargo.toml @@ -9,7 +9,7 @@ name = "rustc_ty" path = "lib.rs" [dependencies] -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_middle = { path = "../librustc_middle" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_typeck/Cargo.toml b/src/librustc_typeck/Cargo.toml index 93b503c976be4..963deda162d62 100644 --- a/src/librustc_typeck/Cargo.toml +++ b/src/librustc_typeck/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] rustc_arena = { path = "../librustc_arena" } -log = "0.4" +log = { package = "tracing", version = "0.1" } rustc_middle = { path = "../librustc_middle" } rustc_attr = { path = "../librustc_attr" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 338a167de3fe5..bd4c5949800f6 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" diff = "0.1.10" env_logger = { version = "0.7", default-features = false } getopts = "0.2" -log = "0.4" +log = { package = "tracing", version = "0.1" } regex = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" From 64296ec698b1c92ce148b968c101c18e63002bb2 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 24 Jul 2020 21:35:14 +0200 Subject: [PATCH 57/71] Add tracing libs to list of permitted dependencies --- src/tools/tidy/src/deps.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index e340a0e3f2486..55e17466a881e 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -166,6 +166,9 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "termcolor", "termize", "thread_local", + "tracing", + "tracing-attributes", + "tracing-core", "typenum", "unicode-normalization", "unicode-script", From 208f973d1f8ed7442a64c7784e1b4f5910722eb5 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sat, 25 Jul 2020 15:50:51 +0200 Subject: [PATCH 58/71] Make rustdoc share the logger initialization routine with rustc. --- src/librustc_driver/lib.rs | 11 +++++++++-- src/librustdoc/lib.rs | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 6faffae305d18..177fb2c2ec69f 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1224,11 +1224,18 @@ pub fn install_ice_hook() { } /// This allows tools to enable rust logging without having to magically match rustc's -/// log crate version +/// log crate version. pub fn init_rustc_env_logger() { + init_env_logger("RUSTC_LOG") +} + +/// This allows tools to enable rust logging without having to magically match rustc's +/// log crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var +/// other than `RUSTC_LOG`. +pub fn init_env_logger(env: &str) { let builder = tracing_subscriber::FmtSubscriber::builder(); - let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env("RUSTC_LOG")); + let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env(env)); builder.init() } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 62780878fd5af..002c5f967105d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -14,7 +14,6 @@ #![feature(never_type)] #![recursion_limit = "256"] -extern crate env_logger; #[macro_use] extern crate lazy_static; extern crate rustc_ast; @@ -90,7 +89,8 @@ pub fn main() { }; rustc_driver::set_sigpipe_handler(); rustc_driver::install_ice_hook(); - env_logger::init_from_env("RUSTDOC_LOG"); + rustc_driver::init_env_logger("RUSTDOC_LOG"); + let res = std::thread::Builder::new() .stack_size(thread_stack_size) .spawn(move || get_args().map(|args| main_args(&args)).unwrap_or(1)) From 720832c644d4dfe14ec43ae9ef4d74b647ccd77d Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sat, 25 Jul 2020 17:19:17 +0200 Subject: [PATCH 59/71] Update error index generator to tracing --- src/tools/error_index_generator/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index c4292d041d051..bd9f8fb045025 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -1,7 +1,7 @@ #![feature(rustc_private)] -extern crate env_logger; extern crate rustc_ast; +extern crate rustc_driver; extern crate rustc_span; use std::cell::RefCell; @@ -282,7 +282,7 @@ fn parse_args() -> (OutputFormat, PathBuf) { } fn main() { - env_logger::init(); + rustc_driver::init_env_logger("RUST_LOG"); let (format, dst) = parse_args(); let result = rustc_ast::with_default_session_globals(move || main_with_result(format, &dst)); if let Err(e) = result { From 358e21ee781cbcee19ff96b3824b583611e860a5 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sun, 26 Jul 2020 13:01:51 +0200 Subject: [PATCH 60/71] Disable log support --- Cargo.lock | 26 +------------------------- src/librustc_driver/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 367bf2ff0d923..46b13db01029f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4997,27 +4997,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "tracing-log" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-serde" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6ccba2f8f16e0ed268fc765d9b7ff22e965e7185d32f8f1ec8294fe17d86e79" -dependencies = [ - "serde", - "tracing-core", -] - [[package]] name = "tracing-subscriber" version = "0.2.10" @@ -5028,14 +5007,11 @@ dependencies = [ "chrono", "lazy_static", "matchers", + "parking_lot 0.9.0", "regex", - "serde", - "serde_json", "sharded-slab", "smallvec 1.4.0", "tracing-core", - "tracing-log", - "tracing-serde", ] [[package]] diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index 69dd221ef969d..2f6c2c6c22c23 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["dylib"] lazy_static = "1.0" libc = "0.2" log = { package = "tracing", version = "0.1.18", features = ["release_max_level_info"] } -tracing-subscriber = { version = "0.2.10", features = ["fmt", "env-filter"] } +tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi", "chrono"] } rustc_middle = { path = "../librustc_middle" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_target = { path = "../librustc_target" } From 401033c68486bc7672cc87e0f4c5b4862e96c778 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 28 Jul 2020 15:49:04 +0200 Subject: [PATCH 61/71] Don't register a tracing dispatcher if no tracing env var was set. --- src/librustc_driver/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 177fb2c2ec69f..7af640c109ed5 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1233,6 +1233,12 @@ pub fn init_rustc_env_logger() { /// log crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var /// other than `RUSTC_LOG`. pub fn init_env_logger(env: &str) { + // Don't register a dispatcher if there's no filter to print anything + match std::env::var(env) { + Err(_) => return, + Ok(s) if s.is_empty() => return, + Ok(_) => {} + } let builder = tracing_subscriber::FmtSubscriber::builder(); let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env(env)); From 011e0ef6362b59a5f8719dbee0a9b603c506f6d5 Mon Sep 17 00:00:00 2001 From: kadmin Date: Fri, 31 Jul 2020 21:12:05 +0000 Subject: [PATCH 62/71] Removed error check in order to prevent ICE --- src/librustc_typeck/variance/constraints.rs | 7 +- src/test/ui/const-generics/nested-type.rs | 18 ++ src/test/ui/const-generics/nested-type.stderr | 159 ++++++++++++++++++ 3 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/const-generics/nested-type.rs create mode 100644 src/test/ui/const-generics/nested-type.stderr diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index cae09267994e3..08a12797a1bcc 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -161,12 +161,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { self.add_constraints_from_sig(current_item, tcx.fn_sig(def_id), self.covariant); } - _ => { - span_bug!( - tcx.def_span(def_id), - "`build_constraints_for_item` unsupported for this item" - ); - } + _ => {} } } diff --git a/src/test/ui/const-generics/nested-type.rs b/src/test/ui/const-generics/nested-type.rs new file mode 100644 index 0000000000000..12ea850c8f686 --- /dev/null +++ b/src/test/ui/const-generics/nested-type.rs @@ -0,0 +1,18 @@ +#![feature(const_generics)] +#![allow(incomplete_features)] + +struct Foo; + + impl Foo { + fn value() -> usize { + N + } + } + + Foo::<17>::value() +}]>; + +fn main() {} diff --git a/src/test/ui/const-generics/nested-type.stderr b/src/test/ui/const-generics/nested-type.stderr new file mode 100644 index 0000000000000..da0e8032404fc --- /dev/null +++ b/src/test/ui/const-generics/nested-type.stderr @@ -0,0 +1,159 @@ +error[E0391]: cycle detected when computing type of `Foo` + --> $DIR/nested-type.rs:4:1 + | +LL | struct Foo $DIR/nested-type.rs:4:18 + | +LL | struct Foo $DIR/nested-type.rs:4:26 + | +LL | struct Foo; +... | +LL | | Foo::<17>::value() +LL | | }]>; + | |_^ +note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`... + --> $DIR/nested-type.rs:4:26 + | +LL | struct Foo; +... | +LL | | Foo::<17>::value() +LL | | }]>; + | |_^ +note: ...which requires const-evaluating `Foo::{{constant}}#0`... + --> $DIR/nested-type.rs:4:26 + | +LL | struct Foo; +... | +LL | | Foo::<17>::value() +LL | | }]>; + | |_^ +note: ...which requires type-checking `Foo::{{constant}}#0`... + --> $DIR/nested-type.rs:4:26 + | +LL | struct Foo; +... | +LL | | Foo::<17>::value() +LL | | }]>; + | |_^ +note: ...which requires computing the variances of `Foo::{{constant}}#0::Foo`... + --> $DIR/nested-type.rs:7:5 + | +LL | struct Foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires computing the variances for items in this crate... + = note: ...which again requires computing type of `Foo`, completing the cycle +note: cycle used when collecting item types in top-level module + --> $DIR/nested-type.rs:1:1 + | +LL | / #![feature(const_generics)] +LL | | #![allow(incomplete_features)] +LL | | +LL | | struct Foo $DIR/nested-type.rs:4:1 + | +LL | struct Foo $DIR/nested-type.rs:4:18 + | +LL | struct Foo $DIR/nested-type.rs:4:26 + | +LL | struct Foo; +... | +LL | | Foo::<17>::value() +LL | | }]>; + | |_^ +note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`... + --> $DIR/nested-type.rs:4:26 + | +LL | struct Foo; +... | +LL | | Foo::<17>::value() +LL | | }]>; + | |_^ +note: ...which requires const-evaluating `Foo::{{constant}}#0`... + --> $DIR/nested-type.rs:4:26 + | +LL | struct Foo; +... | +LL | | Foo::<17>::value() +LL | | }]>; + | |_^ +note: ...which requires type-checking `Foo::{{constant}}#0`... + --> $DIR/nested-type.rs:4:26 + | +LL | struct Foo; +... | +LL | | Foo::<17>::value() +LL | | }]>; + | |_^ +note: ...which requires computing the variances of `Foo::{{constant}}#0::Foo`... + --> $DIR/nested-type.rs:7:5 + | +LL | struct Foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires computing the variances for items in this crate... + = note: ...which again requires computing type of `Foo`, completing the cycle +note: cycle used when collecting item types in top-level module + --> $DIR/nested-type.rs:1:1 + | +LL | / #![feature(const_generics)] +LL | | #![allow(incomplete_features)] +LL | | +LL | | struct Foo Date: Fri, 31 Jul 2020 21:33:55 +0000 Subject: [PATCH 63/71] Added in explicit check for the type being matched --- src/librustc_typeck/variance/constraints.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 08a12797a1bcc..b810c9824ce66 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -161,7 +161,13 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { self.add_constraints_from_sig(current_item, tcx.fn_sig(def_id), self.covariant); } - _ => {} + ty::Error(_) => {} + _ => { + span_bug!( + tcx.def_span(def_id), + "`build_constraints_for_item` unsupported for this item" + ); + } } } From aaffb06c041d282e4eddfd323659e76b55f3781d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 31 Jul 2020 14:47:19 -0700 Subject: [PATCH 64/71] Update the bundled wasi-libc with libstd This just updates WASI libc, in preparation for WASI reactor support in a separate change. --- .../docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh index c82031690ab6a..e9e4a893476a9 100755 --- a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh +++ b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh @@ -9,10 +9,10 @@ curl https://ci-mirrors.rust-lang.org/rustc/clang%2Bllvm-9.0.0-x86_64-linux-gnu- tar xJf - export PATH=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH -git clone https://github.com/CraneStation/wasi-libc +git clone https://github.com/WebAssembly/wasi-libc cd wasi-libc -git reset --hard 9efc2f428358564fe64c374d762d0bfce1d92507 +git reset --hard 215adc8ac9f91eb055311acc72683fd2eb1ae15a make -j$(nproc) INSTALL_DIR=/wasm32-wasi install cd .. From 40e6dccfb4b0e0f21cbc846a70b348132ee4d0f2 Mon Sep 17 00:00:00 2001 From: Valentin Lazureanu Date: Tue, 21 Jul 2020 09:09:27 +0000 Subject: [PATCH 65/71] Rename HAIR to THIR (Typed HIR). --- src/librustc_middle/ty/context.rs | 2 +- src/librustc_mir_build/build/block.rs | 10 ++-- .../build/expr/as_constant.rs | 2 +- .../build/expr/as_operand.rs | 2 +- src/librustc_mir_build/build/expr/as_place.rs | 2 +- .../build/expr/as_rvalue.rs | 2 +- src/librustc_mir_build/build/expr/as_temp.rs | 8 +-- src/librustc_mir_build/build/expr/category.rs | 2 +- src/librustc_mir_build/build/expr/into.rs | 18 +++---- src/librustc_mir_build/build/expr/stmt.rs | 10 ++-- src/librustc_mir_build/build/into.rs | 2 +- src/librustc_mir_build/build/matches/mod.rs | 39 ++++++++------ .../build/matches/simplify.rs | 4 +- src/librustc_mir_build/build/matches/test.rs | 6 +-- src/librustc_mir_build/build/matches/util.rs | 2 +- src/librustc_mir_build/build/mod.rs | 6 +-- src/librustc_mir_build/build/scope.rs | 8 +-- src/librustc_mir_build/lib.rs | 6 +-- .../{hair => thir}/constant.rs | 0 .../{hair => thir}/cx/block.rs | 8 +-- .../{hair => thir}/cx/expr.rs | 12 ++--- .../{hair => thir}/cx/mod.rs | 6 +-- .../{hair => thir}/cx/to_ref.rs | 6 +-- src/librustc_mir_build/{hair => thir}/mod.rs | 20 +++---- .../{hair => thir}/pattern/_match.rs | 0 .../{hair => thir}/pattern/check_match.rs | 0 .../{hair => thir}/pattern/const_to_pat.rs | 0 .../{hair => thir}/pattern/mod.rs | 4 +- src/librustc_mir_build/{hair => thir}/util.rs | 0 src/librustc_typeck/check/pat.rs | 2 +- .../const_constructor/const-construct-call.rs | 2 +- ... half-open-range-pats-thir-lower-empty.rs} | 0 ...f-open-range-pats-thir-lower-empty.stderr} | 52 +++++++++---------- ...k-pat-by-move-and-ref-inverse-promotion.rs | 2 +- src/test/ui/pattern/const-pat-ice.stderr | 2 +- .../clippy/clippy_lints/src/utils/mod.rs | 2 +- 36 files changed, 128 insertions(+), 121 deletions(-) rename src/librustc_mir_build/{hair => thir}/constant.rs (100%) rename src/librustc_mir_build/{hair => thir}/cx/block.rs (96%) rename src/librustc_mir_build/{hair => thir}/cx/expr.rs (99%) rename src/librustc_mir_build/{hair => thir}/cx/mod.rs (98%) rename src/librustc_mir_build/{hair => thir}/cx/to_ref.rs (93%) rename src/librustc_mir_build/{hair => thir}/mod.rs (95%) rename src/librustc_mir_build/{hair => thir}/pattern/_match.rs (100%) rename src/librustc_mir_build/{hair => thir}/pattern/check_match.rs (100%) rename src/librustc_mir_build/{hair => thir}/pattern/const_to_pat.rs (100%) rename src/librustc_mir_build/{hair => thir}/pattern/mod.rs (99%) rename src/librustc_mir_build/{hair => thir}/util.rs (100%) rename src/test/ui/half-open-range-patterns/{half-open-range-pats-hair-lower-empty.rs => half-open-range-pats-thir-lower-empty.rs} (100%) rename src/test/ui/half-open-range-patterns/{half-open-range-pats-hair-lower-empty.stderr => half-open-range-pats-thir-lower-empty.stderr} (69%) diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index d307131a99036..775d755444d7d 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -352,7 +352,7 @@ pub struct TypeckResults<'tcx> { pat_binding_modes: ItemLocalMap, /// Stores the types which were implicitly dereferenced in pattern binding modes - /// for later usage in HAIR lowering. For example, + /// for later usage in THIR lowering. For example, /// /// ``` /// match &&Some(5i32) { diff --git a/src/librustc_mir_build/build/block.rs b/src/librustc_mir_build/build/block.rs index 2be4136ad42a0..d1cbf209b06ce 100644 --- a/src/librustc_mir_build/build/block.rs +++ b/src/librustc_mir_build/build/block.rs @@ -1,7 +1,7 @@ use crate::build::matches::ArmHasGuard; use crate::build::ForGuard::OutsideGuard; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use crate::hair::*; +use crate::thir::*; use rustc_hir as hir; use rustc_middle::mir::*; use rustc_session::lint::builtin::UNSAFE_OP_IN_UNSAFE_FN; @@ -176,7 +176,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let tail_result_is_ignored = destination_ty.is_unit() || this.block_context.currently_ignores_tail_results(); let span = match expr { - ExprRef::Hair(expr) => expr.span, + ExprRef::Thir(expr) => expr.span, ExprRef::Mirror(ref expr) => expr.span, }; this.block_context.push(BlockFrame::TailExpr { tail_result_is_ignored, span }); @@ -235,11 +235,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .push_unsafe_count .checked_sub(1) .unwrap_or_else(|| span_bug!(span, "unsafe count underflow")); - if self.push_unsafe_count == 0 { - Some(self.unpushed_unsafe) - } else { - None - } + if self.push_unsafe_count == 0 { Some(self.unpushed_unsafe) } else { None } } }; diff --git a/src/librustc_mir_build/build/expr/as_constant.rs b/src/librustc_mir_build/build/expr/as_constant.rs index 03ec0b48f8bfe..982aefcf6045c 100644 --- a/src/librustc_mir_build/build/expr/as_constant.rs +++ b/src/librustc_mir_build/build/expr/as_constant.rs @@ -1,7 +1,7 @@ //! See docs in build/expr/mod.rs use crate::build::Builder; -use crate::hair::*; +use crate::thir::*; use rustc_middle::mir::*; use rustc_middle::ty::CanonicalUserTypeAnnotation; diff --git a/src/librustc_mir_build/build/expr/as_operand.rs b/src/librustc_mir_build/build/expr/as_operand.rs index 5949fd1e22ce8..aac93f313f4e1 100644 --- a/src/librustc_mir_build/build/expr/as_operand.rs +++ b/src/librustc_mir_build/build/expr/as_operand.rs @@ -2,7 +2,7 @@ use crate::build::expr::category::Category; use crate::build::{BlockAnd, BlockAndExtension, Builder}; -use crate::hair::*; +use crate::thir::*; use rustc_middle::middle::region; use rustc_middle::mir::*; diff --git a/src/librustc_mir_build/build/expr/as_place.rs b/src/librustc_mir_build/build/expr/as_place.rs index e811d68d5a5f8..1e3e104c2bad6 100644 --- a/src/librustc_mir_build/build/expr/as_place.rs +++ b/src/librustc_mir_build/build/expr/as_place.rs @@ -3,7 +3,7 @@ use crate::build::expr::category::Category; use crate::build::ForGuard::{OutsideGuard, RefWithinGuard}; use crate::build::{BlockAnd, BlockAndExtension, Builder}; -use crate::hair::*; +use crate::thir::*; use rustc_middle::middle::region; use rustc_middle::mir::AssertKind::BoundsCheck; use rustc_middle::mir::*; diff --git a/src/librustc_mir_build/build/expr/as_rvalue.rs b/src/librustc_mir_build/build/expr/as_rvalue.rs index e2217fdfac036..9c5fddc6b77c0 100644 --- a/src/librustc_mir_build/build/expr/as_rvalue.rs +++ b/src/librustc_mir_build/build/expr/as_rvalue.rs @@ -4,7 +4,7 @@ use rustc_index::vec::Idx; use crate::build::expr::category::{Category, RvalueFunc}; use crate::build::{BlockAnd, BlockAndExtension, Builder}; -use crate::hair::*; +use crate::thir::*; use rustc_middle::middle::region; use rustc_middle::mir::AssertKind; use rustc_middle::mir::*; diff --git a/src/librustc_mir_build/build/expr/as_temp.rs b/src/librustc_mir_build/build/expr/as_temp.rs index 901dadd661278..a9cc0cc2f2475 100644 --- a/src/librustc_mir_build/build/expr/as_temp.rs +++ b/src/librustc_mir_build/build/expr/as_temp.rs @@ -2,7 +2,7 @@ use crate::build::scope::DropKind; use crate::build::{BlockAnd, BlockAndExtension, Builder}; -use crate::hair::*; +use crate::thir::*; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_hir as hir; use rustc_middle::middle::region; @@ -67,12 +67,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ExprKind::StaticRef { def_id, .. } => { assert!(!this.hir.tcx().is_thread_local_static(def_id)); local_decl.internal = true; - local_decl.local_info = Some(box LocalInfo::StaticRef { def_id, is_thread_local: false }); + local_decl.local_info = + Some(box LocalInfo::StaticRef { def_id, is_thread_local: false }); } ExprKind::ThreadLocalRef(def_id) => { assert!(this.hir.tcx().is_thread_local_static(def_id)); local_decl.internal = true; - local_decl.local_info = Some(box LocalInfo::StaticRef { def_id, is_thread_local: true }); + local_decl.local_info = + Some(box LocalInfo::StaticRef { def_id, is_thread_local: true }); } _ => {} } diff --git a/src/librustc_mir_build/build/expr/category.rs b/src/librustc_mir_build/build/expr/category.rs index fb4b7997b6a5a..9cabd186d8460 100644 --- a/src/librustc_mir_build/build/expr/category.rs +++ b/src/librustc_mir_build/build/expr/category.rs @@ -1,4 +1,4 @@ -use crate::hair::*; +use crate::thir::*; #[derive(Debug, PartialEq)] crate enum Category { diff --git a/src/librustc_mir_build/build/expr/into.rs b/src/librustc_mir_build/build/expr/into.rs index 36f8034336ba1..c3f54b39a3f38 100644 --- a/src/librustc_mir_build/build/expr/into.rs +++ b/src/librustc_mir_build/build/expr/into.rs @@ -2,7 +2,7 @@ use crate::build::expr::category::{Category, RvalueFunc}; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use crate::hair::*; +use crate::thir::*; use rustc_ast::ast::InlineAsmOptions; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stack::ensure_sufficient_stack; @@ -320,23 +320,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block.unit() } ExprKind::InlineAsm { template, operands, options, line_spans } => { - use crate::hair; + use crate::thir; use rustc_middle::mir; let operands = operands .into_iter() .map(|op| match op { - hair::InlineAsmOperand::In { reg, expr } => mir::InlineAsmOperand::In { + thir::InlineAsmOperand::In { reg, expr } => mir::InlineAsmOperand::In { reg, value: unpack!(block = this.as_local_operand(block, expr)), }, - hair::InlineAsmOperand::Out { reg, late, expr } => { + thir::InlineAsmOperand::Out { reg, late, expr } => { mir::InlineAsmOperand::Out { reg, late, place: expr.map(|expr| unpack!(block = this.as_place(block, expr))), } } - hair::InlineAsmOperand::InOut { reg, late, expr } => { + thir::InlineAsmOperand::InOut { reg, late, expr } => { let place = unpack!(block = this.as_place(block, expr)); mir::InlineAsmOperand::InOut { reg, @@ -346,7 +346,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { out_place: Some(place), } } - hair::InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => { + thir::InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => { mir::InlineAsmOperand::InOut { reg, late, @@ -356,13 +356,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }), } } - hair::InlineAsmOperand::Const { expr } => mir::InlineAsmOperand::Const { + thir::InlineAsmOperand::Const { expr } => mir::InlineAsmOperand::Const { value: unpack!(block = this.as_local_operand(block, expr)), }, - hair::InlineAsmOperand::SymFn { expr } => { + thir::InlineAsmOperand::SymFn { expr } => { mir::InlineAsmOperand::SymFn { value: box this.as_constant(expr) } } - hair::InlineAsmOperand::SymStatic { def_id } => { + thir::InlineAsmOperand::SymStatic { def_id } => { mir::InlineAsmOperand::SymStatic { def_id } } }) diff --git a/src/librustc_mir_build/build/expr/stmt.rs b/src/librustc_mir_build/build/expr/stmt.rs index 49d6ce39ddfa4..f117689d940fd 100644 --- a/src/librustc_mir_build/build/expr/stmt.rs +++ b/src/librustc_mir_build/build/expr/stmt.rs @@ -1,11 +1,11 @@ use crate::build::scope::BreakableTarget; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use crate::hair::*; +use crate::thir::*; use rustc_middle::middle::region; use rustc_middle::mir::*; impl<'a, 'tcx> Builder<'a, 'tcx> { - /// Builds a block of MIR statements to evaluate the HAIR `expr`. + /// Builds a block of MIR statements to evaluate the THIR `expr`. /// If the original expression was an AST statement, /// (e.g., `some().code(&here());`) then `opt_stmt_span` is the /// span of that statement (including its semicolon, if any). @@ -150,8 +150,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { break; } } - this.block_context - .push(BlockFrame::TailExpr { tail_result_is_ignored: true, span: expr.span }); + this.block_context.push(BlockFrame::TailExpr { + tail_result_is_ignored: true, + span: expr.span, + }); return Some(expr.span); } } diff --git a/src/librustc_mir_build/build/into.rs b/src/librustc_mir_build/build/into.rs index 0baa0c833a514..7264e495b84fd 100644 --- a/src/librustc_mir_build/build/into.rs +++ b/src/librustc_mir_build/build/into.rs @@ -5,7 +5,7 @@ //! latter `EvalInto` trait. use crate::build::{BlockAnd, Builder}; -use crate::hair::*; +use crate::thir::*; use rustc_middle::mir::*; pub(in crate::build) trait EvalInto<'tcx> { diff --git a/src/librustc_mir_build/build/matches/mod.rs b/src/librustc_mir_build/build/matches/mod.rs index 19948196f256f..77c0fe8dda534 100644 --- a/src/librustc_mir_build/build/matches/mod.rs +++ b/src/librustc_mir_build/build/matches/mod.rs @@ -9,15 +9,18 @@ use crate::build::scope::DropKind; use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard}; use crate::build::{BlockAnd, BlockAndExtension, Builder}; use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode}; -use crate::hair::{self, *}; -use rustc_data_structures::{fx::{FxHashMap, FxHashSet}, stack::ensure_sufficient_stack}; +use crate::thir::{self, *}; +use rustc_data_structures::{ + fx::{FxHashMap, FxHashSet}, + stack::ensure_sufficient_stack, +}; use rustc_hir::HirId; use rustc_index::bit_set::BitSet; use rustc_middle::middle::region; use rustc_middle::mir::*; use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty}; -use rustc_span::Span; use rustc_span::symbol::Symbol; +use rustc_span::Span; use rustc_target::abi::VariantIdx; use smallvec::{smallvec, SmallVec}; @@ -395,7 +398,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .. }, ascription: - hair::pattern::Ascription { user_ty: pat_ascription_ty, variance: _, user_ty_span }, + thir::pattern::Ascription { user_ty: pat_ascription_ty, variance: _, user_ty_span }, } => { let place = self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard, true); @@ -631,7 +634,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { PatKind::AscribeUserType { ref subpattern, - ascription: hair::pattern::Ascription { ref user_ty, user_ty_span, variance: _ }, + ascription: thir::pattern::Ascription { ref user_ty, user_ty_span, variance: _ }, } => { // This corresponds to something like // @@ -1982,16 +1985,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { source_info, internal: false, is_block_tail: None, - local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm { - binding_mode, - // hypothetically, `visit_primary_bindings` could try to unzip - // an outermost hir::Ty as we descend, matching up - // idents in pat; but complex w/ unclear UI payoff. - // Instead, just abandon providing diagnostic info. - opt_ty_info: None, - opt_match_place, - pat_span, - })))), + local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var( + VarBindingForm { + binding_mode, + // hypothetically, `visit_primary_bindings` could try to unzip + // an outermost hir::Ty as we descend, matching up + // idents in pat; but complex w/ unclear UI payoff. + // Instead, just abandon providing diagnostic info. + opt_ty_info: None, + opt_match_place, + pat_span, + }, + )))), }; let for_arm_body = self.local_decls.push(local); self.var_debug_info.push(VarDebugInfo { @@ -2009,7 +2014,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { source_info, internal: false, is_block_tail: None, - local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::RefForGuard))), + local_info: Some(box LocalInfo::User(ClearCrossCrate::Set( + BindingForm::RefForGuard, + ))), }); self.var_debug_info.push(VarDebugInfo { name, diff --git a/src/librustc_mir_build/build/matches/simplify.rs b/src/librustc_mir_build/build/matches/simplify.rs index 2917a771a2cf8..e584aeb922672 100644 --- a/src/librustc_mir_build/build/matches/simplify.rs +++ b/src/librustc_mir_build/build/matches/simplify.rs @@ -14,7 +14,7 @@ use crate::build::matches::{Ascription, Binding, Candidate, MatchPair}; use crate::build::Builder; -use crate::hair::{self, *}; +use crate::thir::{self, *}; use rustc_attr::{SignedInt, UnsignedInt}; use rustc_hir::RangeEnd; use rustc_middle::mir::interpret::truncate; @@ -108,7 +108,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { match *match_pair.pattern.kind { PatKind::AscribeUserType { ref subpattern, - ascription: hair::pattern::Ascription { variance, user_ty, user_ty_span }, + ascription: thir::pattern::Ascription { variance, user_ty, user_ty_span }, } => { // Apply the type ascription to the value at `match_pair.place`, which is the // value being matched, taking the variance field into account. diff --git a/src/librustc_mir_build/build/matches/test.rs b/src/librustc_mir_build/build/matches/test.rs index 3e7bfc7d59b9b..158ad78a1bf36 100644 --- a/src/librustc_mir_build/build/matches/test.rs +++ b/src/librustc_mir_build/build/matches/test.rs @@ -7,8 +7,8 @@ use crate::build::matches::{Candidate, MatchPair, Test, TestKind}; use crate::build::Builder; -use crate::hair::pattern::compare_const_vals; -use crate::hair::*; +use crate::thir::pattern::compare_const_vals; +use crate::thir::*; use rustc_data_structures::fx::FxHashMap; use rustc_hir::RangeEnd; use rustc_index::bit_set::BitSet; @@ -443,7 +443,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { destination: Some((eq_result, eq_block)), cleanup: Some(cleanup), from_hir_call: false, - fn_span: source_info.span + fn_span: source_info.span, }, ); diff --git a/src/librustc_mir_build/build/matches/util.rs b/src/librustc_mir_build/build/matches/util.rs index 7d89a93129b1b..605396c5eb639 100644 --- a/src/librustc_mir_build/build/matches/util.rs +++ b/src/librustc_mir_build/build/matches/util.rs @@ -1,6 +1,6 @@ use crate::build::matches::MatchPair; use crate::build::Builder; -use crate::hair::*; +use crate::thir::*; use rustc_middle::mir::*; use rustc_middle::ty; use smallvec::SmallVec; diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 2549b90ddfa11..3c4587119cd55 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -1,7 +1,7 @@ use crate::build; use crate::build::scope::DropKind; -use crate::hair::cx::Cx; -use crate::hair::{BindingMode, LintLevel, PatKind}; +use crate::thir::cx::Cx; +use crate::thir::{BindingMode, LintLevel, PatKind}; use rustc_attr::{self as attr, UnwindAttr}; use rustc_errors::ErrorReported; use rustc_hir as hir; @@ -294,7 +294,7 @@ struct Builder<'a, 'tcx> { /// see the `scope` module for more details. scopes: scope::Scopes<'tcx>, - /// The block-context: each time we build the code within an hair::Block, + /// The block-context: each time we build the code within an thir::Block, /// we push a frame here tracking whether we are building a statement or /// if we are pushing the tail expression of the block. This is used to /// embed information in generated temps about whether they were created diff --git a/src/librustc_mir_build/build/scope.rs b/src/librustc_mir_build/build/scope.rs index b8df27094471f..2a03bb78c6b1a 100644 --- a/src/librustc_mir_build/build/scope.rs +++ b/src/librustc_mir_build/build/scope.rs @@ -1,6 +1,6 @@ /*! Managing the scope stack. The scopes are tied to lexical scopes, so as -we descend the HAIR, we push a scope on the stack, build its +we descend the THIR, we push a scope on the stack, build its contents, and then pop it off. Every scope is named by a `region::Scope`. @@ -83,12 +83,12 @@ should go to. */ use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG}; -use crate::hair::{Expr, ExprRef, LintLevel}; -use rustc_middle::middle::region; -use rustc_middle::mir::*; +use crate::thir::{Expr, ExprRef, LintLevel}; use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; use rustc_hir::GeneratorKind; +use rustc_middle::middle::region; +use rustc_middle::mir::*; use rustc_span::{Span, DUMMY_SP}; use std::collections::hash_map::Entry; use std::mem; diff --git a/src/librustc_mir_build/lib.rs b/src/librustc_mir_build/lib.rs index ed154b9dc6f11..30545558933f7 100644 --- a/src/librustc_mir_build/lib.rs +++ b/src/librustc_mir_build/lib.rs @@ -17,13 +17,13 @@ extern crate log; extern crate rustc_middle; mod build; -mod hair; mod lints; +mod thir; use rustc_middle::ty::query::Providers; pub fn provide(providers: &mut Providers) { - providers.check_match = hair::pattern::check_match; - providers.lit_to_const = hair::constant::lit_to_const; + providers.check_match = thir::pattern::check_match; + providers.lit_to_const = thir::constant::lit_to_const; providers.mir_built = build::mir_built; } diff --git a/src/librustc_mir_build/hair/constant.rs b/src/librustc_mir_build/thir/constant.rs similarity index 100% rename from src/librustc_mir_build/hair/constant.rs rename to src/librustc_mir_build/thir/constant.rs diff --git a/src/librustc_mir_build/hair/cx/block.rs b/src/librustc_mir_build/thir/cx/block.rs similarity index 96% rename from src/librustc_mir_build/hair/cx/block.rs rename to src/librustc_mir_build/thir/cx/block.rs index a5381781d1d80..980888df7fee4 100644 --- a/src/librustc_mir_build/hair/cx/block.rs +++ b/src/librustc_mir_build/thir/cx/block.rs @@ -1,6 +1,6 @@ -use crate::hair::cx::to_ref::ToRef; -use crate::hair::cx::Cx; -use crate::hair::{self, *}; +use crate::thir::cx::to_ref::ToRef; +use crate::thir::cx::Cx; +use crate::thir::{self, *}; use rustc_hir as hir; use rustc_middle::middle::region; @@ -71,7 +71,7 @@ fn mirror_stmts<'a, 'tcx>( ty: pattern.ty, span: pattern.span, kind: Box::new(PatKind::AscribeUserType { - ascription: hair::pattern::Ascription { + ascription: thir::pattern::Ascription { user_ty: PatTyProj::from_user_type(user_ty), user_ty_span: ty.span, variance: ty::Variance::Covariant, diff --git a/src/librustc_mir_build/hair/cx/expr.rs b/src/librustc_mir_build/thir/cx/expr.rs similarity index 99% rename from src/librustc_mir_build/hair/cx/expr.rs rename to src/librustc_mir_build/thir/cx/expr.rs index 6e1d8a8fc4012..ea41a66b3e43d 100644 --- a/src/librustc_mir_build/hair/cx/expr.rs +++ b/src/librustc_mir_build/thir/cx/expr.rs @@ -1,8 +1,8 @@ -use crate::hair::cx::block; -use crate::hair::cx::to_ref::ToRef; -use crate::hair::cx::Cx; -use crate::hair::util::UserAnnotatedTyHelpers; -use crate::hair::*; +use crate::thir::cx::block; +use crate::thir::cx::to_ref::ToRef; +use crate::thir::cx::Cx; +use crate::thir::util::UserAnnotatedTyHelpers; +use crate::thir::*; use rustc_hir as hir; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_index::vec::Idx; @@ -1020,7 +1020,7 @@ fn overloaded_place<'a, 'tcx>( // line up (this is because `*x` and `x[y]` represent places): let recv_ty = match args[0] { - ExprRef::Hair(e) => cx.typeck_results().expr_ty_adjusted(e), + ExprRef::Thir(e) => cx.typeck_results().expr_ty_adjusted(e), ExprRef::Mirror(ref e) => e.ty, }; diff --git a/src/librustc_mir_build/hair/cx/mod.rs b/src/librustc_mir_build/thir/cx/mod.rs similarity index 98% rename from src/librustc_mir_build/hair/cx/mod.rs rename to src/librustc_mir_build/thir/cx/mod.rs index 2694cde14fde7..21736df7b0710 100644 --- a/src/librustc_mir_build/hair/cx/mod.rs +++ b/src/librustc_mir_build/thir/cx/mod.rs @@ -1,9 +1,9 @@ //! This module contains the functionality to convert from the wacky tcx data -//! structures into the HAIR. The `builder` is generally ignorant of the tcx, +//! structures into the THIR. The `builder` is generally ignorant of the tcx, //! etc., and instead goes through the `Cx` for most of its work. -use crate::hair::util::UserAnnotatedTyHelpers; -use crate::hair::*; +use crate::thir::util::UserAnnotatedTyHelpers; +use crate::thir::*; use rustc_ast::ast; use rustc_ast::attr; diff --git a/src/librustc_mir_build/hair/cx/to_ref.rs b/src/librustc_mir_build/thir/cx/to_ref.rs similarity index 93% rename from src/librustc_mir_build/hair/cx/to_ref.rs rename to src/librustc_mir_build/thir/cx/to_ref.rs index 6cf8122e200db..53a988ebb79e2 100644 --- a/src/librustc_mir_build/hair/cx/to_ref.rs +++ b/src/librustc_mir_build/thir/cx/to_ref.rs @@ -1,4 +1,4 @@ -use crate::hair::*; +use crate::thir::*; use rustc_hir as hir; @@ -11,7 +11,7 @@ impl<'tcx> ToRef for &'tcx hir::Expr<'tcx> { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { - ExprRef::Hair(self) + ExprRef::Thir(self) } } @@ -19,7 +19,7 @@ impl<'tcx> ToRef for &'tcx &'tcx hir::Expr<'tcx> { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { - ExprRef::Hair(&**self) + ExprRef::Thir(&**self) } } diff --git a/src/librustc_mir_build/hair/mod.rs b/src/librustc_mir_build/thir/mod.rs similarity index 95% rename from src/librustc_mir_build/hair/mod.rs rename to src/librustc_mir_build/thir/mod.rs index ccff510f2d4e5..b6ce7e0b41e54 100644 --- a/src/librustc_mir_build/hair/mod.rs +++ b/src/librustc_mir_build/thir/mod.rs @@ -1,5 +1,5 @@ -//! The MIR is built from some high-level abstract IR -//! (HAIR). This section defines the HAIR along with a trait for +//! The MIR is built from some typed high-level IR +//! (THIR). This section defines the THIR along with a trait for //! accessing it. The intention is to allow MIR construction to be //! unit-tested and separated from the Rust source and compiler data //! structures. @@ -99,18 +99,18 @@ crate enum StmtKind<'tcx> { #[cfg(target_arch = "x86_64")] rustc_data_structures::static_assert_size!(Expr<'_>, 168); -/// The Hair trait implementor lowers their expressions (`&'tcx H::Expr`) +/// The Thir trait implementor lowers their expressions (`&'tcx H::Expr`) /// into instances of this `Expr` enum. This lowering can be done /// basically as lazily or as eagerly as desired: every recursive /// reference to an expression in this enum is an `ExprRef<'tcx>`, which /// may in turn be another instance of this enum (boxed), or else an /// unlowered `&'tcx H::Expr`. Note that instances of `Expr` are very -/// short-lived. They are created by `Hair::to_expr`, analyzed and +/// short-lived. They are created by `Thir::to_expr`, analyzed and /// converted into MIR, and then discarded. /// /// If you compare `Expr` to the full compiler AST, you will see it is /// a good bit simpler. In fact, a number of the more straight-forward -/// MIR simplifications are already done in the impl of `Hair`. For +/// MIR simplifications are already done in the impl of `Thir`. For /// example, method calls and overloaded operators are absent: they are /// expected to be converted into `Expr::Call` instances. #[derive(Clone, Debug)] @@ -302,7 +302,7 @@ crate enum ExprKind<'tcx> { #[derive(Clone, Debug)] crate enum ExprRef<'tcx> { - Hair(&'tcx hir::Expr<'tcx>), + Thir(&'tcx hir::Expr<'tcx>), Mirror(Box>), } @@ -342,7 +342,7 @@ crate enum LogicalOp { impl<'tcx> ExprRef<'tcx> { crate fn span(&self) -> Span { match self { - ExprRef::Hair(expr) => expr.span, + ExprRef::Thir(expr) => expr.span, ExprRef::Mirror(expr) => expr.span, } } @@ -385,7 +385,7 @@ crate enum InlineAsmOperand<'tcx> { // The Mirror trait /// "Mirroring" is the process of converting from a HIR type into one -/// of the HAIR types defined in this file. This is basically a "on +/// of the THIR types defined in this file. This is basically a "on /// the fly" desugaring step that hides a lot of the messiness in the /// tcx. For example, the mirror of a `&'tcx hir::Expr` is an /// `Expr<'tcx>`. @@ -394,7 +394,7 @@ crate enum InlineAsmOperand<'tcx> { /// + e2`, the references to the inner expressions `e1` and `e2` are /// `ExprRef<'tcx>` instances, and they may or may not be eagerly /// mirrored. This allows a single AST node from the compiler to -/// expand into one or more Hair nodes, which lets the Hair nodes be +/// expand into one or more Thir nodes, which lets the Thir nodes be /// simpler. crate trait Mirror<'tcx> { type Output; @@ -415,7 +415,7 @@ impl<'tcx> Mirror<'tcx> for ExprRef<'tcx> { fn make_mirror(self, hir: &mut Cx<'_, 'tcx>) -> Expr<'tcx> { match self { - ExprRef::Hair(h) => h.make_mirror(hir), + ExprRef::Thir(h) => h.make_mirror(hir), ExprRef::Mirror(m) => *m, } } diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/thir/pattern/_match.rs similarity index 100% rename from src/librustc_mir_build/hair/pattern/_match.rs rename to src/librustc_mir_build/thir/pattern/_match.rs diff --git a/src/librustc_mir_build/hair/pattern/check_match.rs b/src/librustc_mir_build/thir/pattern/check_match.rs similarity index 100% rename from src/librustc_mir_build/hair/pattern/check_match.rs rename to src/librustc_mir_build/thir/pattern/check_match.rs diff --git a/src/librustc_mir_build/hair/pattern/const_to_pat.rs b/src/librustc_mir_build/thir/pattern/const_to_pat.rs similarity index 100% rename from src/librustc_mir_build/hair/pattern/const_to_pat.rs rename to src/librustc_mir_build/thir/pattern/const_to_pat.rs diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/thir/pattern/mod.rs similarity index 99% rename from src/librustc_mir_build/hair/pattern/mod.rs rename to src/librustc_mir_build/thir/pattern/mod.rs index 19c86655bd5ed..bdefaadfdfe56 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/thir/pattern/mod.rs @@ -6,7 +6,7 @@ mod const_to_pat; pub(crate) use self::check_match::check_match; -use crate::hair::util::UserAnnotatedTyHelpers; +use crate::thir::util::UserAnnotatedTyHelpers; use rustc_ast::ast; use rustc_errors::struct_span_err; @@ -402,7 +402,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { // // `vec![&&Option, &Option]`. // - // Applying the adjustments, we want to instead output `&&Some(n)` (as a HAIR pattern). So + // Applying the adjustments, we want to instead output `&&Some(n)` (as a THIR pattern). So // we wrap the unadjusted pattern in `PatKind::Deref` repeatedly, consuming the // adjustments in *reverse order* (last-in-first-out, so that the last `Deref` inserted // gets the least-dereferenced type). diff --git a/src/librustc_mir_build/hair/util.rs b/src/librustc_mir_build/thir/util.rs similarity index 100% rename from src/librustc_mir_build/hair/util.rs rename to src/librustc_mir_build/thir/util.rs diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 42170bc199cbc..9c7ea34bf51b6 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -345,7 +345,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("inspecting {:?}", expected); debug!("current discriminant is Ref, inserting implicit deref"); - // Preserve the reference type. We'll need it later during HAIR lowering. + // Preserve the reference type. We'll need it later during THIR lowering. pat_adjustments.push(expected); expected = inner_ty; diff --git a/src/test/ui/consts/const_constructor/const-construct-call.rs b/src/test/ui/consts/const_constructor/const-construct-call.rs index d883d3fa6e40e..d3e6cf78bc93b 100644 --- a/src/test/ui/consts/const_constructor/const-construct-call.rs +++ b/src/test/ui/consts/const_constructor/const-construct-call.rs @@ -6,7 +6,7 @@ #![cfg_attr(const_fn, feature(const_fn))] -// Ctor(..) is transformed to Ctor { 0: ... } in HAIR lowering, so directly +// Ctor(..) is transformed to Ctor { 0: ... } in THIR lowering, so directly // calling constructors doesn't require them to be const. type ExternalType = std::panic::AssertUnwindSafe<(Option, Result)>; diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs similarity index 100% rename from src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.rs rename to src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr similarity index 69% rename from src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.stderr rename to src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr index b536e1b5548d0..12ad86429613b 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.stderr +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr @@ -1,155 +1,155 @@ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:12:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:12:11 | LL | m!(0, ..core::u8::MIN); | ^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:15:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11 | LL | m!(0, ..core::u16::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:18:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:18:11 | LL | m!(0, ..core::u32::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:21:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:21:11 | LL | m!(0, ..core::u64::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:24:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11 | LL | m!(0, ..core::u128::MIN); | ^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:28:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11 | LL | m!(0, ..core::i8::MIN); | ^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:31:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:31:11 | LL | m!(0, ..core::i16::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:34:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:34:11 | LL | m!(0, ..core::i32::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:37:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:37:11 | LL | m!(0, ..core::i64::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:40:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:40:11 | LL | m!(0, ..core::i128::MIN); | ^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:44:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:44:14 | LL | m!(0f32, ..core::f32::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:47:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:47:14 | LL | m!(0f64, ..core::f64::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:51:13 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:51:13 | LL | m!('a', ..'\u{0}'); | ^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:12:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:12:11 | LL | m!(0, ..core::u8::MIN); | ^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:15:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11 | LL | m!(0, ..core::u16::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:18:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:18:11 | LL | m!(0, ..core::u32::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:21:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:21:11 | LL | m!(0, ..core::u64::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:24:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11 | LL | m!(0, ..core::u128::MIN); | ^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:28:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11 | LL | m!(0, ..core::i8::MIN); | ^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:31:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:31:11 | LL | m!(0, ..core::i16::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:34:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:34:11 | LL | m!(0, ..core::i32::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:37:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:37:11 | LL | m!(0, ..core::i64::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:40:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:40:11 | LL | m!(0, ..core::i128::MIN); | ^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:44:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:44:14 | LL | m!(0f32, ..core::f32::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:47:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:47:14 | LL | m!(0f64, ..core::f64::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:51:13 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:51:13 | LL | m!('a', ..'\u{0}'); | ^^^^^^^^^ diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.rs index 1479791719313..993954b450e37 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.rs @@ -1,5 +1,5 @@ // Test that `by_move_binding @ pat_with_by_ref_bindings` is prevented even with promotion. -// Currently this logic exists in HAIR match checking as opposed to borrowck. +// Currently this logic exists in THIR match checking as opposed to borrowck. #![feature(bindings_after_at)] #![feature(move_ref_pattern)] diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 6e87e5c6912c3..2aa0824f30186 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -1,4 +1,4 @@ -thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir_build/hair/pattern/_match.rs:LL:CC +thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir_build/thir/pattern/_match.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index 655b1133cf74f..3f8e15d90297d 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -883,7 +883,7 @@ pub fn is_ctor_or_promotable_const_function(cx: &LateContext<'_>, expr: &Expr<'_ } /// Returns `true` if a pattern is refutable. -// TODO: should be implemented using rustc/mir_build/hair machinery +// TODO: should be implemented using rustc/mir_build/thir machinery pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool { fn is_enum_variant(cx: &LateContext<'_>, qpath: &QPath<'_>, id: HirId) -> bool { matches!( From 9ade8366c076f1b40d846b5ed76c141d48beb70d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 31 Jul 2020 16:07:08 -0700 Subject: [PATCH 66/71] Update the WASI libc build to LLVM 10. Among other things, this brings in [the `__main_argc_argv`] patch, which simplifies the interaction between the compiler and WASI libc's startup code, which will help work on reactor support. [the `__main_argc_argv` patch]: https://github.com/llvm/llvm-project/commit/00072c08c75050ae2c835b7bb0e505475dbcd7b9 --- .../host-x86_64/dist-various-2/build-wasi-toolchain.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh index c82031690ab6a..496639e83db2a 100755 --- a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh +++ b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh @@ -4,10 +4,10 @@ set -ex -# Originally from https://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz -curl https://ci-mirrors.rust-lang.org/rustc/clang%2Bllvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \ +# Originally from https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz +curl https://ci-mirrors.rust-lang.org/rustc/clang%2Bllvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz | \ tar xJf - -export PATH=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH +export PATH=`pwd`/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin:$PATH git clone https://github.com/CraneStation/wasi-libc From 21cab87f08604021bd031b4133287a18b18e359f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 1 Aug 2020 01:41:36 +0200 Subject: [PATCH 67/71] submodules: update cargo from 974eb438d to 2d5c2381e Changes: ```` Use the same index location on nightly as beta relax deprecated diagnostic message check Don't print to raw stderr in test Emit the `test` field in cargo metadata ```` --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 974eb438da8ce..2d5c2381e4e50 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 974eb438da8ced6e3becda2bbf63d9b643eacdeb +Subproject commit 2d5c2381e4e50484bf281fc1bfe19743aa9eb37a From aba0251c78f88b12c499ba956beb8a9734ffdc1a Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 31 Jul 2020 18:40:25 +0200 Subject: [PATCH 68/71] Replace a recursive algorithm with an iterative one and a stack. --- src/librustc_mir/transform/simplify.rs | 69 ++++++++++++++++---------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index 491c37cbe06e8..9288d6e16f5e0 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -33,6 +33,7 @@ use rustc_index::vec::{Idx, IndexVec}; use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; +use smallvec::SmallVec; use std::borrow::Cow; pub struct SimplifyCfg { @@ -172,9 +173,12 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { } } - // Collapse a goto chain starting from `start` - fn collapse_goto_chain(&mut self, start: &mut BasicBlock, changed: &mut bool) { - let mut terminator = match self.basic_blocks[*start] { + /// This function will return `None` if + /// * the block has statements + /// * the block has a terminator other than `goto` + /// * the block has no terminator (meaning some other part of the current optimization stole it) + fn take_terminator_if_simple_goto(&mut self, bb: BasicBlock) -> Option> { + match self.basic_blocks[bb] { BasicBlockData { ref statements, terminator: @@ -183,32 +187,45 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { } if statements.is_empty() => terminator.take(), // if `terminator` is None, this means we are in a loop. In that // case, let all the loop collapse to its entry. - _ => return, - }; - - let target = match terminator { - Some(Terminator { kind: TerminatorKind::Goto { ref mut target }, .. }) => { - self.collapse_goto_chain(target, changed); - *target - } - _ => unreachable!(), - }; - self.basic_blocks[*start].terminator = terminator; - - debug!("collapsing goto chain from {:?} to {:?}", *start, target); - - *changed |= *start != target; + _ => None, + } + } - if self.pred_count[*start] == 1 { - // This is the last reference to *start, so the pred-count to - // to target is moved into the current block. - self.pred_count[*start] = 0; - } else { - self.pred_count[target] += 1; - self.pred_count[*start] -= 1; + /// Collapse a goto chain starting from `start` + fn collapse_goto_chain(&mut self, start: &mut BasicBlock, changed: &mut bool) { + // Using `SmallVec` here, because in some logs on libcore oli-obk saw many single-element + // goto chains. We should probably benchmark different sizes. + let mut terminators: SmallVec<[_; 1]> = Default::default(); + let mut current = *start; + while let Some(terminator) = self.take_terminator_if_simple_goto(current) { + let target = match terminator { + Terminator { kind: TerminatorKind::Goto { target }, .. } => target, + _ => unreachable!(), + }; + terminators.push((current, terminator)); + current = target; } + let last = current; + *start = last; + while let Some((current, mut terminator)) = terminators.pop() { + let target = match terminator { + Terminator { kind: TerminatorKind::Goto { ref mut target }, .. } => target, + _ => unreachable!(), + }; + *target = last; + debug!("collapsing goto chain from {:?} to {:?}", current, target); - *start = target; + if self.pred_count[current] == 1 { + // This is the last reference to current, so the pred-count to + // to target is moved into the current block. + self.pred_count[current] = 0; + } else { + self.pred_count[*target] += 1; + self.pred_count[current] -= 1; + } + *changed = true; + self.basic_blocks[current].terminator = Some(terminator); + } } // merge a block with 1 `goto` predecessor to its parent From d51b71a35a816f4be56f77d1d1a6f4095352649e Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Sat, 1 Aug 2020 07:49:24 +0200 Subject: [PATCH 69/71] add tracking issue --- library/alloc/src/slice.rs | 2 +- library/core/src/slice/mod.rs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index 0bb64d6bb6f02..b791c775548cd 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -95,7 +95,7 @@ use crate::borrow::ToOwned; use crate::boxed::Box; use crate::vec::Vec; -#[unstable(feature = "array_chunks", issue = "none")] +#[unstable(feature = "array_chunks", issue = "74985")] pub use core::slice::ArrayChunks; #[stable(feature = "slice_get_slice", since = "1.28.0")] pub use core::slice::SliceIndex; diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index d2d42d4be4b57..93608a1ce4864 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -868,7 +868,7 @@ impl [T] { /// ``` /// /// [`chunks_exact`]: #method.chunks_exact - #[unstable(feature = "array_chunks", issue = "none")] + #[unstable(feature = "array_chunks", issue = "74985")] #[inline] pub fn array_chunks(&self) -> ArrayChunks<'_, T, N> { assert_ne!(N, 0); @@ -5484,7 +5484,7 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> { /// [`remainder`]: ../../std/slice/struct.ArrayChunks.html#method.remainder /// [slices]: ../../std/primitive.slice.html #[derive(Debug)] -#[unstable(feature = "array_chunks", issue = "none")] +#[unstable(feature = "array_chunks", issue = "74985")] pub struct ArrayChunks<'a, T: 'a, const N: usize> { iter: Iter<'a, [T; N]>, rem: &'a [T], @@ -5494,21 +5494,21 @@ impl<'a, T, const N: usize> ArrayChunks<'a, T, N> { /// Returns the remainder of the original slice that is not going to be /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. - #[unstable(feature = "array_chunks", issue = "none")] + #[unstable(feature = "array_chunks", issue = "74985")] pub fn remainder(&self) -> &'a [T] { self.rem } } // FIXME(#26925) Remove in favor of `#[derive(Clone)]` -#[unstable(feature = "array_chunks", issue = "none")] +#[unstable(feature = "array_chunks", issue = "74985")] impl Clone for ArrayChunks<'_, T, N> { fn clone(&self) -> Self { ArrayChunks { iter: self.iter.clone(), rem: self.rem } } } -#[unstable(feature = "array_chunks", issue = "none")] +#[unstable(feature = "array_chunks", issue = "74985")] impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> { type Item = &'a [T; N]; @@ -5538,7 +5538,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> { } } -#[unstable(feature = "array_chunks", issue = "none")] +#[unstable(feature = "array_chunks", issue = "74985")] impl<'a, T, const N: usize> DoubleEndedIterator for ArrayChunks<'a, T, N> { #[inline] fn next_back(&mut self) -> Option<&'a [T; N]> { @@ -5551,7 +5551,7 @@ impl<'a, T, const N: usize> DoubleEndedIterator for ArrayChunks<'a, T, N> { } } -#[unstable(feature = "array_chunks", issue = "none")] +#[unstable(feature = "array_chunks", issue = "74985")] impl ExactSizeIterator for ArrayChunks<'_, T, N> { fn is_empty(&self) -> bool { self.iter.is_empty() @@ -5561,11 +5561,11 @@ impl ExactSizeIterator for ArrayChunks<'_, T, N> { #[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for ArrayChunks<'_, T, N> {} -#[unstable(feature = "array_chunks", issue = "none")] +#[unstable(feature = "array_chunks", issue = "74985")] impl FusedIterator for ArrayChunks<'_, T, N> {} #[doc(hidden)] -#[unstable(feature = "array_chunks", issue = "none")] +#[unstable(feature = "array_chunks", issue = "74985")] unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunks<'a, T, N> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T; N] { unsafe { self.iter.get_unchecked(i) } From 4bd313fb0fd3436058c10c95958f3eb80125a2a3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 1 Aug 2020 15:19:00 +0200 Subject: [PATCH 70/71] Clean up E0743 explanation --- src/librustc_error_codes/error_codes/E0743.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0743.md b/src/librustc_error_codes/error_codes/E0743.md index 1780fe59cbd69..ddd3136df0c39 100644 --- a/src/librustc_error_codes/error_codes/E0743.md +++ b/src/librustc_error_codes/error_codes/E0743.md @@ -8,10 +8,9 @@ Erroneous code example: fn foo2(x: u8, y: &...) {} // error! ``` -Only foreign functions can use the C-variadic type (`...`). -In such functions, `...` may only occur non-nested. -That is, `y: &'a ...` is not allowed. +Only foreign functions can use the C-variadic type (`...`). In such functions, +`...` may only occur non-nested. That is, `y: &'a ...` is not allowed. -A C-variadic type is used to give an undefined number -of parameters to a given function (like `printf` in C). -The equivalent in Rust would be to use macros directly. +A C-variadic type is used to give an undefined number of parameters to a given +function (like `printf` in C). The equivalent in Rust would be to use macros +directly (like `println!` for example). From c7290379be40f930802f0deea87cdb313332e5cc Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sat, 1 Aug 2020 16:24:52 +0200 Subject: [PATCH 71/71] Remove chrono feature from tracing --- Cargo.lock | 1 - src/librustc_driver/Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 46b13db01029f..7e90b7e6fba1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5004,7 +5004,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7b33f8b2ef2ab0c3778c12646d9c42a24f7772bee4cdafc72199644a9f58fdc" dependencies = [ "ansi_term 0.12.1", - "chrono", "lazy_static", "matchers", "parking_lot 0.9.0", diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index 2f6c2c6c22c23..6474a69b216a9 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["dylib"] lazy_static = "1.0" libc = "0.2" log = { package = "tracing", version = "0.1.18", features = ["release_max_level_info"] } -tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi", "chrono"] } +tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] } rustc_middle = { path = "../librustc_middle" } rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_target = { path = "../librustc_target" }