Skip to content

Commit 1df7adf

Browse files
address review
1 parent a619ad8 commit 1df7adf

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4555,7 +4555,10 @@ pub struct Upvar {
45554555
pub struct TraitCandidate {
45564556
pub def_id: DefId,
45574557
pub import_ids: SmallVec<[LocalDefId; 1]>,
4558-
// FIXME: explain why this is needed for now.
4558+
// Indicates whether this trait candidate is ambiguously glob imported
4559+
// in it's scope. Related to the AMBIGUOUS_GLOB_IMPORTED_TRAIT lint.
4560+
// If this is set to true and the trait is used as a result of methdo lookup, this
4561+
// lint is thrown.
45594562
pub lint_ambiguous: bool,
45604563
}
45614564

compiler/rustc_hir_typeck/src/method/confirm.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir_analysis::hir_ty_lowering::{
1313
use rustc_infer::infer::{
1414
BoundRegionConversionTime, DefineOpaqueTypes, InferOk, RegionVariableOrigin,
1515
};
16-
use rustc_lint::builtin::{AMBIGUOUS_TRAIT_GLOB_IMPORTS, SUPERTRAIT_ITEM_SHADOWING_USAGE};
16+
use rustc_lint::builtin::{AMBIGUOUS_GLOB_IMPORTED_TRAIT, SUPERTRAIT_ITEM_SHADOWING_USAGE};
1717
use rustc_middle::traits::ObligationCauseCode;
1818
use rustc_middle::ty::adjustment::{
1919
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCoercion,
@@ -725,14 +725,13 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
725725
pick: &probe::Pick<'_>,
726726
segment: &hir::PathSegment<'tcx>,
727727
) {
728-
if let probe::PickKind::TraitPick(true) = pick.kind {
729-
} else {
728+
if pick.kind != probe::PickKind::TraitPick(true) {
730729
return;
731-
};
730+
}
732731
let trait_name = self.tcx.item_name(pick.item.container_id(self.tcx));
733732
let import_span = self.tcx.hir_span_if_local(pick.import_ids[0].to_def_id()).unwrap();
734733

735-
self.tcx.node_lint(AMBIGUOUS_TRAIT_GLOB_IMPORTS, segment.hir_id, |diag| {
734+
self.tcx.node_lint(AMBIGUOUS_GLOB_IMPORTED_TRAIT, segment.hir_id, |diag| {
736735
diag.primary_message(format!("Use of ambiguously glob imported trait `{trait_name}`"))
737736
.span(segment.ident.span)
738737
.span_label(import_span, format!("`{trait_name}`imported ambiguously here"))

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ declare_lint_pass! {
1919
AARCH64_SOFTFLOAT_NEON,
2020
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
2121
AMBIGUOUS_ASSOCIATED_ITEMS,
22+
AMBIGUOUS_GLOB_IMPORTED_TRAIT,
2223
AMBIGUOUS_GLOB_IMPORTS,
2324
AMBIGUOUS_GLOB_REEXPORTS,
24-
AMBIGUOUS_TRAIT_GLOB_IMPORTS,
2525
ARITHMETIC_OVERFLOW,
2626
ASM_SUB_REGISTER,
2727
BAD_ASM_STYLE,
@@ -4483,7 +4483,7 @@ declare_lint! {
44834483
/// hard error in the future.
44844484
///
44854485
/// [future-incompatible]: ../index.md#future-incompatible-lints
4486-
pub AMBIGUOUS_TRAIT_GLOB_IMPORTS,
4486+
pub AMBIGUOUS_GLOB_IMPORTED_TRAIT,
44874487
Warn,
44884488
"detects usages of ambiguously glob imported traits",
44894489
@future_incompatible = FutureIncompatibleInfo {

0 commit comments

Comments
 (0)