From 049f6eaa792fbbf2b727fc278ddd23d1e11d57bd Mon Sep 17 00:00:00 2001 From: Alexis Bourget Date: Fri, 12 Jun 2020 23:52:52 +0200 Subject: [PATCH 01/28] Fixing broken link for the Eq trait --- src/libcore/cmp.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 9856efc6bd8a4..79085740119bd 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -35,7 +35,7 @@ use self::Ordering::*; /// /// This trait allows for partial equality, for types that do not have a full /// equivalence relation. For example, in floating point numbers `NaN != NaN`, -/// so floating point types implement `PartialEq` but not [`Eq`]. +/// so floating point types implement `PartialEq` but not [`Eq`](Eq). /// /// Formally, the equality must be (for all `a`, `b` and `c`): /// @@ -191,7 +191,6 @@ use self::Ordering::*; /// assert_eq!(x.eq(&y), false); /// ``` /// -/// [`Eq`]: Eq /// [`eq`]: PartialEq::eq /// [`ne`]: PartialEq::ne #[lang = "eq"] From f25811e34bf89c3dde760d826ad4662c245be202 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 5 Jul 2020 22:58:46 +0300 Subject: [PATCH 02/28] Replace early-bound normalization hack with per-query key/value type aliases. --- .../rmeta/decoder/cstore_impl.rs | 9 +++----- src/librustc_middle/ty/query/plumbing.rs | 23 +++++++++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs index abbe45fe02e25..a1c586b3283c2 100644 --- a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs +++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs @@ -17,7 +17,6 @@ use rustc_middle::middle::cstore::{CrateSource, CrateStore, EncodedMetadata}; use rustc_middle::middle::exported_symbols::ExportedSymbol; use rustc_middle::middle::stability::DeprecationEntry; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::query::QueryConfig; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::utils::NativeLibKind; use rustc_session::{CrateDisambiguator, Session}; @@ -32,12 +31,10 @@ macro_rules! provide { (<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $($name:ident => $compute:block)*) => { pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) { - // HACK(eddyb) `$lt: $lt` forces `$lt` to be early-bound, which - // allows the associated type in the return type to be normalized. - $(fn $name<$lt: $lt, T: IntoArgs>( + $(fn $name<$lt>( $tcx: TyCtxt<$lt>, - def_id_arg: T, - ) -> as QueryConfig>>::Value { + def_id_arg: ty::query::query_keys::$name<$lt>, + ) -> ty::query::query_values::$name<$lt> { let _prof_timer = $tcx.prof.generic_activity("metadata_decode_entry"); diff --git a/src/librustc_middle/ty/query/plumbing.rs b/src/librustc_middle/ty/query/plumbing.rs index c711de9476e9d..de79a33fac462 100644 --- a/src/librustc_middle/ty/query/plumbing.rs +++ b/src/librustc_middle/ty/query/plumbing.rs @@ -318,15 +318,34 @@ macro_rules! define_queries_inner { } } + #[allow(nonstandard_style)] pub mod queries { use std::marker::PhantomData; - $(#[allow(nonstandard_style)] - pub struct $name<$tcx> { + $(pub struct $name<$tcx> { data: PhantomData<&$tcx ()> })* } + // HACK(eddyb) this is like the `impl QueryConfig for queries::$name` + // below, but using type aliases instead of associated types, to bypass + // the limitations around normalizing under HRTB - for example, this: + // `for<'tcx> fn(...) -> as QueryConfig>>::Value` + // doesn't currently normalize to `for<'tcx> fn(...) -> query_values::$name<'tcx>`. + // This is primarily used by the `provide!` macro in `rustc_metadata`. + #[allow(nonstandard_style, unused_lifetimes)] + pub mod query_keys { + use super::*; + + $(pub type $name<$tcx> = $($K)*;)* + } + #[allow(nonstandard_style, unused_lifetimes)] + pub mod query_values { + use super::*; + + $(pub type $name<$tcx> = $V;)* + } + $(impl<$tcx> QueryConfig> for queries::$name<$tcx> { type Key = $($K)*; type Value = $V; From f07100afc8650101ac924d728521e1a5d0ce9080 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 5 Jul 2020 23:00:14 +0300 Subject: [PATCH 03/28] Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>. --- src/librustc_codegen_llvm/attributes.rs | 4 ++-- src/librustc_codegen_llvm/lib.rs | 4 ++-- .../back/symbol_export.rs | 8 +++---- src/librustc_codegen_ssa/base.rs | 2 +- src/librustc_codegen_ssa/lib.rs | 4 ++-- src/librustc_codegen_ssa/traits/backend.rs | 4 ++-- src/librustc_interface/interface.rs | 4 ++-- src/librustc_interface/passes.rs | 4 ++-- src/librustc_interface/proc_macro_decls.rs | 2 +- src/librustc_lint/levels.rs | 2 +- src/librustc_lint/lib.rs | 2 +- .../rmeta/decoder/cstore_impl.rs | 4 ++-- src/librustc_middle/hir/map/mod.rs | 2 +- src/librustc_middle/hir/mod.rs | 2 +- src/librustc_middle/ty/context.rs | 6 +++--- src/librustc_middle/ty/erase_regions.rs | 2 +- src/librustc_middle/ty/layout.rs | 2 +- src/librustc_middle/ty/mod.rs | 2 +- src/librustc_middle/ty/query/plumbing.rs | 21 +++++++++++-------- src/librustc_middle/util/bug.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 2 +- src/librustc_mir/const_eval/fn_queries.rs | 2 +- src/librustc_mir/lib.rs | 2 +- src/librustc_mir/monomorphize/partitioning.rs | 6 +++--- src/librustc_mir/shim.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 2 +- .../transform/instrument_coverage.rs | 2 +- src/librustc_mir/transform/mod.rs | 2 +- src/librustc_mir_build/lib.rs | 2 +- src/librustc_passes/check_attr.rs | 2 +- src/librustc_passes/check_const.rs | 2 +- src/librustc_passes/diagnostic_items.rs | 2 +- src/librustc_passes/entry.rs | 2 +- src/librustc_passes/intrinsicck.rs | 2 +- src/librustc_passes/lang_items.rs | 2 +- src/librustc_passes/lib.rs | 2 +- src/librustc_passes/lib_features.rs | 2 +- src/librustc_passes/liveness.rs | 2 +- src/librustc_passes/loops.rs | 2 +- src/librustc_passes/reachable.rs | 2 +- src/librustc_passes/region.rs | 2 +- src/librustc_passes/stability.rs | 2 +- src/librustc_passes/upvars.rs | 2 +- src/librustc_plugin_impl/build.rs | 2 +- src/librustc_privacy/lib.rs | 2 +- src/librustc_resolve/late/lifetimes.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_symbol_mangling/lib.rs | 2 +- src/librustc_trait_selection/traits/mod.rs | 2 +- .../traits/object_safety.rs | 2 +- .../traits/structural_match.rs | 2 +- src/librustc_traits/chalk/mod.rs | 2 +- src/librustc_traits/dropck_outlives.rs | 2 +- src/librustc_traits/evaluate_obligation.rs | 2 +- .../implied_outlives_bounds.rs | 2 +- src/librustc_traits/lib.rs | 2 +- .../normalize_erasing_regions.rs | 2 +- .../normalize_projection_ty.rs | 2 +- src/librustc_traits/type_op.rs | 2 +- src/librustc_ty/common_traits.rs | 2 +- src/librustc_ty/instance.rs | 2 +- src/librustc_ty/lib.rs | 2 +- src/librustc_ty/needs_drop.rs | 2 +- src/librustc_ty/ty.rs | 2 +- src/librustc_typeck/check/method/mod.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 2 +- src/librustc_typeck/check/method/suggest.rs | 2 +- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/coherence/mod.rs | 2 +- src/librustc_typeck/collect.rs | 2 +- src/librustc_typeck/impl_wf_check.rs | 2 +- src/librustc_typeck/lib.rs | 2 +- src/librustc_typeck/outlives/mod.rs | 2 +- src/librustc_typeck/variance/mod.rs | 2 +- 74 files changed, 99 insertions(+), 96 deletions(-) diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index 6234ade8a1612..c53a64664a639 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -342,7 +342,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty:: } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.target_features_whitelist = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); if tcx.sess.opts.actually_rustdoc { @@ -360,7 +360,7 @@ pub fn provide(providers: &mut Providers<'_>) { provide_extern(providers); } -pub fn provide_extern(providers: &mut Providers<'_>) { +pub fn provide_extern(providers: &mut Providers) { providers.wasm_import_module_map = |tcx, cnum| { // Build up a map from DefId to a `NativeLib` structure, where // `NativeLib` internally contains information about diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 565968f9952e5..67d4b2642c058 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -241,11 +241,11 @@ impl CodegenBackend for LlvmCodegenBackend { Box::new(metadata::LlvmMetadataLoader) } - fn provide(&self, providers: &mut ty::query::Providers<'_>) { + fn provide(&self, providers: &mut ty::query::Providers) { attributes::provide(providers); } - fn provide_extern(&self, providers: &mut ty::query::Providers<'_>) { + fn provide_extern(&self, providers: &mut ty::query::Providers) { attributes::provide_extern(providers); } diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index 217ad57ddc9c3..2efbfcb995027 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -161,9 +161,9 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b } fn exported_symbols_provider_local( - tcx: TyCtxt<'_>, + tcx: TyCtxt<'tcx>, cnum: CrateNum, -) -> &'tcx [(ExportedSymbol<'_>, SymbolExportLevel)] { +) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] { assert_eq!(cnum, LOCAL_CRATE); if !tcx.sess.opts.output_types.should_codegen() { @@ -366,7 +366,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> b } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.reachable_non_generics = reachable_non_generics_provider; providers.is_reachable_non_generic = is_reachable_non_generic_provider_local; providers.exported_symbols = exported_symbols_provider_local; @@ -375,7 +375,7 @@ pub fn provide(providers: &mut Providers<'_>) { providers.upstream_drop_glue_for = upstream_drop_glue_for_provider; } -pub fn provide_extern(providers: &mut Providers<'_>) { +pub fn provide_extern(providers: &mut Providers) { providers.is_reachable_non_generic = is_reachable_non_generic_provider_extern; providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider; } diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 5b14258bd25be..4e257fba44ab6 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -853,7 +853,7 @@ impl CrateInfo { } } -pub fn provide_both(providers: &mut Providers<'_>) { +pub fn provide_both(providers: &mut Providers) { providers.backend_optimization_level = |tcx, cratenum| { let for_speed = match tcx.sess.opts.optimize { // If globally no optimisation is done, #[optimize] has no effect. diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index 618df15f5bcbe..bdd73c0831352 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -138,12 +138,12 @@ pub struct CodegenResults { pub crate_info: CrateInfo, } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { crate::back::symbol_export::provide(providers); crate::base::provide_both(providers); } -pub fn provide_extern(providers: &mut Providers<'_>) { +pub fn provide_extern(providers: &mut Providers) { crate::back::symbol_export::provide_extern(providers); crate::base::provide_both(providers); } diff --git a/src/librustc_codegen_ssa/traits/backend.rs b/src/librustc_codegen_ssa/traits/backend.rs index 6cbb47efa99f2..3522ea0115334 100644 --- a/src/librustc_codegen_ssa/traits/backend.rs +++ b/src/librustc_codegen_ssa/traits/backend.rs @@ -55,8 +55,8 @@ pub trait CodegenBackend { fn print_version(&self) {} fn metadata_loader(&self) -> Box; - fn provide(&self, _providers: &mut Providers<'_>); - fn provide_extern(&self, _providers: &mut Providers<'_>); + fn provide(&self, _providers: &mut Providers); + fn provide_extern(&self, _providers: &mut Providers); fn codegen_crate<'tcx>( &self, tcx: TyCtxt<'tcx>, diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index 920cc6021e687..570104e09b842 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -38,7 +38,7 @@ pub struct Compiler { pub(crate) crate_name: Option, pub(crate) register_lints: Option>, pub(crate) override_queries: - Option, &mut ty::query::Providers<'_>)>, + Option, } impl Compiler { @@ -153,7 +153,7 @@ pub struct Config { /// /// The second parameter is local providers and the third parameter is external providers. pub override_queries: - Option, &mut ty::query::Providers<'_>)>, + Option, /// Registry of diagnostics codes. pub registry: Registry, diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index ed5e715ce7084..6d85c2f182544 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -719,7 +719,7 @@ pub fn prepare_outputs( Ok(outputs) } -pub fn default_provide(providers: &mut ty::query::Providers<'_>) { +pub fn default_provide(providers: &mut ty::query::Providers) { providers.analysis = analysis; proc_macro_decls::provide(providers); plugin::build::provide(providers); @@ -740,7 +740,7 @@ pub fn default_provide(providers: &mut ty::query::Providers<'_>) { rustc_codegen_ssa::provide(providers); } -pub fn default_provide_extern(providers: &mut ty::query::Providers<'_>) { +pub fn default_provide_extern(providers: &mut ty::query::Providers) { rustc_metadata::provide_extern(providers); rustc_codegen_ssa::provide_extern(providers); } diff --git a/src/librustc_interface/proc_macro_decls.rs b/src/librustc_interface/proc_macro_decls.rs index c74cba81ca907..e91003b450c3c 100644 --- a/src/librustc_interface/proc_macro_decls.rs +++ b/src/librustc_interface/proc_macro_decls.rs @@ -35,6 +35,6 @@ impl<'v> ItemLikeVisitor<'v> for Finder { fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'_>) {} } -pub(crate) fn provide(providers: &mut Providers<'_>) { +pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { proc_macro_decls_static, ..*providers }; } diff --git a/src/librustc_lint/levels.rs b/src/librustc_lint/levels.rs index f875e2750a5c5..2e9cd962a7401 100644 --- a/src/librustc_lint/levels.rs +++ b/src/librustc_lint/levels.rs @@ -571,6 +571,6 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> { } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.lint_levels = lint_levels; } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 45a86cf2cc6cc..89e6803e67a2b 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -88,7 +88,7 @@ pub use rustc_session::lint::Level::{self, *}; pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId}; pub use rustc_session::lint::{LintArray, LintPass}; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { levels::provide(providers); *providers = Providers { lint_mod, ..*providers }; } diff --git a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs index a1c586b3283c2..201a32d387779 100644 --- a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs +++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs @@ -30,7 +30,7 @@ use std::any::Any; macro_rules! provide { (<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $($name:ident => $compute:block)*) => { - pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) { + pub fn provide_extern(providers: &mut Providers) { $(fn $name<$lt>( $tcx: TyCtxt<$lt>, def_id_arg: ty::query::query_keys::$name<$lt>, @@ -240,7 +240,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, crate_extern_paths => { cdata.source().paths().cloned().collect() } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { // FIXME(#44234) - almost all of these queries have no sub-queries and // therefore no actual inputs, they're just reading tables calculated in // resolve! Does this work? Unsure! That's what the issue is about diff --git a/src/librustc_middle/hir/map/mod.rs b/src/librustc_middle/hir/map/mod.rs index 75c10de9bbe5e..250f4d5187f2f 100644 --- a/src/librustc_middle/hir/map/mod.rs +++ b/src/librustc_middle/hir/map/mod.rs @@ -1067,6 +1067,6 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String { } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.def_kind = |tcx, def_id| tcx.hir().def_kind(def_id.expect_local()); } diff --git a/src/librustc_middle/hir/mod.rs b/src/librustc_middle/hir/mod.rs index e152d11c081a1..485f9b7ce8a6c 100644 --- a/src/librustc_middle/hir/mod.rs +++ b/src/librustc_middle/hir/mod.rs @@ -62,7 +62,7 @@ impl<'tcx> TyCtxt<'tcx> { } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.parent_module_from_def_id = |tcx, id| { let hir = tcx.hir(); hir.local_def_id(hir.get_module_parent_node(hir.as_local_hir_id(id))) diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index d942c07965a49..cb2a6a231a716 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -1060,8 +1060,8 @@ impl<'tcx> TyCtxt<'tcx> { pub fn create_global_ctxt( s: &'tcx Session, lint_store: Lrc, - local_providers: ty::query::Providers<'tcx>, - extern_providers: ty::query::Providers<'tcx>, + local_providers: ty::query::Providers, + extern_providers: ty::query::Providers, arena: &'tcx WorkerLocal>, resolutions: ty::ResolverOutputs, krate: &'tcx hir::Crate<'tcx>, @@ -2699,7 +2699,7 @@ fn ptr_eq(t: *const T, u: *const U) -> bool { t as *const () == u as *const () } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id); providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).map(|v| &v[..]); providers.crate_name = |tcx, id| { diff --git a/src/librustc_middle/ty/erase_regions.rs b/src/librustc_middle/ty/erase_regions.rs index ba165925b6474..48d0fc1839e2f 100644 --- a/src/librustc_middle/ty/erase_regions.rs +++ b/src/librustc_middle/ty/erase_regions.rs @@ -1,7 +1,7 @@ use crate::ty::fold::{TypeFoldable, TypeFolder}; use crate::ty::{self, Ty, TyCtxt, TypeFlags}; -pub(super) fn provide(providers: &mut ty::query::Providers<'_>) { +pub(super) fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { erase_regions_ty, ..*providers }; } diff --git a/src/librustc_middle/ty/layout.rs b/src/librustc_middle/ty/layout.rs index 39b8566e7a873..73ab54db59f0e 100644 --- a/src/librustc_middle/ty/layout.rs +++ b/src/librustc_middle/ty/layout.rs @@ -210,7 +210,7 @@ fn layout_raw<'tcx>( }) } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { layout_raw, ..*providers }; } diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 03aab2c0f9f2c..6b405f77b2e8b 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -2864,7 +2864,7 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option { None } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { context::provide(providers); erase_regions::provide(providers); layout::provide(providers); diff --git a/src/librustc_middle/ty/query/plumbing.rs b/src/librustc_middle/ty/query/plumbing.rs index de79a33fac462..f3fa3634026fd 100644 --- a/src/librustc_middle/ty/query/plumbing.rs +++ b/src/librustc_middle/ty/query/plumbing.rs @@ -497,13 +497,16 @@ macro_rules! define_queries_inner { input: ($(([$($modifiers)*] [$name] [$($K)*] [$V]))*) } - impl<$tcx> Copy for Providers<$tcx> {} - impl<$tcx> Clone for Providers<$tcx> { + impl Copy for Providers {} + impl Clone for Providers { fn clone(&self) -> Self { *self } } } } +// FIXME(eddyb) this macro (and others?) use `$tcx` and `'tcx` interchangeably. +// We should either not take `$tcx` at all and use `'tcx` everywhere, or use +// `$tcx` everywhere (even if that isn't necessary due to lack of hygiene). macro_rules! define_queries_struct { (tcx: $tcx:tt, input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => { @@ -513,8 +516,8 @@ macro_rules! define_queries_struct { /// `DepGraph::try_mark_green()` and the query infrastructure. pub(crate) on_disk_cache: OnDiskCache<'tcx>, - providers: IndexVec>, - fallback_extern_providers: Box>, + providers: IndexVec, + fallback_extern_providers: Box, $($(#[$attr])* $name: QueryState< TyCtxt<$tcx>, @@ -524,8 +527,8 @@ macro_rules! define_queries_struct { impl<$tcx> Queries<$tcx> { pub(crate) fn new( - providers: IndexVec>, - fallback_extern_providers: Providers<$tcx>, + providers: IndexVec, + fallback_extern_providers: Providers, on_disk_cache: OnDiskCache<'tcx>, ) -> Self { Queries { @@ -558,11 +561,11 @@ macro_rules! define_queries_struct { macro_rules! define_provider_struct { (tcx: $tcx:tt, input: ($(([$($modifiers:tt)*] [$name:ident] [$K:ty] [$R:ty]))*)) => { - pub struct Providers<$tcx> { - $(pub $name: fn(TyCtxt<$tcx>, $K) -> $R,)* + pub struct Providers { + $(pub $name: for<$tcx> fn(TyCtxt<$tcx>, $K) -> $R,)* } - impl<$tcx> Default for Providers<$tcx> { + impl Default for Providers { fn default() -> Self { $(fn $name<$tcx>(_: TyCtxt<$tcx>, key: $K) -> $R { bug!("`tcx.{}({:?})` unsupported by its crate", diff --git a/src/librustc_middle/util/bug.rs b/src/librustc_middle/util/bug.rs index 9c3a97d8332f1..0903ef5089861 100644 --- a/src/librustc_middle/util/bug.rs +++ b/src/librustc_middle/util/bug.rs @@ -47,6 +47,6 @@ pub fn trigger_delay_span_bug(tcx: TyCtxt<'_>, key: rustc_hir::def_id::DefId) { ); } -pub fn provide(providers: &mut crate::ty::query::Providers<'_>) { +pub fn provide(providers: &mut crate::ty::query::Providers) { *providers = crate::ty::query::Providers { trigger_delay_span_bug, ..*providers }; } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 83691d439eb81..beb5f1fe924ec 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -86,7 +86,7 @@ crate struct Upvar { const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref]; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { mir_borrowck, ..*providers }; } diff --git a/src/librustc_mir/const_eval/fn_queries.rs b/src/librustc_mir/const_eval/fn_queries.rs index 74f8a1cb6d124..daa458f70f9a7 100644 --- a/src/librustc_mir/const_eval/fn_queries.rs +++ b/src/librustc_mir/const_eval/fn_queries.rs @@ -156,7 +156,7 @@ fn const_fn_is_allowed_fn_ptr(tcx: TyCtxt<'_>, def_id: DefId) -> bool { && tcx.lookup_const_stability(def_id).map(|stab| stab.allow_const_fn_ptr).unwrap_or(false) } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { is_const_fn_raw, is_const_impl_raw: |tcx, def_id| is_const_impl_raw(tcx, def_id.expect_local()), diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index cb6893166fd79..eff1dc135554f 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -47,7 +47,7 @@ pub mod util; use rustc_middle::ty::query::Providers; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { borrow_check::provide(providers); const_eval::provide(providers); shim::provide(providers); diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index a945c1d626a9a..ebea65c8f96f2 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -880,9 +880,9 @@ where } fn collect_and_partition_mono_items( - tcx: TyCtxt<'_>, + tcx: TyCtxt<'tcx>, cnum: CrateNum, -) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'_>]) { +) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) { assert_eq!(cnum, LOCAL_CRATE); let collection_mode = match tcx.sess.opts.debugging_opts.print_mono_items { @@ -994,7 +994,7 @@ fn collect_and_partition_mono_items( (tcx.arena.alloc(mono_items), codegen_units) } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.collect_and_partition_mono_items = collect_and_partition_mono_items; providers.is_codegened_item = |tcx, def_id| { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 5671b5b4f04c1..98286cddea68b 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -23,7 +23,7 @@ use crate::util::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle use crate::util::expand_aggregate; use crate::util::patch::MirPatch; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.mir_shims = make_shim; } diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index b8f725e967ddb..f218dd397c0c8 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -488,7 +488,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { } } -pub(crate) fn provide(providers: &mut Providers<'_>) { +pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { unsafety_check_result, unsafe_derive_on_repr_packed, ..*providers }; } diff --git a/src/librustc_mir/transform/instrument_coverage.rs b/src/librustc_mir/transform/instrument_coverage.rs index 25e154f2e9597..76904b7edd533 100644 --- a/src/librustc_mir/transform/instrument_coverage.rs +++ b/src/librustc_mir/transform/instrument_coverage.rs @@ -25,7 +25,7 @@ pub struct InstrumentCoverage; /// The `query` provider for `CoverageInfo`, requested by `codegen_intrinsic_call()` when /// constructing the arguments for `llvm.instrprof.increment`. -pub(crate) fn provide(providers: &mut Providers<'_>) { +pub(crate) fn provide(providers: &mut Providers) { providers.coverageinfo = |tcx, def_id| coverageinfo_from_mir(tcx, def_id); } diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 8ca240d2c7da7..1f48052c1ce0f 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -43,7 +43,7 @@ pub mod uninhabited_enum_branching; pub mod unreachable_prop; pub mod validate; -pub(crate) fn provide(providers: &mut Providers<'_>) { +pub(crate) fn provide(providers: &mut Providers) { self::check_unsafety::provide(providers); *providers = Providers { mir_keys, diff --git a/src/librustc_mir_build/lib.rs b/src/librustc_mir_build/lib.rs index b44d8eee462f0..be495e431eb3c 100644 --- a/src/librustc_mir_build/lib.rs +++ b/src/librustc_mir_build/lib.rs @@ -23,7 +23,7 @@ mod lints; use rustc_middle::ty::query::Providers; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.check_match = hair::pattern::check_match; providers.lit_to_const = hair::constant::lit_to_const; providers.mir_built = build::mir_built; diff --git a/src/librustc_passes/check_attr.rs b/src/librustc_passes/check_attr.rs index ef84f251390e6..3272ac8f9c73d 100644 --- a/src/librustc_passes/check_attr.rs +++ b/src/librustc_passes/check_attr.rs @@ -469,6 +469,6 @@ fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { .visit_item_likes_in_module(module_def_id, &mut CheckAttrVisitor { tcx }.as_deep_visitor()); } -pub(crate) fn provide(providers: &mut Providers<'_>) { +pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { check_mod_attrs, ..*providers }; } diff --git a/src/librustc_passes/check_const.rs b/src/librustc_passes/check_const.rs index 738754557d84c..b1ebab3f2f806 100644 --- a/src/librustc_passes/check_const.rs +++ b/src/librustc_passes/check_const.rs @@ -62,7 +62,7 @@ fn check_mod_const_bodies(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { tcx.hir().visit_item_likes_in_module(module_def_id, &mut vis.as_deep_visitor()); } -pub(crate) fn provide(providers: &mut Providers<'_>) { +pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { check_mod_const_bodies, ..*providers }; } diff --git a/src/librustc_passes/diagnostic_items.rs b/src/librustc_passes/diagnostic_items.rs index d91f49554ff48..3cce4b8d00e8b 100644 --- a/src/librustc_passes/diagnostic_items.rs +++ b/src/librustc_passes/diagnostic_items.rs @@ -118,7 +118,7 @@ fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap { collector } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.diagnostic_items = |tcx, id| { assert_eq!(id, LOCAL_CRATE); collect(tcx) diff --git a/src/librustc_passes/entry.rs b/src/librustc_passes/entry.rs index e0ad0ac77476f..11612101e3771 100644 --- a/src/librustc_passes/entry.rs +++ b/src/librustc_passes/entry.rs @@ -217,6 +217,6 @@ pub fn find_entry_point(tcx: TyCtxt<'_>) -> Option<(LocalDefId, EntryFnType)> { tcx.entry_fn(LOCAL_CRATE) } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { entry_fn, ..*providers }; } diff --git a/src/librustc_passes/intrinsicck.rs b/src/librustc_passes/intrinsicck.rs index e4f4885690fd9..25edfad86e8ec 100644 --- a/src/librustc_passes/intrinsicck.rs +++ b/src/librustc_passes/intrinsicck.rs @@ -18,7 +18,7 @@ fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { tcx.hir().visit_item_likes_in_module(module_def_id, &mut ItemVisitor { tcx }.as_deep_visitor()); } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { check_mod_intrinsics, ..*providers }; } diff --git a/src/librustc_passes/lang_items.rs b/src/librustc_passes/lang_items.rs index 0326591a931f5..809697134b759 100644 --- a/src/librustc_passes/lang_items.rs +++ b/src/librustc_passes/lang_items.rs @@ -205,7 +205,7 @@ fn collect(tcx: TyCtxt<'_>) -> LanguageItems { items } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.get_lang_items = |tcx, id| { assert_eq!(id, LOCAL_CRATE); collect(tcx) diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 5109d8debeefd..3f10c418811b7 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -37,7 +37,7 @@ pub mod stability; mod upvars; mod weak_lang_items; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { check_attr::provide(providers); check_const::provide(providers); diagnostic_items::provide(providers); diff --git a/src/librustc_passes/lib_features.rs b/src/librustc_passes/lib_features.rs index 31c7ba2a4b205..922a475e5f4e4 100644 --- a/src/librustc_passes/lib_features.rs +++ b/src/librustc_passes/lib_features.rs @@ -135,7 +135,7 @@ fn collect(tcx: TyCtxt<'_>) -> LibFeatures { collector.lib_features } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.get_lib_features = |tcx, id| { assert_eq!(id, LOCAL_CRATE); collect(tcx) diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index b288a41e0cfd6..3675a987644da 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -179,7 +179,7 @@ fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { ); } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { check_mod_liveness, ..*providers }; } diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index d7012d4d711df..9b4da71e5e961 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -36,7 +36,7 @@ fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { ); } -pub(crate) fn provide(providers: &mut Providers<'_>) { +pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { check_mod_loops, ..*providers }; } diff --git a/src/librustc_passes/reachable.rs b/src/librustc_passes/reachable.rs index 50fcefa3569ac..c46f4856cfe3a 100644 --- a/src/librustc_passes/reachable.rs +++ b/src/librustc_passes/reachable.rs @@ -425,6 +425,6 @@ fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx HirIdSet tcx.arena.alloc(reachable_context.reachable_symbols) } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { reachable_set, ..*providers }; } diff --git a/src/librustc_passes/region.rs b/src/librustc_passes/region.rs index a6fa677cbc0af..b2a89651881e5 100644 --- a/src/librustc_passes/region.rs +++ b/src/librustc_passes/region.rs @@ -842,6 +842,6 @@ fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree { tcx.arena.alloc(scope_tree) } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { region_scope_tree, ..*providers }; } diff --git a/src/librustc_passes/stability.rs b/src/librustc_passes/stability.rs index 2e1775ca46534..5bacab671ec14 100644 --- a/src/librustc_passes/stability.rs +++ b/src/librustc_passes/stability.rs @@ -476,7 +476,7 @@ fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor()); } -pub(crate) fn provide(providers: &mut Providers<'_>) { +pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { check_mod_unstable_api_usage, ..*providers }; providers.stability_index = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); diff --git a/src/librustc_passes/upvars.rs b/src/librustc_passes/upvars.rs index 99b4ef9d12fcd..3aed4942563dd 100644 --- a/src/librustc_passes/upvars.rs +++ b/src/librustc_passes/upvars.rs @@ -9,7 +9,7 @@ use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_span::Span; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.upvars_mentioned = |tcx, def_id| { if !tcx.is_closure(def_id) { return None; diff --git a/src/librustc_plugin_impl/build.rs b/src/librustc_plugin_impl/build.rs index 34522cfe97f35..db2363316cd1a 100644 --- a/src/librustc_plugin_impl/build.rs +++ b/src/librustc_plugin_impl/build.rs @@ -57,6 +57,6 @@ fn plugin_registrar_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option { } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { plugin_registrar_fn, ..*providers }; } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index de21365c5369a..2c5cbed2192ef 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -2029,7 +2029,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { privacy_access_levels, check_private_in_public, diff --git a/src/librustc_resolve/late/lifetimes.rs b/src/librustc_resolve/late/lifetimes.rs index 903eee672cf1f..e9b917168d67b 100644 --- a/src/librustc_resolve/late/lifetimes.rs +++ b/src/librustc_resolve/late/lifetimes.rs @@ -278,7 +278,7 @@ type ScopeRef<'a> = &'a Scope<'a>; const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root; -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { resolve_lifetimes, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index f3a1934abc9fe..a4ae9eb773168 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3102,6 +3102,6 @@ impl CrateLint { } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { late::lifetimes::provide(providers); } diff --git a/src/librustc_symbol_mangling/lib.rs b/src/librustc_symbol_mangling/lib.rs index 5a1c6491f86d8..012321026938e 100644 --- a/src/librustc_symbol_mangling/lib.rs +++ b/src/librustc_symbol_mangling/lib.rs @@ -126,7 +126,7 @@ pub fn symbol_name_for_instance_in_crate( compute_symbol_name(tcx, instance, || instantiating_crate) } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { symbol_name: symbol_name_provider, ..*providers }; } diff --git a/src/librustc_trait_selection/traits/mod.rs b/src/librustc_trait_selection/traits/mod.rs index 9ab87e6b6ca01..597d05145dad6 100644 --- a/src/librustc_trait_selection/traits/mod.rs +++ b/src/librustc_trait_selection/traits/mod.rs @@ -550,7 +550,7 @@ fn type_implements_trait<'tcx>( tcx.infer_ctxt().enter(|infcx| infcx.predicate_must_hold_modulo_regions(&obligation)) } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { object_safety::provide(providers); structural_match::provide(providers); *providers = ty::query::Providers { diff --git a/src/librustc_trait_selection/traits/object_safety.rs b/src/librustc_trait_selection/traits/object_safety.rs index 5befc797a517a..9e523865abb8d 100644 --- a/src/librustc_trait_selection/traits/object_safety.rs +++ b/src/librustc_trait_selection/traits/object_safety.rs @@ -790,6 +790,6 @@ fn contains_illegal_self_type_reference<'tcx>( }) } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { object_safety_violations, ..*providers }; } diff --git a/src/librustc_trait_selection/traits/structural_match.rs b/src/librustc_trait_selection/traits/structural_match.rs index 201edf27a655c..377d163d10439 100644 --- a/src/librustc_trait_selection/traits/structural_match.rs +++ b/src/librustc_trait_selection/traits/structural_match.rs @@ -271,7 +271,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> { } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { providers.has_structural_eq_impls = |tcx, ty| { tcx.infer_ctxt().enter(|infcx| { let cause = ObligationCause::dummy(); diff --git a/src/librustc_traits/chalk/mod.rs b/src/librustc_traits/chalk/mod.rs index 52ec0f2409dce..0c5d57551f9c5 100644 --- a/src/librustc_traits/chalk/mod.rs +++ b/src/librustc_traits/chalk/mod.rs @@ -29,7 +29,7 @@ use crate::chalk::lowering::{LowerInto, ParamsSubstitutor}; use chalk_solve::Solution; -crate fn provide(p: &mut Providers<'_>) { +crate fn provide(p: &mut Providers) { *p = Providers { evaluate_goal, ..*p }; } diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index 6339f8288d54e..ce00060b9b172 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -17,7 +17,7 @@ use rustc_trait_selection::traits::{ Normalized, ObligationCause, TraitEngine, TraitEngineExt as _, }; -crate fn provide(p: &mut Providers<'_>) { +crate fn provide(p: &mut Providers) { *p = Providers { dropck_outlives, adt_dtorck_constraint, ..*p }; } diff --git a/src/librustc_traits/evaluate_obligation.rs b/src/librustc_traits/evaluate_obligation.rs index e6afc15fa15fe..2404b7ff4b54a 100644 --- a/src/librustc_traits/evaluate_obligation.rs +++ b/src/librustc_traits/evaluate_obligation.rs @@ -7,7 +7,7 @@ use rustc_trait_selection::traits::{ EvaluationResult, Obligation, ObligationCause, OverflowError, SelectionContext, TraitQueryMode, }; -crate fn provide(p: &mut Providers<'_>) { +crate fn provide(p: &mut Providers) { *p = Providers { evaluate_obligation, ..*p }; } diff --git a/src/librustc_traits/implied_outlives_bounds.rs b/src/librustc_traits/implied_outlives_bounds.rs index 651596d0379bb..bda3da120e958 100644 --- a/src/librustc_traits/implied_outlives_bounds.rs +++ b/src/librustc_traits/implied_outlives_bounds.rs @@ -18,7 +18,7 @@ use rustc_trait_selection::traits::FulfillmentContext; use rustc_trait_selection::traits::TraitEngine; use smallvec::{smallvec, SmallVec}; -crate fn provide(p: &mut Providers<'_>) { +crate fn provide(p: &mut Providers) { *p = Providers { implied_outlives_bounds, ..*p }; } diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index f3dfdffda4191..b8e23760ba5d4 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -22,7 +22,7 @@ mod type_op; use rustc_middle::ty::query::Providers; -pub fn provide(p: &mut Providers<'_>) { +pub fn provide(p: &mut Providers) { dropck_outlives::provide(p); evaluate_obligation::provide(p); implied_outlives_bounds::provide(p); diff --git a/src/librustc_traits/normalize_erasing_regions.rs b/src/librustc_traits/normalize_erasing_regions.rs index fcb75142269df..7092515af0882 100644 --- a/src/librustc_traits/normalize_erasing_regions.rs +++ b/src/librustc_traits/normalize_erasing_regions.rs @@ -7,7 +7,7 @@ use rustc_trait_selection::traits::query::normalize::AtExt; use rustc_trait_selection::traits::{Normalized, ObligationCause}; use std::sync::atomic::Ordering; -crate fn provide(p: &mut Providers<'_>) { +crate fn provide(p: &mut Providers) { *p = Providers { normalize_generic_arg_after_erasing_regions, ..*p }; } diff --git a/src/librustc_traits/normalize_projection_ty.rs b/src/librustc_traits/normalize_projection_ty.rs index d6d3e86a2c8d3..a8e376838e218 100644 --- a/src/librustc_traits/normalize_projection_ty.rs +++ b/src/librustc_traits/normalize_projection_ty.rs @@ -10,7 +10,7 @@ use rustc_trait_selection::traits::query::{ use rustc_trait_selection::traits::{self, ObligationCause, SelectionContext}; use std::sync::atomic::Ordering; -crate fn provide(p: &mut Providers<'_>) { +crate fn provide(p: &mut Providers) { *p = Providers { normalize_projection_ty, ..*p }; } diff --git a/src/librustc_traits/type_op.rs b/src/librustc_traits/type_op.rs index 374ef3fc9c783..9cc9a35b38b8a 100644 --- a/src/librustc_traits/type_op.rs +++ b/src/librustc_traits/type_op.rs @@ -21,7 +21,7 @@ use rustc_trait_selection::traits::query::{Fallible, NoSolution}; use rustc_trait_selection::traits::{Normalized, Obligation, ObligationCause, TraitEngine}; use std::fmt; -crate fn provide(p: &mut Providers<'_>) { +crate fn provide(p: &mut Providers) { *p = Providers { type_op_ascribe_user_type, type_op_eq, diff --git a/src/librustc_ty/common_traits.rs b/src/librustc_ty/common_traits.rs index 265b811571afe..8d153e77f0b7d 100644 --- a/src/librustc_ty/common_traits.rs +++ b/src/librustc_ty/common_traits.rs @@ -36,6 +36,6 @@ fn is_item_raw<'tcx>( }) } -pub(crate) fn provide(providers: &mut ty::query::Providers<'_>) { +pub(crate) fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { is_copy_raw, is_sized_raw, is_freeze_raw, ..*providers }; } diff --git a/src/librustc_ty/instance.rs b/src/librustc_ty/instance.rs index 0acf769168137..d74f25e655611 100644 --- a/src/librustc_ty/instance.rs +++ b/src/librustc_ty/instance.rs @@ -243,6 +243,6 @@ fn resolve_associated_item<'tcx>( }) } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { resolve_instance, ..*providers }; } diff --git a/src/librustc_ty/lib.rs b/src/librustc_ty/lib.rs index 75e62e796408a..8f3b20c7aaf40 100644 --- a/src/librustc_ty/lib.rs +++ b/src/librustc_ty/lib.rs @@ -21,7 +21,7 @@ pub mod instance; mod needs_drop; mod ty; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { common_traits::provide(providers); needs_drop::provide(providers); ty::provide(providers); diff --git a/src/librustc_ty/needs_drop.rs b/src/librustc_ty/needs_drop.rs index 7880c09c2ad81..c4af95205fe27 100644 --- a/src/librustc_ty/needs_drop.rs +++ b/src/librustc_ty/needs_drop.rs @@ -183,6 +183,6 @@ fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List>, Alw res.map(|components| tcx.intern_type_list(&components)) } -pub(crate) fn provide(providers: &mut ty::query::Providers<'_>) { +pub(crate) fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { needs_drop_raw, adt_drop_tys, ..*providers }; } diff --git a/src/librustc_ty/ty.rs b/src/librustc_ty/ty.rs index 595992d01dd2d..c99bc8a47e33b 100644 --- a/src/librustc_ty/ty.rs +++ b/src/librustc_ty/ty.rs @@ -494,7 +494,7 @@ fn projection_predicates(tcx: TyCtxt<'_>, def_id: DefId) -> &'_ ty::List) { +pub fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { asyncness, associated_item, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 7bdf137f116c8..b1799c6eef336 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -28,7 +28,7 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use self::probe::{IsSuggestion, ProbeScope}; -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { suggest::provide(providers); probe::provide(providers); } diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 8842ca877268a..a11198348682d 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -440,7 +440,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { providers.method_autoderef_steps = method_autoderef_steps; } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index fbf81e94d03d5..44ffabc4c2662 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -1292,7 +1292,7 @@ fn compute_all_traits(tcx: TyCtxt<'_>) -> Vec { traits } -pub fn provide(providers: &mut ty::query::Providers<'_>) { +pub fn provide(providers: &mut ty::query::Providers) { providers.all_traits = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); &tcx.arena.alloc(compute_all_traits(tcx))[..] diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 58fd0f989c678..dc62c7ec01ce3 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -760,7 +760,7 @@ fn check_impl_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) { wfcheck::check_impl_item(tcx, def_id); } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { method::provide(providers); *providers = Providers { typeck_item_bodies, diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 3b203dd222afb..1483244717b4f 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -151,7 +151,7 @@ fn enforce_empty_impls_for_marker_traits( struct_span_err!(tcx.sess, span, E0715, "impls for marker traits cannot contain items").emit(); } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { use self::builtin::coerce_unsized_info; use self::inherent_impls::{crate_inherent_impls, inherent_impls}; use self::inherent_impls_overlap::crate_inherent_impls_overlap_check; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 8920203e6af40..cbee74a0e0124 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -62,7 +62,7 @@ fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { ); } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { type_of: type_of::type_of, generics_of, diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 77cd1b3de0106..891e482b43133 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -69,7 +69,7 @@ fn check_mod_impl_wf(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { .visit_item_likes_in_module(module_def_id, &mut ImplWfCheck { tcx, min_specialization }); } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { check_mod_impl_wf, ..*providers }; } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 8d8a1b4d96761..9ba2545ba63cb 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -309,7 +309,7 @@ fn check_for_entry_fn(tcx: TyCtxt<'_>) { } } -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { collect::provide(providers); coherence::provide(providers); check::provide(providers); diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 1b2b08a2e62ee..cc5858314597c 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -13,7 +13,7 @@ mod implicit_infer; pub mod test; mod utils; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { inferred_outlives_of, inferred_outlives_crate, ..*providers }; } diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 23f4e1f5346e5..b307363dc3ab0 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -26,7 +26,7 @@ pub mod test; /// Code for transforming variances. mod xform; -pub fn provide(providers: &mut Providers<'_>) { +pub fn provide(providers: &mut Providers) { *providers = Providers { variances_of, crate_variances, ..*providers }; } From 81fbfc40594e0c74aa46bbf50225c4d923f1464b Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Sun, 5 Jul 2020 17:22:21 -0700 Subject: [PATCH 04/28] Use relative path for local links to primitives in libcore Else, links to `char::foo` would point into `/path/to/src/libcore/std/primitive.char.html#method.foo`. Split out from #73804. --- src/librustdoc/clean/types.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6dec016cc2ee3..34f91bfec5a88 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -628,6 +628,7 @@ impl Attributes { /// Cache must be populated before call pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> { use crate::html::format::href; + use crate::html::render::CURRENT_DEPTH; self.links .iter() @@ -648,12 +649,13 @@ impl Attributes { if let Some(ref fragment) = *fragment { let cache = cache(); let url = match cache.extern_locations.get(krate) { - Some(&(_, ref src, ExternalLocation::Local)) => { - src.to_str().expect("invalid file path") + Some(&(_, _, ExternalLocation::Local)) => { + let depth = CURRENT_DEPTH.with(|l| l.get()); + "../".repeat(depth) } - Some(&(_, _, ExternalLocation::Remote(ref s))) => s, + Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(), Some(&(_, _, ExternalLocation::Unknown)) | None => { - "https://doc.rust-lang.org/nightly" + String::from("https://doc.rust-lang.org/nightly") } }; // This is a primitive so the url is done "by hand". From ee3a0f867e938f469cbbb422a76ed5662be2ecc7 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Mon, 6 Jul 2020 08:46:44 -0700 Subject: [PATCH 05/28] Add guard to check for local `core` crate --- src/librustdoc/clean/types.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 34f91bfec5a88..d2ba34ccb8107 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -649,14 +649,16 @@ impl Attributes { if let Some(ref fragment) = *fragment { let cache = cache(); let url = match cache.extern_locations.get(krate) { - Some(&(_, _, ExternalLocation::Local)) => { + Some(&(ref krate_name, _, ExternalLocation::Local)) + if krate_name == "core" => + { let depth = CURRENT_DEPTH.with(|l| l.get()); "../".repeat(depth) } Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(), - Some(&(_, _, ExternalLocation::Unknown)) | None => { - String::from("https://doc.rust-lang.org/nightly") - } + Some(&(_, _, ExternalLocation::Local)) + | Some(&(_, _, ExternalLocation::Unknown)) + | None => String::from("https://doc.rust-lang.org/nightly"), }; // This is a primitive so the url is done "by hand". let tail = fragment.find('#').unwrap_or_else(|| fragment.len()); From e0b69f207b276e0432e45bbe41d26a28bbfbfa2e Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Mon, 6 Jul 2020 20:32:26 +0100 Subject: [PATCH 06/28] Hide `&mut self` methods from Deref in sidebar If there are no `DerefMut` impl for the type. --- src/librustdoc/html/render.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 04c4685213b2e..6d3576ed8078c 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -4095,6 +4095,10 @@ fn sidebar_assoc_items(it: &clean::Item) -> String { _ => None, }) { + let deref_mut = v + .iter() + .filter(|i| i.inner_impl().trait_.is_some()) + .any(|i| i.inner_impl().trait_.def_id() == c.deref_mut_trait_did); let inner_impl = target .def_id() .or(target @@ -4115,7 +4119,9 @@ fn sidebar_assoc_items(it: &clean::Item) -> String { let mut ret = impls .iter() .filter(|i| i.inner_impl().trait_.is_none()) - .flat_map(|i| get_methods(i.inner_impl(), true, &mut used_links, true)) + .flat_map(|i| { + get_methods(i.inner_impl(), true, &mut used_links, deref_mut) + }) .collect::>(); // We want links' order to be reproducible so we don't use unstable sort. ret.sort(); From 368aa6f1e292d264bcb74fafa25069fe19c49450 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Mon, 6 Jul 2020 21:06:58 +0100 Subject: [PATCH 07/28] Add test for issue 74083 --- src/test/rustdoc/issue-74083.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/rustdoc/issue-74083.rs diff --git a/src/test/rustdoc/issue-74083.rs b/src/test/rustdoc/issue-74083.rs new file mode 100644 index 0000000000000..28585dafa142a --- /dev/null +++ b/src/test/rustdoc/issue-74083.rs @@ -0,0 +1,21 @@ +use std::ops::Deref; + +pub struct Foo; + +impl Foo { + pub fn foo(&mut self) {} +} + +// @has issue_74083/struct.Bar.html +// !@has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' +pub struct Bar { + foo: Foo, +} + +impl Deref for Bar { + type Target = Foo; + + fn deref(&self) -> &Foo { + &self.foo + } +} From 33a5d00efb4347736dd766c06cb9e0bcc0d6c377 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Mon, 6 Jul 2020 19:35:07 -0700 Subject: [PATCH 08/28] Two new rustdoc tests for intra links They both produce less-than-desirable output (links going to docs.rust-lang.org), but I haven't figured out yet how to assert about them properly. --- src/test/rustdoc/auxiliary/my-core.rs | 18 ++++++++++++++++ .../intra-link-prim-methods-external-core.rs | 10 +++++++++ .../rustdoc/intra-link-prim-methods-local.rs | 21 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/test/rustdoc/auxiliary/my-core.rs create mode 100644 src/test/rustdoc/intra-link-prim-methods-external-core.rs create mode 100644 src/test/rustdoc/intra-link-prim-methods-local.rs diff --git a/src/test/rustdoc/auxiliary/my-core.rs b/src/test/rustdoc/auxiliary/my-core.rs new file mode 100644 index 0000000000000..999dfbdd8a3f5 --- /dev/null +++ b/src/test/rustdoc/auxiliary/my-core.rs @@ -0,0 +1,18 @@ +#![feature(no_core, lang_items)] +#![no_core] + +#[lang = "char"] +impl char { + pub fn len_utf8(self) -> usize { + 42 + } +} + +#[lang = "sized"] +pub trait Sized {} + +#[lang = "clone"] +pub trait Clone: Sized {} + +#[lang = "copy"] +pub trait Copy: Clone {} diff --git a/src/test/rustdoc/intra-link-prim-methods-external-core.rs b/src/test/rustdoc/intra-link-prim-methods-external-core.rs new file mode 100644 index 0000000000000..85e017e89b146 --- /dev/null +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -0,0 +1,10 @@ +// aux-build:my-core.rs +// ignore-cross-compile + +#![deny(intra_doc_link_resolution_failure)] +#![feature(no_core, lang_items)] +#![no_core] + +//! A [`char`] and its [`char::len_utf8`]. + +extern crate my_core; diff --git a/src/test/rustdoc/intra-link-prim-methods-local.rs b/src/test/rustdoc/intra-link-prim-methods-local.rs new file mode 100644 index 0000000000000..c0be16885dae8 --- /dev/null +++ b/src/test/rustdoc/intra-link-prim-methods-local.rs @@ -0,0 +1,21 @@ +#![deny(intra_doc_link_resolution_failure)] +#![feature(no_core, lang_items)] +#![no_core] + +//! A [`char`] and its [`char::len_utf8`]. + +#[lang = "char"] +impl char { + pub fn len_utf8(self) -> usize { + 42 + } +} + +#[lang = "sized"] +pub trait Sized {} + +#[lang = "clone"] +pub trait Clone: Sized {} + +#[lang = "copy"] +pub trait Copy: Clone {} From 165aecbee31c3e628aaa8e6e7edbbd113f46e3f2 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Mon, 6 Jul 2020 19:46:53 -0700 Subject: [PATCH 09/28] build extern docs as well --- src/test/rustdoc/intra-link-prim-methods-external-core.rs | 1 + 1 file changed, 1 insertion(+) 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 85e017e89b146..a7f243f63a893 100644 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -1,4 +1,5 @@ // aux-build:my-core.rs +// build-aux-docs // ignore-cross-compile #![deny(intra_doc_link_resolution_failure)] From 865b930bc99680bd170a677c095a2116a5c4159d Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Tue, 7 Jul 2020 10:23:29 -0700 Subject: [PATCH 10/28] Assert current behavior for links For the two of these tests that have a local `char` to link to, this behavior isn't what's expected, but is what's happening presently. --- src/test/rustdoc/intra-link-prim-methods-external-core.rs | 4 ++++ src/test/rustdoc/intra-link-prim-methods-local.rs | 4 ++++ src/test/rustdoc/intra-link-prim-methods.rs | 4 ++++ 3 files changed, 12 insertions(+) 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 a7f243f63a893..f3953ef3f2eb4 100644 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -6,6 +6,10 @@ #![feature(no_core, lang_items)] #![no_core] +// @has intra_link_prim_methods_external_core/index.html +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' + //! A [`char`] and its [`char::len_utf8`]. extern crate my_core; diff --git a/src/test/rustdoc/intra-link-prim-methods-local.rs b/src/test/rustdoc/intra-link-prim-methods-local.rs index c0be16885dae8..ed72b5f40de87 100644 --- a/src/test/rustdoc/intra-link-prim-methods-local.rs +++ b/src/test/rustdoc/intra-link-prim-methods-local.rs @@ -2,6 +2,10 @@ #![feature(no_core, lang_items)] #![no_core] +// @has intra_link_prim_methods_local/index.html +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' + //! A [`char`] and its [`char::len_utf8`]. #[lang = "char"] diff --git a/src/test/rustdoc/intra-link-prim-methods.rs b/src/test/rustdoc/intra-link-prim-methods.rs index af0426b22c557..ba050968ce0ac 100644 --- a/src/test/rustdoc/intra-link-prim-methods.rs +++ b/src/test/rustdoc/intra-link-prim-methods.rs @@ -1,3 +1,7 @@ #![deny(intra_doc_link_resolution_failure)] +// @has intra_link_prim_methods/index.html +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' + //! A [`char`] and its [`char::len_utf8`]. From f258d98f65ef1408a6045f5ca7873371720409c2 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Tue, 7 Jul 2020 10:39:10 -0700 Subject: [PATCH 11/28] ignore-tidy-linelength for @has assertions --- src/test/rustdoc/intra-link-prim-methods-external-core.rs | 1 + src/test/rustdoc/intra-link-prim-methods-local.rs | 2 ++ src/test/rustdoc/intra-link-prim-methods.rs | 2 ++ 3 files changed, 5 insertions(+) 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 f3953ef3f2eb4..1569cf4734075 100644 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -1,6 +1,7 @@ // aux-build:my-core.rs // build-aux-docs // ignore-cross-compile +// ignore-tidy-linelength #![deny(intra_doc_link_resolution_failure)] #![feature(no_core, lang_items)] diff --git a/src/test/rustdoc/intra-link-prim-methods-local.rs b/src/test/rustdoc/intra-link-prim-methods-local.rs index ed72b5f40de87..ea64efe6d6701 100644 --- a/src/test/rustdoc/intra-link-prim-methods-local.rs +++ b/src/test/rustdoc/intra-link-prim-methods-local.rs @@ -2,6 +2,8 @@ #![feature(no_core, lang_items)] #![no_core] +// ignore-tidy-linelength + // @has intra_link_prim_methods_local/index.html // @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' // @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' diff --git a/src/test/rustdoc/intra-link-prim-methods.rs b/src/test/rustdoc/intra-link-prim-methods.rs index ba050968ce0ac..76636b80b5eb5 100644 --- a/src/test/rustdoc/intra-link-prim-methods.rs +++ b/src/test/rustdoc/intra-link-prim-methods.rs @@ -1,5 +1,7 @@ #![deny(intra_doc_link_resolution_failure)] +// ignore-tidy-linelength + // @has intra_link_prim_methods/index.html // @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' // @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' From 8d267db31a767f22f07e06439ae682329c22bef1 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Tue, 7 Jul 2020 14:15:31 -0700 Subject: [PATCH 12/28] Revert "Add guard to check for local `core` crate" This reverts commit ee3a0f867e938f469cbbb422a76ed5662be2ecc7. --- src/librustdoc/clean/types.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index d2ba34ccb8107..34f91bfec5a88 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -649,16 +649,14 @@ impl Attributes { if let Some(ref fragment) = *fragment { let cache = cache(); let url = match cache.extern_locations.get(krate) { - Some(&(ref krate_name, _, ExternalLocation::Local)) - if krate_name == "core" => - { + Some(&(_, _, ExternalLocation::Local)) => { let depth = CURRENT_DEPTH.with(|l| l.get()); "../".repeat(depth) } Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(), - Some(&(_, _, ExternalLocation::Local)) - | Some(&(_, _, ExternalLocation::Unknown)) - | None => String::from("https://doc.rust-lang.org/nightly"), + Some(&(_, _, ExternalLocation::Unknown)) | None => { + String::from("https://doc.rust-lang.org/nightly") + } }; // This is a primitive so the url is done "by hand". let tail = fragment.find('#').unwrap_or_else(|| fragment.len()); From dd077746174b7ddbbd004b47f475c46cda3b5f27 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 8 Jul 2020 07:15:17 +0900 Subject: [PATCH 13/28] Fix broken link in rustdocdoc --- src/doc/rustdoc/src/unstable-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 84e1ebe5e01f5..20c0f4a3713cc 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -321,7 +321,7 @@ library, as an equivalent command-line argument is provided to `rustc` when buil ### `--index-page`: provide a top-level landing page for docs This feature allows you to generate an index-page with a given markdown file. A good example of it -is the [rust documentation index](https://doc.rust-lang.org/index.html). +is the [rust documentation index](https://doc.rust-lang.org/nightly/index.html). With this, you'll have a page which you can custom as much as you want at the top of your crates. From 7bc85e29c94084a5b24af4b38a6d9dd7f9177f06 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 8 Jul 2020 12:44:43 +0800 Subject: [PATCH 14/28] Liballoc use vec instead of vector Keep congruency with other parts, full word vector is rarely used. --- src/liballoc/slice.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index d7dc2174d665f..3dbe24428663f 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -156,9 +156,9 @@ mod hack { where T: Clone, { - let mut vector = Vec::with_capacity(s.len()); - vector.extend_from_slice(s); - vector + let mut vec = Vec::with_capacity(s.len()); + vec.extend_from_slice(s); + vec } } From 09654430017b9ed8488ca45c414410af1417a482 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 8 Jul 2020 12:47:19 +0800 Subject: [PATCH 15/28] Remove unneeded ToString import in liballoc slice --- src/liballoc/slice.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index d7dc2174d665f..daa1a13c1ea3e 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -136,8 +136,6 @@ pub use hack::to_vec; // `test_permutations` test mod hack { use crate::boxed::Box; - #[cfg(test)] - use crate::string::ToString; use crate::vec::Vec; // We shouldn't add inline attribute to this since this is used in From 9366458c58a60b9573f45f1c407bd4c7f2fa1876 Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Wed, 8 Jul 2020 08:20:43 -0700 Subject: [PATCH 16/28] Apply #![crate_type = "rlib"] directly to the linker --- src/test/rustdoc/auxiliary/my-core.rs | 1 + src/test/rustdoc/intra-link-prim-methods-external-core.rs | 1 + src/test/rustdoc/intra-link-prim-methods-local.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/test/rustdoc/auxiliary/my-core.rs b/src/test/rustdoc/auxiliary/my-core.rs index 999dfbdd8a3f5..54e986be9eccf 100644 --- a/src/test/rustdoc/auxiliary/my-core.rs +++ b/src/test/rustdoc/auxiliary/my-core.rs @@ -1,5 +1,6 @@ #![feature(no_core, lang_items)] #![no_core] +#![crate_type="rlib"] #[lang = "char"] impl char { 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 1569cf4734075..b9bdd86ecc56b 100644 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -6,6 +6,7 @@ #![deny(intra_doc_link_resolution_failure)] #![feature(no_core, lang_items)] #![no_core] +#![crate_type = "rlib"] // @has intra_link_prim_methods_external_core/index.html // @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' diff --git a/src/test/rustdoc/intra-link-prim-methods-local.rs b/src/test/rustdoc/intra-link-prim-methods-local.rs index ea64efe6d6701..d24cd2cbb5e20 100644 --- a/src/test/rustdoc/intra-link-prim-methods-local.rs +++ b/src/test/rustdoc/intra-link-prim-methods-local.rs @@ -1,6 +1,7 @@ #![deny(intra_doc_link_resolution_failure)] #![feature(no_core, lang_items)] #![no_core] +#![crate_type = "rlib"] // ignore-tidy-linelength From 1e567c11686f20b4e7422ba9cc0f1eac45e9c9fb Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Wed, 8 Jul 2020 09:36:52 -0400 Subject: [PATCH 17/28] Avoid "blacklist" Other terms are more inclusive and precise. Clippy still has a lint named "blacklisted-name", but renaming it would be a breaking change, so is left for future work. The target configuration option "abi-blacklist" has been depreciated and renamed to "unsupported-abis". The old name continues to work. --- src/librustc_error_codes/error_codes/E0570.md | 2 +- src/librustc_resolve/imports.rs | 36 ++++++------- src/librustc_resolve/late.rs | 6 +-- src/librustc_resolve/lib.rs | 4 +- src/librustc_target/spec/aarch64_apple_ios.rs | 2 +- .../spec/aarch64_apple_tvos.rs | 2 +- src/librustc_target/spec/aarch64_fuchsia.rs | 2 +- .../spec/aarch64_linux_android.rs | 2 +- .../spec/aarch64_unknown_cloudabi.rs | 2 +- .../spec/aarch64_unknown_freebsd.rs | 2 +- .../spec/aarch64_unknown_hermit.rs | 2 +- .../spec/aarch64_unknown_linux_gnu.rs | 2 +- .../spec/aarch64_unknown_linux_musl.rs | 2 +- .../spec/aarch64_unknown_netbsd.rs | 2 +- .../spec/aarch64_unknown_none.rs | 2 +- .../spec/aarch64_unknown_none_softfloat.rs | 2 +- .../spec/aarch64_unknown_openbsd.rs | 2 +- .../spec/aarch64_wrs_vxworks.rs | 2 +- src/librustc_target/spec/arm_base.rs | 2 +- .../spec/arm_linux_androideabi.rs | 2 +- .../spec/arm_unknown_linux_gnueabi.rs | 2 +- .../spec/arm_unknown_linux_gnueabihf.rs | 2 +- .../spec/arm_unknown_linux_musleabi.rs | 2 +- .../spec/arm_unknown_linux_musleabihf.rs | 2 +- .../spec/armebv7r_none_eabi.rs | 2 +- .../spec/armebv7r_none_eabihf.rs | 2 +- .../spec/armv4t_unknown_linux_gnueabi.rs | 2 +- .../spec/armv5te_unknown_linux_gnueabi.rs | 2 +- .../spec/armv5te_unknown_linux_musleabi.rs | 2 +- .../spec/armv6_unknown_freebsd.rs | 2 +- .../spec/armv6_unknown_netbsd_eabihf.rs | 2 +- src/librustc_target/spec/armv7_apple_ios.rs | 2 +- .../spec/armv7_linux_androideabi.rs | 2 +- .../spec/armv7_unknown_cloudabi_eabihf.rs | 2 +- .../spec/armv7_unknown_freebsd.rs | 2 +- .../spec/armv7_unknown_linux_gnueabi.rs | 2 +- .../spec/armv7_unknown_linux_gnueabihf.rs | 2 +- .../spec/armv7_unknown_linux_musleabi.rs | 2 +- .../spec/armv7_unknown_linux_musleabihf.rs | 2 +- .../spec/armv7_unknown_netbsd_eabihf.rs | 2 +- .../spec/armv7_wrs_vxworks_eabihf.rs | 2 +- src/librustc_target/spec/armv7a_none_eabi.rs | 2 +- .../spec/armv7a_none_eabihf.rs | 2 +- src/librustc_target/spec/armv7r_none_eabi.rs | 2 +- .../spec/armv7r_none_eabihf.rs | 2 +- src/librustc_target/spec/armv7s_apple_ios.rs | 2 +- src/librustc_target/spec/mod.rs | 50 +++++++++++-------- .../spec/nvptx64_nvidia_cuda.rs | 2 +- .../spec/riscv32i_unknown_none_elf.rs | 2 +- .../spec/riscv32imac_unknown_none_elf.rs | 2 +- .../spec/riscv32imc_unknown_none_elf.rs | 2 +- .../spec/riscv64gc_unknown_linux_gnu.rs | 2 +- .../spec/riscv64gc_unknown_none_elf.rs | 2 +- .../spec/riscv64imac_unknown_none_elf.rs | 2 +- src/librustc_target/spec/riscv_base.rs | 2 +- src/librustc_target/spec/thumb_base.rs | 2 +- .../spec/thumbv7a_pc_windows_msvc.rs | 2 +- .../spec/thumbv7a_uwp_windows_msvc.rs | 2 +- .../spec/thumbv7neon_linux_androideabi.rs | 2 +- .../thumbv7neon_unknown_linux_gnueabihf.rs | 2 +- .../thumbv7neon_unknown_linux_musleabihf.rs | 2 +- src/test/ui/issues/issue-29540.rs | 2 +- src/tools/compiletest/src/main.rs | 6 +-- 63 files changed, 111 insertions(+), 107 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0570.md b/src/librustc_error_codes/error_codes/E0570.md index bf9615f87387d..355e71ffb4329 100644 --- a/src/librustc_error_codes/error_codes/E0570.md +++ b/src/librustc_error_codes/error_codes/E0570.md @@ -1,6 +1,6 @@ The requested ABI is unsupported by the current target. -The rust compiler maintains for each target a blacklist of ABIs unsupported on +The rust compiler maintains for each target a list of unsupported ABIs on that target. If an ABI is present in such a list this usually means that the target / ABI combination is currently unsupported by llvm. diff --git a/src/librustc_resolve/imports.rs b/src/librustc_resolve/imports.rs index ded0ee8a96699..4595a96ce24f5 100644 --- a/src/librustc_resolve/imports.rs +++ b/src/librustc_resolve/imports.rs @@ -262,8 +262,8 @@ impl<'a> Resolver<'a> { } let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| { - if let Some(blacklisted_binding) = this.blacklisted_binding { - if ptr::eq(binding, blacklisted_binding) { + if let Some(unusable_binding) = this.unusable_binding { + if ptr::eq(binding, unusable_binding) { return Err((Determined, Weak::No)); } } @@ -278,12 +278,12 @@ impl<'a> Resolver<'a> { return resolution .binding .and_then(|binding| { - // If the primary binding is blacklisted, search further and return the shadowed - // glob binding if it exists. What we really want here is having two separate - // scopes in a module - one for non-globs and one for globs, but until that's done - // use this hack to avoid inconsistent resolution ICEs during import validation. - if let Some(blacklisted_binding) = self.blacklisted_binding { - if ptr::eq(binding, blacklisted_binding) { + // If the primary binding is unusable, search further and return the shadowed glob + // binding if it exists. What we really want here is having two separate scopes in + // a module - one for non-globs and one for globs, but until that's done use this + // hack to avoid inconsistent resolution ICEs during import validation. + if let Some(unusable_binding) = self.unusable_binding { + if ptr::eq(binding, unusable_binding) { return resolution.shadowed_glob; } } @@ -875,9 +875,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> { /// consolidate multiple unresolved import errors into a single diagnostic. fn finalize_import(&mut self, import: &'b Import<'b>) -> Option { let orig_vis = import.vis.replace(ty::Visibility::Invisible); - let orig_blacklisted_binding = match &import.kind { + let orig_unusable_binding = match &import.kind { ImportKind::Single { target_bindings, .. } => { - Some(mem::replace(&mut self.r.blacklisted_binding, target_bindings[TypeNS].get())) + Some(mem::replace(&mut self.r.unusable_binding, target_bindings[TypeNS].get())) } _ => None, }; @@ -891,8 +891,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> { import.crate_lint(), ); let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len; - if let Some(orig_blacklisted_binding) = orig_blacklisted_binding { - self.r.blacklisted_binding = orig_blacklisted_binding; + if let Some(orig_unusable_binding) = orig_unusable_binding { + self.r.unusable_binding = orig_unusable_binding; } import.vis.set(orig_vis); if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res { @@ -1013,8 +1013,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> { self.r.per_ns(|this, ns| { if !type_ns_only || ns == TypeNS { let orig_vis = import.vis.replace(ty::Visibility::Invisible); - let orig_blacklisted_binding = - mem::replace(&mut this.blacklisted_binding, target_bindings[ns].get()); + let orig_unusable_binding = + mem::replace(&mut this.unusable_binding, target_bindings[ns].get()); let orig_last_import_segment = mem::replace(&mut this.last_import_segment, true); let binding = this.resolve_ident_in_module( module, @@ -1025,7 +1025,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { import.span, ); this.last_import_segment = orig_last_import_segment; - this.blacklisted_binding = orig_blacklisted_binding; + this.unusable_binding = orig_unusable_binding; import.vis.set(orig_vis); match binding { @@ -1291,8 +1291,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> { return; } - let orig_blacklisted_binding = - mem::replace(&mut this.blacklisted_binding, target_bindings[ns].get()); + let orig_unusable_binding = + mem::replace(&mut this.unusable_binding, target_bindings[ns].get()); match this.early_resolve_ident_in_lexical_scope( target, @@ -1311,7 +1311,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { Err(_) => is_redundant[ns] = Some(false), } - this.blacklisted_binding = orig_blacklisted_binding; + this.unusable_binding = orig_unusable_binding; } }); diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 4451791780ead..679f5637686ff 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -842,14 +842,14 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { report_error(self, ns); } Some(LexicalScopeBinding::Item(binding)) => { - let orig_blacklisted_binding = - replace(&mut self.r.blacklisted_binding, Some(binding)); + let orig_unusable_binding = + replace(&mut self.r.unusable_binding, Some(binding)); if let Some(LexicalScopeBinding::Res(..)) = self .resolve_ident_in_lexical_scope(ident, ns, None, use_tree.prefix.span) { report_error(self, ns); } - self.r.blacklisted_binding = orig_blacklisted_binding; + self.r.unusable_binding = orig_unusable_binding; } None => {} } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index f3a1934abc9fe..edc37bac5dc67 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -867,7 +867,7 @@ pub struct Resolver<'a> { last_import_segment: bool, /// This binding should be ignored during in-module resolution, so that we don't get /// "self-confirming" import resolutions during import validation. - blacklisted_binding: Option<&'a NameBinding<'a>>, + unusable_binding: Option<&'a NameBinding<'a>>, /// The idents for the primitive types. primitive_type_table: PrimitiveTypeTable, @@ -1266,7 +1266,7 @@ impl<'a> Resolver<'a> { indeterminate_imports: Vec::new(), last_import_segment: false, - blacklisted_binding: None, + unusable_binding: None, primitive_type_table: PrimitiveTypeTable::new(), diff --git a/src/librustc_target/spec/aarch64_apple_ios.rs b/src/librustc_target/spec/aarch64_apple_ios.rs index 1447716ca8484..21dcec8d5e384 100644 --- a/src/librustc_target/spec/aarch64_apple_ios.rs +++ b/src/librustc_target/spec/aarch64_apple_ios.rs @@ -18,7 +18,7 @@ pub fn target() -> TargetResult { features: "+neon,+fp-armv8,+apple-a7".to_string(), eliminate_frame_pointer: false, max_atomic_width: Some(128), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), forces_embed_bitcode: true, // Taken from a clang build on Xcode 11.4.1. // These arguments are not actually invoked - they just have diff --git a/src/librustc_target/spec/aarch64_apple_tvos.rs b/src/librustc_target/spec/aarch64_apple_tvos.rs index 21f660ac8b839..2b0cd6cabf80f 100644 --- a/src/librustc_target/spec/aarch64_apple_tvos.rs +++ b/src/librustc_target/spec/aarch64_apple_tvos.rs @@ -18,7 +18,7 @@ pub fn target() -> TargetResult { features: "+neon,+fp-armv8,+apple-a7".to_string(), eliminate_frame_pointer: false, max_atomic_width: Some(128), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), forces_embed_bitcode: true, ..base }, diff --git a/src/librustc_target/spec/aarch64_fuchsia.rs b/src/librustc_target/spec/aarch64_fuchsia.rs index c0d5d575b6eb5..aabfe458ca3b6 100644 --- a/src/librustc_target/spec/aarch64_fuchsia.rs +++ b/src/librustc_target/spec/aarch64_fuchsia.rs @@ -15,6 +15,6 @@ pub fn target() -> TargetResult { target_env: String::new(), target_vendor: String::new(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base }, + options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) } diff --git a/src/librustc_target/spec/aarch64_linux_android.rs b/src/librustc_target/spec/aarch64_linux_android.rs index 03fd059d60278..e4ecc7ac2dc80 100644 --- a/src/librustc_target/spec/aarch64_linux_android.rs +++ b/src/librustc_target/spec/aarch64_linux_android.rs @@ -20,6 +20,6 @@ pub fn target() -> TargetResult { target_env: String::new(), target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base }, + options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) } diff --git a/src/librustc_target/spec/aarch64_unknown_cloudabi.rs b/src/librustc_target/spec/aarch64_unknown_cloudabi.rs index 7141954306769..1278b89c7fde2 100644 --- a/src/librustc_target/spec/aarch64_unknown_cloudabi.rs +++ b/src/librustc_target/spec/aarch64_unknown_cloudabi.rs @@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::cloudabi_base::opts(); base.max_atomic_width = Some(128); - base.abi_blacklist = super::arm_base::abi_blacklist(); + base.unsupported_abis = super::arm_base::unsupported_abis(); base.linker = Some("aarch64-unknown-cloudabi-cc".to_string()); Ok(Target { diff --git a/src/librustc_target/spec/aarch64_unknown_freebsd.rs b/src/librustc_target/spec/aarch64_unknown_freebsd.rs index 2177b7a0add32..5ae592c5139c8 100644 --- a/src/librustc_target/spec/aarch64_unknown_freebsd.rs +++ b/src/librustc_target/spec/aarch64_unknown_freebsd.rs @@ -15,6 +15,6 @@ pub fn target() -> TargetResult { target_env: String::new(), target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base }, + options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) } diff --git a/src/librustc_target/spec/aarch64_unknown_hermit.rs b/src/librustc_target/spec/aarch64_unknown_hermit.rs index 7b020605102b1..5f978c03248b2 100644 --- a/src/librustc_target/spec/aarch64_unknown_hermit.rs +++ b/src/librustc_target/spec/aarch64_unknown_hermit.rs @@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::hermit_base::opts(); base.max_atomic_width = Some(128); - base.abi_blacklist = super::arm_base::abi_blacklist(); + base.unsupported_abis = super::arm_base::unsupported_abis(); base.linker = Some("aarch64-hermit-gcc".to_string()); Ok(Target { diff --git a/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs b/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs index 81f5fc8501584..036162248c76e 100644 --- a/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/aarch64_unknown_linux_gnu.rs @@ -16,7 +16,7 @@ pub fn target() -> TargetResult { target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}_mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/aarch64_unknown_linux_musl.rs b/src/librustc_target/spec/aarch64_unknown_linux_musl.rs index 608b9d29b329f..dc613f35d1d31 100644 --- a/src/librustc_target/spec/aarch64_unknown_linux_musl.rs +++ b/src/librustc_target/spec/aarch64_unknown_linux_musl.rs @@ -16,7 +16,7 @@ pub fn target() -> TargetResult { target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}_mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/aarch64_unknown_netbsd.rs b/src/librustc_target/spec/aarch64_unknown_netbsd.rs index b06a2a906697c..8c2f6fcff7304 100644 --- a/src/librustc_target/spec/aarch64_unknown_netbsd.rs +++ b/src/librustc_target/spec/aarch64_unknown_netbsd.rs @@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); base.max_atomic_width = Some(128); - base.abi_blacklist = super::arm_base::abi_blacklist(); + base.unsupported_abis = super::arm_base::unsupported_abis(); Ok(Target { llvm_target: "aarch64-unknown-netbsd".to_string(), diff --git a/src/librustc_target/spec/aarch64_unknown_none.rs b/src/librustc_target/spec/aarch64_unknown_none.rs index 7177c4e251e77..e012dce73fecb 100644 --- a/src/librustc_target/spec/aarch64_unknown_none.rs +++ b/src/librustc_target/spec/aarch64_unknown_none.rs @@ -18,7 +18,7 @@ pub fn target() -> Result { linker_is_gnu: true, max_atomic_width: Some(128), panic_strategy: PanicStrategy::Abort, - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), ..Default::default() }; Ok(Target { diff --git a/src/librustc_target/spec/aarch64_unknown_none_softfloat.rs b/src/librustc_target/spec/aarch64_unknown_none_softfloat.rs index 986300c677dfc..e2aa6e3b8f52c 100644 --- a/src/librustc_target/spec/aarch64_unknown_none_softfloat.rs +++ b/src/librustc_target/spec/aarch64_unknown_none_softfloat.rs @@ -18,7 +18,7 @@ pub fn target() -> Result { linker_is_gnu: true, max_atomic_width: Some(128), panic_strategy: PanicStrategy::Abort, - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), ..Default::default() }; Ok(Target { diff --git a/src/librustc_target/spec/aarch64_unknown_openbsd.rs b/src/librustc_target/spec/aarch64_unknown_openbsd.rs index c9cd64c3a84af..fd726c70f496b 100644 --- a/src/librustc_target/spec/aarch64_unknown_openbsd.rs +++ b/src/librustc_target/spec/aarch64_unknown_openbsd.rs @@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::openbsd_base::opts(); base.max_atomic_width = Some(128); - base.abi_blacklist = super::arm_base::abi_blacklist(); + base.unsupported_abis = super::arm_base::unsupported_abis(); Ok(Target { llvm_target: "aarch64-unknown-openbsd".to_string(), diff --git a/src/librustc_target/spec/aarch64_wrs_vxworks.rs b/src/librustc_target/spec/aarch64_wrs_vxworks.rs index 47b003b71144c..05f5d7d3a8b47 100644 --- a/src/librustc_target/spec/aarch64_wrs_vxworks.rs +++ b/src/librustc_target/spec/aarch64_wrs_vxworks.rs @@ -15,6 +15,6 @@ pub fn target() -> TargetResult { target_env: "gnu".to_string(), target_vendor: "wrs".to_string(), linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base }, + options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) } diff --git a/src/librustc_target/spec/arm_base.rs b/src/librustc_target/spec/arm_base.rs index 77e7bfac62d58..b74d80dc6bb2b 100644 --- a/src/librustc_target/spec/arm_base.rs +++ b/src/librustc_target/spec/arm_base.rs @@ -1,6 +1,6 @@ use crate::spec::abi::Abi; // All the calling conventions trigger an assertion(Unsupported calling convention) in llvm on arm -pub fn abi_blacklist() -> Vec { +pub fn unsupported_abis() -> Vec { vec![Abi::Stdcall, Abi::Fastcall, Abi::Vectorcall, Abi::Thiscall, Abi::Win64, Abi::SysV64] } diff --git a/src/librustc_target/spec/arm_linux_androideabi.rs b/src/librustc_target/spec/arm_linux_androideabi.rs index 5dc6eaca9194e..7109d043f519c 100644 --- a/src/librustc_target/spec/arm_linux_androideabi.rs +++ b/src/librustc_target/spec/arm_linux_androideabi.rs @@ -17,6 +17,6 @@ pub fn target() -> TargetResult { target_env: String::new(), target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base }, + options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) } diff --git a/src/librustc_target/spec/arm_unknown_linux_gnueabi.rs b/src/librustc_target/spec/arm_unknown_linux_gnueabi.rs index ead483df155a9..2e3bad83e2559 100644 --- a/src/librustc_target/spec/arm_unknown_linux_gnueabi.rs +++ b/src/librustc_target/spec/arm_unknown_linux_gnueabi.rs @@ -17,7 +17,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+strict-align,+v6".to_string(), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}__gnu_mcount_nc".to_string(), ..base }, diff --git a/src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs b/src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs index 53d2e9a46d080..f8e357cce6636 100644 --- a/src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs +++ b/src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs @@ -17,7 +17,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+strict-align,+v6,+vfp2,-d32".to_string(), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}__gnu_mcount_nc".to_string(), ..base }, diff --git a/src/librustc_target/spec/arm_unknown_linux_musleabi.rs b/src/librustc_target/spec/arm_unknown_linux_musleabi.rs index 03d191990c397..75753af9f3078 100644 --- a/src/librustc_target/spec/arm_unknown_linux_musleabi.rs +++ b/src/librustc_target/spec/arm_unknown_linux_musleabi.rs @@ -22,7 +22,7 @@ pub fn target() -> TargetResult { target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/arm_unknown_linux_musleabihf.rs b/src/librustc_target/spec/arm_unknown_linux_musleabihf.rs index bd92f0f434711..c74c88e36125f 100644 --- a/src/librustc_target/spec/arm_unknown_linux_musleabihf.rs +++ b/src/librustc_target/spec/arm_unknown_linux_musleabihf.rs @@ -22,7 +22,7 @@ pub fn target() -> TargetResult { target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/armebv7r_none_eabi.rs b/src/librustc_target/spec/armebv7r_none_eabi.rs index a1f68f6706a2a..e0d1f2653ce0b 100644 --- a/src/librustc_target/spec/armebv7r_none_eabi.rs +++ b/src/librustc_target/spec/armebv7r_none_eabi.rs @@ -22,7 +22,7 @@ pub fn target() -> TargetResult { relocation_model: RelocModel::Static, panic_strategy: PanicStrategy::Abort, max_atomic_width: Some(32), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), emit_debug_gdb_scripts: false, ..Default::default() }, diff --git a/src/librustc_target/spec/armebv7r_none_eabihf.rs b/src/librustc_target/spec/armebv7r_none_eabihf.rs index 4d81c21f52a7b..e2d37d45bf147 100644 --- a/src/librustc_target/spec/armebv7r_none_eabihf.rs +++ b/src/librustc_target/spec/armebv7r_none_eabihf.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { panic_strategy: PanicStrategy::Abort, features: "+vfp3,-d32,-fp16".to_string(), max_atomic_width: Some(32), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), emit_debug_gdb_scripts: false, ..Default::default() }, diff --git a/src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs b/src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs index 60f822a02947d..2580e8b0f8515 100644 --- a/src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs +++ b/src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs @@ -18,7 +18,7 @@ pub fn target() -> TargetResult { features: "+soft-float,+strict-align".to_string(), // Atomic operations provided by compiler-builtins max_atomic_width: Some(32), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}__gnu_mcount_nc".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs b/src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs index 9fa0f609c7481..f28421dc77593 100644 --- a/src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs +++ b/src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs @@ -18,7 +18,7 @@ pub fn target() -> TargetResult { features: "+soft-float,+strict-align".to_string(), // Atomic operations provided by compiler-builtins max_atomic_width: Some(32), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}__gnu_mcount_nc".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs b/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs index bb19eb455cd3b..fe1fa88883d3e 100644 --- a/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs +++ b/src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs @@ -21,7 +21,7 @@ pub fn target() -> TargetResult { features: "+soft-float,+strict-align".to_string(), // Atomic operations provided by compiler-builtins max_atomic_width: Some(32), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv6_unknown_freebsd.rs b/src/librustc_target/spec/armv6_unknown_freebsd.rs index bbab1c60b1358..1e06f837997a1 100644 --- a/src/librustc_target/spec/armv6_unknown_freebsd.rs +++ b/src/librustc_target/spec/armv6_unknown_freebsd.rs @@ -17,7 +17,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+v6,+vfp2,-d32".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}__gnu_mcount_nc".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs b/src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs index 4332d1498e7fa..ef40085888c81 100644 --- a/src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs +++ b/src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs @@ -17,7 +17,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+v6,+vfp2,-d32".to_string(), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "__mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv7_apple_ios.rs b/src/librustc_target/spec/armv7_apple_ios.rs index c0c2ae909f8f0..393843526a8cc 100644 --- a/src/librustc_target/spec/armv7_apple_ios.rs +++ b/src/librustc_target/spec/armv7_apple_ios.rs @@ -17,7 +17,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+v7,+vfp3,+neon".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) diff --git a/src/librustc_target/spec/armv7_linux_androideabi.rs b/src/librustc_target/spec/armv7_linux_androideabi.rs index 38d854163ecb6..38c6c31bd10da 100644 --- a/src/librustc_target/spec/armv7_linux_androideabi.rs +++ b/src/librustc_target/spec/armv7_linux_androideabi.rs @@ -25,6 +25,6 @@ pub fn target() -> TargetResult { target_env: String::new(), target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base }, + options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) } diff --git a/src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs b/src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs index 7d34f5c63bfa1..e3f4fe0b2efb6 100644 --- a/src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs +++ b/src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs @@ -5,7 +5,7 @@ pub fn target() -> TargetResult { base.cpu = "cortex-a8".to_string(); base.max_atomic_width = Some(64); base.features = "+v7,+vfp3,+neon".to_string(); - base.abi_blacklist = super::arm_base::abi_blacklist(); + base.unsupported_abis = super::arm_base::unsupported_abis(); base.linker = Some("armv7-unknown-cloudabi-eabihf-cc".to_string()); Ok(Target { diff --git a/src/librustc_target/spec/armv7_unknown_freebsd.rs b/src/librustc_target/spec/armv7_unknown_freebsd.rs index e747ddca58a85..80a9e6d7e3c80 100644 --- a/src/librustc_target/spec/armv7_unknown_freebsd.rs +++ b/src/librustc_target/spec/armv7_unknown_freebsd.rs @@ -17,7 +17,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}__gnu_mcount_nc".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv7_unknown_linux_gnueabi.rs b/src/librustc_target/spec/armv7_unknown_linux_gnueabi.rs index c887bdf2a102b..0f175e9aef5e8 100644 --- a/src/librustc_target/spec/armv7_unknown_linux_gnueabi.rs +++ b/src/librustc_target/spec/armv7_unknown_linux_gnueabi.rs @@ -21,7 +21,7 @@ pub fn target() -> TargetResult { features: "+v7,+thumb2,+soft-float,-neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}__gnu_mcount_nc".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs b/src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs index 4ebc3416156b6..27923457cd16e 100644 --- a/src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs +++ b/src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs @@ -22,7 +22,7 @@ pub fn target() -> TargetResult { features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}__gnu_mcount_nc".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv7_unknown_linux_musleabi.rs b/src/librustc_target/spec/armv7_unknown_linux_musleabi.rs index bee3e2604adf2..3d1bf05237fd9 100644 --- a/src/librustc_target/spec/armv7_unknown_linux_musleabi.rs +++ b/src/librustc_target/spec/armv7_unknown_linux_musleabi.rs @@ -26,7 +26,7 @@ pub fn target() -> TargetResult { features: "+v7,+thumb2,+soft-float,-neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs b/src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs index c3cfeca7f27b7..03d7d88b0d6d0 100644 --- a/src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs +++ b/src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs @@ -25,7 +25,7 @@ pub fn target() -> TargetResult { features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs b/src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs index 9d382fe04be2d..18fc9ed2ec638 100644 --- a/src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs +++ b/src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs @@ -18,7 +18,7 @@ pub fn target() -> TargetResult { features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "__mcount".to_string(), ..base }, diff --git a/src/librustc_target/spec/armv7_wrs_vxworks_eabihf.rs b/src/librustc_target/spec/armv7_wrs_vxworks_eabihf.rs index 34eb04ea83e11..04d8702471af5 100644 --- a/src/librustc_target/spec/armv7_wrs_vxworks_eabihf.rs +++ b/src/librustc_target/spec/armv7_wrs_vxworks_eabihf.rs @@ -18,7 +18,7 @@ pub fn target() -> TargetResult { features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) diff --git a/src/librustc_target/spec/armv7a_none_eabi.rs b/src/librustc_target/spec/armv7a_none_eabi.rs index 09f1494e81cdb..1db279defff39 100644 --- a/src/librustc_target/spec/armv7a_none_eabi.rs +++ b/src/librustc_target/spec/armv7a_none_eabi.rs @@ -28,7 +28,7 @@ pub fn target() -> Result { disable_redzone: true, max_atomic_width: Some(64), panic_strategy: PanicStrategy::Abort, - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), emit_debug_gdb_scripts: false, ..Default::default() }; diff --git a/src/librustc_target/spec/armv7a_none_eabihf.rs b/src/librustc_target/spec/armv7a_none_eabihf.rs index 653ca76435bc5..22c2b306b43bb 100644 --- a/src/librustc_target/spec/armv7a_none_eabihf.rs +++ b/src/librustc_target/spec/armv7a_none_eabihf.rs @@ -16,7 +16,7 @@ pub fn target() -> Result { disable_redzone: true, max_atomic_width: Some(64), panic_strategy: PanicStrategy::Abort, - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), emit_debug_gdb_scripts: false, ..Default::default() }; diff --git a/src/librustc_target/spec/armv7r_none_eabi.rs b/src/librustc_target/spec/armv7r_none_eabi.rs index 29dfa17039736..fed83997190a7 100644 --- a/src/librustc_target/spec/armv7r_none_eabi.rs +++ b/src/librustc_target/spec/armv7r_none_eabi.rs @@ -22,7 +22,7 @@ pub fn target() -> TargetResult { relocation_model: RelocModel::Static, panic_strategy: PanicStrategy::Abort, max_atomic_width: Some(32), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), emit_debug_gdb_scripts: false, ..Default::default() }, diff --git a/src/librustc_target/spec/armv7r_none_eabihf.rs b/src/librustc_target/spec/armv7r_none_eabihf.rs index e6b0187c3313a..769ac13e51506 100644 --- a/src/librustc_target/spec/armv7r_none_eabihf.rs +++ b/src/librustc_target/spec/armv7r_none_eabihf.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { panic_strategy: PanicStrategy::Abort, features: "+vfp3,-d32,-fp16".to_string(), max_atomic_width: Some(32), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), emit_debug_gdb_scripts: false, ..Default::default() }, diff --git a/src/librustc_target/spec/armv7s_apple_ios.rs b/src/librustc_target/spec/armv7s_apple_ios.rs index 6a5654f10d416..998a7b2e16489 100644 --- a/src/librustc_target/spec/armv7s_apple_ios.rs +++ b/src/librustc_target/spec/armv7s_apple_ios.rs @@ -17,7 +17,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+v7,+vfp4,+neon".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 29250f21383be..4a2dd8913185f 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -902,9 +902,10 @@ pub struct TargetOptions { /// Panic strategy: "unwind" or "abort" pub panic_strategy: PanicStrategy, - /// A blacklist of ABIs unsupported by the current target. Note that generic - /// ABIs are considered to be supported on all platforms and cannot be blacklisted. - pub abi_blacklist: Vec, + /// A list of ABIs unsupported by the current target. Note that generic ABIs + /// are considered to be supported on all platforms and cannot be marked + /// unsupported. + pub unsupported_abis: Vec, /// Whether or not linking dylibs to a static CRT is allowed. pub crt_static_allows_dylibs: bool, @@ -1056,7 +1057,7 @@ impl Default for TargetOptions { max_atomic_width: None, atomic_cas: true, panic_strategy: PanicStrategy::Unwind, - abi_blacklist: vec![], + unsupported_abis: vec![], crt_static_allows_dylibs: false, crt_static_default: false, crt_static_respected: false, @@ -1125,7 +1126,7 @@ impl Target { } pub fn is_abi_supported(&self, abi: Abi) -> bool { - abi.generic() || !self.options.abi_blacklist.contains(&abi) + abi.generic() || !self.options.unsupported_abis.contains(&abi) } /// Loads a target descriptor from a JSON object. @@ -1474,22 +1475,29 @@ impl Target { key!(llvm_args, list); key!(use_ctors_section, bool); - if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) { - for name in array.iter().filter_map(|abi| abi.as_string()) { - match lookup_abi(name) { - Some(abi) => { - if abi.generic() { + // NB: The old name is deprecated, but support for it is retained for + // compatibility. + for name in ["abi-blacklist", "unsupported-abis"].iter() { + if let Some(array) = obj.find(name).and_then(Json::as_array) { + for name in array.iter().filter_map(|abi| abi.as_string()) { + match lookup_abi(name) { + Some(abi) => { + if abi.generic() { + return Err(format!( + "The ABI \"{}\" is considered to be supported on all \ + targets and cannot be marked unsupported", + abi + )); + } + + base.options.unsupported_abis.push(abi) + } + None => { return Err(format!( - "The ABI \"{}\" is considered to be supported on \ - all targets and cannot be blacklisted", - abi + "Unknown ABI \"{}\" in target specification", + name )); } - - base.options.abi_blacklist.push(abi) - } - None => { - return Err(format!("Unknown ABI \"{}\" in target specification", name)); } } } @@ -1705,11 +1713,11 @@ impl ToJson for Target { target_option_val!(llvm_args); target_option_val!(use_ctors_section); - if default.abi_blacklist != self.options.abi_blacklist { + if default.unsupported_abis != self.options.unsupported_abis { d.insert( - "abi-blacklist".to_string(), + "unsupported-abis".to_string(), self.options - .abi_blacklist + .unsupported_abis .iter() .map(|&name| Abi::name(name).to_json()) .collect::>() diff --git a/src/librustc_target/spec/nvptx64_nvidia_cuda.rs b/src/librustc_target/spec/nvptx64_nvidia_cuda.rs index e0a402533e777..0c8f2a34301ee 100644 --- a/src/librustc_target/spec/nvptx64_nvidia_cuda.rs +++ b/src/librustc_target/spec/nvptx64_nvidia_cuda.rs @@ -55,7 +55,7 @@ pub fn target() -> TargetResult { // FIXME: enable compilation tests for the target and // create the tests for this. - abi_blacklist: vec![ + unsupported_abis: vec![ Abi::Cdecl, Abi::Stdcall, Abi::Fastcall, diff --git a/src/librustc_target/spec/riscv32i_unknown_none_elf.rs b/src/librustc_target/spec/riscv32i_unknown_none_elf.rs index d7b3e7e15307a..977aa896f2520 100644 --- a/src/librustc_target/spec/riscv32i_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv32i_unknown_none_elf.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, emit_debug_gdb_scripts: false, - abi_blacklist: super::riscv_base::abi_blacklist(), + unsupported_abis: super::riscv_base::unsupported_abis(), ..Default::default() }, }) diff --git a/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs b/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs index b93b6fcf8002a..1a85cdff1315c 100644 --- a/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, emit_debug_gdb_scripts: false, - abi_blacklist: super::riscv_base::abi_blacklist(), + unsupported_abis: super::riscv_base::unsupported_abis(), ..Default::default() }, }) diff --git a/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs b/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs index a16e7e31c6619..e3c1c6908a23a 100644 --- a/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, emit_debug_gdb_scripts: false, - abi_blacklist: super::riscv_base::abi_blacklist(), + unsupported_abis: super::riscv_base::unsupported_abis(), ..Default::default() }, }) diff --git a/src/librustc_target/spec/riscv64gc_unknown_linux_gnu.rs b/src/librustc_target/spec/riscv64gc_unknown_linux_gnu.rs index 715449d74ce22..f7a93c916d1d5 100644 --- a/src/librustc_target/spec/riscv64gc_unknown_linux_gnu.rs +++ b/src/librustc_target/spec/riscv64gc_unknown_linux_gnu.rs @@ -13,7 +13,7 @@ pub fn target() -> TargetResult { target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { - abi_blacklist: super::riscv_base::abi_blacklist(), + unsupported_abis: super::riscv_base::unsupported_abis(), code_model: Some(CodeModel::Medium), cpu: "generic-rv64".to_string(), features: "+m,+a,+f,+d,+c".to_string(), diff --git a/src/librustc_target/spec/riscv64gc_unknown_none_elf.rs b/src/librustc_target/spec/riscv64gc_unknown_none_elf.rs index e5147a12ed320..857af4ceb0d9f 100644 --- a/src/librustc_target/spec/riscv64gc_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv64gc_unknown_none_elf.rs @@ -25,7 +25,7 @@ pub fn target() -> TargetResult { relocation_model: RelocModel::Static, code_model: Some(CodeModel::Medium), emit_debug_gdb_scripts: false, - abi_blacklist: super::riscv_base::abi_blacklist(), + unsupported_abis: super::riscv_base::unsupported_abis(), ..Default::default() }, }) diff --git a/src/librustc_target/spec/riscv64imac_unknown_none_elf.rs b/src/librustc_target/spec/riscv64imac_unknown_none_elf.rs index dc056b55b3868..36fe7730f95bf 100644 --- a/src/librustc_target/spec/riscv64imac_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv64imac_unknown_none_elf.rs @@ -25,7 +25,7 @@ pub fn target() -> TargetResult { relocation_model: RelocModel::Static, code_model: Some(CodeModel::Medium), emit_debug_gdb_scripts: false, - abi_blacklist: super::riscv_base::abi_blacklist(), + unsupported_abis: super::riscv_base::unsupported_abis(), ..Default::default() }, }) diff --git a/src/librustc_target/spec/riscv_base.rs b/src/librustc_target/spec/riscv_base.rs index ec1dc9b4918bd..64cf890037e51 100644 --- a/src/librustc_target/spec/riscv_base.rs +++ b/src/librustc_target/spec/riscv_base.rs @@ -2,7 +2,7 @@ use crate::spec::abi::Abi; // All the calling conventions trigger an assertion(Unsupported calling // convention) in llvm on RISCV -pub fn abi_blacklist() -> Vec { +pub fn unsupported_abis() -> Vec { vec![ Abi::Cdecl, Abi::Stdcall, diff --git a/src/librustc_target/spec/thumb_base.rs b/src/librustc_target/spec/thumb_base.rs index 646a149a33621..2f7d15d5856f6 100644 --- a/src/librustc_target/spec/thumb_base.rs +++ b/src/librustc_target/spec/thumb_base.rs @@ -41,7 +41,7 @@ pub fn opts() -> TargetOptions { // Similarly, one almost always never wants to use relocatable code because of the extra // costs it involves. relocation_model: RelocModel::Static, - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), // When this section is added a volatile load to its start address is also generated. This // volatile load is a footgun as it can end up loading an invalid memory address, depending // on how the user set up their linker scripts. This section adds pretty printer for stuff diff --git a/src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs b/src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs index 21d62d252e09a..37828026fe113 100644 --- a/src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs +++ b/src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs @@ -37,7 +37,7 @@ pub fn target() -> TargetResult { features: "+vfp3,+neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) diff --git a/src/librustc_target/spec/thumbv7a_uwp_windows_msvc.rs b/src/librustc_target/spec/thumbv7a_uwp_windows_msvc.rs index ff2e892100607..29a4a9875e5b0 100644 --- a/src/librustc_target/spec/thumbv7a_uwp_windows_msvc.rs +++ b/src/librustc_target/spec/thumbv7a_uwp_windows_msvc.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+vfp3,+neon".to_string(), cpu: "generic".to_string(), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) diff --git a/src/librustc_target/spec/thumbv7neon_linux_androideabi.rs b/src/librustc_target/spec/thumbv7neon_linux_androideabi.rs index 02ad9ab7d9a8c..c52f077f6f16c 100644 --- a/src/librustc_target/spec/thumbv7neon_linux_androideabi.rs +++ b/src/librustc_target/spec/thumbv7neon_linux_androideabi.rs @@ -25,6 +25,6 @@ pub fn target() -> TargetResult { target_env: "".to_string(), target_vendor: "unknown".to_string(), linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base }, + options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) } diff --git a/src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs b/src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs index 04e051485a933..78936948e642e 100644 --- a/src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs +++ b/src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs @@ -25,7 +25,7 @@ pub fn target() -> TargetResult { features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), ..base }, }) diff --git a/src/librustc_target/spec/thumbv7neon_unknown_linux_musleabihf.rs b/src/librustc_target/spec/thumbv7neon_unknown_linux_musleabihf.rs index 3d39a405a411c..f759c3eeb011c 100644 --- a/src/librustc_target/spec/thumbv7neon_unknown_linux_musleabihf.rs +++ b/src/librustc_target/spec/thumbv7neon_unknown_linux_musleabihf.rs @@ -29,7 +29,7 @@ pub fn target() -> TargetResult { features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), + unsupported_abis: super::arm_base::unsupported_abis(), target_mcount: "\u{1}mcount".to_string(), ..base }, diff --git a/src/test/ui/issues/issue-29540.rs b/src/test/ui/issues/issue-29540.rs index 2a4d50f613cdc..c0de20822bacf 100644 --- a/src/test/ui/issues/issue-29540.rs +++ b/src/test/ui/issues/issue-29540.rs @@ -283,7 +283,7 @@ pub struct Config { pub mds_beacon_interval: String, pub mds_beacon_grace: String, pub mds_enforce_unique_name: String, - pub mds_blacklist_interval: String, + pub mds_interval: String, pub mds_session_timeout: String, pub mds_freeze_tree_timeout: String, pub mds_session_autoclose: String, diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 2aea4d22700f3..97272f1a9c1b6 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -401,7 +401,7 @@ fn configure_lldb(config: &Config) -> Option { } if let Some(lldb_version) = config.lldb_version.as_ref() { - if is_blacklisted_lldb_version(&lldb_version) { + if lldb_version == "350" { println!( "WARNING: The used version of LLDB ({}) has a \ known issue that breaks debuginfo tests. See \ @@ -979,7 +979,3 @@ fn extract_lldb_version(full_version_line: Option) -> (Option, b } (None, false) } - -fn is_blacklisted_lldb_version(version: &str) -> bool { - version == "350" -} From 56b6b44641f0dc999a63b478c93af5279ad7464f Mon Sep 17 00:00:00 2001 From: Seth Pellegrino Date: Wed, 8 Jul 2020 09:48:15 -0700 Subject: [PATCH 18/28] Avoid running test on Windows platforms There don't seem to be any other compiletests that are 1) building a standalone "no_core" create and then 2) trying to link against it. There seems to be a platform-specific limitation in doing so: ``` 2020-07-08T16:07:42.9419409Z = note: Creating library D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\intra-link-prim-methods-external-core\auxiliary\my_core.dll.lib and object D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\intra-link-prim-methods-external-core\auxiliary\my_core.dll.exp 2020-07-08T16:07:42.9419810Z LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12 2020-07-08T16:07:42.9420032Z D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\intra-link-prim-methods-external-core\auxiliary\my_core.dll : fatal error LNK1120: 1 unresolved externals ``` Possibly this could be resolved by adding a `__DllMainCRTStartup` or `__DllMainCRTStartup@12` symbol in an architecture- and platform-specific way. --- src/test/rustdoc/intra-link-prim-methods-external-core.rs | 1 + 1 file changed, 1 insertion(+) 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 b9bdd86ecc56b..e09d36594edf9 100644 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ b/src/test/rustdoc/intra-link-prim-methods-external-core.rs @@ -1,6 +1,7 @@ // aux-build:my-core.rs // build-aux-docs // ignore-cross-compile +// ignore-windows // ignore-tidy-linelength #![deny(intra_doc_link_resolution_failure)] From ca22091a9070e7bc05b7c3577cdd5555b226ffa3 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 7 Jul 2020 15:33:21 -0700 Subject: [PATCH 19/28] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index fede83ccf9734..4f74d9b2a771c 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit fede83ccf973457de319ba6fa0e36ead454d2e20 +Subproject commit 4f74d9b2a771c58b7ef4906b2668afd075bc8081 From 81c5bb6a3fb02d1c1c3a4698e9e0e031ef2f4e4e Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 6 Jul 2020 10:53:14 +1000 Subject: [PATCH 20/28] Eliminate confusing "globals" terminology. There are some structures that are called "globals", but are they global to a compilation session, and not truly global. I have always found this highly confusing, so this commit renames them as "session globals" and adds a comment explaining things. Also, the commit fixes an unnecessary nesting of `set()` calls `src/librustc_errors/json/tests.rs` --- src/librustc_ast/attr/mod.rs | 42 +++++++++++-------- src/librustc_ast/lib.rs | 2 +- src/librustc_ast/util/lev_distance/tests.rs | 4 +- src/librustc_ast_pretty/pprust/tests.rs | 6 +-- src/librustc_errors/json/tests.rs | 8 ++-- src/librustc_expand/mut_visit/tests.rs | 6 +-- src/librustc_expand/parse/lexer/tests.rs | 28 ++++++------- src/librustc_expand/parse/tests.rs | 24 +++++------ src/librustc_expand/tests.rs | 4 +- src/librustc_expand/tokenstream/tests.rs | 20 ++++----- src/librustc_interface/interface.rs | 2 +- src/librustc_interface/tests.rs | 10 ++--- src/librustc_interface/util.rs | 21 +++++----- src/librustc_middle/ty/query/job.rs | 15 ++++--- src/librustc_parse_format/tests.rs | 4 +- src/librustc_span/hygiene.rs | 4 +- src/librustc_span/lib.rs | 26 +++++++----- src/librustc_span/span_encoding.rs | 4 +- src/librustc_span/symbol.rs | 4 +- src/librustc_span/symbol/tests.rs | 4 +- src/librustdoc/clean/cfg/tests.rs | 16 +++---- src/librustdoc/test.rs | 3 +- .../ui-fulldeps/mod_dir_path_canonicalized.rs | 2 +- src/test/ui-fulldeps/pprust-expr-roundtrip.rs | 2 +- src/tools/error_index_generator/main.rs | 2 +- 25 files changed, 136 insertions(+), 127 deletions(-) diff --git a/src/librustc_ast/attr/mod.rs b/src/librustc_ast/attr/mod.rs index 76139209c9151..9d4b6dbed9870 100644 --- a/src/librustc_ast/attr/mod.rs +++ b/src/librustc_ast/attr/mod.rs @@ -21,55 +21,61 @@ use log::debug; use std::iter; use std::ops::DerefMut; -pub struct Globals { +// Per-session global variables: this struct is stored in thread-local storage +// in such a way that it is accessible without any kind of handle to all +// threads within the compilation session, but is not accessible outside the +// session. +pub struct SessionGlobals { used_attrs: Lock>, known_attrs: Lock>, - rustc_span_globals: rustc_span::Globals, + span_session_globals: rustc_span::SessionGlobals, } -impl Globals { - fn new(edition: Edition) -> Globals { - Globals { +impl SessionGlobals { + fn new(edition: Edition) -> SessionGlobals { + SessionGlobals { // We have no idea how many attributes there will be, so just // initiate the vectors with 0 bits. We'll grow them as necessary. used_attrs: Lock::new(GrowableBitSet::new_empty()), known_attrs: Lock::new(GrowableBitSet::new_empty()), - rustc_span_globals: rustc_span::Globals::new(edition), + span_session_globals: rustc_span::SessionGlobals::new(edition), } } } -pub fn with_globals(edition: Edition, f: impl FnOnce() -> R) -> R { - let globals = Globals::new(edition); - GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals.rustc_span_globals, f)) +pub fn with_session_globals(edition: Edition, f: impl FnOnce() -> R) -> R { + let ast_session_globals = SessionGlobals::new(edition); + SESSION_GLOBALS.set(&ast_session_globals, || { + rustc_span::SESSION_GLOBALS.set(&ast_session_globals.span_session_globals, f) + }) } -pub fn with_default_globals(f: impl FnOnce() -> R) -> R { - with_globals(DEFAULT_EDITION, f) +pub fn with_default_session_globals(f: impl FnOnce() -> R) -> R { + with_session_globals(DEFAULT_EDITION, f) } -scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals); +scoped_tls::scoped_thread_local!(pub static SESSION_GLOBALS: SessionGlobals); pub fn mark_used(attr: &Attribute) { debug!("marking {:?} as used", attr); - GLOBALS.with(|globals| { - globals.used_attrs.lock().insert(attr.id); + SESSION_GLOBALS.with(|session_globals| { + session_globals.used_attrs.lock().insert(attr.id); }); } pub fn is_used(attr: &Attribute) -> bool { - GLOBALS.with(|globals| globals.used_attrs.lock().contains(attr.id)) + SESSION_GLOBALS.with(|session_globals| session_globals.used_attrs.lock().contains(attr.id)) } pub fn mark_known(attr: &Attribute) { debug!("marking {:?} as known", attr); - GLOBALS.with(|globals| { - globals.known_attrs.lock().insert(attr.id); + SESSION_GLOBALS.with(|session_globals| { + session_globals.known_attrs.lock().insert(attr.id); }); } pub fn is_known(attr: &Attribute) -> bool { - GLOBALS.with(|globals| globals.known_attrs.lock().contains(attr.id)) + SESSION_GLOBALS.with(|session_globals| session_globals.known_attrs.lock().contains(attr.id)) } pub fn is_known_lint_tool(m_item: Ident) -> bool { diff --git a/src/librustc_ast/lib.rs b/src/librustc_ast/lib.rs index 5c1c9d6ab906e..ffd2aa61f2866 100644 --- a/src/librustc_ast/lib.rs +++ b/src/librustc_ast/lib.rs @@ -43,7 +43,7 @@ pub mod util { pub mod ast; pub mod attr; -pub use attr::{with_default_globals, with_globals, GLOBALS}; +pub use attr::{with_default_session_globals, with_session_globals, SESSION_GLOBALS}; pub mod crate_disambiguator; pub mod entry; pub mod expand; diff --git a/src/librustc_ast/util/lev_distance/tests.rs b/src/librustc_ast/util/lev_distance/tests.rs index 222661687c1c2..e9b6c9759b644 100644 --- a/src/librustc_ast/util/lev_distance/tests.rs +++ b/src/librustc_ast/util/lev_distance/tests.rs @@ -21,8 +21,8 @@ fn test_lev_distance() { #[test] fn test_find_best_match_for_name() { - use crate::with_default_globals; - with_default_globals(|| { + use crate::with_default_session_globals; + with_default_session_globals(|| { let input = vec![Symbol::intern("aaab"), Symbol::intern("aaabc")]; assert_eq!( find_best_match_for_name(input.iter(), "aaaa", None), diff --git a/src/librustc_ast_pretty/pprust/tests.rs b/src/librustc_ast_pretty/pprust/tests.rs index f92e40ed6ffab..96377a4ae02fa 100644 --- a/src/librustc_ast_pretty/pprust/tests.rs +++ b/src/librustc_ast_pretty/pprust/tests.rs @@ -1,7 +1,7 @@ use super::*; use rustc_ast::ast; -use rustc_ast::with_default_globals; +use rustc_ast::with_default_session_globals; use rustc_span::source_map::respan; use rustc_span::symbol::Ident; @@ -25,7 +25,7 @@ fn variant_to_string(var: &ast::Variant) -> String { #[test] fn test_fun_to_string() { - with_default_globals(|| { + with_default_session_globals(|| { let abba_ident = Ident::from_str("abba"); let decl = @@ -40,7 +40,7 @@ fn test_fun_to_string() { #[test] fn test_variant_to_string() { - with_default_globals(|| { + with_default_session_globals(|| { let ident = Ident::from_str("principal_skinner"); let var = ast::Variant { diff --git a/src/librustc_errors/json/tests.rs b/src/librustc_errors/json/tests.rs index 35912901d688a..3a501dd5254c4 100644 --- a/src/librustc_errors/json/tests.rs +++ b/src/librustc_errors/json/tests.rs @@ -39,16 +39,16 @@ impl Write for Shared { } } -fn with_default_globals(f: impl FnOnce()) { - let globals = rustc_span::Globals::new(rustc_span::edition::DEFAULT_EDITION); - rustc_span::GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals, f)) +fn with_default_session_globals(f: impl FnOnce()) { + let session_globals = rustc_span::SessionGlobals::new(rustc_span::edition::DEFAULT_EDITION); + rustc_span::SESSION_GLOBALS.set(&session_globals, f); } /// Test the span yields correct positions in JSON. fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) { let expected_output = TestData { spans: vec![expected_output] }; - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); sm.new_source_file(Path::new("test.rs").to_owned().into(), code.to_owned()); diff --git a/src/librustc_expand/mut_visit/tests.rs b/src/librustc_expand/mut_visit/tests.rs index 48da1a3ccc420..c22d2a100c32e 100644 --- a/src/librustc_expand/mut_visit/tests.rs +++ b/src/librustc_expand/mut_visit/tests.rs @@ -2,7 +2,7 @@ use crate::tests::{matches_codepattern, string_to_crate}; use rustc_ast::ast; use rustc_ast::mut_visit::{self, MutVisitor}; -use rustc_ast::with_default_globals; +use rustc_ast::with_default_session_globals; use rustc_ast_pretty::pprust; use rustc_span::symbol::Ident; @@ -38,7 +38,7 @@ macro_rules! assert_pred { // Make sure idents get transformed everywhere. #[test] fn ident_transformation() { - with_default_globals(|| { + with_default_session_globals(|| { let mut zz_visitor = ToZzIdentMutVisitor; let mut krate = string_to_crate("#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string()); @@ -55,7 +55,7 @@ fn ident_transformation() { // Make sure idents get transformed even inside macro defs. #[test] fn ident_transformation_in_defs() { - with_default_globals(|| { + with_default_session_globals(|| { let mut zz_visitor = ToZzIdentMutVisitor; let mut krate = string_to_crate( "macro_rules! a {(b $c:expr $(d $e:token)f+ => \ diff --git a/src/librustc_expand/parse/lexer/tests.rs b/src/librustc_expand/parse/lexer/tests.rs index 2932475430bbf..b3775c78e7345 100644 --- a/src/librustc_expand/parse/lexer/tests.rs +++ b/src/librustc_expand/parse/lexer/tests.rs @@ -1,6 +1,6 @@ use rustc_ast::token::{self, Token, TokenKind}; use rustc_ast::util::comments::is_doc_comment; -use rustc_ast::with_default_globals; +use rustc_ast::with_default_session_globals; use rustc_data_structures::sync::Lrc; use rustc_errors::{emitter::EmitterWriter, Handler}; use rustc_parse::lexer::StringReader; @@ -33,7 +33,7 @@ fn setup<'a>(sm: &SourceMap, sess: &'a ParseSess, teststr: String) -> StringRead #[test] fn t1() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); let mut string_reader = setup( @@ -79,7 +79,7 @@ fn mk_lit(kind: token::LitKind, symbol: &str, suffix: Option<&str>) -> TokenKind #[test] fn doublecolon_parsing() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); check_tokenization( @@ -91,7 +91,7 @@ fn doublecolon_parsing() { #[test] fn doublecolon_parsing_2() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); check_tokenization( @@ -103,7 +103,7 @@ fn doublecolon_parsing_2() { #[test] fn doublecolon_parsing_3() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); check_tokenization( @@ -115,7 +115,7 @@ fn doublecolon_parsing_3() { #[test] fn doublecolon_parsing_4() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); check_tokenization( @@ -127,7 +127,7 @@ fn doublecolon_parsing_4() { #[test] fn character_a() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token(), mk_lit(token::Char, "a", None),); @@ -136,7 +136,7 @@ fn character_a() { #[test] fn character_space() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token(), mk_lit(token::Char, " ", None),); @@ -145,7 +145,7 @@ fn character_space() { #[test] fn character_escaped() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); assert_eq!( @@ -157,7 +157,7 @@ fn character_escaped() { #[test] fn lifetime_name() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); assert_eq!( @@ -169,7 +169,7 @@ fn lifetime_name() { #[test] fn raw_string() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); assert_eq!( @@ -181,7 +181,7 @@ fn raw_string() { #[test] fn literal_suffixes() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); macro_rules! test { @@ -232,7 +232,7 @@ fn line_doc_comments() { #[test] fn nested_block_comments() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); let mut lexer = setup(&sm, &sh, "/* /* */ */'a'".to_string()); @@ -243,7 +243,7 @@ fn nested_block_comments() { #[test] fn crlf_comments() { - with_default_globals(|| { + with_default_session_globals(|| { let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let sh = mk_sess(sm.clone()); let mut lexer = setup(&sm, &sh, "// test\r\n/// test\r\n".to_string()); diff --git a/src/librustc_expand/parse/tests.rs b/src/librustc_expand/parse/tests.rs index 437f6e62d7d33..fc9b9f2dab04e 100644 --- a/src/librustc_expand/parse/tests.rs +++ b/src/librustc_expand/parse/tests.rs @@ -5,7 +5,7 @@ use rustc_ast::ptr::P; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; use rustc_ast::visit; -use rustc_ast::with_default_globals; +use rustc_ast::with_default_session_globals; use rustc_ast_pretty::pprust::item_to_string; use rustc_errors::PResult; use rustc_parse::new_parser_from_source_str; @@ -50,7 +50,7 @@ fn string_to_item(source_str: String) -> Option> { #[should_panic] #[test] fn bad_path_expr_1() { - with_default_globals(|| { + with_default_session_globals(|| { string_to_expr("::abc::def::return".to_string()); }) } @@ -58,7 +58,7 @@ fn bad_path_expr_1() { // Checks the token-tree-ization of macros. #[test] fn string_to_tts_macro() { - with_default_globals(|| { + with_default_session_globals(|| { let tts: Vec<_> = string_to_stream("macro_rules! zip (($a)=>($a))".to_string()).trees().collect(); let tts: &[TokenTree] = &tts[..]; @@ -95,7 +95,7 @@ fn string_to_tts_macro() { #[test] fn string_to_tts_1() { - with_default_globals(|| { + with_default_session_globals(|| { let tts = string_to_stream("fn a (b : i32) { b; }".to_string()); let expected = TokenStream::new(vec![ @@ -130,7 +130,7 @@ fn string_to_tts_1() { #[test] fn parse_use() { - with_default_globals(|| { + with_default_session_globals(|| { let use_s = "use foo::bar::baz;"; let vitem = string_to_item(use_s.to_string()).unwrap(); let vitem_s = item_to_string(&vitem); @@ -145,7 +145,7 @@ fn parse_use() { #[test] fn parse_extern_crate() { - with_default_globals(|| { + with_default_session_globals(|| { let ex_s = "extern crate foo;"; let vitem = string_to_item(ex_s.to_string()).unwrap(); let vitem_s = item_to_string(&vitem); @@ -183,7 +183,7 @@ fn get_spans_of_pat_idents(src: &str) -> Vec { #[test] fn span_of_self_arg_pat_idents_are_correct() { - with_default_globals(|| { + with_default_session_globals(|| { let srcs = [ "impl z { fn a (&self, &myarg: i32) {} }", "impl z { fn a (&mut self, &myarg: i32) {} }", @@ -207,7 +207,7 @@ fn span_of_self_arg_pat_idents_are_correct() { #[test] fn parse_exprs() { - with_default_globals(|| { + with_default_session_globals(|| { // just make sure that they parse.... string_to_expr("3 + 4".to_string()); string_to_expr("a::z.froob(b,&(987+3))".to_string()); @@ -216,7 +216,7 @@ fn parse_exprs() { #[test] fn attrs_fix_bug() { - with_default_globals(|| { + with_default_session_globals(|| { string_to_item( "pub fn mk_file_writer(path: &Path, flags: &[FileFlag]) -> Result, String> { @@ -237,7 +237,7 @@ let mut fflags: c_int = wb(); #[test] fn crlf_doc_comments() { - with_default_globals(|| { + with_default_session_globals(|| { let sess = sess(); let name_1 = FileName::Custom("crlf_source_1".to_string()); @@ -271,7 +271,7 @@ fn ttdelim_span() { new_parser_from_source_str(sess, name, source).parse_expr() } - with_default_globals(|| { + with_default_session_globals(|| { let sess = sess(); let expr = parse_expr_from_source_str( PathBuf::from("foo").into(), @@ -299,7 +299,7 @@ fn ttdelim_span() { // See `recurse_into_file_modules` in the parser. #[test] fn out_of_line_mod() { - with_default_globals(|| { + with_default_session_globals(|| { let item = parse_item_from_source_str( PathBuf::from("foo").into(), "mod foo { struct S; mod this_does_not_exist; }".to_owned(), diff --git a/src/librustc_expand/tests.rs b/src/librustc_expand/tests.rs index fbc49ddd562b5..283ea0f68d924 100644 --- a/src/librustc_expand/tests.rs +++ b/src/librustc_expand/tests.rs @@ -1,6 +1,6 @@ use rustc_ast::ast; use rustc_ast::tokenstream::TokenStream; -use rustc_ast::with_default_globals; +use rustc_ast::with_default_session_globals; use rustc_parse::{new_parser_from_source_str, parser::Parser, source_file_to_stream}; use rustc_session::parse::ParseSess; use rustc_span::source_map::{FilePathMapping, SourceMap}; @@ -124,7 +124,7 @@ impl Write for Shared { } fn test_harness(file_text: &str, span_labels: Vec, expected_output: &str) { - with_default_globals(|| { + with_default_session_globals(|| { let output = Arc::new(Mutex::new(Vec::new())); let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty())); diff --git a/src/librustc_expand/tokenstream/tests.rs b/src/librustc_expand/tokenstream/tests.rs index caaa08df49981..bc171bec6ff7a 100644 --- a/src/librustc_expand/tokenstream/tests.rs +++ b/src/librustc_expand/tokenstream/tests.rs @@ -2,7 +2,7 @@ use crate::tests::string_to_stream; use rustc_ast::token; use rustc_ast::tokenstream::{TokenStream, TokenStreamBuilder, TokenTree}; -use rustc_ast::with_default_globals; +use rustc_ast::with_default_session_globals; use rustc_span::{BytePos, Span, Symbol}; use smallvec::smallvec; @@ -16,7 +16,7 @@ fn sp(a: u32, b: u32) -> Span { #[test] fn test_concat() { - with_default_globals(|| { + with_default_session_globals(|| { let test_res = string_to_ts("foo::bar::baz"); let test_fst = string_to_ts("foo::bar"); let test_snd = string_to_ts("::baz"); @@ -29,7 +29,7 @@ fn test_concat() { #[test] fn test_to_from_bijection() { - with_default_globals(|| { + with_default_session_globals(|| { let test_start = string_to_ts("foo::bar(baz)"); let test_end = test_start.trees().collect(); assert_eq!(test_start, test_end) @@ -38,7 +38,7 @@ fn test_to_from_bijection() { #[test] fn test_eq_0() { - with_default_globals(|| { + with_default_session_globals(|| { let test_res = string_to_ts("foo"); let test_eqs = string_to_ts("foo"); assert_eq!(test_res, test_eqs) @@ -47,7 +47,7 @@ fn test_eq_0() { #[test] fn test_eq_1() { - with_default_globals(|| { + with_default_session_globals(|| { let test_res = string_to_ts("::bar::baz"); let test_eqs = string_to_ts("::bar::baz"); assert_eq!(test_res, test_eqs) @@ -56,7 +56,7 @@ fn test_eq_1() { #[test] fn test_eq_3() { - with_default_globals(|| { + with_default_session_globals(|| { let test_res = string_to_ts(""); let test_eqs = string_to_ts(""); assert_eq!(test_res, test_eqs) @@ -65,7 +65,7 @@ fn test_eq_3() { #[test] fn test_diseq_0() { - with_default_globals(|| { + with_default_session_globals(|| { let test_res = string_to_ts("::bar::baz"); let test_eqs = string_to_ts("bar::baz"); assert_eq!(test_res == test_eqs, false) @@ -74,7 +74,7 @@ fn test_diseq_0() { #[test] fn test_diseq_1() { - with_default_globals(|| { + with_default_session_globals(|| { let test_res = string_to_ts("(bar,baz)"); let test_eqs = string_to_ts("bar,baz"); assert_eq!(test_res == test_eqs, false) @@ -83,7 +83,7 @@ fn test_diseq_1() { #[test] fn test_is_empty() { - with_default_globals(|| { + with_default_session_globals(|| { let test0: TokenStream = Vec::::new().into_iter().collect(); let test1: TokenStream = TokenTree::token(token::Ident(Symbol::intern("a"), false), sp(0, 1)).into(); @@ -97,7 +97,7 @@ fn test_is_empty() { #[test] fn test_dotdotdot() { - with_default_globals(|| { + with_default_session_globals(|| { let mut builder = TokenStreamBuilder::new(); builder.push(TokenTree::token(token::Dot, sp(0, 1)).joint()); builder.push(TokenTree::token(token::Dot, sp(1, 2)).joint()); diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index 920cc6021e687..4059022e7a581 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -74,7 +74,7 @@ impl Compiler { /// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`. pub fn parse_cfgspecs(cfgspecs: Vec) -> FxHashSet<(String, Option)> { - rustc_ast::with_default_globals(move || { + rustc_ast::with_default_session_globals(move || { let cfg = cfgspecs .into_iter() .map(|s| { diff --git a/src/librustc_interface/tests.rs b/src/librustc_interface/tests.rs index e35dbbc0c2f24..651a77912c6d0 100644 --- a/src/librustc_interface/tests.rs +++ b/src/librustc_interface/tests.rs @@ -73,7 +73,7 @@ fn mk_map(entries: Vec<(K, V)>) -> BTreeMap { // When the user supplies --test we should implicitly supply --cfg test #[test] fn test_switch_implies_cfg_test() { - rustc_ast::with_default_globals(|| { + rustc_ast::with_default_session_globals(|| { let matches = optgroups().parse(&["--test".to_string()]).unwrap(); let (sess, cfg) = mk_session(matches); let cfg = build_configuration(&sess, to_crate_config(cfg)); @@ -84,7 +84,7 @@ fn test_switch_implies_cfg_test() { // When the user supplies --test and --cfg test, don't implicitly add another --cfg test #[test] fn test_switch_implies_cfg_test_unless_cfg_test() { - rustc_ast::with_default_globals(|| { + rustc_ast::with_default_session_globals(|| { let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap(); let (sess, cfg) = mk_session(matches); let cfg = build_configuration(&sess, to_crate_config(cfg)); @@ -96,20 +96,20 @@ fn test_switch_implies_cfg_test_unless_cfg_test() { #[test] fn test_can_print_warnings() { - rustc_ast::with_default_globals(|| { + rustc_ast::with_default_session_globals(|| { let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap(); let (sess, _) = mk_session(matches); assert!(!sess.diagnostic().can_emit_warnings()); }); - rustc_ast::with_default_globals(|| { + rustc_ast::with_default_session_globals(|| { let matches = optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap(); let (sess, _) = mk_session(matches); assert!(sess.diagnostic().can_emit_warnings()); }); - rustc_ast::with_default_globals(|| { + rustc_ast::with_default_session_globals(|| { let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap(); let (sess, _) = mk_session(matches); assert!(sess.diagnostic().can_emit_warnings()); diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 924908e572487..fe091e920627c 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -141,7 +141,7 @@ pub fn spawn_thread_pool R + Send, R: Send>( crate::callbacks::setup_callbacks(); scoped_thread(cfg, || { - rustc_ast::with_globals(edition, || { + rustc_ast::with_session_globals(edition, || { ty::tls::GCX_PTR.set(&Lock::new(0), || { if let Some(stderr) = stderr { io::set_panic(Some(box Sink(stderr.clone()))); @@ -177,16 +177,17 @@ pub fn spawn_thread_pool R + Send, R: Send>( let with_pool = move |pool: &ThreadPool| pool.install(move || f()); - rustc_ast::with_globals(edition, || { - rustc_ast::GLOBALS.with(|syntax_globals| { - rustc_span::GLOBALS.with(|rustc_span_globals| { - // The main handler runs for each Rayon worker thread and sets up - // the thread local rustc uses. syntax_globals and rustc_span_globals are - // captured and set on the new threads. ty::tls::with_thread_locals sets up - // thread local callbacks from librustc_ast + rustc_ast::with_session_globals(edition, || { + rustc_ast::SESSION_GLOBALS.with(|ast_session_globals| { + rustc_span::SESSION_GLOBALS.with(|span_session_globals| { + // The main handler runs for each Rayon worker thread and sets + // up the thread local rustc uses. ast_session_globals and + // span_session_globals are captured and set on the new + // threads. ty::tls::with_thread_locals sets up thread local + // callbacks from librustc_ast. let main_handler = move |thread: ThreadBuilder| { - rustc_ast::GLOBALS.set(syntax_globals, || { - rustc_span::GLOBALS.set(rustc_span_globals, || { + rustc_ast::SESSION_GLOBALS.set(ast_session_globals, || { + rustc_span::SESSION_GLOBALS.set(span_session_globals, || { if let Some(stderr) = stderr { io::set_panic(Some(box Sink(stderr.clone()))); } diff --git a/src/librustc_middle/ty/query/job.rs b/src/librustc_middle/ty/query/job.rs index 5f7a9e81158e0..60b93b3d44d28 100644 --- a/src/librustc_middle/ty/query/job.rs +++ b/src/librustc_middle/ty/query/job.rs @@ -13,16 +13,15 @@ pub unsafe fn handle_deadlock() { let gcx_ptr = tls::GCX_PTR.with(|gcx_ptr| gcx_ptr as *const _); let gcx_ptr = &*gcx_ptr; - let rustc_span_globals = - rustc_span::GLOBALS.with(|rustc_span_globals| rustc_span_globals as *const _); - let rustc_span_globals = &*rustc_span_globals; - let syntax_globals = rustc_ast::attr::GLOBALS.with(|syntax_globals| syntax_globals as *const _); - let syntax_globals = &*syntax_globals; + let span_session_globals = rustc_span::SESSION_GLOBALS.with(|ssg| ssg as *const _); + let span_session_globals = &*span_session_globals; + let ast_session_globals = rustc_ast::attr::SESSION_GLOBALS.with(|asg| asg as *const _); + let ast_session_globals = &*ast_session_globals; thread::spawn(move || { tls::GCX_PTR.set(gcx_ptr, || { - rustc_ast::attr::GLOBALS.set(syntax_globals, || { - rustc_span::GLOBALS - .set(rustc_span_globals, || tls::with_global(|tcx| deadlock(tcx, ®istry))) + rustc_ast::attr::SESSION_GLOBALS.set(ast_session_globals, || { + rustc_span::SESSION_GLOBALS + .set(span_session_globals, || tls::with_global(|tcx| deadlock(tcx, ®istry))) }); }) }); diff --git a/src/librustc_parse_format/tests.rs b/src/librustc_parse_format/tests.rs index 9932c1df7a935..9fd0497fffee5 100644 --- a/src/librustc_parse_format/tests.rs +++ b/src/librustc_parse_format/tests.rs @@ -144,8 +144,8 @@ fn format_align_fill() { } #[test] fn format_counts() { - use rustc_span::{edition, Globals, GLOBALS}; - GLOBALS.set(&Globals::new(edition::DEFAULT_EDITION), || { + use rustc_span::{edition, SessionGlobals, SESSION_GLOBALS}; + SESSION_GLOBALS.set(&SessionGlobals::new(edition::DEFAULT_EDITION), || { same( "{:10x}", &[NextArgument(Argument { diff --git a/src/librustc_span/hygiene.rs b/src/librustc_span/hygiene.rs index fef1e34a23ba3..7249894ba28be 100644 --- a/src/librustc_span/hygiene.rs +++ b/src/librustc_span/hygiene.rs @@ -27,7 +27,7 @@ use crate::def_id::{DefId, CRATE_DEF_INDEX}; use crate::edition::Edition; use crate::symbol::{kw, sym, Symbol}; -use crate::GLOBALS; +use crate::SESSION_GLOBALS; use crate::{Span, DUMMY_SP}; use rustc_data_structures::fx::FxHashMap; @@ -174,7 +174,7 @@ impl HygieneData { } fn with T>(f: F) -> T { - GLOBALS.with(|globals| f(&mut *globals.hygiene_data.borrow_mut())) + SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.hygiene_data.borrow_mut())) } fn fresh_expn(&mut self, expn_data: Option) -> ExpnId { diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 046554067f4ce..699871f1c61ce 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -65,16 +65,20 @@ use sha1::Sha1; #[cfg(test)] mod tests; -pub struct Globals { +// Per-session global variables: this struct is stored in thread-local storage +// in such a way that it is accessible without any kind of handle to all +// threads within the compilation session, but is not accessible outside the +// session. +pub struct SessionGlobals { symbol_interner: Lock, span_interner: Lock, hygiene_data: Lock, source_map: Lock>>, } -impl Globals { - pub fn new(edition: Edition) -> Globals { - Globals { +impl SessionGlobals { + pub fn new(edition: Edition) -> SessionGlobals { + SessionGlobals { symbol_interner: Lock::new(symbol::Interner::fresh()), span_interner: Lock::new(span_encoding::SpanInterner::default()), hygiene_data: Lock::new(hygiene::HygieneData::new(edition)), @@ -83,7 +87,7 @@ impl Globals { } } -scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals); +scoped_tls::scoped_thread_local!(pub static SESSION_GLOBALS: SessionGlobals); // FIXME: Perhaps this should not implement Rustc{Decodable, Encodable} // @@ -713,14 +717,14 @@ impl rustc_serialize::UseSpecializedDecodable for Span { /// the `SourceMap` provided to this function. If that is not available, /// we fall back to printing the raw `Span` field values pub fn with_source_map T>(source_map: Lrc, f: F) -> T { - GLOBALS.with(|globals| { - *globals.source_map.borrow_mut() = Some(source_map); + SESSION_GLOBALS.with(|session_globals| { + *session_globals.source_map.borrow_mut() = Some(source_map); }); struct ClearSourceMap; impl Drop for ClearSourceMap { fn drop(&mut self) { - GLOBALS.with(|globals| { - globals.source_map.borrow_mut().take(); + SESSION_GLOBALS.with(|session_globals| { + session_globals.source_map.borrow_mut().take(); }); } } @@ -738,8 +742,8 @@ pub fn debug_with_source_map( } pub fn default_span_debug(span: Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { - GLOBALS.with(|globals| { - if let Some(source_map) = &*globals.source_map.borrow() { + SESSION_GLOBALS.with(|session_globals| { + if let Some(source_map) = &*session_globals.source_map.borrow() { debug_with_source_map(span, f, source_map) } else { f.debug_struct("Span") diff --git a/src/librustc_span/span_encoding.rs b/src/librustc_span/span_encoding.rs index d769cf83a0347..6b672d344fa51 100644 --- a/src/librustc_span/span_encoding.rs +++ b/src/librustc_span/span_encoding.rs @@ -5,7 +5,7 @@ // See https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28 use crate::hygiene::SyntaxContext; -use crate::GLOBALS; +use crate::SESSION_GLOBALS; use crate::{BytePos, SpanData}; use rustc_data_structures::fx::FxHashMap; @@ -136,5 +136,5 @@ impl SpanInterner { // If an interner exists, return it. Otherwise, prepare a fresh one. #[inline] fn with_span_interner T>(f: F) -> T { - GLOBALS.with(|globals| f(&mut *globals.span_interner.lock())) + SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.span_interner.lock())) } diff --git a/src/librustc_span/symbol.rs b/src/librustc_span/symbol.rs index acc2a50abe88e..0470ceb60b15c 100644 --- a/src/librustc_span/symbol.rs +++ b/src/librustc_span/symbol.rs @@ -14,7 +14,7 @@ use std::fmt; use std::hash::{Hash, Hasher}; use std::str; -use crate::{Span, DUMMY_SP, GLOBALS}; +use crate::{Span, DUMMY_SP, SESSION_GLOBALS}; #[cfg(test)] mod tests; @@ -1307,7 +1307,7 @@ impl Ident { #[inline] fn with_interner T>(f: F) -> T { - GLOBALS.with(|globals| f(&mut *globals.symbol_interner.lock())) + SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.symbol_interner.lock())) } /// An alternative to `Symbol`, useful when the chars within the symbol need to diff --git a/src/librustc_span/symbol/tests.rs b/src/librustc_span/symbol/tests.rs index f74b9a0cd1d1d..47da03424b770 100644 --- a/src/librustc_span/symbol/tests.rs +++ b/src/librustc_span/symbol/tests.rs @@ -1,6 +1,6 @@ use super::*; -use crate::{edition, Globals}; +use crate::{edition, SessionGlobals}; #[test] fn interner_tests() { @@ -18,7 +18,7 @@ fn interner_tests() { #[test] fn without_first_quote_test() { - GLOBALS.set(&Globals::new(edition::DEFAULT_EDITION), || { + SESSION_GLOBALS.set(&SessionGlobals::new(edition::DEFAULT_EDITION), || { let i = Ident::from_str("'break"); assert_eq!(i.without_first_quote().name, kw::Break); }); diff --git a/src/librustdoc/clean/cfg/tests.rs b/src/librustdoc/clean/cfg/tests.rs index 716263393ba8d..8d1193e7f82b5 100644 --- a/src/librustdoc/clean/cfg/tests.rs +++ b/src/librustdoc/clean/cfg/tests.rs @@ -2,7 +2,7 @@ use super::*; use rustc_ast::ast::*; use rustc_ast::attr; -use rustc_ast::with_default_globals; +use rustc_ast::with_default_session_globals; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::DUMMY_SP; @@ -52,7 +52,7 @@ macro_rules! dummy_meta_item_list { #[test] fn test_cfg_not() { - with_default_globals(|| { + with_default_session_globals(|| { assert_eq!(!Cfg::False, Cfg::True); assert_eq!(!Cfg::True, Cfg::False); assert_eq!(!word_cfg("test"), Cfg::Not(Box::new(word_cfg("test")))); @@ -70,7 +70,7 @@ fn test_cfg_not() { #[test] fn test_cfg_and() { - with_default_globals(|| { + with_default_session_globals(|| { let mut x = Cfg::False; x &= Cfg::True; assert_eq!(x, Cfg::False); @@ -154,7 +154,7 @@ fn test_cfg_and() { #[test] fn test_cfg_or() { - with_default_globals(|| { + with_default_session_globals(|| { let mut x = Cfg::True; x |= Cfg::False; assert_eq!(x, Cfg::True); @@ -238,7 +238,7 @@ fn test_cfg_or() { #[test] fn test_parse_ok() { - with_default_globals(|| { + with_default_session_globals(|| { let mi = dummy_meta_item_word("all"); assert_eq!(Cfg::parse(&mi), Ok(word_cfg("all"))); @@ -271,7 +271,7 @@ fn test_parse_ok() { #[test] fn test_parse_err() { - with_default_globals(|| { + with_default_session_globals(|| { let mi = attr::mk_name_value_item(Ident::from_str("foo"), LitKind::Bool(false), DUMMY_SP); assert!(Cfg::parse(&mi).is_err()); @@ -303,7 +303,7 @@ fn test_parse_err() { #[test] fn test_render_short_html() { - with_default_globals(|| { + with_default_session_globals(|| { assert_eq!(word_cfg("unix").render_short_html(), "Unix"); assert_eq!(name_value_cfg("target_os", "macos").render_short_html(), "macOS"); assert_eq!(name_value_cfg("target_pointer_width", "16").render_short_html(), "16-bit"); @@ -358,7 +358,7 @@ fn test_render_short_html() { #[test] fn test_render_long_html() { - with_default_globals(|| { + with_default_session_globals(|| { assert_eq!( word_cfg("unix").render_long_html(), "This is supported on Unix only." diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index e9504aa3af123..71d74e77e33f8 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -1,5 +1,4 @@ use rustc_ast::ast; -use rustc_ast::with_globals; use rustc_data_structures::sync::Lrc; use rustc_errors::ErrorReported; use rustc_feature::UnstableFeatures; @@ -399,7 +398,7 @@ pub fn make_test( // Uses librustc_ast to parse the doctest and find if there's a main fn and the extern // crate already is included. let result = rustc_driver::catch_fatal_errors(|| { - with_globals(edition, || { + rustc_ast::with_session_globals(edition, || { use rustc_errors::emitter::EmitterWriter; use rustc_errors::Handler; use rustc_parse::maybe_new_parser_from_source_str; diff --git a/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs b/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs index ff7bbafe7c212..836cb07d5d172 100644 --- a/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs +++ b/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs @@ -19,7 +19,7 @@ use std::path::Path; mod gravy; pub fn main() { - rustc_ast::with_default_globals(|| parse()); + rustc_ast::with_default_session_globals(|| parse()); assert_eq!(gravy::foo(), 10); } diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index 6da26e6cfbe41..8286b7fdb6698 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -208,7 +208,7 @@ impl MutVisitor for AddParens { } fn main() { - rustc_ast::with_default_globals(|| run()); + rustc_ast::with_default_session_globals(|| run()); } fn run() { diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index 097fb1f985a74..9aea859999cea 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -284,7 +284,7 @@ fn parse_args() -> (OutputFormat, PathBuf) { fn main() { env_logger::init(); let (format, dst) = parse_args(); - let result = rustc_ast::with_default_globals(move || main_with_result(format, &dst)); + let result = rustc_ast::with_default_session_globals(move || main_with_result(format, &dst)); if let Err(e) = result { panic!("{}", e.to_string()); } From 35fae7364f228dd2b0bd8f1955ef655842d0450c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 9 Jul 2020 13:36:16 +0200 Subject: [PATCH 21/28] update miri --- src/tools/miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri b/src/tools/miri index fd8101247749c..eb5ff1791be70 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit fd8101247749c5be6850d5cb5096f01a1867e5ba +Subproject commit eb5ff1791be706d173b4f4c29e9c0529b4235c0e From 09f51d41cc5b567679a7b844f64d7ced37b66e83 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sat, 27 Jun 2020 12:12:55 -0700 Subject: [PATCH 22/28] Add docs for intra-doc-links --- src/doc/rustdoc/src/SUMMARY.md | 1 + src/doc/rustdoc/src/intra-doc-links.md | 59 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/doc/rustdoc/src/intra-doc-links.md diff --git a/src/doc/rustdoc/src/SUMMARY.md b/src/doc/rustdoc/src/SUMMARY.md index f982863e67b94..1f38ab9c835e3 100644 --- a/src/doc/rustdoc/src/SUMMARY.md +++ b/src/doc/rustdoc/src/SUMMARY.md @@ -7,5 +7,6 @@ - [Documentation tests](documentation-tests.md) - [Lints](lints.md) - [Passes](passes.md) +- [Intra-doc links](intra-doc-links.md) - [Advanced Features](advanced-features.md) - [Unstable features](unstable-features.md) diff --git a/src/doc/rustdoc/src/intra-doc-links.md b/src/doc/rustdoc/src/intra-doc-links.md new file mode 100644 index 0000000000000..d203978111547 --- /dev/null +++ b/src/doc/rustdoc/src/intra-doc-links.md @@ -0,0 +1,59 @@ +# Intra-doc links + +_This feature is currently nightly-only_ + +Rustdoc is capable of directly linking to other rustdoc pages in Markdown documentation using the path of item as a link. + +For example, in the following code all of the links will link to the rustdoc page for `Bar`: + +```rust + +/// This struct is not [Bar] +pub struct Foo1; + +/// This struct is also not [bar](Bar) +pub struct Foo2; + +/// This struct is also not [bar][b] +/// +/// [b]: Bar +pub struct Foo3; + +/// This struct is also not [`Bar`] +pub struct Foo4; + +pub struct Bar; +``` + +You can refer to anything in scope, and use paths, including `Self`. You may also use `foo()` and `foo!()` to refer to methods/functions and macros respectively. + +```rust,edition2018 +use std::sync::mpsc::Receiver; + +/// This is an version of [`Receiver`], with support for [`std::future`]. +/// +/// You can obtain a [`std::future::Future`] by calling [`Self::recv()`]. +pub struct AsyncReceiver { + sender: Receiver +} + +impl AsyncReceiver { + pub async fn recv() -> T { + unimplemented!() + } +} +``` + +Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@` , `macro@`, or `derive@`: + +```rust +/// See also: [`Foo`](struct@Foo) +struct Bar; + +/// This is different from [`Foo`](fn@Foo) +struct Foo {} + +fn Foo() {} +``` + +Note: Because of how `macro_rules` macros are scoped in Rust, the intra-doc links of a `macro_rules` macro will be resolved relative to the crate root, as opposed to the module it is defined in. From 271e2a988faa00e7cd1308641ade1f25304ef459 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 9 Jul 2020 08:31:44 -0700 Subject: [PATCH 23/28] Update src/doc/rustdoc/src/intra-doc-links.md --- src/doc/rustdoc/src/intra-doc-links.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/rustdoc/src/intra-doc-links.md b/src/doc/rustdoc/src/intra-doc-links.md index d203978111547..a0781e2e7690f 100644 --- a/src/doc/rustdoc/src/intra-doc-links.md +++ b/src/doc/rustdoc/src/intra-doc-links.md @@ -7,7 +7,6 @@ Rustdoc is capable of directly linking to other rustdoc pages in Markdown docume For example, in the following code all of the links will link to the rustdoc page for `Bar`: ```rust - /// This struct is not [Bar] pub struct Foo1; From 08d3a74a8f2538714129386f3f1a7153c49c9300 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sat, 27 Jun 2020 00:22:03 -0700 Subject: [PATCH 24/28] Allow for parentheses after macro intra-doc-links --- src/librustdoc/passes/collect_intra_doc_links.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index f1d1bf439f171..4fcf6ceb44d50 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -602,6 +602,9 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { kind = Some(ValueNS); disambiguator = Some(&prefix[..prefix.len() - 1]); link.trim_start_matches(prefix) + } else if link.ends_with("!()") { + kind = Some(MacroNS); + link.trim_end_matches("!()") } else if link.ends_with("()") { kind = Some(ValueNS); disambiguator = Some("fn"); From fc6ee8f38b42830378c770e3b786138be0f35ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 9 Jul 2020 09:05:40 -0700 Subject: [PATCH 25/28] Reduce indentation --- src/librustc_resolve/diagnostics.rs | 68 ++++++++++++++--------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 2854683b61bab..be2ad6d17389e 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -840,44 +840,42 @@ impl<'a> Resolver<'a> { suggestion: Option, span: Span, ) -> bool { - if let Some(suggestion) = suggestion { + let suggestion = match suggestion { + None => return false, // We shouldn't suggest underscore. - if suggestion.candidate == kw::Underscore { - return false; - } - - let msg = format!( - "{} {} with a similar name exists", - suggestion.res.article(), - suggestion.res.descr() - ); - err.span_suggestion( - span, - &msg, - suggestion.candidate.to_string(), - Applicability::MaybeIncorrect, - ); - let def_span = suggestion.res.opt_def_id().and_then(|def_id| match def_id.krate { - LOCAL_CRATE => self.opt_span(def_id), - _ => Some( - self.session - .source_map() - .guess_head_span(self.cstore().get_span_untracked(def_id, self.session)), + Some(suggestion) if suggestion.candidate == kw::Underscore => return false, + Some(suggestion) => suggestion, + }; + let msg = format!( + "{} {} with a similar name exists", + suggestion.res.article(), + suggestion.res.descr() + ); + err.span_suggestion( + span, + &msg, + suggestion.candidate.to_string(), + Applicability::MaybeIncorrect, + ); + let def_span = suggestion.res.opt_def_id().and_then(|def_id| match def_id.krate { + LOCAL_CRATE => self.opt_span(def_id), + _ => Some( + self.session + .source_map() + .guess_head_span(self.cstore().get_span_untracked(def_id, self.session)), + ), + }); + if let Some(span) = def_span { + err.span_label( + self.session.source_map().guess_head_span(span), + &format!( + "similarly named {} `{}` defined here", + suggestion.res.descr(), + suggestion.candidate.as_str(), ), - }); - if let Some(span) = def_span { - err.span_label( - self.session.source_map().guess_head_span(span), - &format!( - "similarly named {} `{}` defined here", - suggestion.res.descr(), - suggestion.candidate.as_str(), - ), - ); - } - return true; + ); } - false + true } fn binding_description(&self, b: &NameBinding<'_>, ident: Ident, from_prelude: bool) -> String { From e771a4f989644fd6397c391af1db94d459980b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 9 Jul 2020 09:09:25 -0700 Subject: [PATCH 26/28] Tweak `::` -> `:` typo heuristic and reduce verbosity Do not trigger on correct type ascription expressions with trailing operators and _do_ trigger on likely path typos where a turbofish is used. On likely path typos, remove note explaining type ascription. --- src/librustc_parse/parser/diagnostics.rs | 21 ++++++++++++------- .../ui/lifetime_starts_expressions.stderr | 3 +-- .../issue-35813-postfix-after-cast.stderr | 20 +++++++++--------- .../type-ascription-instead-of-method.stderr | 1 - .../type-ascription-instead-of-path-2.stderr | 1 - .../type-ascription-instead-of-variant.stderr | 1 - .../ui/type/ascription/issue-47666.stderr | 1 - .../ui/type/ascription/issue-54516.stderr | 1 - .../ui/type/ascription/issue-60933.stderr | 1 - 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index fc9ffc3092447..df601bce58973 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -346,13 +346,16 @@ impl<'a> Parser<'a> { if allow_unstable { // Give extra information about type ascription only if it's a nightly compiler. err.note( - "`#![feature(type_ascription)]` lets you annotate an expression with a \ - type: `: `", - ); - err.note( - "see issue #23416 \ - for more information", + "`#![feature(type_ascription)]` lets you annotate an expression with a type: \ + `: `", ); + if !likely_path { + // Avoid giving too much info when it was likely an unrelated typo. + err.note( + "see issue #23416 \ + for more information", + ); + } } } } @@ -1152,8 +1155,10 @@ impl<'a> Parser<'a> { } && !self.token.is_reserved_ident() && // v `foo:bar(baz)` self.look_ahead(1, |t| t == &token::OpenDelim(token::Paren)) - || self.look_ahead(1, |t| t == &token::Lt) && // `foo:bar: ` - = note: see issue #23416 for more information error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/issue-35813-postfix-after-cast.stderr b/src/test/ui/parser/issue-35813-postfix-after-cast.stderr index 255e9f409218b..9ccf17a6cb10e 100644 --- a/src/test/ui/parser/issue-35813-postfix-after-cast.stderr +++ b/src/test/ui/parser/issue-35813-postfix-after-cast.stderr @@ -280,12 +280,12 @@ error: casts cannot be followed by ? --> $DIR/issue-35813-postfix-after-cast.rs:121:5 | LL | Err(0u64): Result?; - | ^^^^^^^^^-^^^^^^^^^^^^^^^^ - | | - | help: maybe write a path separator here: `::` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information +help: try surrounding the expression in parentheses + | +LL | (Err(0u64): Result)?; + | ^ ^ error: casts cannot be followed by a function call --> $DIR/issue-35813-postfix-after-cast.rs:145:5 @@ -324,12 +324,12 @@ error: casts cannot be followed by `.await` --> $DIR/issue-35813-postfix-after-cast.rs:155:5 | LL | Box::pin(noop()): Pin>.await; - | ^^^^^^^^^^^^^^^^-^^^^^^^^^^^^ - | | - | help: maybe write a path separator here: `::` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information +LL | (Box::pin(noop()): Pin>).await; + | ^ ^ error: casts cannot be followed by a field access --> $DIR/issue-35813-postfix-after-cast.rs:167:5 diff --git a/src/test/ui/suggestions/type-ascription-instead-of-method.stderr b/src/test/ui/suggestions/type-ascription-instead-of-method.stderr index 998129ebd1d40..c111b4a9bc706 100644 --- a/src/test/ui/suggestions/type-ascription-instead-of-method.stderr +++ b/src/test/ui/suggestions/type-ascription-instead-of-method.stderr @@ -7,7 +7,6 @@ LL | Box:new("foo".to_string()) | help: maybe write a path separator here: `::` | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information error: aborting due to previous error diff --git a/src/test/ui/suggestions/type-ascription-instead-of-path-2.stderr b/src/test/ui/suggestions/type-ascription-instead-of-path-2.stderr index 0dd1494414fee..1d1999d350fe4 100644 --- a/src/test/ui/suggestions/type-ascription-instead-of-path-2.stderr +++ b/src/test/ui/suggestions/type-ascription-instead-of-path-2.stderr @@ -7,7 +7,6 @@ LL | vec![Ok(2)].into_iter().collect:,_>>()?; | help: maybe write a path separator here: `::` | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information error: aborting due to previous error diff --git a/src/test/ui/suggestions/type-ascription-instead-of-variant.stderr b/src/test/ui/suggestions/type-ascription-instead-of-variant.stderr index 5b40e16a51436..f38020dcc3820 100644 --- a/src/test/ui/suggestions/type-ascription-instead-of-variant.stderr +++ b/src/test/ui/suggestions/type-ascription-instead-of-variant.stderr @@ -7,7 +7,6 @@ LL | let _ = Option:Some(""); | help: maybe write a path separator here: `::` | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information error: aborting due to previous error diff --git a/src/test/ui/type/ascription/issue-47666.stderr b/src/test/ui/type/ascription/issue-47666.stderr index 3cd3be70aa75b..72c7c144b537d 100644 --- a/src/test/ui/type/ascription/issue-47666.stderr +++ b/src/test/ui/type/ascription/issue-47666.stderr @@ -10,7 +10,6 @@ LL | let _ = Option:Some(vec![0, 1]); | help: maybe write a path separator here: `::` | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0423]: expected value, found enum `Option` diff --git a/src/test/ui/type/ascription/issue-54516.stderr b/src/test/ui/type/ascription/issue-54516.stderr index fdf35700ef94c..ec08cf209c21a 100644 --- a/src/test/ui/type/ascription/issue-54516.stderr +++ b/src/test/ui/type/ascription/issue-54516.stderr @@ -7,7 +7,6 @@ LL | println!("{}", std::mem:size_of::>()); | help: maybe write a path separator here: `::` | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information error[E0423]: expected value, found module `std::mem` --> $DIR/issue-54516.rs:4:20 diff --git a/src/test/ui/type/ascription/issue-60933.stderr b/src/test/ui/type/ascription/issue-60933.stderr index cd9ae8f49f4f1..2006362e1bb7e 100644 --- a/src/test/ui/type/ascription/issue-60933.stderr +++ b/src/test/ui/type/ascription/issue-60933.stderr @@ -7,7 +7,6 @@ LL | let u: usize = std::mem:size_of::(); | help: maybe write a path separator here: `::` | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: see issue #23416 for more information error[E0423]: expected value, found module `std::mem` --> $DIR/issue-60933.rs:2:20 From 36a229b28db2d96105769afa001baeb5cd99ca15 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 9 Jul 2020 08:36:41 -0700 Subject: [PATCH 27/28] Move to unstable section --- src/doc/rustdoc/src/SUMMARY.md | 1 - src/doc/rustdoc/src/intra-doc-links.md | 58 ------------------- src/doc/rustdoc/src/unstable-features.md | 72 ++++++++++++++---------- 3 files changed, 42 insertions(+), 89 deletions(-) delete mode 100644 src/doc/rustdoc/src/intra-doc-links.md diff --git a/src/doc/rustdoc/src/SUMMARY.md b/src/doc/rustdoc/src/SUMMARY.md index 1f38ab9c835e3..f982863e67b94 100644 --- a/src/doc/rustdoc/src/SUMMARY.md +++ b/src/doc/rustdoc/src/SUMMARY.md @@ -7,6 +7,5 @@ - [Documentation tests](documentation-tests.md) - [Lints](lints.md) - [Passes](passes.md) -- [Intra-doc links](intra-doc-links.md) - [Advanced Features](advanced-features.md) - [Unstable features](unstable-features.md) diff --git a/src/doc/rustdoc/src/intra-doc-links.md b/src/doc/rustdoc/src/intra-doc-links.md deleted file mode 100644 index a0781e2e7690f..0000000000000 --- a/src/doc/rustdoc/src/intra-doc-links.md +++ /dev/null @@ -1,58 +0,0 @@ -# Intra-doc links - -_This feature is currently nightly-only_ - -Rustdoc is capable of directly linking to other rustdoc pages in Markdown documentation using the path of item as a link. - -For example, in the following code all of the links will link to the rustdoc page for `Bar`: - -```rust -/// This struct is not [Bar] -pub struct Foo1; - -/// This struct is also not [bar](Bar) -pub struct Foo2; - -/// This struct is also not [bar][b] -/// -/// [b]: Bar -pub struct Foo3; - -/// This struct is also not [`Bar`] -pub struct Foo4; - -pub struct Bar; -``` - -You can refer to anything in scope, and use paths, including `Self`. You may also use `foo()` and `foo!()` to refer to methods/functions and macros respectively. - -```rust,edition2018 -use std::sync::mpsc::Receiver; - -/// This is an version of [`Receiver`], with support for [`std::future`]. -/// -/// You can obtain a [`std::future::Future`] by calling [`Self::recv()`]. -pub struct AsyncReceiver { - sender: Receiver -} - -impl AsyncReceiver { - pub async fn recv() -> T { - unimplemented!() - } -} -``` - -Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@` , `macro@`, or `derive@`: - -```rust -/// See also: [`Foo`](struct@Foo) -struct Bar; - -/// This is different from [`Foo`](fn@Foo) -struct Foo {} - -fn Foo() {} -``` - -Note: Because of how `macro_rules` macros are scoped in Rust, the intra-doc links of a `macro_rules` macro will be resolved relative to the crate root, as opposed to the module it is defined in. diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 84e1ebe5e01f5..8abb253465e85 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -38,50 +38,62 @@ future. Attempting to use these error numbers on stable will result in the code sample being interpreted as plain text. -### Linking to items by type +### Linking to items by name -As designed in [RFC 1946], Rustdoc can parse paths to items when you use them as links. To resolve -these type names, it uses the items currently in-scope, either by declaration or by `use` statement. -For modules, the "active scope" depends on whether the documentation is written outside the module -(as `///` comments on the `mod` statement) or inside the module (at `//!` comments inside the file -or block). For all other items, it uses the enclosing module's scope. +Rustdoc is capable of directly linking to other rustdoc pages in Markdown documentation using the path of item as a link. -[RFC 1946]: https://github.com/rust-lang/rfcs/pull/1946 - -For example, in the following code: +For example, in the following code all of the links will link to the rustdoc page for `Bar`: ```rust -/// Does the thing. -pub fn do_the_thing(_: SomeType) { - println!("Let's do the thing!"); -} +/// This struct is not [Bar] +pub struct Foo1; + +/// This struct is also not [bar](Bar) +pub struct Foo2; + +/// This struct is also not [bar][b] +/// +/// [b]: Bar +pub struct Foo3; + +/// This struct is also not [`Bar`] +pub struct Foo4; -/// Token you use to [`do_the_thing`]. -pub struct SomeType; +pub struct Bar; ``` -The link to ``[`do_the_thing`]`` in `SomeType`'s docs will properly link to the page for `fn -do_the_thing`. Note that here, rustdoc will insert the link target for you, but manually writing the -target out also works: +You can refer to anything in scope, and use paths, including `Self`. You may also use `foo()` and `foo!()` to refer to methods/functions and macros respectively. -```rust -pub mod some_module { - /// Token you use to do the thing. - pub struct SomeStruct; -} +```rust,edition2018 +use std::sync::mpsc::Receiver; -/// Does the thing. Requires one [`SomeStruct`] for the thing to work. +/// This is an version of [`Receiver`], with support for [`std::future`]. /// -/// [`SomeStruct`]: some_module::SomeStruct -pub fn do_the_thing(_: some_module::SomeStruct) { - println!("Let's do the thing!"); +/// You can obtain a [`std::future::Future`] by calling [`Self::recv()`]. +pub struct AsyncReceiver { + sender: Receiver +} + +impl AsyncReceiver { + pub async fn recv() -> T { + unimplemented!() + } } ``` -For more details, check out [the RFC][RFC 1946], and see [the tracking issue][43466] for more -information about what parts of the feature are available. +Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@` , `macro@`, or `derive@`: + +```rust +/// See also: [`Foo`](struct@Foo) +struct Bar; + +/// This is different from [`Foo`](fn@Foo) +struct Foo {} + +fn Foo() {} +``` -[43466]: https://github.com/rust-lang/rust/issues/43466 +Note: Because of how `macro_rules` macros are scoped in Rust, the intra-doc links of a `macro_rules` macro will be resolved relative to the crate root, as opposed to the module it is defined in. ## Extensions to the `#[doc]` attribute From fe351e9b8eb19aeda4a34f4c64c75ffb60600cc0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 9 Jul 2020 10:27:48 -0700 Subject: [PATCH 28/28] Add test --- src/test/rustdoc/intra-links.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/rustdoc/intra-links.rs b/src/test/rustdoc/intra-links.rs index c6725f526aa2a..751c10925c017 100644 --- a/src/test/rustdoc/intra-links.rs +++ b/src/test/rustdoc/intra-links.rs @@ -46,6 +46,8 @@ macro_rules! this_macro { () => {}; } +// @has intra_links/struct.ThisType.html '//a/@href' '../intra_links/macro.this_macro.html' +/// another link to [`this_macro!()`] pub struct ThisType; impl ThisType { @@ -70,7 +72,7 @@ pub trait SoAmbiguous {} pub fn SoAmbiguous() {} -// @has - '//a/@href' '../intra_links/struct.ThisType.html' +// @has intra_links/struct.SomeOtherType.html '//a/@href' '../intra_links/struct.ThisType.html' // @has - '//a/@href' '../intra_links/struct.ThisType.html#method.this_method' // @has - '//a/@href' '../intra_links/enum.ThisEnum.html' // @has - '//a/@href' '../intra_links/enum.ThisEnum.html#variant.ThisVariant'