Skip to content

Commit f07100a

Browse files
committed
Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.
1 parent f25811e commit f07100a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+99
-96
lines changed

src/librustc_codegen_llvm/attributes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
342342
}
343343
}
344344

345-
pub fn provide(providers: &mut Providers<'_>) {
345+
pub fn provide(providers: &mut Providers) {
346346
providers.target_features_whitelist = |tcx, cnum| {
347347
assert_eq!(cnum, LOCAL_CRATE);
348348
if tcx.sess.opts.actually_rustdoc {
@@ -360,7 +360,7 @@ pub fn provide(providers: &mut Providers<'_>) {
360360
provide_extern(providers);
361361
}
362362

363-
pub fn provide_extern(providers: &mut Providers<'_>) {
363+
pub fn provide_extern(providers: &mut Providers) {
364364
providers.wasm_import_module_map = |tcx, cnum| {
365365
// Build up a map from DefId to a `NativeLib` structure, where
366366
// `NativeLib` internally contains information about

src/librustc_codegen_llvm/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ impl CodegenBackend for LlvmCodegenBackend {
241241
Box::new(metadata::LlvmMetadataLoader)
242242
}
243243

244-
fn provide(&self, providers: &mut ty::query::Providers<'_>) {
244+
fn provide(&self, providers: &mut ty::query::Providers) {
245245
attributes::provide(providers);
246246
}
247247

248-
fn provide_extern(&self, providers: &mut ty::query::Providers<'_>) {
248+
fn provide_extern(&self, providers: &mut ty::query::Providers) {
249249
attributes::provide_extern(providers);
250250
}
251251

src/librustc_codegen_ssa/back/symbol_export.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
161161
}
162162

163163
fn exported_symbols_provider_local(
164-
tcx: TyCtxt<'_>,
164+
tcx: TyCtxt<'tcx>,
165165
cnum: CrateNum,
166-
) -> &'tcx [(ExportedSymbol<'_>, SymbolExportLevel)] {
166+
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
167167
assert_eq!(cnum, LOCAL_CRATE);
168168

169169
if !tcx.sess.opts.output_types.should_codegen() {
@@ -366,7 +366,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> b
366366
}
367367
}
368368

369-
pub fn provide(providers: &mut Providers<'_>) {
369+
pub fn provide(providers: &mut Providers) {
370370
providers.reachable_non_generics = reachable_non_generics_provider;
371371
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
372372
providers.exported_symbols = exported_symbols_provider_local;
@@ -375,7 +375,7 @@ pub fn provide(providers: &mut Providers<'_>) {
375375
providers.upstream_drop_glue_for = upstream_drop_glue_for_provider;
376376
}
377377

378-
pub fn provide_extern(providers: &mut Providers<'_>) {
378+
pub fn provide_extern(providers: &mut Providers) {
379379
providers.is_reachable_non_generic = is_reachable_non_generic_provider_extern;
380380
providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider;
381381
}

src/librustc_codegen_ssa/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ impl CrateInfo {
853853
}
854854
}
855855

856-
pub fn provide_both(providers: &mut Providers<'_>) {
856+
pub fn provide_both(providers: &mut Providers) {
857857
providers.backend_optimization_level = |tcx, cratenum| {
858858
let for_speed = match tcx.sess.opts.optimize {
859859
// If globally no optimisation is done, #[optimize] has no effect.

src/librustc_codegen_ssa/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ pub struct CodegenResults {
138138
pub crate_info: CrateInfo,
139139
}
140140

141-
pub fn provide(providers: &mut Providers<'_>) {
141+
pub fn provide(providers: &mut Providers) {
142142
crate::back::symbol_export::provide(providers);
143143
crate::base::provide_both(providers);
144144
}
145145

146-
pub fn provide_extern(providers: &mut Providers<'_>) {
146+
pub fn provide_extern(providers: &mut Providers) {
147147
crate::back::symbol_export::provide_extern(providers);
148148
crate::base::provide_both(providers);
149149
}

src/librustc_codegen_ssa/traits/backend.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub trait CodegenBackend {
5555
fn print_version(&self) {}
5656

5757
fn metadata_loader(&self) -> Box<MetadataLoaderDyn>;
58-
fn provide(&self, _providers: &mut Providers<'_>);
59-
fn provide_extern(&self, _providers: &mut Providers<'_>);
58+
fn provide(&self, _providers: &mut Providers);
59+
fn provide_extern(&self, _providers: &mut Providers);
6060
fn codegen_crate<'tcx>(
6161
&self,
6262
tcx: TyCtxt<'tcx>,

src/librustc_interface/interface.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct Compiler {
3838
pub(crate) crate_name: Option<String>,
3939
pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>>,
4040
pub(crate) override_queries:
41-
Option<fn(&Session, &mut ty::query::Providers<'_>, &mut ty::query::Providers<'_>)>,
41+
Option<fn(&Session, &mut ty::query::Providers, &mut ty::query::Providers)>,
4242
}
4343

4444
impl Compiler {
@@ -153,7 +153,7 @@ pub struct Config {
153153
///
154154
/// The second parameter is local providers and the third parameter is external providers.
155155
pub override_queries:
156-
Option<fn(&Session, &mut ty::query::Providers<'_>, &mut ty::query::Providers<'_>)>,
156+
Option<fn(&Session, &mut ty::query::Providers, &mut ty::query::Providers)>,
157157

158158
/// Registry of diagnostics codes.
159159
pub registry: Registry,

src/librustc_interface/passes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ pub fn prepare_outputs(
719719
Ok(outputs)
720720
}
721721

722-
pub fn default_provide(providers: &mut ty::query::Providers<'_>) {
722+
pub fn default_provide(providers: &mut ty::query::Providers) {
723723
providers.analysis = analysis;
724724
proc_macro_decls::provide(providers);
725725
plugin::build::provide(providers);
@@ -740,7 +740,7 @@ pub fn default_provide(providers: &mut ty::query::Providers<'_>) {
740740
rustc_codegen_ssa::provide(providers);
741741
}
742742

743-
pub fn default_provide_extern(providers: &mut ty::query::Providers<'_>) {
743+
pub fn default_provide_extern(providers: &mut ty::query::Providers) {
744744
rustc_metadata::provide_extern(providers);
745745
rustc_codegen_ssa::provide_extern(providers);
746746
}

src/librustc_interface/proc_macro_decls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ impl<'v> ItemLikeVisitor<'v> for Finder {
3535
fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'_>) {}
3636
}
3737

38-
pub(crate) fn provide(providers: &mut Providers<'_>) {
38+
pub(crate) fn provide(providers: &mut Providers) {
3939
*providers = Providers { proc_macro_decls_static, ..*providers };
4040
}

src/librustc_lint/levels.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,6 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
571571
}
572572
}
573573

574-
pub fn provide(providers: &mut Providers<'_>) {
574+
pub fn provide(providers: &mut Providers) {
575575
providers.lint_levels = lint_levels;
576576
}

src/librustc_lint/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub use rustc_session::lint::Level::{self, *};
8888
pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId};
8989
pub use rustc_session::lint::{LintArray, LintPass};
9090

91-
pub fn provide(providers: &mut Providers<'_>) {
91+
pub fn provide(providers: &mut Providers) {
9292
levels::provide(providers);
9393
*providers = Providers { lint_mod, ..*providers };
9494
}

src/librustc_metadata/rmeta/decoder/cstore_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::any::Any;
3030
macro_rules! provide {
3131
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
3232
$($name:ident => $compute:block)*) => {
33-
pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) {
33+
pub fn provide_extern(providers: &mut Providers) {
3434
$(fn $name<$lt>(
3535
$tcx: TyCtxt<$lt>,
3636
def_id_arg: ty::query::query_keys::$name<$lt>,
@@ -240,7 +240,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
240240
crate_extern_paths => { cdata.source().paths().cloned().collect() }
241241
}
242242

243-
pub fn provide(providers: &mut Providers<'_>) {
243+
pub fn provide(providers: &mut Providers) {
244244
// FIXME(#44234) - almost all of these queries have no sub-queries and
245245
// therefore no actual inputs, they're just reading tables calculated in
246246
// resolve! Does this work? Unsure! That's what the issue is about

src/librustc_middle/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,6 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
10671067
}
10681068
}
10691069

1070-
pub fn provide(providers: &mut Providers<'_>) {
1070+
pub fn provide(providers: &mut Providers) {
10711071
providers.def_kind = |tcx, def_id| tcx.hir().def_kind(def_id.expect_local());
10721072
}

src/librustc_middle/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'tcx> TyCtxt<'tcx> {
6262
}
6363
}
6464

65-
pub fn provide(providers: &mut Providers<'_>) {
65+
pub fn provide(providers: &mut Providers) {
6666
providers.parent_module_from_def_id = |tcx, id| {
6767
let hir = tcx.hir();
6868
hir.local_def_id(hir.get_module_parent_node(hir.as_local_hir_id(id)))

src/librustc_middle/ty/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ impl<'tcx> TyCtxt<'tcx> {
10601060
pub fn create_global_ctxt(
10611061
s: &'tcx Session,
10621062
lint_store: Lrc<dyn Any + sync::Send + sync::Sync>,
1063-
local_providers: ty::query::Providers<'tcx>,
1064-
extern_providers: ty::query::Providers<'tcx>,
1063+
local_providers: ty::query::Providers,
1064+
extern_providers: ty::query::Providers,
10651065
arena: &'tcx WorkerLocal<Arena<'tcx>>,
10661066
resolutions: ty::ResolverOutputs,
10671067
krate: &'tcx hir::Crate<'tcx>,
@@ -2699,7 +2699,7 @@ fn ptr_eq<T, U>(t: *const T, u: *const U) -> bool {
26992699
t as *const () == u as *const ()
27002700
}
27012701

2702-
pub fn provide(providers: &mut ty::query::Providers<'_>) {
2702+
pub fn provide(providers: &mut ty::query::Providers) {
27032703
providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id);
27042704
providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).map(|v| &v[..]);
27052705
providers.crate_name = |tcx, id| {

src/librustc_middle/ty/erase_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::ty::fold::{TypeFoldable, TypeFolder};
22
use crate::ty::{self, Ty, TyCtxt, TypeFlags};
33

4-
pub(super) fn provide(providers: &mut ty::query::Providers<'_>) {
4+
pub(super) fn provide(providers: &mut ty::query::Providers) {
55
*providers = ty::query::Providers { erase_regions_ty, ..*providers };
66
}
77

src/librustc_middle/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn layout_raw<'tcx>(
210210
})
211211
}
212212

213-
pub fn provide(providers: &mut ty::query::Providers<'_>) {
213+
pub fn provide(providers: &mut ty::query::Providers) {
214214
*providers = ty::query::Providers { layout_raw, ..*providers };
215215
}
216216

src/librustc_middle/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2864,7 +2864,7 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
28642864
None
28652865
}
28662866

2867-
pub fn provide(providers: &mut ty::query::Providers<'_>) {
2867+
pub fn provide(providers: &mut ty::query::Providers) {
28682868
context::provide(providers);
28692869
erase_regions::provide(providers);
28702870
layout::provide(providers);

src/librustc_middle/ty/query/plumbing.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,16 @@ macro_rules! define_queries_inner {
497497
input: ($(([$($modifiers)*] [$name] [$($K)*] [$V]))*)
498498
}
499499

500-
impl<$tcx> Copy for Providers<$tcx> {}
501-
impl<$tcx> Clone for Providers<$tcx> {
500+
impl Copy for Providers {}
501+
impl Clone for Providers {
502502
fn clone(&self) -> Self { *self }
503503
}
504504
}
505505
}
506506

507+
// FIXME(eddyb) this macro (and others?) use `$tcx` and `'tcx` interchangeably.
508+
// We should either not take `$tcx` at all and use `'tcx` everywhere, or use
509+
// `$tcx` everywhere (even if that isn't necessary due to lack of hygiene).
507510
macro_rules! define_queries_struct {
508511
(tcx: $tcx:tt,
509512
input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => {
@@ -513,8 +516,8 @@ macro_rules! define_queries_struct {
513516
/// `DepGraph::try_mark_green()` and the query infrastructure.
514517
pub(crate) on_disk_cache: OnDiskCache<'tcx>,
515518

516-
providers: IndexVec<CrateNum, Providers<$tcx>>,
517-
fallback_extern_providers: Box<Providers<$tcx>>,
519+
providers: IndexVec<CrateNum, Providers>,
520+
fallback_extern_providers: Box<Providers>,
518521

519522
$($(#[$attr])* $name: QueryState<
520523
TyCtxt<$tcx>,
@@ -524,8 +527,8 @@ macro_rules! define_queries_struct {
524527

525528
impl<$tcx> Queries<$tcx> {
526529
pub(crate) fn new(
527-
providers: IndexVec<CrateNum, Providers<$tcx>>,
528-
fallback_extern_providers: Providers<$tcx>,
530+
providers: IndexVec<CrateNum, Providers>,
531+
fallback_extern_providers: Providers,
529532
on_disk_cache: OnDiskCache<'tcx>,
530533
) -> Self {
531534
Queries {
@@ -558,11 +561,11 @@ macro_rules! define_queries_struct {
558561
macro_rules! define_provider_struct {
559562
(tcx: $tcx:tt,
560563
input: ($(([$($modifiers:tt)*] [$name:ident] [$K:ty] [$R:ty]))*)) => {
561-
pub struct Providers<$tcx> {
562-
$(pub $name: fn(TyCtxt<$tcx>, $K) -> $R,)*
564+
pub struct Providers {
565+
$(pub $name: for<$tcx> fn(TyCtxt<$tcx>, $K) -> $R,)*
563566
}
564567

565-
impl<$tcx> Default for Providers<$tcx> {
568+
impl Default for Providers {
566569
fn default() -> Self {
567570
$(fn $name<$tcx>(_: TyCtxt<$tcx>, key: $K) -> $R {
568571
bug!("`tcx.{}({:?})` unsupported by its crate",

src/librustc_middle/util/bug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ pub fn trigger_delay_span_bug(tcx: TyCtxt<'_>, key: rustc_hir::def_id::DefId) {
4747
);
4848
}
4949

50-
pub fn provide(providers: &mut crate::ty::query::Providers<'_>) {
50+
pub fn provide(providers: &mut crate::ty::query::Providers) {
5151
*providers = crate::ty::query::Providers { trigger_delay_span_bug, ..*providers };
5252
}

src/librustc_mir/borrow_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ crate struct Upvar {
8686

8787
const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref];
8888

89-
pub fn provide(providers: &mut Providers<'_>) {
89+
pub fn provide(providers: &mut Providers) {
9090
*providers = Providers { mir_borrowck, ..*providers };
9191
}
9292

src/librustc_mir/const_eval/fn_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn const_fn_is_allowed_fn_ptr(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
156156
&& tcx.lookup_const_stability(def_id).map(|stab| stab.allow_const_fn_ptr).unwrap_or(false)
157157
}
158158

159-
pub fn provide(providers: &mut Providers<'_>) {
159+
pub fn provide(providers: &mut Providers) {
160160
*providers = Providers {
161161
is_const_fn_raw,
162162
is_const_impl_raw: |tcx, def_id| is_const_impl_raw(tcx, def_id.expect_local()),

src/librustc_mir/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub mod util;
4747

4848
use rustc_middle::ty::query::Providers;
4949

50-
pub fn provide(providers: &mut Providers<'_>) {
50+
pub fn provide(providers: &mut Providers) {
5151
borrow_check::provide(providers);
5252
const_eval::provide(providers);
5353
shim::provide(providers);

src/librustc_mir/monomorphize/partitioning.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,9 @@ where
880880
}
881881

882882
fn collect_and_partition_mono_items(
883-
tcx: TyCtxt<'_>,
883+
tcx: TyCtxt<'tcx>,
884884
cnum: CrateNum,
885-
) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'_>]) {
885+
) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
886886
assert_eq!(cnum, LOCAL_CRATE);
887887

888888
let collection_mode = match tcx.sess.opts.debugging_opts.print_mono_items {
@@ -994,7 +994,7 @@ fn collect_and_partition_mono_items(
994994
(tcx.arena.alloc(mono_items), codegen_units)
995995
}
996996

997-
pub fn provide(providers: &mut Providers<'_>) {
997+
pub fn provide(providers: &mut Providers) {
998998
providers.collect_and_partition_mono_items = collect_and_partition_mono_items;
999999

10001000
providers.is_codegened_item = |tcx, def_id| {

src/librustc_mir/shim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::util::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle
2323
use crate::util::expand_aggregate;
2424
use crate::util::patch::MirPatch;
2525

26-
pub fn provide(providers: &mut Providers<'_>) {
26+
pub fn provide(providers: &mut Providers) {
2727
providers.mir_shims = make_shim;
2828
}
2929

src/librustc_mir/transform/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
488488
}
489489
}
490490

491-
pub(crate) fn provide(providers: &mut Providers<'_>) {
491+
pub(crate) fn provide(providers: &mut Providers) {
492492
*providers = Providers { unsafety_check_result, unsafe_derive_on_repr_packed, ..*providers };
493493
}
494494

src/librustc_mir/transform/instrument_coverage.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub struct InstrumentCoverage;
2525

2626
/// The `query` provider for `CoverageInfo`, requested by `codegen_intrinsic_call()` when
2727
/// constructing the arguments for `llvm.instrprof.increment`.
28-
pub(crate) fn provide(providers: &mut Providers<'_>) {
28+
pub(crate) fn provide(providers: &mut Providers) {
2929
providers.coverageinfo = |tcx, def_id| coverageinfo_from_mir(tcx, def_id);
3030
}
3131

src/librustc_mir/transform/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub mod uninhabited_enum_branching;
4343
pub mod unreachable_prop;
4444
pub mod validate;
4545

46-
pub(crate) fn provide(providers: &mut Providers<'_>) {
46+
pub(crate) fn provide(providers: &mut Providers) {
4747
self::check_unsafety::provide(providers);
4848
*providers = Providers {
4949
mir_keys,

src/librustc_mir_build/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod lints;
2323

2424
use rustc_middle::ty::query::Providers;
2525

26-
pub fn provide(providers: &mut Providers<'_>) {
26+
pub fn provide(providers: &mut Providers) {
2727
providers.check_match = hair::pattern::check_match;
2828
providers.lit_to_const = hair::constant::lit_to_const;
2929
providers.mir_built = build::mir_built;

0 commit comments

Comments
 (0)