Skip to content

Commit 6cd311e

Browse files
committed
Rename all_traits query.
This commit renames the `all_traits` query to `all_suggestible_traits` to better highlight that it is intended for diagnostic/error reporting purposes. This was already the case, as highlighted by a doc comment on the function as it existed previously.
1 parent 0c475a6 commit 6cd311e

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ define_dep_nodes!( <'tcx>
638638
[input] MaybeUnusedExternCrates,
639639
[input] NamesImportedByGlobUse(DefId),
640640
[eval_always] StabilityIndex,
641-
[eval_always] AllTraits,
641+
[eval_always] AllSuggestibleTraits,
642642
[input] AllCrateNums,
643643
[] ExportedSymbols(CrateNum),
644644
[eval_always] CollectAndPartitionMonoItems,

src/librustc/ty/query/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::stability_index<'tcx> {
838838
}
839839
}
840840

841-
impl<'tcx> QueryDescription<'tcx> for queries::all_traits<'tcx> {
841+
impl<'tcx> QueryDescription<'tcx> for queries::all_suggestible_traits<'tcx> {
842842
fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> {
843843
"fetching all foreign and local traits".into()
844844
}

src/librustc/ty/query/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ define_queries! { <'tcx>
563563
/// A vector of every trait accessible in the whole crate
564564
/// (i.e., including those from subcrates). This is used only for
565565
/// error reporting.
566-
[] fn all_traits: all_traits_node(CrateNum) -> Lrc<Vec<DefId>>,
566+
[] fn all_suggestible_traits: all_suggestible_traits_node(CrateNum) -> Lrc<Vec<DefId>>,
567567
},
568568

569569
Linking {
@@ -899,8 +899,8 @@ fn all_crate_nums_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
899899
DepConstructor::AllCrateNums
900900
}
901901

902-
fn all_traits_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
903-
DepConstructor::AllTraits
902+
fn all_suggestible_traits_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
903+
DepConstructor::AllSuggestibleTraits
904904
}
905905

906906
fn collect_and_partition_mono_items_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {

src/librustc/ty/query/plumbing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
14161416
DepKind::NamesImportedByGlobUse => { force!(names_imported_by_glob_use, def_id!()); }
14171417
DepKind::MaybeUnusedExternCrates => { force!(maybe_unused_extern_crates, LOCAL_CRATE); }
14181418
DepKind::StabilityIndex => { force!(stability_index, LOCAL_CRATE); }
1419-
DepKind::AllTraits => { force!(all_traits, LOCAL_CRATE); }
1419+
DepKind::AllSuggestibleTraits => { force!(all_suggestible_traits, LOCAL_CRATE); }
14201420
DepKind::AllCrateNums => { force!(all_crate_nums, LOCAL_CRATE); }
14211421
DepKind::ExportedSymbols => { force!(exported_symbols, krate!()); }
14221422
DepKind::CollectAndPartitionMonoItems => {

src/librustc_typeck/check/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
853853
fn assemble_extension_candidates_for_all_traits(&mut self) -> Result<(), MethodError<'tcx>> {
854854
debug!("assemble_extension_candidates_for_all_traits");
855855
let mut duplicates = FxHashSet::default();
856-
for trait_info in suggest::all_traits(self.tcx) {
856+
for trait_info in suggest::all_suggestible_traits(self.tcx) {
857857
if duplicates.insert(trait_info.def_id) {
858858
self.assemble_extension_candidates_for_trait(None, trait_info.def_id)?;
859859
}

src/librustc_typeck/check/method/suggest.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
207207
// Suggest clamping down the type if the method that is being attempted to
208208
// be used exists at all, and the type is an ambiuous numeric type
209209
// ({integer}/{float}).
210-
let mut candidates = all_traits(self.tcx)
210+
let mut candidates = all_suggestible_traits(self.tcx)
211211
.into_iter()
212212
.filter_map(|info|
213213
self.associated_item(info.def_id, item_name, Namespace::Value)
@@ -593,7 +593,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
593593
// There are no traits implemented, so lets suggest some traits to
594594
// implement, by finding ones that have the item name, and are
595595
// legal to implement.
596-
let mut candidates = all_traits(self.tcx)
596+
let mut candidates = all_suggestible_traits(self.tcx)
597597
.into_iter()
598598
.filter(|info| {
599599
// We approximate the coherence rules to only suggest
@@ -716,8 +716,8 @@ impl Ord for TraitInfo {
716716
}
717717

718718
/// Retrieves all traits in this crate and any dependent crates.
719-
pub fn all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<TraitInfo> {
720-
tcx.all_traits(LOCAL_CRATE).iter().map(|&def_id| TraitInfo { def_id }).collect()
719+
pub fn all_suggestible_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<TraitInfo> {
720+
tcx.all_suggestible_traits(LOCAL_CRATE).iter().map(|&def_id| TraitInfo { def_id }).collect()
721721
}
722722

723723
/// Computes all traits in this crate and any dependent crates.
@@ -807,7 +807,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId>
807807
}
808808

809809
pub fn provide(providers: &mut ty::query::Providers) {
810-
providers.all_traits = |tcx, cnum| {
810+
providers.all_suggestible_traits = |tcx, cnum| {
811811
assert_eq!(cnum, LOCAL_CRATE);
812812
Lrc::new(compute_all_traits(tcx))
813813
}

src/librustdoc/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
532532
fake_def_ids: Default::default(),
533533
all_fake_def_ids: Default::default(),
534534
generated_synthetics: Default::default(),
535-
all_traits: tcx.all_traits(LOCAL_CRATE).to_vec(),
535+
all_traits: tcx.all_suggestible_traits(LOCAL_CRATE).to_vec(),
536536
};
537537
debug!("crate: {:?}", tcx.hir().krate());
538538

0 commit comments

Comments
 (0)