Skip to content

Commit c57a721

Browse files
committed
debug
1 parent 89c4b25 commit c57a721

File tree

11 files changed

+107
-19
lines changed

11 files changed

+107
-19
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3291,7 +3291,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32913291
}
32923292
}
32933293

3294-
#[instrument(level = "debug", skip(self))]
3294+
#[instrument(level = "debug", skip(self, handle_candidates))]
32953295
fn suggest_use_candidates<F>(&self, candidates: Vec<DefId>, handle_candidates: F)
32963296
where
32973297
F: FnOnce(Vec<String>, Vec<String>, Span),

compiler/rustc_middle/src/ty/print/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_data_structures::sso::SsoHashSet;
66
use rustc_hir as hir;
77
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
88
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
9+
#[allow(unused_imports)]
910
use tracing::{debug, instrument, trace};
1011

1112
use crate::ty::{self, GenericArg, ShortInstance, Ty, TyCtxt};
@@ -111,14 +112,14 @@ pub trait Printer<'tcx>: Sized {
111112

112113
// Defaults (should not be overridden):
113114

114-
#[instrument(skip(self), level = "debug")]
115+
// #[instrument(skip(self), level = "debug")]
115116
fn default_print_def_path(
116117
&mut self,
117118
def_id: DefId,
118119
args: &'tcx [GenericArg<'tcx>],
119120
) -> Result<(), PrintError> {
120121
let key = self.tcx().def_key(def_id);
121-
debug!(?key);
122+
// debug!(?key);
122123

123124
match key.disambiguated_data.data {
124125
DefPathData::CrateRoot => {
@@ -207,10 +208,10 @@ pub trait Printer<'tcx>: Sized {
207208
self_ty: Ty<'tcx>,
208209
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
209210
) -> Result<(), PrintError> {
210-
debug!(
211-
"default_print_impl_path: impl_def_id={:?}, self_ty={}, impl_trait_ref={:?}",
212-
impl_def_id, self_ty, impl_trait_ref
213-
);
211+
// debug!(
212+
// "default_print_impl_path: impl_def_id={:?}, self_ty={}, impl_trait_ref={:?}",
213+
// impl_def_id, self_ty, impl_trait_ref
214+
// );
214215

215216
let key = self.tcx().def_key(impl_def_id);
216217
let parent_def_id = DefId { index: key.parent.unwrap(), ..impl_def_id };

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
370370
/// from at least one local module, and returns `true`. If the crate defining `def_id` is
371371
/// declared with an `extern crate`, the path is guaranteed to use the `extern crate`.
372372
fn try_print_visible_def_path(&mut self, def_id: DefId) -> Result<bool, PrintError> {
373+
debug!("try_print_visible_def_path: def_id={:?}", def_id);
373374
if with_no_visible_paths() {
374375
return Ok(false);
375376
}
@@ -488,7 +489,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
488489
def_id: DefId,
489490
callers: &mut Vec<DefId>,
490491
) -> Result<bool, PrintError> {
491-
debug!("try_print_visible_def_path: def_id={:?}", def_id);
492+
// debug!("try_print_visible_def_path: def_id={:?}", def_id);
492493

493494
// If `def_id` is a direct or injected extern crate, return the
494495
// path to the crate followed by the path to the item within the crate.
@@ -551,7 +552,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
551552
let visible_parent_map = self.tcx().visible_parent_map(());
552553

553554
let mut cur_def_key = self.tcx().def_key(def_id);
554-
debug!("try_print_visible_def_path: cur_def_key={:?}", cur_def_key);
555+
// debug!("try_print_visible_def_path: cur_def_key={:?}", cur_def_key);
555556

556557
// For a constructor, we want the name of its parent rather than <unnamed>.
557558
if let DefPathData::Ctor = cur_def_key.disambiguated_data.data {
@@ -566,20 +567,21 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
566567
}
567568

568569
let Some(visible_parent) = visible_parent_map.get(&def_id).cloned() else {
570+
debug!("try_print_visible_def_path: no visible parent for {:?}", def_id);
569571
return Ok(false);
570572
};
571573

572574
let actual_parent = self.tcx().opt_parent(def_id);
573-
debug!(
574-
"try_print_visible_def_path: visible_parent={:?} actual_parent={:?}",
575-
visible_parent, actual_parent,
576-
);
575+
// debug!(
576+
// "try_print_visible_def_path: visible_parent={:?} actual_parent={:?}",
577+
// visible_parent, actual_parent,
578+
// );
577579

578580
let mut data = cur_def_key.disambiguated_data.data;
579-
debug!(
580-
"try_print_visible_def_path: data={:?} visible_parent={:?} actual_parent={:?}",
581-
data, visible_parent, actual_parent,
582-
);
581+
// debug!(
582+
// "try_print_visible_def_path: data={:?} visible_parent={:?} actual_parent={:?}",
583+
// data, visible_parent, actual_parent,
584+
// );
583585

584586
match data {
585587
// In order to output a path that could actually be imported (valid and visible),
@@ -616,6 +618,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
616618
DefPathData::TypeNs(Some(ref mut name)) if Some(visible_parent) != actual_parent => {
617619
// Item might be re-exported several times, but filter for the one
618620
// that's public and whose identifier isn't `_`.
621+
debug!(
622+
"try_print_visible_def_path: def_id={:?}, visible_parent={:?}, actual_parent={:?}",
623+
def_id, visible_parent, actual_parent
624+
);
619625
let reexport = self
620626
.tcx()
621627
// FIXME(typed_def_id): Further propagate ModDefId
@@ -624,6 +630,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
624630
.filter(|child| child.res.opt_def_id() == Some(def_id))
625631
.find(|child| child.vis.is_public() && child.ident.name != kw::Underscore)
626632
.map(|child| child.ident.name);
633+
debug!("try_print_visible_def_path: reexport={:?}", reexport);
627634

628635
if let Some(new_name) = reexport {
629636
*name = new_name;
@@ -638,7 +645,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
638645
}
639646
_ => {}
640647
}
641-
debug!("try_print_visible_def_path: data={:?}", data);
648+
// debug!("try_print_visible_def_path: data={:?}", data);
642649

643650
if callers.contains(&visible_parent) {
644651
return Ok(false);
@@ -2185,7 +2192,7 @@ impl<'t> TyCtxt<'t> {
21852192
) -> String {
21862193
let def_id = def_id.into_query_param();
21872194
let ns = guess_def_namespace(self, def_id);
2188-
debug!("def_path_str: def_id={:?}, ns={:?}", def_id, ns);
2195+
// debug!("def_path_str: def_id={:?}, ns={:?}", def_id, ns);
21892196

21902197
FmtPrinter::print_string(self, ns, |cx| cx.print_def_path(def_id, args)).unwrap()
21912198
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ edition: 2021
2+
3+
pub trait Foo {
4+
fn foo();
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ edition: 2021
2+
3+
pub trait Foo {
4+
fn foo();
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ edition: 2021
2+
//@ aux-crate:issue_127011_a_2=issue-127011-a-2.rs
3+
4+
use issue_127011_a_2::Foo;
5+
6+
pub struct Bar;
7+
8+
impl Foo for Bar {
9+
fn foo() {}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ edition: 2021
2+
//@ aux-crate:issue_127011_a=issue-127011-a.rs
3+
4+
pub use issue_127011_a::Foo;
5+
6+
pub struct Bar;
7+
8+
impl Foo for Bar {
9+
fn foo() {}
10+
}

tests/ui/issues/issue-127011-2.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ edition: 2021
2+
//@ aux-crate:issue_127011_a_2=issue-127011-a-2.rs
3+
//@ aux-crate:issue_127011_b_2=issue-127011-b-2.rs
4+
5+
use issue_127011_b_2::Bar;
6+
7+
fn main() {
8+
Bar::foo();
9+
//~^ ERROR: no function or associated item named `foo` found for struct `Bar` in the current scope [E0599]
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0599]: no function or associated item named `foo` found for struct `Bar` in the current scope
2+
--> $DIR/issue-127011-2.rs:8:10
3+
|
4+
LL | Bar::foo();
5+
| ^^^ function or associated item not found in `Bar`
6+
|
7+
= help: items from traits can only be used if the trait is in scope
8+
help: trait `Foo` which provides `foo` is implemented but not in scope; perhaps you want to import it
9+
|
10+
LL + use issue_127011_a_2::Foo;
11+
|
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0599`.

tests/ui/issues/issue-127011.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ edition: 2021
2+
//@ aux-crate:issue_127011_a=issue-127011-a.rs
3+
//@ aux-crate:issue_127011_b=issue-127011-b.rs
4+
5+
use issue_127011_b::Bar;
6+
7+
fn main() {
8+
Bar::foo();
9+
//~^ ERROR: no function or associated item named `foo` found for struct `Bar` in the current scope [E0599]
10+
}

0 commit comments

Comments
 (0)