diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml index 41003ad83f311..84b40fd957fc7 100644 --- a/compiler/rustc/Cargo.toml +++ b/compiler/rustc/Cargo.toml @@ -22,5 +22,5 @@ features = ['unprefixed_malloc_on_supported_platforms'] [features] jemalloc = ['jemalloc-sys'] llvm = ['rustc_driver_impl/llvm'] -max_level_info = ['rustc_driver_impl/max_level_info'] +max_level_debug = ['rustc_driver_impl/max_level_debug'] rustc_use_parallel_compiler = ['rustc_driver_impl/rustc_use_parallel_compiler'] diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs index 6be20b0974ddb..ac416064ccf2e 100644 --- a/compiler/rustc_borrowck/src/borrow_set.rs +++ b/compiler/rustc_borrowck/src/borrow_set.rs @@ -199,7 +199,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> { ) { if let &mir::Rvalue::Ref(region, kind, borrowed_place) = rvalue { if borrowed_place.ignore_borrow(self.tcx, self.body, &self.locals_state_at_exit) { - debug!("ignoring_borrow of {:?}", borrowed_place); + trace!("ignoring_borrow of {:?}", borrowed_place); return; } @@ -296,13 +296,15 @@ impl<'a, 'tcx> GatherBorrows<'a, 'tcx> { kind: mir::BorrowKind, borrow_index: BorrowIndex, ) { - debug!( + trace!( "Borrows::insert_as_pending_if_two_phase({:?}, {:?}, {:?})", - start_location, assigned_place, borrow_index, + start_location, + assigned_place, + borrow_index, ); if !allow_two_phase_borrow(kind) { - debug!(" -> {:?}", start_location); + trace!(" -> {:?}", start_location); return; } diff --git a/compiler/rustc_borrowck/src/constraint_generation.rs b/compiler/rustc_borrowck/src/constraint_generation.rs index 2aa09a3f26c17..4610c02407aaf 100644 --- a/compiler/rustc_borrowck/src/constraint_generation.rs +++ b/compiler/rustc_borrowck/src/constraint_generation.rs @@ -167,7 +167,7 @@ impl<'cx, 'tcx> ConstraintGeneration<'cx, 'tcx> { where T: TypeVisitable>, { - debug!("add_regular_live_constraint(live_ty={:?}, location={:?})", live_ty, location); + trace!("add_regular_live_constraint(live_ty={:?}, location={:?})", live_ty, location); self.infcx.tcx.for_each_free_region(&live_ty, |live_region| { let vid = live_region.as_var(); @@ -190,9 +190,10 @@ impl<'cx, 'tcx> ConstraintGeneration<'cx, 'tcx> { match place.as_ref() { PlaceRef { local, projection: &[] } | PlaceRef { local, projection: &[ProjectionElem::Deref] } => { - debug!( + trace!( "Recording `killed` facts for borrows of local={:?} at location={:?}", - local, location + local, + location ); record_killed_borrows_for_local( @@ -206,10 +207,11 @@ impl<'cx, 'tcx> ConstraintGeneration<'cx, 'tcx> { PlaceRef { local, projection: &[.., _] } => { // Kill conflicting borrows of the innermost local. - debug!( + trace!( "Recording `killed` facts for borrows of \ innermost projected local={:?} at location={:?}", - local, location + local, + location ); if let Some(borrow_indices) = self.borrow_set.local_map.get(&local) { diff --git a/compiler/rustc_borrowck/src/constraints/mod.rs b/compiler/rustc_borrowck/src/constraints/mod.rs index 315886bbe29ba..fb55d4a9e81e6 100644 --- a/compiler/rustc_borrowck/src/constraints/mod.rs +++ b/compiler/rustc_borrowck/src/constraints/mod.rs @@ -24,7 +24,7 @@ pub(crate) struct OutlivesConstraintSet<'tcx> { impl<'tcx> OutlivesConstraintSet<'tcx> { pub(crate) fn push(&mut self, constraint: OutlivesConstraint<'tcx>) { - debug!("OutlivesConstraintSet::push({:?})", constraint); + trace!("OutlivesConstraintSet::push({:?})", constraint); if constraint.sup == constraint.sub { // 'a: 'a is pretty uninteresting return; diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs index 2daa82aef3957..6a3bd5cb69b91 100644 --- a/compiler/rustc_borrowck/src/dataflow.rs +++ b/compiler/rustc_borrowck/src/dataflow.rs @@ -183,7 +183,7 @@ impl<'tcx> OutOfScopePrecomputer<'_, 'tcx> { let kill_location = Location { block: bb, statement_index: kill_stmt }; // If region does not contain a point at the location, then add to list and skip // successor locations. - debug!("borrow {:?} gets killed at {:?}", borrow_index, kill_location); + trace!("borrow {:?} gets killed at {:?}", borrow_index, kill_location); self.borrows_out_of_scope_at_location .entry(kill_location) .or_default() @@ -285,7 +285,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> { /// Kill any borrows that conflict with `place`. fn kill_borrows_on_place(&self, trans: &mut impl GenKill, place: Place<'tcx>) { - debug!("kill_borrows_on_place: place={:?}", place); + trace!("kill_borrows_on_place: place={:?}", place); let other_borrows_of_local = self .borrow_set diff --git a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs index cfcf31fce32bd..fc34a65e05071 100644 --- a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs @@ -161,7 +161,7 @@ trait TypeOpInfo<'tcx> { error_region: Option>, ) -> Option>; - #[instrument(level = "debug", skip(self, mbcx))] + #[instrument(level = "trace", skip(self, mbcx))] fn report_error( &self, mbcx: &mut MirBorrowckCtxt<'_, 'tcx>, @@ -171,7 +171,7 @@ trait TypeOpInfo<'tcx> { ) { let tcx = mbcx.infcx.tcx; let base_universe = self.base_universe(); - debug!(?base_universe); + trace!(?base_universe); let Some(adjusted_universe) = placeholder.universe.as_u32().checked_sub(base_universe.as_u32()) @@ -200,7 +200,7 @@ trait TypeOpInfo<'tcx> { None }; - debug!(?placeholder_region); + trace!(?placeholder_region); let span = cause.span; let nice_error = self.nice_error(mbcx, cause, placeholder_region, error_region); @@ -374,7 +374,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> { } } -#[instrument(skip(ocx), level = "debug")] +#[instrument(skip(ocx), level = "trace")] fn try_extract_error_from_fulfill_cx<'tcx>( ocx: &ObligationCtxt<'_, 'tcx>, placeholder_region: ty::Region<'tcx>, @@ -395,7 +395,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>( ) } -#[instrument(level = "debug", skip(infcx, region_var_origin, universe_of_region))] +#[instrument(level = "trace", skip(infcx, region_var_origin, universe_of_region))] fn try_extract_error_from_region_constraints<'tcx>( infcx: &InferCtxt<'tcx>, placeholder_region: ty::Region<'tcx>, @@ -418,7 +418,7 @@ fn try_extract_error_from_region_constraints<'tcx>( } })?; - debug!(?sub_region, "cause = {:#?}", cause); + trace!(?sub_region, "cause = {:#?}", cause); let error = match (error_region, *sub_region) { (Some(error_region), ty::ReVar(vid)) => RegionResolutionError::SubSupConflict( vid, diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 15d73ed732f50..d14addd0346cc 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -69,10 +69,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { (moved_place, used_place, span): (PlaceRef<'tcx>, PlaceRef<'tcx>, Span), mpi: MovePathIndex, ) { - debug!( + trace!( "report_use_of_moved_or_uninitialized: location={:?} desired_action={:?} \ moved_place={:?} used_place={:?} span={:?} mpi={:?}", - location, desired_action, moved_place, used_place, span, mpi + location, + desired_action, + moved_place, + used_place, + span, + mpi ); let use_spans = @@ -80,9 +85,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let span = use_spans.args_or_use(); let (move_site_vec, maybe_reinitialized_locations) = self.get_moved_indexes(location, mpi); - debug!( + trace!( "report_use_of_moved_or_uninitialized: move_site_vec={:?} use_spans={:?}", - move_site_vec, use_spans + move_site_vec, + use_spans ); let move_out_indices: Vec<_> = move_site_vec.iter().map(|move_site| move_site.moi).collect(); @@ -91,7 +97,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let root_place = PlaceRef { projection: &[], ..used_place }; if !self.uninitialized_error_reported.insert(root_place) { - debug!( + trace!( "report_use_of_moved_or_uninitialized place: error about {:?} suppressed", root_place ); @@ -110,7 +116,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } else { if let Some((reported_place, _)) = self.has_move_error(&move_out_indices) { if self.prefixes(*reported_place, PrefixSet::All).any(|p| p == used_place) { - debug!( + trace!( "report_use_of_moved_or_uninitialized place: error suppressed mois={:?}", move_out_indices ); @@ -635,7 +641,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { sugg_span: Span, ) { let ty = moved_place.ty(self.body, self.infcx.tcx).ty; - debug!("ty: {:?}, kind: {:?}", ty, ty.kind()); + trace!("ty: {:?}, kind: {:?}", ty, ty.kind()); let tcx = self.infcx.tcx; let implements_default = |ty, param_env| { @@ -807,9 +813,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { (place, span): (Place<'tcx>, Span), borrow: &BorrowData<'tcx>, ) { - debug!( + trace!( "report_move_out_while_borrowed: location={:?} place={:?} span={:?} borrow={:?}", - location, place, span, borrow + location, + place, + span, + borrow ); let value_msg = self.describe_any_place(place.as_ref()); let borrow_msg = self.describe_any_place(borrow.borrowed_place.as_ref()); @@ -1160,7 +1169,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err } - #[instrument(level = "debug", skip(self, err))] + #[instrument(level = "trace", skip(self, err))] fn suggest_using_local_if_applicable( &self, err: &mut Diagnostic, @@ -1173,7 +1182,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { BorrowExplanation::UsedLater(LaterUseKind::Call | LaterUseKind::Other, _call_span, _) ); if !used_in_call { - debug!("not later used in call"); + trace!("not later used in call"); return; } @@ -1194,11 +1203,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let inner_param_location = location; let Some(inner_param_stmt) = self.body.stmt_at(inner_param_location).left() else { - debug!("`inner_param_location` {:?} is not for a statement", inner_param_location); + trace!("`inner_param_location` {:?} is not for a statement", inner_param_location); return; }; let Some(&inner_param) = inner_param_stmt.kind.as_assign().map(|(p, _)| p) else { - debug!( + trace!( "`inner_param_location` {:?} is not for an assignment: {:?}", inner_param_location, inner_param_stmt ); @@ -1207,20 +1216,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let inner_param_uses = find_all_local_uses::find(self.body, inner_param.local); let Some((inner_call_loc, inner_call_term)) = inner_param_uses.into_iter().find_map(|loc| { let Either::Right(term) = self.body.stmt_at(loc) else { - debug!("{:?} is a statement, so it can't be a call", loc); + trace!("{:?} is a statement, so it can't be a call", loc); return None; }; let TerminatorKind::Call { args, .. } = &term.kind else { - debug!("not a call: {:?}", term); + trace!("not a call: {:?}", term); return None; }; - debug!("checking call args for uses of inner_param: {:?}", args); + trace!("checking call args for uses of inner_param: {:?}", args); args.contains(&Operand::Move(inner_param)).then_some((loc, term)) }) else { - debug!("no uses of inner_param found as a by-move call arg"); + trace!("no uses of inner_param found as a by-move call arg"); return; }; - debug!("===> outer_call_loc = {:?}, inner_call_loc = {:?}", outer_call_loc, inner_call_loc); + trace!("===> outer_call_loc = {:?}, inner_call_loc = {:?}", outer_call_loc, inner_call_loc); let inner_call_span = inner_call_term.source_info.span; let outer_call_span = match use_span { @@ -1230,9 +1239,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if outer_call_span == inner_call_span || !outer_call_span.contains(inner_call_span) { // FIXME: This stops the suggestion in some cases where it should be emitted. // Fix the spans for those cases so it's emitted correctly. - debug!( + trace!( "outer span {:?} does not strictly contain inner span {:?}", - outer_call_span, inner_call_span + outer_call_span, + inner_call_span ); return; } @@ -1641,7 +1651,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// short a lifetime. (But sometimes it is more useful to report /// it as a more direct conflict between the execution of a /// `Drop::drop` with an aliasing borrow.) - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(crate) fn report_borrowed_value_does_not_live_long_enough( &mut self, location: Location, @@ -1665,7 +1675,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Place { local: root_place.local, projection: root_place_projection }, borrow_span, )) { - debug!( + trace!( "suppressing access_place error when borrow doesn't live long enough for {:?}", borrow_span ); @@ -1705,7 +1715,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let kind_place = kind.filter(|_| place_desc.is_some()).map(|k| (k, place_span.0)); let explanation = self.explain_why_borrow_contains_point(location, &borrow, kind_place); - debug!(?place_desc, ?explanation); + trace!(?place_desc, ?explanation); let err = match (place_desc, explanation) { // If the outlives constraint comes from inside the closure, @@ -1798,11 +1808,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { borrow_spans: UseSpans<'tcx>, explanation: BorrowExplanation<'tcx>, ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> { - debug!( + trace!( "report_local_value_does_not_live_long_enough(\ {:?}, {:?}, {:?}, {:?}, {:?}\ )", - location, name, borrow, drop_span, borrow_spans + location, + name, + borrow, + drop_span, + borrow_spans ); let borrow_span = borrow_spans.var_or_use_path_span(); @@ -1909,11 +1923,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { kind: Option, dropped_ty: Ty<'tcx>, ) { - debug!( + trace!( "report_borrow_conflicts_with_destructor(\ {:?}, {:?}, ({:?}, {:?}), {:?}\ )", - location, borrow, place, drop_span, kind, + location, + borrow, + place, + drop_span, + kind, ); let borrow_spans = self.retrieve_borrow_spans(borrow); @@ -1971,11 +1989,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { drop_span: Span, borrow_span: Span, ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> { - debug!( + trace!( "report_thread_local_value_does_not_live_long_enough(\ {:?}, {:?}\ )", - drop_span, borrow_span + drop_span, + borrow_span ); let mut err = self.thread_local_value_does_not_live_long_enough(borrow_span); @@ -1989,7 +2008,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn report_temporary_value_does_not_live_long_enough( &mut self, location: Location, @@ -2204,7 +2223,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Some(err) } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn report_escaping_closure_capture( &mut self, use_span: UseSpans<'tcx>, @@ -2378,9 +2397,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let mut result = vec![]; let mut dfs_iter = |result: &mut Vec, location: Location, is_back_edge: bool| { - debug!( + trace!( "report_use_of_moved_or_uninitialized: (current_location={:?}, back_edge={})", - location, is_back_edge + location, + is_back_edge ); if !visited.insert(location) { @@ -2404,10 +2424,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // marked as a move of a.b and a as well, so we will generate the correct errors // there. for moi in &self.move_data.loc_map[location] { - debug!("report_use_of_moved_or_uninitialized: moi={:?}", moi); + trace!("report_use_of_moved_or_uninitialized: moi={:?}", moi); let path = self.move_data.moves[*moi].path; if mpis.contains(&path) { - debug!( + trace!( "report_use_of_moved_or_uninitialized: found {:?}", move_paths[path].place ); @@ -2778,11 +2798,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // place. If it was, we can add annotations about the function's return type and arguments // and it'll make sense. let location = borrow.reserve_location; - debug!("annotate_argument_and_return_for_borrow: location={:?}", location); + trace!("annotate_argument_and_return_for_borrow: location={:?}", location); if let Some(Statement { kind: StatementKind::Assign(box (reservation, _)), .. }) = &self.body[location.block].statements.get(location.statement_index) { - debug!("annotate_argument_and_return_for_borrow: reservation={:?}", reservation); + trace!("annotate_argument_and_return_for_borrow: reservation={:?}", reservation); // Check that the initial assignment of the reserve location is into a temporary. let mut target = match reservation.as_local() { Some(local) if self.body.local_kind(local) == LocalKind::Temp => local, @@ -2793,16 +2813,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // `target` (that is, the place that contains our borrow) to anything. let mut annotated_closure = None; for stmt in &self.body[location.block].statements[location.statement_index + 1..] { - debug!( + trace!( "annotate_argument_and_return_for_borrow: target={:?} stmt={:?}", - target, stmt + target, + stmt ); if let StatementKind::Assign(box (place, rvalue)) = &stmt.kind { if let Some(assigned_to) = place.as_local() { - debug!( + trace!( "annotate_argument_and_return_for_borrow: assigned_to={:?} \ rvalue={:?}", - assigned_to, rvalue + assigned_to, + rvalue ); // Check if our `target` was captured by a closure. if let Rvalue::Aggregate( @@ -2815,7 +2837,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) = operand else { continue; }; - debug!( + trace!( "annotate_argument_and_return_for_borrow: assigned_from={:?}", assigned_from ); @@ -2834,11 +2856,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // case it ends up being assigned into the return place. annotated_closure = self.annotate_fn_sig(def_id, substs.as_closure().sig()); - debug!( + trace!( "annotate_argument_and_return_for_borrow: \ annotated_closure={:?} assigned_from_local={:?} \ assigned_to={:?}", - annotated_closure, assigned_from_local, assigned_to + annotated_closure, + assigned_from_local, + assigned_to ); if assigned_to == mir::RETURN_PLACE { @@ -2867,7 +2891,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }, _ => continue, }; - debug!( + trace!( "annotate_argument_and_return_for_borrow: \ assigned_from={:?}", assigned_from, @@ -2875,7 +2899,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Find the local from the rvalue. let Some(assigned_from_local) = assigned_from.local_or_deref_local() else { continue }; - debug!( + trace!( "annotate_argument_and_return_for_borrow: \ assigned_from_local={:?}", assigned_from_local, @@ -2889,10 +2913,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // If we assigned our `target` into a new place, then we should // check if it was the return place. - debug!( + trace!( "annotate_argument_and_return_for_borrow: \ assigned_from_local={:?} assigned_to={:?}", - assigned_from_local, assigned_to + assigned_from_local, + assigned_to ); if assigned_to == mir::RETURN_PLACE { // If it was then return the annotated closure if there was one, @@ -2909,29 +2934,31 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Check the terminator if we didn't find anything in the statements. let terminator = &self.body[location.block].terminator(); - debug!( + trace!( "annotate_argument_and_return_for_borrow: target={:?} terminator={:?}", - target, terminator + target, + terminator ); if let TerminatorKind::Call { destination, target: Some(_), args, .. } = &terminator.kind { if let Some(assigned_to) = destination.as_local() { - debug!( + trace!( "annotate_argument_and_return_for_borrow: assigned_to={:?} args={:?}", - assigned_to, args + assigned_to, + args ); for operand in args { let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) = operand else { continue; }; - debug!( + trace!( "annotate_argument_and_return_for_borrow: assigned_from={:?}", assigned_from, ); if let Some(assigned_from_local) = assigned_from.local_or_deref_local() { - debug!( + trace!( "annotate_argument_and_return_for_borrow: assigned_from_local={:?}", assigned_from_local, ); @@ -2947,7 +2974,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // If we haven't found an assignment into the return place, then we need not add // any annotations. - debug!("annotate_argument_and_return_for_borrow: none found"); + trace!("annotate_argument_and_return_for_borrow: none found"); None } @@ -2958,7 +2985,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { did: LocalDefId, sig: ty::PolyFnSig<'tcx>, ) -> Option> { - debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig); + trace!("annotate_fn_sig: did={:?} sig={:?}", did, sig); let is_closure = self.infcx.tcx.is_closure(did.to_def_id()); let fn_hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(did); let fn_decl = self.infcx.tcx.hir().fn_decl_by_hir_id(fn_hir_id)?; diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 1d430a93a876d..1c676c69c2bef 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -359,7 +359,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// - second half is the place being accessed /// /// [d]: https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(crate) fn explain_why_borrow_contains_point( &self, location: Location, @@ -371,10 +371,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let tcx = self.infcx.tcx; let borrow_region_vid = borrow.region; - debug!(?borrow_region_vid); + trace!(?borrow_region_vid); let mut region_sub = self.regioncx.find_sub_region_live_at(borrow_region_vid, location); - debug!(?region_sub); + trace!(?region_sub); let mut use_location = location; let mut use_in_later_iteration_of_loop = false; @@ -389,7 +389,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { region_sub = self .regioncx .find_sub_region_live_at(borrow_region_vid, loop_terminator_location); - debug!("explain_why_borrow_contains_point: region_sub in loop={:?}", region_sub); + trace!("explain_why_borrow_contains_point: region_sub in loop={:?}", region_sub); use_location = loop_terminator_location; use_in_later_iteration_of_loop = true; } @@ -446,11 +446,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { extra_info, } } else { - debug!("Could not generate a region name"); + trace!("Could not generate a region name"); BorrowExplanation::Unexplained } } else { - debug!("Could not generate an error region vid"); + trace!("Could not generate an error region vid"); BorrowExplanation::Unexplained } } @@ -461,7 +461,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// First span returned points to the location of the conflicting use /// Second span if `Some` is returned in the case of closures and points /// to the use of the path - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn later_use_kind( &self, borrow: &BorrowData<'tcx>, @@ -534,7 +534,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let location = borrow.reserve_location; let block = &self.body[location.block]; let stmt = block.statements.get(location.statement_index); - debug!("was_captured_by_trait_object: location={:?} stmt={:?}", location, stmt); + trace!("was_captured_by_trait_object: location={:?} stmt={:?}", location, stmt); // We make a `queue` vector that has the locations we want to visit. As of writing, this // will only ever have one item at any given time, but by using a vector, we can pop from @@ -551,15 +551,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { return false; }; - debug!("was_captured_by_trait: target={:?} queue={:?}", target, queue); + trace!("was_captured_by_trait: target={:?} queue={:?}", target, queue); while let Some(current_location) = queue.pop() { - debug!("was_captured_by_trait: target={:?}", target); + trace!("was_captured_by_trait: target={:?}", target); let block = &self.body[current_location.block]; // We need to check the current location to find out if it is a terminator. let is_terminator = current_location.statement_index == block.statements.len(); if !is_terminator { let stmt = &block.statements[current_location.statement_index]; - debug!("was_captured_by_trait_object: stmt={:?}", stmt); + trace!("was_captured_by_trait_object: stmt={:?}", stmt); // The only kind of statement that we care about is assignments... if let StatementKind::Assign(box (place, rvalue)) = &stmt.kind { @@ -589,7 +589,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Operand::Copy(place) | Operand::Move(place) => { if let Some(from) = place.as_local() { if from == target { - debug!("was_captured_by_trait_object: ty={:?}", ty); + trace!("was_captured_by_trait_object: ty={:?}", ty); // Check the type for a trait object. return match ty.kind() { // `&dyn Trait` @@ -619,15 +619,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } else { // The only thing we need to do for terminators is progress to the next block. let terminator = block.terminator(); - debug!("was_captured_by_trait_object: terminator={:?}", terminator); + trace!("was_captured_by_trait_object: terminator={:?}", terminator); if let TerminatorKind::Call { destination, target: Some(block), args, .. } = &terminator.kind { if let Some(dest) = destination.as_local() { - debug!( + trace!( "was_captured_by_trait_object: target={:?} dest={:?} args={:?}", - target, dest, args + target, + dest, + args ); // Check if one of the arguments to this function is the target place. let found_target = args.iter().any(|arg| { @@ -651,7 +653,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - debug!("was_captured_by_trait: queue={:?}", queue); + trace!("was_captured_by_trait: queue={:?}", queue); } // We didn't find anything and ran out of locations to check. diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 20370e4c6ac3c..6422504a1ea6c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -79,12 +79,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { place: PlaceRef<'tcx>, diag: &mut Diagnostic, ) -> bool { - debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place); + trace!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place); let mut target = place.local_or_deref_local(); for stmt in &self.body[location.block].statements[location.statement_index..] { - debug!("add_moved_or_invoked_closure_note: stmt={:?} target={:?}", stmt, target); + trace!("add_moved_or_invoked_closure_note: stmt={:?} target={:?}", stmt, target); if let StatementKind::Assign(box (into, Rvalue::Use(from))) = &stmt.kind { - debug!("add_fnonce_closure_note: into={:?} from={:?}", into, from); + trace!("add_fnonce_closure_note: into={:?} from={:?}", into, from); match from { Operand::Copy(place) | Operand::Move(place) if target == place.local_or_deref_local() => @@ -98,7 +98,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Check if we are attempting to call a closure after it has been invoked. let terminator = self.body[location.block].terminator(); - debug!("add_moved_or_invoked_closure_note: terminator={:?}", terminator); + trace!("add_moved_or_invoked_closure_note: terminator={:?}", terminator); if let TerminatorKind::Call { func: Operand::Constant(box Constant { literal, .. }), args, @@ -106,7 +106,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } = &terminator.kind { if let ty::FnDef(id, _) = *literal.ty().kind() { - debug!("add_moved_or_invoked_closure_note: id={:?}", id); + trace!("add_moved_or_invoked_closure_note: id={:?}", id); if Some(self.infcx.tcx.parent(id)) == self.infcx.tcx.lang_items().fn_once_trait() { let closure = match args.first() { Some(Operand::Copy(place) | Operand::Move(place)) @@ -117,7 +117,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { _ => return false, }; - debug!("add_moved_or_invoked_closure_note: closure={:?}", closure); + trace!("add_moved_or_invoked_closure_note: closure={:?}", closure); if let ty::Closure(did, _) = self.body.local_decls[closure].ty.kind() { let did = did.expect_local(); if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) { @@ -396,20 +396,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // operator. match self.move_data.rev_lookup.find(deref_base) { LookupResult::Exact(mpi) | LookupResult::Parent(Some(mpi)) => { - debug!("borrowed_content_source: mpi={:?}", mpi); + trace!("borrowed_content_source: mpi={:?}", mpi); for i in &self.move_data.init_path_map[mpi] { let init = &self.move_data.inits[*i]; - debug!("borrowed_content_source: init={:?}", init); + trace!("borrowed_content_source: init={:?}", init); // We're only interested in statements that initialized a value, not the // initializations from arguments. let InitLocation::Statement(loc) = init.location else { continue }; let bbd = &self.body[loc.block]; let is_terminator = bbd.statements.len() == loc.statement_index; - debug!( + trace!( "borrowed_content_source: loc={:?} is_terminator={:?}", - loc, is_terminator, + loc, + is_terminator, ); if !is_terminator { continue; @@ -770,11 +771,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { return OtherUse(self.body.source_info(location).span); }; - debug!("move_spans: moved_place={:?} location={:?} stmt={:?}", moved_place, location, stmt); + trace!("move_spans: moved_place={:?} location={:?} stmt={:?}", moved_place, location, stmt); if let StatementKind::Assign(box (_, Rvalue::Aggregate(kind, places))) = &stmt.kind && let AggregateKind::Closure(def_id, _) | AggregateKind::Generator(def_id, _, _) = **kind { - debug!("move_spans: def_id={:?} places={:?}", def_id, places); + trace!("move_spans: def_id={:?} places={:?}", def_id, places); let def_id = def_id.expect_local(); if let Some((args_span, generator_kind, capture_kind_span, path_span)) = self.closure_span(def_id, moved_place, places) @@ -794,7 +795,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { match cause { FakeReadCause::ForMatchedPlace(Some(closure_def_id)) | FakeReadCause::ForLet(Some(closure_def_id)) => { - debug!("move_spans: def_id={:?} place={:?}", closure_def_id, place); + trace!("move_spans: def_id={:?} place={:?}", closure_def_id, place); let places = &[Operand::Move(place)]; if let Some((args_span, generator_kind, capture_kind_span, path_span)) = self.closure_span(closure_def_id, moved_place, IndexSlice::from_raw(places)) @@ -836,7 +837,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { _ => return normal_ret, }; - debug!("move_spans: target_temp = {:?}", target_temp); + trace!("move_spans: target_temp = {:?}", target_temp); if let Some(Terminator { kind: TerminatorKind::Call { fn_span, from_hir_call, .. }, .. @@ -879,7 +880,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// and originating from `maybe_closure_span`. pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpans<'tcx> { use self::UseSpans::*; - debug!("borrow_spans: use_span={:?} location={:?}", use_span, location); + trace!("borrow_spans: use_span={:?} location={:?}", use_span, location); let target = match self.body[location.block].statements.get(location.statement_index) { Some(Statement { kind: StatementKind::Assign(box (place, _)), .. }) => { @@ -919,9 +920,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }; let def_id = def_id.expect_local(); - debug!( + trace!( "borrow_spans: def_id={:?} is_generator={:?} places={:?}", - def_id, is_generator, places + def_id, + is_generator, + places ); if let Some((args_span, generator_kind, capture_kind_span, path_span)) = self.closure_span(def_id, Place::from(target).as_ref(), places) @@ -949,13 +952,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { target_place: PlaceRef<'tcx>, places: &IndexSlice>, ) -> Option<(Span, Option, Span, Span)> { - debug!( + trace!( "closure_span: def_id={:?} target_place={:?} places={:?}", - def_id, target_place, places + def_id, + target_place, + places ); let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(def_id); let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind; - debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr); + trace!("closure_span: hir_id={:?} expr={:?}", hir_id, expr); if let hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, .. }) = expr { for (captured_place, place) in self.infcx.tcx.closure_captures(def_id).iter().zip(places) @@ -964,7 +969,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Operand::Copy(place) | Operand::Move(place) if target_place == place.as_ref() => { - debug!("closure_span: found captured local {:?}", place); + trace!("closure_span: found captured local {:?}", place); let body = self.infcx.tcx.hir().body(body); let generator_kind = body.generator_kind(); diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 8b77477a31a33..58446db8ee2d7 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -147,7 +147,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { match_span: Span, statement_span: Span, ) { - debug!(?match_place, ?match_span, "append_binding_error"); + trace!(?match_place, ?match_span, "append_binding_error"); let from_simple_let = match_place.is_none(); let match_place = match_place.unwrap_or(move_from); @@ -159,14 +159,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if let GroupedMoveError::MovesFromPlace { span, binds_to, .. } = ge && match_span == *span { - debug!("appending local({bind_to:?}) to list"); + trace!("appending local({bind_to:?}) to list"); if !binds_to.is_empty() { binds_to.push(bind_to); } return; } } - debug!("found a new move error location"); + trace!("found a new move error location"); // Don't need to point to x in let x = ... . let (binds_to, span) = if from_simple_let { @@ -197,13 +197,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } = ge { if match_span == *span && mpi == *other_mpi { - debug!("appending local({bind_to:?}) to list"); + trace!("appending local({bind_to:?}) to list"); binds_to.push(bind_to); return; } } } - debug!("found a new move error location"); + trace!("found a new move error location"); grouped_errors.push(GroupedMoveError::MovesFromValue { span: match_span, move_from: mpi, @@ -226,7 +226,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { (use_spans.args_or_use(), Some(use_spans), original_path, kind) } }; - debug!( + trace!( "report: original_path={:?} span={:?}, kind={:?} \ original_path.is_upvar_field_projection={:?}", original_path, @@ -317,7 +317,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } } - debug!("report: ty={:?}", ty); + trace!("report: ty={:?}", ty); let mut err = match ty.kind() { ty::Array(..) | ty::Slice(..) => { self.cannot_move_out_of_interior_noncopy(span, ty, None) @@ -350,9 +350,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { format!("{place_name}, as `{upvar_name}` is a {capture_description}") }; - debug!( + trace!( "report: closure_kind_ty={:?} closure_kind={:?} place_description={:?}", - closure_kind_ty, closure_kind, place_description, + closure_kind_ty, + closure_kind, + place_description, ); let mut diag = self.cannot_move_out_of(span, &place_description); diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index d0e17bf5a0848..4f157e22a1df2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -33,11 +33,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { error_access: AccessKind, location: Location, ) { - debug!( + trace!( "report_mutability_error(\ access_place={:?}, span={:?}, the_place_err={:?}, error_access={:?}, location={:?},\ )", - access_place, span, the_place_err, error_access, location, + access_place, + span, + the_place_err, + error_access, + location, ); let mut err; @@ -45,7 +49,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let reason; let mut opt_source = None; let access_place_desc = self.describe_any_place(access_place.as_ref()); - debug!("report_mutability_error: access_place_desc={:?}", access_place_desc); + trace!("report_mutability_error: access_place_desc={:?}", access_place_desc); match the_place_err { PlaceRef { local, projection: [] } => { @@ -173,7 +177,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } => bug!("Unexpected immutable place."), } - debug!("report_mutability_error: item_msg={:?}, reason={:?}", item_msg, reason); + trace!("report_mutability_error: item_msg={:?}, reason={:?}", item_msg, reason); // `act` and `acted_on` are strings that let us abstract over // the verbs used in some diagnostic messages. @@ -248,7 +252,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } }; - debug!("report_mutability_error: act={:?}, acted_on={:?}", act, acted_on); + trace!("report_mutability_error: act={:?}, acted_on={:?}", act, acted_on); match the_place_err { // Suggest making an existing shared borrow in a struct definition a mutable borrow. @@ -1135,7 +1139,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option) -> bool { - debug!("local_info: {:?}, ty.kind(): {:?}", local_decl.local_info, local_decl.ty.kind()); + trace!("local_info: {:?}, ty.kind(): {:?}", local_decl.local_info, local_decl.ty.kind()); match *local_decl.local_info() { // Check if mutably borrowing a mutable reference. diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs index b6eb9ae980e4e..1ecfc36b914ff 100644 --- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs +++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs @@ -63,7 +63,7 @@ impl OutlivesSuggestionBuilder { | RegionNameSource::AnonRegionFromYieldTy(..) | RegionNameSource::AnonRegionFromAsyncFn(..) | RegionNameSource::AnonRegionFromImplSignature(..) => { - debug!("Region {:?} is NOT suggestable", name); + trace!("Region {:?} is NOT suggestable", name); false } } @@ -149,7 +149,7 @@ impl OutlivesSuggestionBuilder { /// Add the outlives constraint `fr: outlived_fr` to the set of constraints we need to suggest. pub(crate) fn collect_constraint(&mut self, fr: RegionVid, outlived_fr: RegionVid) { - debug!("Collected {:?}: {:?}", fr, outlived_fr); + trace!("Collected {:?}: {:?}", fr, outlived_fr); // Add to set of constraints for final help note. self.constraints_to_add.entry(fr).or_default().push(outlived_fr); @@ -181,7 +181,7 @@ impl OutlivesSuggestionBuilder { pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_>) { // No constraints to add? Done. if self.constraints_to_add.is_empty() { - debug!("No constraints to suggest."); + trace!("No constraints to suggest."); return; } @@ -190,7 +190,7 @@ impl OutlivesSuggestionBuilder { if self.constraints_to_add.len() == 1 && self.constraints_to_add.values().next().unwrap().len() == 1 { - debug!("Only 1 suggestion. Skipping."); + trace!("Only 1 suggestion. Skipping."); return; } @@ -199,7 +199,7 @@ impl OutlivesSuggestionBuilder { // If there are no suggestable constraints... if suggested.is_empty() { - debug!("Only 1 suggestable constraint. Skipping."); + trace!("Only 1 suggestable constraint. Skipping."); return; } diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 8ec872e205792..b6a6f3e3a24b9 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -218,7 +218,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } }) .collect::>(); - debug!(?gat_id_and_generics); + trace!(?gat_id_and_generics); // find higher-ranked trait bounds bounded to the generic associated types let mut hrtb_bounds = vec![]; @@ -241,7 +241,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } } }); - debug!(?hrtb_bounds); + trace!(?hrtb_bounds); hrtb_bounds.iter().for_each(|bound| { let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; }; @@ -251,7 +251,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { ); let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; }; let Def(_, trait_res_defid) = trait_ref.path.res else { return; }; - debug!(?generics_fn); + trace!(?generics_fn); generics_fn.predicates.iter().for_each(|predicate| { let BoundPredicate( WhereBoundPredicate { @@ -395,9 +395,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { // FIXME: currently we do nothing with these, but perhaps we can do better? // FIXME: try collecting these constraints on the outlives suggestion // builder. Does it make the suggestions any better? - debug!( + trace!( "Unreported region error: can't prove that {:?}: {:?}", - longer_fr, shorter_fr + longer_fr, + shorter_fr ); } } @@ -423,7 +424,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { outlived_fr: RegionVid, outlives_suggestion: &mut OutlivesSuggestionBuilder, ) { - debug!("report_region_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr); + trace!("report_region_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr); let (blame_constraint, extra_info) = self.regioncx.best_blame_constraint(fr, fr_origin, |r| { @@ -431,7 +432,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { }); let BlameConstraint { category, cause, variance_info, .. } = blame_constraint; - debug!("report_region_error: category={:?} {:?} {:?}", category, cause, variance_info); + trace!("report_region_error: category={:?} {:?} {:?}", category, cause, variance_info); // Check if we can use one of the "nice region errors". if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) { @@ -448,9 +449,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { self.regioncx.universal_regions().is_local_free_region(outlived_fr), ); - debug!( + trace!( "report_region_error: fr_is_local={:?} outlived_fr_is_local={:?} category={:?}", - fr_is_local, outlived_fr_is_local, category + fr_is_local, + outlived_fr_is_local, + category ); let errci = ErrorConstraintInfo { @@ -578,7 +581,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { output_ty = self.infcx.tcx.type_of(def_id).subst_identity() }; - debug!("report_fnmut_error: output_ty={:?}", output_ty); + trace!("report_fnmut_error: output_ty={:?}", output_ty); let err = FnMutError { span: *span, @@ -638,7 +641,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { /// LL | ref_obj(x) /// | ^^^^^^^^^^ `x` escapes the function body here /// ``` - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn report_escaping_data_error( &self, errci: &ErrorConstraintInfo<'tcx>, @@ -900,11 +903,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { ty::FnDef(fn_did, substs) => (fn_did, substs), _ => return, }; - debug!(?fn_did, ?substs); + trace!(?fn_did, ?substs); // Only suggest this on function calls, not closures let ty = tcx.type_of(fn_did).subst_identity(); - debug!("ty: {:?}, ty.kind: {:?}", ty, ty.kind()); + trace!("ty: {:?}, ty.kind: {:?}", ty, ty.kind()); if let ty::Closure(_, _) = ty.kind() { return; } @@ -927,7 +930,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { Some(param) => param, None => return, }; - debug!(?param); + trace!(?param); let mut visitor = TraitObjectVisitor(FxIndexSet::default()); visitor.visit_ty(param.param_ty); @@ -938,7 +941,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { self.suggest_constrain_dyn_trait_in_impl(diag, &visitor.0, ident, self_ty); } - #[instrument(skip(self, err), level = "debug")] + #[instrument(skip(self, err), level = "trace")] fn suggest_constrain_dyn_trait_in_impl( &self, err: &mut Diagnostic, @@ -946,13 +949,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { ident: Ident, self_ty: &hir::Ty<'_>, ) -> bool { - debug!("err: {:#?}", err); + trace!("err: {:#?}", err); let mut suggested = false; for found_did in found_dids { let mut traits = vec![]; let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did); hir_v.visit_ty(&self_ty); - debug!("trait spans found: {:?}", traits); + trace!("trait spans found: {:?}", traits); for span in &traits { let mut multi_span: MultiSpan = vec![*span].into(); multi_span diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index f38e1605fa5ca..abffd26d7469b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -239,7 +239,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { /// /// and then return the name `'1` for us to use. pub(crate) fn give_region_a_name(&self, fr: RegionVid) -> Option { - debug!( + trace!( "give_region_a_name(fr={:?}, counter={:?})", fr, self.next_region_name.try_borrow().unwrap() @@ -264,7 +264,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { self.region_names.try_borrow_mut().unwrap().insert(fr, value.clone()); } - debug!("give_region_a_name: gave name {:?}", value); + trace!("give_region_a_name: gave name {:?}", value); value } @@ -278,7 +278,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { let tcx = self.infcx.tcx; - debug!("give_region_a_name: error_region = {:?}", error_region); + trace!("give_region_a_name: error_region = {:?}", error_region); match *error_region { ty::ReEarlyBound(ebr) => ebr.has_name().then(|| { let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP); @@ -293,7 +293,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { ty::BoundRegionKind::BrNamed(region_def_id, name) => { // Get the span to point to, even if we don't use the name. let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP); - debug!( + trace!( "bound region named: {:?}, is_named: {:?}", name, free_region.bound_region.is_named() @@ -447,9 +447,10 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { let type_name = self.infcx.extract_inference_diagnostics_data(ty.into(), Some(highlight)).name; - debug!( + trace!( "highlight_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}", - type_name, needle_fr + type_name, + needle_fr ); if type_name.contains(&format!("'{counter}")) { // Only add a label if we can confirm that a region was labelled. @@ -665,7 +666,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { let hir = tcx.hir(); let return_ty = self.regioncx.universal_regions().unnormalized_output_ty; - debug!("give_name_if_anonymous_region_appears_in_output: return_ty = {:?}", return_ty); + trace!("give_name_if_anonymous_region_appears_in_output: return_ty = {:?}", return_ty); if !tcx.any_free_region_meets(&return_ty, |r| r.as_var() == fr) { return None; } @@ -799,7 +800,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { // Note: generators from `async fn` yield `()`, so we don't have to // worry about them here. let yield_ty = self.regioncx.universal_regions().yield_ty?; - debug!("give_name_if_anonymous_region_appears_in_yield_ty: yield_ty = {:?}", yield_ty); + trace!("give_name_if_anonymous_region_appears_in_yield_ty: yield_ty = {:?}", yield_ty); let tcx = self.infcx.tcx; @@ -820,10 +821,11 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { _ => self.body.span, }; - debug!( + trace!( "give_name_if_anonymous_region_appears_in_yield_ty: \ type_name = {:?}, yield_span = {:?}", - yield_span, type_name, + yield_span, + type_name, ); Some(RegionName { diff --git a/compiler/rustc_borrowck/src/diagnostics/var_name.rs b/compiler/rustc_borrowck/src/diagnostics/var_name.rs index 98418e2372f0e..2dc24076b9cb4 100644 --- a/compiler/rustc_borrowck/src/diagnostics/var_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/var_name.rs @@ -18,10 +18,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { upvars: &[Upvar<'tcx>], fr: RegionVid, ) -> Option<(Option, Span)> { - debug!("get_var_name_and_span_for_region(fr={fr:?})"); + trace!("get_var_name_and_span_for_region(fr={fr:?})"); assert!(self.universal_regions().is_universal_region(fr)); - debug!("get_var_name_and_span_for_region: attempting upvar"); + trace!("get_var_name_and_span_for_region: attempting upvar"); self.get_upvar_index_for_region(tcx, fr) .map(|index| { // FIXME(project-rfc-2229#8): Use place span for diagnostics @@ -29,7 +29,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { (Some(name), span) }) .or_else(|| { - debug!("get_var_name_and_span_for_region: attempting argument"); + trace!("get_var_name_and_span_for_region: attempting argument"); self.get_argument_index_for_region(tcx, fr).map(|index| { self.get_argument_name_and_span_for_region(body, local_names, index) }) @@ -44,17 +44,17 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) -> Option { let upvar_index = self.universal_regions().defining_ty.upvar_tys().position(|upvar_ty| { - debug!("get_upvar_index_for_region: upvar_ty={upvar_ty:?}"); + trace!("get_upvar_index_for_region: upvar_ty={upvar_ty:?}"); tcx.any_free_region_meets(&upvar_ty, |r| { let r = r.as_var(); - debug!("get_upvar_index_for_region: r={r:?} fr={fr:?}"); + trace!("get_upvar_index_for_region: r={r:?} fr={fr:?}"); r == fr }) })?; let upvar_ty = self.universal_regions().defining_ty.upvar_tys().nth(upvar_index); - debug!( + trace!( "get_upvar_index_for_region: found {fr:?} in upvar {upvar_index} which has type {upvar_ty:?}", ); @@ -70,11 +70,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { upvar_index: usize, ) -> (Symbol, Span) { let upvar_hir_id = upvars[upvar_index].place.get_root_variable(); - debug!("get_upvar_name_and_span_for_region: upvar_hir_id={upvar_hir_id:?}"); + trace!("get_upvar_name_and_span_for_region: upvar_hir_id={upvar_hir_id:?}"); let upvar_name = tcx.hir().name(upvar_hir_id); let upvar_span = tcx.hir().span(upvar_hir_id); - debug!( + trace!( "get_upvar_name_and_span_for_region: upvar_name={upvar_name:?} upvar_span={upvar_span:?}", ); @@ -95,12 +95,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { let argument_index = self.universal_regions().unnormalized_input_tys.iter().skip(implicit_inputs).position( |arg_ty| { - debug!("get_argument_index_for_region: arg_ty = {arg_ty:?}"); + trace!("get_argument_index_for_region: arg_ty = {arg_ty:?}"); tcx.any_free_region_meets(arg_ty, |r| r.as_var() == fr) }, )?; - debug!( + trace!( "get_argument_index_for_region: found {fr:?} in argument {argument_index} which has type {:?}", self.universal_regions().unnormalized_input_tys[argument_index], ); @@ -118,11 +118,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) -> (Option, Span) { let implicit_inputs = self.universal_regions().defining_ty.implicit_inputs(); let argument_local = Local::from_usize(implicit_inputs + argument_index + 1); - debug!("get_argument_name_and_span_for_region: argument_local={argument_local:?}"); + trace!("get_argument_name_and_span_for_region: argument_local={argument_local:?}"); let argument_name = local_names[argument_local]; let argument_span = body.local_decls[argument_local].source_info.span; - debug!( + trace!( "get_argument_name_and_span_for_region: argument_name={argument_name:?} argument_span={argument_span:?}", ); diff --git a/compiler/rustc_borrowck/src/invalidation.rs b/compiler/rustc_borrowck/src/invalidation.rs index b2ff25ecb96f4..d4b699fa22e35 100644 --- a/compiler/rustc_borrowck/src/invalidation.rs +++ b/compiler/rustc_borrowck/src/invalidation.rs @@ -345,10 +345,13 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> { sd: AccessDepth, rw: ReadOrWrite, ) { - debug!( + trace!( "invalidation::check_access_for_conflict(location={:?}, place={:?}, sd={:?}, \ rw={:?})", - location, place, sd, rw, + location, + place, + sd, + rw, ); let tcx = self.tcx; let body = self.body; diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index a53ea100c2242..8446b1092386e 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -124,10 +124,10 @@ pub fn provide(providers: &mut Providers) { fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> { let (input_body, promoted) = tcx.mir_promoted(def); - debug!("run query mir_borrowck: {}", tcx.def_path_str(def)); + trace!("run query mir_borrowck: {}", tcx.def_path_str(def)); if input_body.borrow().should_skip() { - debug!("Skipping borrowck because of injected body"); + trace!("Skipping borrowck because of injected body"); // Let's make up a borrowck result! Fun times! let result = BorrowCheckResult { concrete_opaque_types: FxIndexMap::default(), @@ -145,7 +145,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> { let input_body: &Body<'_> = &input_body.borrow(); let promoted: &IndexSlice<_, _> = &promoted.borrow(); let opt_closure_req = do_mir_borrowck(&infcx, input_body, promoted, None).0; - debug!("mir_borrowck done"); + trace!("mir_borrowck done"); tcx.arena.alloc(opt_closure_req) } @@ -155,7 +155,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> { /// Use `consumer_options: None` for the default behavior of returning /// [`BorrowCheckResult`] only. Otherwise, return [`BodyWithBorrowckFacts`] according /// to the given [`ConsumerOptions`]. -#[instrument(skip(infcx, input_body, input_promoted), fields(id=?input_body.source.def_id()), level = "debug")] +#[instrument(skip(infcx, input_body, input_promoted), fields(id=?input_body.source.def_id()), level = "trace")] fn do_mir_borrowck<'tcx>( infcx: &InferCtxt<'tcx>, input_body: &Body<'tcx>, @@ -163,7 +163,7 @@ fn do_mir_borrowck<'tcx>( consumer_options: Option, ) -> (BorrowCheckResult<'tcx>, Option>>) { let def = input_body.source.def_id().expect_local(); - debug!(?def); + trace!(?def); let tcx = infcx.tcx; let infcx = BorrowckInferCtxt::new(infcx); @@ -401,7 +401,7 @@ fn do_mir_borrowck<'tcx>( mbcx.body.mut_vars_iter().filter(|local| !mbcx.used_mut.contains(local)).collect(); mbcx.gather_used_muts(temporary_used_locals, unused_mut_locals); - debug!("mbcx.used_mut: {:?}", mbcx.used_mut); + trace!("mbcx.used_mut: {:?}", mbcx.used_mut); let used_mut = std::mem::take(&mut mbcx.used_mut); for local in mbcx.body.mut_vars_and_args_iter().filter(|local| !used_mut.contains(local)) { let local_decl = &mbcx.body.local_decls[local]; @@ -455,7 +455,7 @@ fn do_mir_borrowck<'tcx>( None }; - debug!("do_mir_borrowck: result = {:#?}", result); + trace!("do_mir_borrowck: result = {:#?}", result); (result, body_with_facts) } @@ -482,7 +482,7 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> { let vid = next_region.as_var(); if cfg!(debug_assertions) { - debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin); + trace!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin); let ctxt = get_ctxt_fn(); let mut var_to_origin = self.reg_var_to_origin.borrow_mut(); assert_eq!(var_to_origin.insert(vid, ctxt), None); @@ -491,7 +491,7 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> { next_region } - #[instrument(skip(self, get_ctxt_fn), level = "debug")] + #[instrument(skip(self, get_ctxt_fn), level = "trace")] pub(crate) fn next_nll_region_var( &self, origin: NllRegionVariableOrigin, @@ -504,7 +504,7 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> { let vid = next_region.as_var(); if cfg!(debug_assertions) { - debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin); + trace!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin); let ctxt = get_ctxt_fn(); let mut var_to_origin = self.reg_var_to_origin.borrow_mut(); assert_eq!(var_to_origin.insert(vid, ctxt), None); @@ -607,7 +607,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx stmt: &'cx Statement<'tcx>, location: Location, ) { - debug!("MirBorrowckCtxt::process_statement({:?}, {:?}): {:?}", location, stmt, flow_state); + trace!("MirBorrowckCtxt::process_statement({:?}, {:?}): {:?}", location, stmt, flow_state); let span = stmt.source_info.span; self.check_activations(location, span, flow_state); @@ -676,7 +676,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx term: &'cx Terminator<'tcx>, loc: Location, ) { - debug!("MirBorrowckCtxt::process_terminator({:?}, {:?}): {:?}", loc, term, flow_state); + trace!("MirBorrowckCtxt::process_terminator({:?}, {:?}): {:?}", loc, term, flow_state); let span = term.source_info.span; self.check_activations(loc, span, flow_state); @@ -686,10 +686,13 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx self.consume_operand(loc, (discr, span), flow_state); } TerminatorKind::Drop { place, target: _, unwind: _, replace } => { - debug!( + trace!( "visit_terminator_drop \ loc: {:?} term: {:?} place: {:?} span: {:?}", - loc, term, place, span + loc, + term, + place, + span ); let write_kind = @@ -980,10 +983,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if let Activation(_, borrow_index) = rw { if self.reservation_error_reported.contains(&place_span.0) { - debug!( + trace!( "skipping access_place for activation of invalid reservation \ place: {:?} borrow_index: {:?}", - place_span.0, borrow_index + place_span.0, + borrow_index ); return; } @@ -994,9 +998,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if !self.access_place_error_reported.is_empty() && self.access_place_error_reported.contains(&(place_span.0, place_span.1)) { - debug!( + trace!( "access_place: suppressing error place_span=`{:?}` kind=`{:?}`", - place_span, kind + place_span, + kind ); return; } @@ -1012,12 +1017,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.check_access_for_conflict(location, place_span, sd, rw, flow_state); if conflict_error || mutability_error { - debug!("access_place: logging error place_span=`{:?}` kind=`{:?}`", place_span, kind); + trace!("access_place: logging error place_span=`{:?}` kind=`{:?}`", place_span, kind); self.access_place_error_reported.insert((place_span.0, place_span.1)); } } - #[instrument(level = "debug", skip(self, flow_state))] + #[instrument(level = "trace", skip(self, flow_state))] fn check_access_for_conflict( &mut self, location: Location, @@ -1056,7 +1061,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // NOTE: *reservations* do conflict with themselves; // thus aren't injecting unsoundness w/ this check.) (Activation(_, activating), _) if activating == borrow_index => { - debug!( + trace!( "check_access_for_conflict place_span: {:?} sd: {:?} rw: {:?} \ skipping {:?} b/c activation of same borrow_index", place_span, @@ -1110,7 +1115,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { (Reservation(kind) | Activation(kind, _) | Write(kind), _) => { match rw { Reservation(..) => { - debug!( + trace!( "recording invalid reservation of \ place: {:?}", place_span.0 @@ -1118,7 +1123,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { this.reservation_error_reported.insert(place_span.0); } Activation(_, activating) => { - debug!( + trace!( "observing check_place for activation of \ borrow_index: {:?}", activating @@ -1318,7 +1323,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let def_id = def_id.expect_local(); let BorrowCheckResult { used_mut_upvars, .. } = self.infcx.tcx.mir_borrowck(def_id); - debug!("{:?} used_mut_upvars={:?}", def_id, used_mut_upvars); + trace!("{:?} used_mut_upvars={:?}", def_id, used_mut_upvars); for field in used_mut_upvars { self.propagate_closure_used_mut_upvar(&operands[*field]); } @@ -1411,7 +1416,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let body = self.body; let bbd = &body[loc.block]; let stmt = &bbd.statements[loc.statement_index]; - debug!("temporary assigned in: stmt={:?}", stmt); + trace!("temporary assigned in: stmt={:?}", stmt); if let StatementKind::Assign(box (_, Rvalue::Ref(_, _, source))) = stmt.kind { @@ -1480,7 +1485,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Checks whether a borrow of this place is invalidated when the function /// exits - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn check_for_invalidation_at_exit( &mut self, location: Location, @@ -1508,7 +1513,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }; if !will_be_dropped { - debug!("place_is_invalidated_at_exit({:?}) - won't be dropped", place); + trace!("place_is_invalidated_at_exit({:?}) - won't be dropped", place); return; } @@ -1523,7 +1528,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { sd, places_conflict::PlaceConflictBias::Overlap, ) { - debug!("check_for_invalidation_at_exit({:?}): INVALID", place); + trace!("check_for_invalidation_at_exit({:?}): INVALID", place); // FIXME: should be talking about the region lifetime instead // of just a span here. let span = self.infcx.tcx.sess.source_map().end_point(span); @@ -1539,7 +1544,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// Reports an error if this is a borrow of local data. /// This is called for all Yield expressions on movable generators fn check_for_local_borrow(&mut self, borrow: &BorrowData<'tcx>, yield_span: Span) { - debug!("check_for_local_borrow({:?})", borrow); + trace!("check_for_local_borrow({:?})", borrow); if borrow_of_local_data(borrow.borrowed_place) { let err = self.cannot_borrow_across_generator_yield( @@ -1622,7 +1627,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // // This code covers scenarios 1, 2, and 3. - debug!("check_if_full_path_is_moved place: {:?}", place_span.0); + trace!("check_if_full_path_is_moved place: {:?}", place_span.0); let (prefix, mpi) = self.move_path_closest_to(place_span.0); if maybe_uninits.contains(mpi) { self.report_use_of_moved_or_uninitialized( @@ -1735,7 +1740,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // // This code covers scenario 1. - debug!("check_if_path_or_subpath_is_moved place: {:?}", place_span.0); + trace!("check_if_path_or_subpath_is_moved place: {:?}", place_span.0); if let Some(mpi) = self.move_path_for_place(place_span.0) { let uninit_mpi = self .move_data @@ -1789,7 +1794,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { (place, span): (Place<'tcx>, Span), flow_state: &Flows<'cx, 'tcx>, ) { - debug!("check_if_assigned_path_is_moved place: {:?}", place); + trace!("check_if_assigned_path_is_moved place: {:?}", place); // None case => assigning to `x` does not require `x` be initialized. for (place_base, elem) in place.iter_projections().rev() { @@ -1895,14 +1900,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let Some(mpi) = this.move_path_for_place(prefix) else { continue }; if maybe_uninits.contains(mpi) { - debug!( + trace!( "check_parent_of_field updating shortest_uninit_seen from {:?} to {:?}", shortest_uninit_seen, Some((prefix, mpi)) ); shortest_uninit_seen = Some((prefix, mpi)); } else { - debug!("check_parent_of_field {:?} is definitely initialized", (prefix, mpi)); + trace!("check_parent_of_field {:?} is definitely initialized", (prefix, mpi)); } } @@ -1947,9 +1952,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { flow_state: &Flows<'cx, 'tcx>, location: Location, ) -> bool { - debug!( + trace!( "check_access_permissions({:?}, {:?}, is_local_mutation_allowed: {:?})", - place, kind, is_local_mutation_allowed + place, + kind, + is_local_mutation_allowed ); let error_access; @@ -2114,7 +2121,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { place: PlaceRef<'tcx>, is_local_mutation_allowed: LocalMutationIsAllowed, ) -> Result, PlaceRef<'tcx>> { - debug!("is_mutable: place={:?}, is_local...={:?}", place, is_local_mutation_allowed); + trace!("is_mutable: place={:?}, is_local...={:?}", place, is_local_mutation_allowed); match place.last_projection() { None => { let local = &self.body.local_decls[place.local]; @@ -2196,10 +2203,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let upvar_field_projection = self.is_upvar_field_projection(place); if let Some(field) = upvar_field_projection { let upvar = &self.upvars[field.index()]; - debug!( + trace!( "is_mutable: upvar.mutability={:?} local_mutation_is_allowed={:?} \ place={:?}, place_base={:?}", - upvar, is_local_mutation_allowed, place, place_base + upvar, + is_local_mutation_allowed, + place, + place_base ); match (upvar.place.mutability, is_local_mutation_allowed) { ( diff --git a/compiler/rustc_borrowck/src/location.rs b/compiler/rustc_borrowck/src/location.rs index 0e669abfd14aa..aaeb3880bc587 100644 --- a/compiler/rustc_borrowck/src/location.rs +++ b/compiler/rustc_borrowck/src/location.rs @@ -43,8 +43,8 @@ impl LocationTable { }) .collect(); - debug!("LocationTable(statements_before_block={:#?})", statements_before_block); - debug!("LocationTable: num_points={:#?}", num_points); + trace!("LocationTable(statements_before_block={:#?})", statements_before_block); + trace!("LocationTable: num_points={:#?}", num_points); Self { num_points, statements_before_block } } diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs index 842e90080582f..9f6089c9fda37 100644 --- a/compiler/rustc_borrowck/src/member_constraints.rs +++ b/compiler/rustc_borrowck/src/member_constraints.rs @@ -84,12 +84,12 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> { m_c: &MemberConstraint<'tcx>, mut to_region_vid: impl FnMut(ty::Region<'tcx>) -> ty::RegionVid, ) { - debug!("push_constraint(m_c={:?})", m_c); + trace!("push_constraint(m_c={:?})", m_c); let member_region_vid: ty::RegionVid = to_region_vid(m_c.member_region); let next_constraint = self.first_constraints.get(&member_region_vid).cloned(); let start_index = self.choice_regions.len(); let end_index = start_index + m_c.choice_regions.len(); - debug!("push_constraint: member_region_vid={:?}", member_region_vid); + trace!("push_constraint: member_region_vid={:?}", member_region_vid); let constraint_index = self.constraints.push(NllMemberConstraint { next_constraint, member_region_vid, diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index b5014a3f479c7..b581cf09ef435 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -55,7 +55,7 @@ pub(crate) struct NllOutput<'tcx> { /// Rewrites the regions in the MIR to use NLL variables, also scraping out the set of universal /// regions (e.g., region parameters) declared on the function. That set will need to be given to /// `compute_regions`. -#[instrument(skip(infcx, param_env, body, promoted), level = "debug")] +#[instrument(skip(infcx, param_env, body, promoted), level = "trace")] pub(crate) fn replace_regions_in_mir<'tcx>( infcx: &BorrowckInferCtxt<'_, 'tcx>, param_env: ty::ParamEnv<'tcx>, @@ -64,7 +64,7 @@ pub(crate) fn replace_regions_in_mir<'tcx>( ) -> UniversalRegions<'tcx> { let def = body.source.def_id().expect_local(); - debug!(?def); + trace!(?def); // Compute named region information. This also renumbers the inputs/outputs. let universal_regions = UniversalRegions::new(infcx, def, param_env); @@ -211,7 +211,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>( // added to the existing number of loans, as if they succeeded them in the set. // let borrow_count = borrow_set.len(); - debug!( + trace!( "compute_regions: polonius placeholders, num_universals={}, borrow_count={}", universal_regions.len(), borrow_count @@ -227,10 +227,11 @@ pub(crate) fn compute_regions<'cx, 'tcx>( // `known_placeholder_subset` facts. for (fr1, fr2) in universal_region_relations.known_outlives() { if fr1 != fr2 { - debug!( + trace!( "compute_regions: emitting polonius `known_placeholder_subset` \ fr1={:?}, fr2={:?}", - fr1, fr2 + fr1, + fr2 ); all_facts.known_placeholder_subset.push((fr1, fr2)); } @@ -293,7 +294,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>( let algorithm = env::var("POLONIUS_ALGORITHM").unwrap_or_else(|_| String::from("Hybrid")); let algorithm = Algorithm::from_str(&algorithm).unwrap(); - debug!("compute_regions: using polonius algorithm {:?}", algorithm); + trace!("compute_regions: using polonius algorithm {:?}", algorithm); let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis"); Some(Rc::new(Output::compute(&all_facts, algorithm, false))) } else { diff --git a/compiler/rustc_borrowck/src/path_utils.rs b/compiler/rustc_borrowck/src/path_utils.rs index ea9f8683ca7bb..67c3bb0d9c65c 100644 --- a/compiler/rustc_borrowck/src/path_utils.rs +++ b/compiler/rustc_borrowck/src/path_utils.rs @@ -58,9 +58,12 @@ pub(super) fn each_borrow_involving_path<'tcx, F, I, S>( access, places_conflict::PlaceConflictBias::Overlap, ) { - debug!( + trace!( "each_borrow_involving_path: {:?} @ {:?} vs. {:?}/{:?}", - i, borrowed, place, access + i, + borrowed, + place, + access ); let ctrl = op(s, i, borrowed); if ctrl == Control::Break { @@ -75,7 +78,7 @@ pub(super) fn is_active<'tcx>( borrow_data: &BorrowData<'tcx>, location: Location, ) -> bool { - debug!("is_active(borrow_data={:?}, location={:?})", borrow_data, location); + trace!("is_active(borrow_data={:?}, location={:?})", borrow_data, location); let activation_location = match borrow_data.activation_location { // If this is not a 2-phase borrow, it is always active. diff --git a/compiler/rustc_borrowck/src/place_ext.rs b/compiler/rustc_borrowck/src/place_ext.rs index d521d0db21323..5ce360f51111d 100644 --- a/compiler/rustc_borrowck/src/place_ext.rs +++ b/compiler/rustc_borrowck/src/place_ext.rs @@ -40,7 +40,7 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { { let ignore = !has_storage_dead_or_moved.contains(self.local) && body.local_decls[self.local].mutability == Mutability::Not; - debug!("ignore_borrow: local {:?} => {:?}", self.local, ignore); + trace!("ignore_borrow: local {:?} => {:?}", self.local, ignore); if ignore { return true; } diff --git a/compiler/rustc_borrowck/src/places_conflict.rs b/compiler/rustc_borrowck/src/places_conflict.rs index 25c485b814f4a..5f67e00ffd485 100644 --- a/compiler/rustc_borrowck/src/places_conflict.rs +++ b/compiler/rustc_borrowck/src/places_conflict.rs @@ -46,7 +46,7 @@ pub fn places_conflict<'tcx>( /// access depth. The `bias` parameter is used to determine how the unknowable (comparing runtime /// array indices, for example) should be interpreted - this depends on what the caller wants in /// order to make the conservative choice and preserve soundness. -#[instrument(level = "debug", skip(tcx, body))] +#[instrument(level = "trace", skip(tcx, body))] pub(super) fn borrow_conflicts_with_place<'tcx>( tcx: TyCtxt<'tcx>, body: &Body<'tcx>, @@ -129,7 +129,7 @@ fn place_components_conflict<'tcx>( Overlap::Disjoint => { // We have proven the borrow disjoint - further // projections will remain disjoint. - debug!("borrow_conflicts_with_place: disjoint"); + trace!("borrow_conflicts_with_place: disjoint"); return false; } } @@ -138,7 +138,7 @@ fn place_components_conflict<'tcx>( for (i, (borrow_c, &access_c)) in iter::zip(borrow_place.projection, access_place.projection).enumerate() { - debug!(?borrow_c, ?access_c); + trace!(?borrow_c, ?access_c); let borrow_proj_base = &borrow_place.projection[..i]; @@ -177,7 +177,7 @@ fn place_components_conflict<'tcx>( // idea, at least for now, so just give up and // report a conflict. This is unsafe code anyway so // the user could always use raw pointers. - debug!("arbitrary -> conflict"); + trace!("arbitrary -> conflict"); return true; } Overlap::EqualOrDisjoint => { @@ -186,7 +186,7 @@ fn place_components_conflict<'tcx>( Overlap::Disjoint => { // We have proven the borrow disjoint - further // projections will remain disjoint. - debug!("disjoint"); + trace!("disjoint"); return false; } } @@ -216,7 +216,7 @@ fn place_components_conflict<'tcx>( // // e.g., a (mutable) borrow of `a[5]` while we read the // array length of `a`. - debug!("borrow_conflicts_with_place: implicit field"); + trace!("borrow_conflicts_with_place: implicit field"); return false; } @@ -224,7 +224,7 @@ fn place_components_conflict<'tcx>( // e.g., a borrow of `*x.y` while we shallowly access `x.y` or some // prefix thereof - the shallow access can't touch anything behind // the pointer. - debug!("borrow_conflicts_with_place: shallow access behind ptr"); + trace!("borrow_conflicts_with_place: shallow access behind ptr"); return false; } (ProjectionElem::Deref, ty::Ref(_, _, hir::Mutability::Not), _) => { @@ -234,7 +234,7 @@ fn place_components_conflict<'tcx>( (ProjectionElem::Deref, ty::Ref(_, _, hir::Mutability::Mut), AccessDepth::Drop) => { // Values behind a mutable reference are not access either by dropping a // value, or by StorageDead - debug!("borrow_conflicts_with_place: drop access behind ptr"); + trace!("borrow_conflicts_with_place: drop access behind ptr"); return false; } @@ -279,10 +279,10 @@ fn place_components_conflict<'tcx>( if borrow_kind == BorrowKind::Shallow && borrow_place.projection.len() < access_place.projection.len() { - debug!("borrow_conflicts_with_place: shallow borrow"); + trace!("borrow_conflicts_with_place: shallow borrow"); false } else { - debug!("borrow_conflicts_with_place: full borrow, CONFLICT"); + trace!("borrow_conflicts_with_place: full borrow, CONFLICT"); true } } @@ -293,11 +293,11 @@ fn place_components_conflict<'tcx>( fn place_base_conflict(l1: Local, l2: Local) -> Overlap { if l1 == l2 { // the same local - base case, equal - debug!("place_element_conflict: DISJOINT-OR-EQ-LOCAL"); + trace!("place_element_conflict: DISJOINT-OR-EQ-LOCAL"); Overlap::EqualOrDisjoint } else { // different locals - base case, disjoint - debug!("place_element_conflict: DISJOINT-LOCAL"); + trace!("place_element_conflict: DISJOINT-LOCAL"); Overlap::Disjoint } } @@ -317,28 +317,28 @@ fn place_projection_conflict<'tcx>( match (pi1_elem, pi2_elem) { (ProjectionElem::Deref, ProjectionElem::Deref) => { // derefs (e.g., `*x` vs. `*x`) - recur. - debug!("place_element_conflict: DISJOINT-OR-EQ-DEREF"); + trace!("place_element_conflict: DISJOINT-OR-EQ-DEREF"); Overlap::EqualOrDisjoint } (ProjectionElem::OpaqueCast(_), ProjectionElem::OpaqueCast(_)) => { // casts to other types may always conflict irrespective of the type being cast to. - debug!("place_element_conflict: DISJOINT-OR-EQ-OPAQUE"); + trace!("place_element_conflict: DISJOINT-OR-EQ-OPAQUE"); Overlap::EqualOrDisjoint } (ProjectionElem::Field(f1, _), ProjectionElem::Field(f2, _)) => { if f1 == f2 { // same field (e.g., `a.y` vs. `a.y`) - recur. - debug!("place_element_conflict: DISJOINT-OR-EQ-FIELD"); + trace!("place_element_conflict: DISJOINT-OR-EQ-FIELD"); Overlap::EqualOrDisjoint } else { let ty = Place::ty_from(pi1_local, pi1_proj_base, body, tcx).ty; if ty.is_union() { // Different fields of a union, we are basically stuck. - debug!("place_element_conflict: STUCK-UNION"); + trace!("place_element_conflict: STUCK-UNION"); Overlap::Arbitrary } else { // Different fields of a struct (`a.x` vs. `a.y`). Disjoint! - debug!("place_element_conflict: DISJOINT-FIELD"); + trace!("place_element_conflict: DISJOINT-FIELD"); Overlap::Disjoint } } @@ -369,10 +369,10 @@ fn place_projection_conflict<'tcx>( // } // ``` if v1 == v2 { - debug!("place_element_conflict: DISJOINT-OR-EQ-FIELD"); + trace!("place_element_conflict: DISJOINT-OR-EQ-FIELD"); Overlap::EqualOrDisjoint } else { - debug!("place_element_conflict: DISJOINT-FIELD"); + trace!("place_element_conflict: DISJOINT-FIELD"); Overlap::Disjoint } } @@ -392,12 +392,12 @@ fn place_projection_conflict<'tcx>( PlaceConflictBias::Overlap => { // If we are biased towards overlapping, then this is the recursive // case that gives "equal *or* disjoint" its meaning. - debug!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-INDEX"); + trace!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-INDEX"); Overlap::EqualOrDisjoint } PlaceConflictBias::NoOverlap => { // If we are biased towards no overlapping, then this is disjoint. - debug!("place_element_conflict: DISJOINT-ARRAY-INDEX"); + trace!("place_element_conflict: DISJOINT-ARRAY-INDEX"); Overlap::Disjoint } } @@ -411,10 +411,10 @@ fn place_projection_conflict<'tcx>( ProjectionElem::ConstantIndex { offset: o2, min_length: _, from_end: true }, ) => { if o1 == o2 { - debug!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-CONSTANT-INDEX"); + trace!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-CONSTANT-INDEX"); Overlap::EqualOrDisjoint } else { - debug!("place_element_conflict: DISJOINT-ARRAY-CONSTANT-INDEX"); + trace!("place_element_conflict: DISJOINT-ARRAY-CONSTANT-INDEX"); Overlap::Disjoint } } @@ -449,10 +449,10 @@ fn place_projection_conflict<'tcx>( // Therefore, `min_length - offset_from_end` gives the minimal possible // offset from the beginning if offset_from_begin >= min_length - offset_from_end { - debug!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-CONSTANT-INDEX-FE"); + trace!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-CONSTANT-INDEX-FE"); Overlap::EqualOrDisjoint } else { - debug!("place_element_conflict: DISJOINT-ARRAY-CONSTANT-INDEX-FE"); + trace!("place_element_conflict: DISJOINT-ARRAY-CONSTANT-INDEX-FE"); Overlap::Disjoint } } @@ -465,10 +465,10 @@ fn place_projection_conflict<'tcx>( ProjectionElem::ConstantIndex { offset, min_length: _, from_end: false }, ) => { if (from..to).contains(&offset) { - debug!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-CONSTANT-INDEX-SUBSLICE"); + trace!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-CONSTANT-INDEX-SUBSLICE"); Overlap::EqualOrDisjoint } else { - debug!("place_element_conflict: DISJOINT-ARRAY-CONSTANT-INDEX-SUBSLICE"); + trace!("place_element_conflict: DISJOINT-ARRAY-CONSTANT-INDEX-SUBSLICE"); Overlap::Disjoint } } @@ -481,10 +481,10 @@ fn place_projection_conflict<'tcx>( ProjectionElem::ConstantIndex { offset, min_length: _, from_end: false }, ) => { if offset >= from { - debug!("place_element_conflict: DISJOINT-OR-EQ-SLICE-CONSTANT-INDEX-SUBSLICE"); + trace!("place_element_conflict: DISJOINT-OR-EQ-SLICE-CONSTANT-INDEX-SUBSLICE"); Overlap::EqualOrDisjoint } else { - debug!("place_element_conflict: DISJOINT-SLICE-CONSTANT-INDEX-SUBSLICE"); + trace!("place_element_conflict: DISJOINT-SLICE-CONSTANT-INDEX-SUBSLICE"); Overlap::Disjoint } } @@ -497,13 +497,13 @@ fn place_projection_conflict<'tcx>( ProjectionElem::ConstantIndex { offset, min_length: _, from_end: true }, ) => { if offset > to { - debug!( + trace!( "place_element_conflict: \ DISJOINT-OR-EQ-SLICE-CONSTANT-INDEX-SUBSLICE-FE" ); Overlap::EqualOrDisjoint } else { - debug!("place_element_conflict: DISJOINT-SLICE-CONSTANT-INDEX-SUBSLICE-FE"); + trace!("place_element_conflict: DISJOINT-SLICE-CONSTANT-INDEX-SUBSLICE-FE"); Overlap::Disjoint } } @@ -512,15 +512,15 @@ fn place_projection_conflict<'tcx>( ProjectionElem::Subslice { from: f2, to: t2, from_end: false }, ) => { if f2 >= t1 || f1 >= t2 { - debug!("place_element_conflict: DISJOINT-ARRAY-SUBSLICES"); + trace!("place_element_conflict: DISJOINT-ARRAY-SUBSLICES"); Overlap::Disjoint } else { - debug!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-SUBSLICES"); + trace!("place_element_conflict: DISJOINT-OR-EQ-ARRAY-SUBSLICES"); Overlap::EqualOrDisjoint } } (ProjectionElem::Subslice { .. }, ProjectionElem::Subslice { .. }) => { - debug!("place_element_conflict: DISJOINT-OR-EQ-SLICE-SUBSLICES"); + trace!("place_element_conflict: DISJOINT-OR-EQ-SLICE-SUBSLICES"); Overlap::EqualOrDisjoint } ( diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 2a0cb49672b83..ca787d925376a 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -245,7 +245,7 @@ pub enum ExtraConstraintInfo { PlaceholderFromPredicate(Span), } -#[instrument(skip(infcx, sccs), level = "debug")] +#[instrument(skip(infcx, sccs), level = "trace")] fn sccs_info<'cx, 'tcx>( infcx: &'cx BorrowckInferCtxt<'cx, 'tcx>, sccs: Rc>, @@ -261,7 +261,7 @@ fn sccs_info<'cx, 'tcx>( for (reg_var, origin) in var_to_origin_sorted.into_iter() { reg_vars_to_origins_str.push_str(&format!("{:?}: {:?}\n", reg_var, origin)); } - debug!("{}", reg_vars_to_origins_str); + trace!("{}", reg_vars_to_origins_str); let num_components = sccs.scc_data().ranges().len(); let mut components = vec![FxIndexSet::default(); num_components]; @@ -281,7 +281,7 @@ fn sccs_info<'cx, 'tcx>( regions_info, )) } - debug!("{}", components_str); + trace!("{}", components_str); // calculate the best representative for each component let components_representatives = components @@ -307,7 +307,7 @@ fn sccs_info<'cx, 'tcx>( scc_node_to_edges.insert((scc_idx, repr), edge_representatives); } - debug!("SCC edges {:#?}", scc_node_to_edges); + trace!("SCC edges {:#?}", scc_node_to_edges); } impl<'tcx> RegionInferenceContext<'tcx> { @@ -331,10 +331,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { liveness_constraints: LivenessValues, elements: &Rc, ) -> Self { - debug!("universal_regions: {:#?}", universal_regions); - debug!("outlives constraints: {:#?}", outlives_constraints); - debug!("placeholder_indices: {:#?}", placeholder_indices); - debug!("type tests: {:#?}", type_tests); + trace!("universal_regions: {:#?}", universal_regions); + trace!("outlives constraints: {:#?}", outlives_constraints); + trace!("placeholder_indices: {:#?}", placeholder_indices); + trace!("type tests: {:#?}", type_tests); // Create a RegionDefinition for each inference variable. let definitions: IndexVec<_, _> = var_infos @@ -404,7 +404,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let num_sccs = constraint_sccs.num_sccs(); let mut scc_universes = IndexVec::from_elem_n(ty::UniverseIndex::MAX, num_sccs); - debug!("compute_scc_universes()"); + trace!("compute_scc_universes()"); // For each region R in universe U, ensure that the universe for the SCC // that contains R is "no bigger" than U. This effectively sets the universe @@ -415,7 +415,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let scc_min = std::cmp::min(region_definition.universe, *scc_universe); if scc_min != *scc_universe { *scc_universe = scc_min; - debug!( + trace!( "compute_scc_universes: lowered universe of {scc:?} to {scc_min:?} \ because it contains {region_vid:?} in {region_universe:?}", scc = scc, @@ -463,7 +463,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { if scc_universe_a != scc_universe_min { scc_universes[scc_a] = scc_universe_min; - debug!( + trace!( "compute_scc_universes: lowered universe of {scc_a:?} to {scc_universe_min:?} \ because {scc_a:?}: {scc_b:?} and {scc_b:?} is in universe {scc_universe_b:?}", scc_a = scc_a, @@ -475,7 +475,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } } - debug!("compute_scc_universes: scc_universe = {:#?}", scc_universes); + trace!("compute_scc_universes: scc_universe = {:#?}", scc_universes); scc_universes } @@ -525,9 +525,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Update the names (if any) // This iterator has unstable order but we collect it all into an IndexVec for (external_name, variable) in self.universal_regions.named_universal_regions() { - debug!( + trace!( "init_universal_regions: region {:?} has external name {:?}", - variable, external_name + variable, + external_name ); self.definitions[variable].external_name = Some(external_name); } @@ -556,10 +557,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { if scc_universe.can_name(placeholder.universe) { self.scc_values.add_element(scc, placeholder); } else { - debug!( + trace!( "init_free_and_bound_regions: placeholder {:?} is \ not compatible with universe {:?} of its SCC {:?}", - placeholder, scc_universe, scc, + placeholder, + scc_universe, + scc, ); self.add_incompatible_universe(scc); } @@ -652,7 +655,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// Performs region inference and report errors if we see any /// unsatisfiable constraints. If this is a closure, returns the /// region requirements to propagate to our creator, if any. - #[instrument(skip(self, infcx, body, polonius_output), level = "debug")] + #[instrument(skip(self, infcx, body, polonius_output), level = "trace")] pub(super) fn solve( &mut self, infcx: &InferCtxt<'tcx>, @@ -714,9 +717,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// for each region variable until all the constraints are /// satisfied. Note that some values may grow **too** large to be /// feasible, but we check this later. - #[instrument(skip(self, _body), level = "debug")] + #[instrument(skip(self, _body), level = "trace")] fn propagate_constraints(&mut self, _body: &Body<'tcx>) { - debug!("constraints={:#?}", { + trace!("constraints={:#?}", { let mut constraints: Vec<_> = self.outlives_constraints().collect(); constraints.sort_by_key(|c| (c.sup, c.sub)); constraints @@ -743,13 +746,13 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// computed, by unioning the values of its successors. /// Assumes that all successors have been computed already /// (which is assured by iterating over SCCs in dependency order). - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn compute_value_for_scc(&mut self, scc_a: ConstraintSccIndex) { let constraint_sccs = self.constraint_sccs.clone(); // Walk each SCC `B` such that `A: B`... for &scc_b in constraint_sccs.successors(scc_a) { - debug!(?scc_b); + trace!(?scc_b); // ...and add elements from `B` into `A`. One complication // arises because of universes: If `B` contains something @@ -770,7 +773,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { self.apply_member_constraint(scc_a, m_c_i, member_constraints.choice_regions(m_c_i)); } - debug!(value = ?self.scc_values.region_value_str(scc_a)); + trace!(value = ?self.scc_values.region_value_str(scc_a)); } /// Invoked for each `R0 member of [R1..Rn]` constraint. @@ -784,7 +787,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// is considered a *lower bound*. If possible, we will modify /// the constraint to set it equal to one of the option regions. /// If we make any changes, returns true, else false. - #[instrument(skip(self, member_constraint_index), level = "debug")] + #[instrument(skip(self, member_constraint_index), level = "trace")] fn apply_member_constraint( &mut self, scc: ConstraintSccIndex, @@ -826,7 +829,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { .universal_regions_outlived_by(scc) .all(|lb| self.universal_region_relations.outlives(o_r, lb)) }); - debug!(?choice_regions, "after lb"); + trace!(?choice_regions, "after lb"); // Now find all the *upper bounds* -- that is, each UB is a // free region that must outlive the member region `R0` (`UB: @@ -835,10 +838,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { self.compute_reverse_scc_graph(); let universal_region_relations = &self.universal_region_relations; for ub in self.rev_scc_graph.as_ref().unwrap().upper_bounds(scc) { - debug!(?ub); + trace!(?ub); choice_regions.retain(|&o_r| universal_region_relations.outlives(ub, o_r)); } - debug!(?choice_regions, "after ub"); + trace!(?choice_regions, "after ub"); // At this point we can pick any member of `choice_regions`, but to avoid potential // non-determinism we will pick the *unique minimum* choice. @@ -866,12 +869,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { (false, false) => bug!("incomparable regions in total order"), } }) else { - debug!("no unique minimum choice"); + trace!("no unique minimum choice"); return false; }; let min_choice_scc = self.constraint_sccs.scc(min_choice); - debug!(?min_choice, ?min_choice_scc); + trace!(?min_choice, ?min_choice_scc); if self.scc_values.add_region(scc, min_choice_scc) { self.member_constraints_applied.push(AppliedMemberConstraint { member_region_scc: scc, @@ -912,7 +915,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// `'a` with `'b` and not `'static`. But it will have to do for /// now. fn add_incompatible_universe(&mut self, scc: ConstraintSccIndex) { - debug!("add_incompatible_universe(scc={:?})", scc); + trace!("add_incompatible_universe(scc={:?})", scc); let fr_static = self.universal_regions.fr_static; self.scc_values.add_all_points(scc); @@ -939,7 +942,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let mut deduplicate_errors = FxIndexSet::default(); for type_test in &self.type_tests { - debug!("check_type_test: {:?}", type_test); + trace!("check_type_test: {:?}", type_test); let generic_ty = type_test.generic_kind.to_ty(tcx); if self.eval_verify_bound( @@ -973,11 +976,13 @@ impl<'tcx> RegionInferenceContext<'tcx> { type_test.lower_bound, type_test.span, )) { - debug!( + trace!( "check_type_test: reporting error for erased_generic_kind={:?}, \ lower_bound_region={:?}, \ type_test.span={:?}", - erased_generic_kind, type_test.lower_bound, type_test.span, + erased_generic_kind, + type_test.lower_bound, + type_test.span, ); errors_buffer.push(RegionErrorKind::TypeTestError { type_test: type_test.clone() }); @@ -1009,7 +1014,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// The idea then is to lower the `T: 'X` constraint into multiple /// bounds -- e.g., if `'X` is the union of two free lifetimes, /// `'1` and `'2`, then we would create `T: '1` and `T: '2`. - #[instrument(level = "debug", skip(self, infcx, propagated_outlives_requirements))] + #[instrument(level = "trace", skip(self, infcx, propagated_outlives_requirements))] fn try_promote_type_test( &self, infcx: &InferCtxt<'tcx>, @@ -1027,13 +1032,15 @@ impl<'tcx> RegionInferenceContext<'tcx> { return false; }; - debug!("subject = {:?}", subject); + trace!("subject = {:?}", subject); let r_scc = self.constraint_sccs.scc(*lower_bound); - debug!( + trace!( "lower_bound = {:?} r_scc={:?} universe={:?}", - lower_bound, r_scc, self.scc_universes[r_scc] + lower_bound, + r_scc, + self.scc_universes[r_scc] ); // If the type test requires that `T: 'a` where `'a` is a @@ -1043,7 +1050,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // It doesn't matter *what* universe because the promoted `T` will // always be in the root universe. if let Some(p) = self.scc_values.placeholders_contained_in(r_scc).next() { - debug!("encountered placeholder in higher universe: {:?}, requiring 'static", p); + trace!("encountered placeholder in higher universe: {:?}, requiring 'static", p); let static_r = self.universal_regions.fr_static; propagated_outlives_requirements.push(ClosureOutlivesRequirement { subject, @@ -1061,7 +1068,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // universal region (it may be the same region) and add it to // `ClosureOutlivesRequirement`. for ur in self.scc_values.universal_regions_outlived_by(r_scc) { - debug!("universal_region_outlived_by ur={:?}", ur); + trace!("universal_region_outlived_by ur={:?}", ur); // Check whether we can already prove that the "subject" outlives `ur`. // If so, we don't have to propagate this requirement to our caller. // @@ -1080,7 +1087,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } let non_local_ub = self.universal_region_relations.non_local_upper_bounds(ur); - debug!("try_promote_type_test: non_local_ub={:?}", non_local_ub); + trace!("try_promote_type_test: non_local_ub={:?}", non_local_ub); // This is slightly too conservative. To show T: '1, given `'2: '1` // and `'3: '1` we only need to prove that T: '2 *or* T: '3, but to @@ -1096,7 +1103,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { blame_span: type_test.span, category: ConstraintCategory::Boring, }; - debug!("try_promote_type_test: pushing {:#?}", requirement); + trace!("try_promote_type_test: pushing {:#?}", requirement); propagated_outlives_requirements.push(requirement); } } @@ -1107,7 +1114,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// variables in the type `T` with an equal universal region from the /// closure signature. /// This is not always possible, so this is a fallible process. - #[instrument(level = "debug", skip(self, infcx))] + #[instrument(level = "trace", skip(self, infcx))] fn try_promote_type_test_subject( &self, infcx: &InferCtxt<'tcx>, @@ -1164,7 +1171,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { .unwrap_or(tcx.lifetimes.re_erased) }); - debug!("try_promote_type_test_subject: folded ty = {:?}", ty); + trace!("try_promote_type_test_subject: folded ty = {:?}", ty); // This will be true if we failed to promote some region. if ty.has_erased_regions() { @@ -1188,9 +1195,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// include the CFG anyhow. /// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding /// a result `'y`. - #[instrument(skip(self), level = "debug", ret)] + #[instrument(skip(self), level = "trace", ret)] pub(crate) fn universal_upper_bound(&self, r: RegionVid) -> RegionVid { - debug!(r = %self.region_value_str(r)); + trace!(r = %self.region_value_str(r)); // Find the smallest universal region that contains all other // universal regions within `region`. @@ -1214,9 +1221,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// Therefore, this method should only be used in diagnostic code, /// where displaying *some* named universal region is better than /// falling back to 'static. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(crate) fn approx_universal_upper_bound(&self, r: RegionVid) -> RegionVid { - debug!("{}", self.region_value_str(r)); + trace!("{}", self.region_value_str(r)); // Find the smallest universal region that contains all other // universal regions within `region`. @@ -1225,7 +1232,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let static_r = self.universal_regions.fr_static; for ur in self.scc_values.universal_regions_outlived_by(r_scc) { let new_lub = self.universal_region_relations.postdom_upper_bound(lub, ur); - debug!(?ur, ?lub, ?new_lub); + trace!(?ur, ?lub, ?new_lub); // The upper bound of two non-static regions is static: this // means we know nothing about the relationship between these // two regions. Pick a 'better' one to use when constructing @@ -1249,7 +1256,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } } - debug!(?r, ?lub); + trace!(?r, ?lub); lub } @@ -1264,7 +1271,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { lower_bound: RegionVid, verify_bound: &VerifyBound<'tcx>, ) -> bool { - debug!("eval_verify_bound(lower_bound={:?}, verify_bound={:?})", lower_bound, verify_bound); + trace!("eval_verify_bound(lower_bound={:?}, verify_bound={:?})", lower_bound, verify_bound); match verify_bound { VerifyBound::IfEq(verify_if_eq_b) => { @@ -1365,14 +1372,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { } // Evaluate whether `sup_region: sub_region`. - #[instrument(skip(self), level = "debug", ret)] + #[instrument(skip(self), level = "trace", ret)] fn eval_outlives(&self, sup_region: RegionVid, sub_region: RegionVid) -> bool { - debug!( + trace!( "sup_region's value = {:?} universal={:?}", self.region_value_str(sup_region), self.universal_regions.is_universal_region(sup_region), ); - debug!( + trace!( "sub_region's value = {:?} universal={:?}", self.region_value_str(sub_region), self.universal_regions.is_universal_region(sub_region), @@ -1385,7 +1392,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // some placeholder that `'sup` cannot name, then this is only // true if `'sup` outlives static. if !self.universe_compatible(sub_region_scc, sup_region_scc) { - debug!( + trace!( "sub universe `{sub_region_scc:?}` is not nameable \ by super `{sup_region_scc:?}`, promoting to static", ); @@ -1407,7 +1414,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { }); if !universal_outlives { - debug!("sub region contains a universal region not present in super"); + trace!("sub region contains a universal region not present in super"); return false; } @@ -1416,11 +1423,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { if self.universal_regions.is_universal_region(sup_region) { // Micro-opt: universal regions contain all points. - debug!("super is universal and hence contains all points"); + trace!("super is universal and hence contains all points"); return true; } - debug!("comparison between points in sup/sub"); + trace!("comparison between points in sup/sub"); self.scc_values.contains_points(sup_region_scc, sub_region_scc) } @@ -1498,7 +1505,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { errors_buffer: &mut RegionErrors<'tcx>, polonius_output: Rc, ) { - debug!( + trace!( "check_polonius_subset_errors: {} subset_errors", polonius_output.subset_errors.len() ); @@ -1533,10 +1540,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { subset_errors.dedup(); for (longer_fr, shorter_fr) in subset_errors.into_iter() { - debug!( + trace!( "check_polonius_subset_errors: subset_error longer_fr={:?},\ shorter_fr={:?}", - longer_fr, shorter_fr + longer_fr, + shorter_fr ); let propagated = self.try_propagate_universal_region_error( @@ -1581,7 +1589,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// /// Things that are to be propagated are accumulated into the /// `outlives_requirements` vector. - #[instrument(skip(self, propagated_outlives_requirements, errors_buffer), level = "debug")] + #[instrument(skip(self, propagated_outlives_requirements, errors_buffer), level = "trace")] fn check_universal_region( &self, longer_fr: RegionVid, @@ -1683,7 +1691,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // `longer_fr`. if let Some(fr_minus) = self.universal_region_relations.non_local_lower_bound(longer_fr) { - debug!("try_propagate_universal_region_error: fr_minus={:?}", fr_minus); + trace!("try_propagate_universal_region_error: fr_minus={:?}", fr_minus); let blame_span_category = self.find_outlives_blame_span( longer_fr, @@ -1696,7 +1704,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // so slightly larger than `shorter_fr`. let shorter_fr_plus = self.universal_region_relations.non_local_upper_bounds(shorter_fr); - debug!( + trace!( "try_propagate_universal_region_error: shorter_fr_plus={:?}", shorter_fr_plus ); @@ -1722,10 +1730,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { placeholder: ty::PlaceholderRegion, errors_buffer: &mut RegionErrors<'tcx>, ) { - debug!("check_bound_universal_region(fr={:?}, placeholder={:?})", longer_fr, placeholder,); + trace!("check_bound_universal_region(fr={:?}, placeholder={:?})", longer_fr, placeholder,); let longer_fr_scc = self.constraint_sccs.scc(longer_fr); - debug!("check_bound_universal_region: longer_fr_scc={:?}", longer_fr_scc,); + trace!("check_bound_universal_region: longer_fr_scc={:?}", longer_fr_scc,); for error_element in self.scc_values.elements_contained_in(longer_fr_scc) { match error_element { @@ -1749,10 +1757,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Stop after the first error, it gets too noisy otherwise, and does not provide more information. break; } - debug!("check_bound_universal_region: all bounds satisfied"); + trace!("check_bound_universal_region: all bounds satisfied"); } - #[instrument(level = "debug", skip(self, infcx, errors_buffer))] + #[instrument(level = "trace", skip(self, infcx, errors_buffer))] fn check_member_constraints( &self, infcx: &InferCtxt<'tcx>, @@ -1760,21 +1768,21 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) { let member_constraints = self.member_constraints.clone(); for m_c_i in member_constraints.all_indices() { - debug!(?m_c_i); + trace!(?m_c_i); let m_c = &member_constraints[m_c_i]; let member_region_vid = m_c.member_region_vid; - debug!( + trace!( ?member_region_vid, value = ?self.region_value_str(member_region_vid), ); let choice_regions = member_constraints.choice_regions(m_c_i); - debug!(?choice_regions); + trace!(?choice_regions); // Did the member region wind up equal to any of the option regions? if let Some(o) = choice_regions.iter().find(|&&o_r| self.eval_equal(o_r, m_c.member_region_vid)) { - debug!("evaluated as equal to {:?}", o); + trace!("evaluated as equal to {:?}", o); continue; } @@ -1808,13 +1816,13 @@ impl<'tcx> RegionInferenceContext<'tcx> { fr1: RegionVid, fr2: RegionVid, ) -> bool { - debug!("provides_universal_region(r={:?}, fr1={:?}, fr2={:?})", r, fr1, fr2); + trace!("provides_universal_region(r={:?}, fr1={:?}, fr2={:?})", r, fr1, fr2); let result = { r == fr2 || { fr2 == self.universal_regions.fr_static && self.cannot_name_placeholder(fr1, r) } }; - debug!("provides_universal_region: result = {:?}", result); + trace!("provides_universal_region: result = {:?}", result); result } @@ -1822,14 +1830,15 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// `true` if `r1` cannot name that placeholder in its /// value; otherwise, returns `false`. pub(crate) fn cannot_name_placeholder(&self, r1: RegionVid, r2: RegionVid) -> bool { - debug!("cannot_name_value_of(r1={:?}, r2={:?})", r1, r2); + trace!("cannot_name_value_of(r1={:?}, r2={:?})", r1, r2); match self.definitions[r2].origin { NllRegionVariableOrigin::Placeholder(placeholder) => { let universe1 = self.definitions[r1].universe; - debug!( + trace!( "cannot_name_value_of: universe1={:?} placeholder={:?}", - universe1, placeholder + universe1, + placeholder ); universe1.cannot_name(placeholder.universe) } @@ -1876,7 +1885,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { deque.push_back(from_region); while let Some(r) = deque.pop_front() { - debug!( + trace!( "find_constraint_paths_between_regions: from_region={:?} r={:?} value={}", from_region, r, @@ -2033,7 +2042,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// creating a constraint path that forces `R` to outlive /// `from_region`, and then finding the best choices within that /// path to blame. - #[instrument(level = "debug", skip(self, target_test))] + #[instrument(level = "trace", skip(self, target_test))] pub(crate) fn best_blame_constraint( &self, from_region: RegionVid, @@ -2043,7 +2052,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Find all paths let (path, target_region) = self.find_constraint_paths_between_regions(from_region, target_test).unwrap(); - debug!( + trace!( "path={:#?}", path.iter() .map(|c| format!( @@ -2060,7 +2069,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let outlived = constraint.sub; let Some(origin) = self.var_infos.get(outlived) else { continue; }; let RegionVariableOrigin::Nll(NllRegionVariableOrigin::Placeholder(p)) = origin.origin else { continue; }; - debug!(?constraint, ?p); + trace!(?constraint, ?p); let ConstraintCategory::Predicate(span) = constraint.category else { continue; }; extra_info.push(ExtraConstraintInfo::PlaceholderFromPredicate(span)); // We only want to point to one @@ -2099,7 +2108,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { outlives_constraint: *constraint, }) .collect(); - debug!("categorized_path={:#?}", categorized_path); + trace!("categorized_path={:#?}", categorized_path); // To find the best span to cite, we first try to look for the // final constraint that is interesting and where the `sup` is @@ -2197,7 +2206,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let best_choice = if blame_source { range.rev().find(find_region) } else { range.find(find_region) }; - debug!(?best_choice, ?blame_source, ?extra_info); + trace!(?best_choice, ?blame_source, ?extra_info); if let Some(i) = best_choice { if let Some(next) = categorized_path.get(i + 1) { @@ -2234,7 +2243,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // appears to be the most interesting point to report to the // user via an even more ad-hoc guess. categorized_path.sort_by_key(|p| p.category); - debug!("sorted_path={:#?}", categorized_path); + trace!("sorted_path={:#?}", categorized_path); (categorized_path.remove(0), extra_info) } diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index 33f07c1d8fc41..9fa9facecd1a4 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -57,7 +57,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// Calling `universal_upper_bound` for such a region gives `fr_fn_body`, /// which has no `external_name` in which case we use `'empty` as the /// region to pass to `infer_opaque_definition_from_instantiation`. - #[instrument(level = "debug", skip(self, infcx), ret)] + #[instrument(level = "trace", skip(self, infcx), ret)] pub(crate) fn infer_opaque_types( &self, infcx: &InferCtxt<'tcx>, @@ -70,11 +70,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { .all_indices() .map(|ci| (self.member_constraints[ci].key, ci)) .collect(); - debug!(?member_constraints); + trace!(?member_constraints); for (opaque_type_key, (concrete_type, origin)) in opaque_ty_decls { let substs = opaque_type_key.substs; - debug!(?concrete_type, ?substs); + trace!(?concrete_type, ?substs); let mut subst_regions = vec![self.universal_regions.fr_static]; @@ -108,7 +108,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { to_universal_region(vid, &mut subst_regions); } } - debug!(?subst_regions); + trace!(?subst_regions); // Next, insert universal regions from substs, so we can translate regions that appear // in them but are not subject to member constraints, for instance closure substs. @@ -120,12 +120,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { let vid = self.to_region_vid(region); to_universal_region(vid, &mut subst_regions) }); - debug!(?universal_substs); - debug!(?subst_regions); + trace!(?universal_substs); + trace!(?subst_regions); // Deduplicate the set of regions while keeping the chosen order. let subst_regions = subst_regions.into_iter().collect::>(); - debug!(?subst_regions); + trace!(?subst_regions); let universal_concrete_type = infcx.tcx.fold_regions(concrete_type, |region, _| match *region { @@ -136,7 +136,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { .unwrap_or(infcx.tcx.lifetimes.re_erased), _ => region, }); - debug!(?universal_concrete_type); + trace!(?universal_concrete_type); let opaque_type_key = OpaqueTypeKey { def_id: opaque_type_key.def_id, substs: universal_substs }; @@ -243,7 +243,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { /// - `substs`, the substs used to instantiate this opaque type /// - `instantiated_ty`, the inferred type C1 -- fully resolved, lifted version of /// `opaque_defn.concrete_ty` - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn infer_opaque_definition_from_instantiation( &self, opaque_type_key: OpaqueTypeKey<'tcx>, diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index 9290e7479144a..7b54311805a14 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -35,8 +35,8 @@ impl RegionValueElements { v }) .collect(); - debug!("RegionValueElements: statements_before_block={:#?}", statements_before_block); - debug!("RegionValueElements: num_points={:#?}", num_points); + trace!("RegionValueElements: statements_before_block={:#?}", statements_before_block); + trace!("RegionValueElements: num_points={:#?}", num_points); let mut basic_blocks = IndexVec::with_capacity(num_points); for (bb, bb_data) in body.basic_blocks.iter_enumerated() { @@ -139,7 +139,7 @@ impl LivenessValues { /// Adds the given element to the value for the given region. Returns whether /// the element is newly added (i.e., was not already present). pub(crate) fn add_element(&mut self, row: N, location: Location) -> bool { - debug!("LivenessValues::add(r={:?}, location={:?})", row, location); + trace!("LivenessValues::add(r={:?}, location={:?})", row, location); let index = self.elements.point_from_location(location); self.points.insert(row, index) } @@ -147,7 +147,7 @@ impl LivenessValues { /// Adds all the elements in the given bit array into the given /// region. Returns whether any of them are newly added. pub(crate) fn add_elements(&mut self, row: N, locations: &IntervalSet) -> bool { - debug!("LivenessValues::add_elements(row={:?}, locations={:?})", row, locations); + trace!("LivenessValues::add_elements(row={:?}, locations={:?})", row, locations); self.points.union_row(row, locations) } @@ -261,7 +261,7 @@ impl RegionValues { /// Adds the given element to the value for the given region. Returns whether /// the element is newly added (i.e., was not already present). pub(crate) fn add_element(&mut self, r: N, elem: impl ToElementIndex) -> bool { - debug!("add(r={:?}, elem={:?})", r, elem); + trace!("add(r={:?}, elem={:?})", r, elem); elem.add_to_row(self, r) } diff --git a/compiler/rustc_borrowck/src/renumber.rs b/compiler/rustc_borrowck/src/renumber.rs index 4389d2b60bc55..db1bb7446b610 100644 --- a/compiler/rustc_borrowck/src/renumber.rs +++ b/compiler/rustc_borrowck/src/renumber.rs @@ -12,13 +12,13 @@ use rustc_span::{Span, Symbol}; /// Replaces all free regions appearing in the MIR with fresh /// inference variables, returning the number of variables created. -#[instrument(skip(infcx, body, promoted), level = "debug")] +#[instrument(skip(infcx, body, promoted), level = "trace")] pub fn renumber_mir<'tcx>( infcx: &BorrowckInferCtxt<'_, 'tcx>, body: &mut Body<'tcx>, promoted: &mut IndexSlice>, ) { - debug!(?body.arg_count); + trace!(?body.arg_count); let mut renumberer = RegionRenumberer { infcx }; @@ -86,40 +86,40 @@ impl<'a, 'tcx> MutVisitor<'tcx> for RegionRenumberer<'a, 'tcx> { self.infcx.tcx } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) { *ty = self.renumber_regions(*ty, || RegionCtxt::TyContext(ty_context)); - debug!(?ty); + trace!(?ty); } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, location: Location) { *substs = self.renumber_regions(*substs, || RegionCtxt::Location(location)); - debug!(?substs); + trace!(?substs); } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn visit_region(&mut self, region: &mut ty::Region<'tcx>, location: Location) { let old_region = *region; *region = self.renumber_regions(old_region, || RegionCtxt::Location(location)); - debug!(?region); + trace!(?region); } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn visit_ty_const(&mut self, ct: &mut ty::Const<'tcx>, location: Location) { let old_ct = *ct; *ct = self.renumber_regions(old_ct, || RegionCtxt::Location(location)); - debug!(?ct); + trace!(?ct); } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn visit_constant(&mut self, constant: &mut Constant<'tcx>, location: Location) { let literal = constant.literal; constant.literal = self.renumber_regions(literal, || RegionCtxt::Location(location)); - debug!("constant: {:#?}", constant); + trace!("constant: {:#?}", constant); } } diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index f527eee7bda05..1994859486f60 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -40,7 +40,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let TypeOpOutput { output, constraints, error_info } = op.fully_perform(self.infcx, locations.span(self.body))?; - debug!(?output, ?constraints); + trace!(?output, ?constraints); if let Some(data) = constraints { self.push_region_constraints(locations, category, data); @@ -81,7 +81,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { instantiated } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(super) fn prove_trait_ref( &mut self, trait_ref: ty::TraitRef<'tcx>, @@ -99,7 +99,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(super) fn normalize_and_prove_instantiated_predicates( &mut self, // Keep this parameter for now, in case we start using @@ -109,7 +109,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { locations: Locations, ) { for (predicate, span) in instantiated_predicates { - debug!(?predicate); + trace!(?predicate); let category = ConstraintCategory::Predicate(span); let predicate = self.normalize_with_category(predicate, locations, category); self.prove_predicate(predicate, locations, category); @@ -127,7 +127,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(super) fn prove_predicate( &mut self, predicate: impl ToPredicate<'tcx> + std::fmt::Debug, @@ -150,7 +150,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { self.normalize_with_category(value, location, ConstraintCategory::Boring) } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(super) fn normalize_with_category( &mut self, value: T, @@ -169,7 +169,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { result.unwrap_or(value) } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(super) fn ascribe_user_type( &mut self, mir_ty: Ty<'tcx>, @@ -186,7 +186,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { /// *Incorrectly* skips the WF checks we normally do in `ascribe_user_type`. /// /// FIXME(#104478, #104477): This is a hack for backward-compatibility. - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(super) fn ascribe_user_type_skip_wf( &mut self, mir_ty: Ty<'tcx>, diff --git a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs index 71eae7b27d1db..f2cf379899f54 100644 --- a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs +++ b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs @@ -68,7 +68,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(super) fn convert_all(&mut self, query_constraints: &QueryRegionConstraints<'tcx>) { let QueryRegionConstraints { outlives, member_constraints } = query_constraints; @@ -90,7 +90,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { /// Given an instance of the closure type, this method instantiates the "extra" requirements /// that we computed for the closure. This has the effect of adding new outlives obligations /// to existing region variables in `closure_substs`. - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub fn apply_closure_requirements( &mut self, closure_requirements: &ClosureRegionRequirements<'tcx>, @@ -106,7 +106,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { closure_requirements.num_external_vids, closure_def_id.expect_local(), ); - debug!(?closure_mapping); + trace!(?closure_mapping); // Create the predicates. let backup = (self.category, self.span, self.from_closure); @@ -132,7 +132,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { predicate: ty::OutlivesPredicate, ty::Region<'tcx>>, constraint_category: ConstraintCategory<'tcx>, ) { - debug!("generate: constraints at: {:#?}", self.locations); + trace!("generate: constraints at: {:#?}", self.locations); // Extract out various useful fields we'll need below. let ConstraintConversion { @@ -225,7 +225,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { } fn add_type_test(&mut self, type_test: TypeTest<'tcx>) { - debug!("add_type_test(type_test={:?})", type_test); + trace!("add_type_test(type_test={:?})", type_test); self.constraints.type_tests.push(type_test); } } diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index c8ec1257d376e..e1f6d4049558b 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -87,7 +87,7 @@ impl UniversalRegionRelations<'_> { /// /// (*) If there are multiple competing choices, we return all of them. pub(crate) fn non_local_upper_bounds(&self, fr: RegionVid) -> Vec { - debug!("non_local_upper_bound(fr={:?})", fr); + trace!("non_local_upper_bound(fr={:?})", fr); let res = self.non_local_bounds(&self.inverse_outlives, fr); assert!(!res.is_empty(), "can't find an upper bound!?"); res @@ -100,7 +100,7 @@ impl UniversalRegionRelations<'_> { /// (*) If there are multiple competing choices, we pick the "postdominating" /// one. See `TransitiveRelation::postdom_upper_bound` for details. pub(crate) fn non_local_lower_bound(&self, fr: RegionVid) -> Option { - debug!("non_local_lower_bound(fr={:?})", fr); + trace!("non_local_lower_bound(fr={:?})", fr); let lower_bounds = self.non_local_bounds(&self.outlives, fr); // In case we find more than one, reduce to one for @@ -108,7 +108,7 @@ impl UniversalRegionRelations<'_> { // complex constraints, but it will cause spurious errors. let post_dom = self.outlives.mutual_immediate_postdominator(lower_bounds); - debug!("non_local_bound: post_dom={:?}", post_dom); + trace!("non_local_bound: post_dom={:?}", post_dom); post_dom.and_then(|post_dom| { // If the mutual immediate postdom is not local, then @@ -147,7 +147,7 @@ impl UniversalRegionRelations<'_> { queue.extend(relation.parents(fr)); } - debug!("non_local_bound: external_parents={:?}", external_parents); + trace!("non_local_bound: external_parents={:?}", external_parents); external_parents } @@ -188,12 +188,12 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { /// Records in the `outlives_relation` (and /// `inverse_outlives_relation`) that `fr_a: fr_b`. fn relate_universal_regions(&mut self, fr_a: RegionVid, fr_b: RegionVid) { - debug!("relate_universal_regions: fr_a={:?} outlives fr_b={:?}", fr_a, fr_b); + trace!("relate_universal_regions: fr_a={:?} outlives fr_b={:?}", fr_a, fr_b); self.outlives.add(fr_a, fr_b); self.inverse_outlives.add(fr_b, fr_a); } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(crate) fn create(mut self) -> CreateResult<'tcx> { let span = self.infcx.tcx.def_span(self.universal_regions.defining_ty.def_id()); @@ -208,7 +208,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { let fr_static = self.universal_regions.fr_static; let fr_fn_body = self.universal_regions.fr_fn_body; for fr in self.universal_regions.universal_regions() { - debug!("build: relating free region {:?} to itself and to 'static", fr); + trace!("build: relating free region {:?} to itself and to 'static", fr); self.relate_universal_regions(fr, fr); self.relate_universal_regions(fr_static, fr); self.relate_universal_regions(fr, fr_fn_body); @@ -233,7 +233,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { Vec::with_capacity(self.universal_regions.unnormalized_input_tys.len() + 1); let mut constraints = vec![]; for ty in unnormalized_input_output_tys { - debug!("build: input_or_output={:?}", ty); + trace!("build: input_or_output={:?}", ty); // We add implied bounds from both the unnormalized and normalized ty. // See issue #87748 let constraints_unnorm = self.add_implied_bounds(ty); @@ -290,9 +290,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { } } - #[instrument(skip(self, data), level = "debug")] + #[instrument(skip(self, data), level = "trace")] fn push_region_constraints(&mut self, data: &QueryRegionConstraints<'tcx>, span: Span) { - debug!("constraints generated: {:#?}", data); + trace!("constraints generated: {:#?}", data); constraint_conversion::ConstraintConversion::new( self.infcx, @@ -312,14 +312,14 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { /// either the return type of the MIR or one of its arguments. At /// the same time, compute and add any implied bounds that come /// from this local. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn add_implied_bounds(&mut self, ty: Ty<'tcx>) -> Option<&'tcx QueryRegionConstraints<'tcx>> { let TypeOpOutput { output: bounds, constraints, .. } = self .param_env .and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty }) .fully_perform(self.infcx, DUMMY_SP) .unwrap_or_else(|_| bug!("failed to compute implied bounds {:?}", ty)); - debug!(?bounds, ?constraints); + trace!(?bounds, ?constraints); self.add_outlives_bounds(bounds); constraints } @@ -332,7 +332,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { I: IntoIterator>, { for outlives_bound in outlives_bounds { - debug!("add_outlives_bounds(bound={:?})", outlives_bound); + trace!("add_outlives_bounds(bound={:?})", outlives_bound); match outlives_bound { OutlivesBound::RegionSubRegion(r1, r2) => { diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index a06d4bcc6c7ae..467540d37eacd 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -19,7 +19,7 @@ use super::{Locations, TypeChecker}; impl<'a, 'tcx> TypeChecker<'a, 'tcx> { /// Check explicit closure signature annotation, /// e.g., `|x: FxIndexMap<_, &'static u32>| ...`. - #[instrument(skip(self, body), level = "debug")] + #[instrument(skip(self, body), level = "trace")] pub(super) fn check_signature_annotation(&mut self, body: &Body<'tcx>) { let mir_def_id = body.source.def_id().expect_local(); if !self.tcx().is_closure(mir_def_id.to_def_id()) { @@ -59,7 +59,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); } - #[instrument(skip(self, body, universal_regions), level = "debug")] + #[instrument(skip(self, body, universal_regions), level = "trace")] pub(super) fn equate_inputs_and_outputs( &mut self, body: &Body<'tcx>, @@ -69,8 +69,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let (&normalized_output_ty, normalized_input_tys) = normalized_inputs_and_output.split_last().unwrap(); - debug!(?normalized_output_ty); - debug!(?normalized_input_tys); + trace!(?normalized_output_ty); + trace!(?normalized_input_tys); // Equate expected input tys with those in the MIR. for (argument_index, &normalized_input_ty) in normalized_input_tys.iter().enumerate() { @@ -94,7 +94,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); } - debug!( + trace!( "equate_inputs_and_outputs: body.yield_ty {:?}, universal_regions.yield_ty {:?}", body.yield_ty(), universal_regions.yield_ty @@ -141,7 +141,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { }; } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn equate_normalized_input_or_output(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, span: Span) { if let Err(_) = self.eq_types(a, b, Locations::All(span), ConstraintCategory::BoringNoLocation) diff --git a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs index f1ad0ca55ccfd..0b341a1b65fae 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs @@ -38,7 +38,7 @@ pub(super) fn generate<'mir, 'tcx>( location_table: &LocationTable, use_polonius: bool, ) { - debug!("liveness::generate"); + trace!("liveness::generate"); let free_regions = regions_that_outlive_free_regions( typeck.infcx.num_region_vars(), @@ -86,9 +86,9 @@ fn compute_relevant_live_locals<'tcx>( } }); - debug!("{} total variables", body.local_decls.len()); - debug!("{} variables need liveness", relevant_live_locals.len()); - debug!("{} regions outlive free regions", free_regions.len()); + trace!("{} total variables", body.local_decls.len()); + trace!("{} variables need liveness", relevant_live_locals.len()); + trace!("{} regions outlive free regions", free_regions.len()); (relevant_live_locals, boring_locals) } diff --git a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs index b344ab46adbde..523dfb798be59 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs @@ -26,22 +26,22 @@ impl UseFactsExtractor<'_, '_> { } fn insert_def(&mut self, local: Local, location: Location) { - debug!("UseFactsExtractor::insert_def()"); + trace!("UseFactsExtractor::insert_def()"); self.var_defined_at.push((local, self.location_to_index(location))); } fn insert_use(&mut self, local: Local, location: Location) { - debug!("UseFactsExtractor::insert_use()"); + trace!("UseFactsExtractor::insert_use()"); self.var_used_at.push((local, self.location_to_index(location))); } fn insert_drop_use(&mut self, local: Local, location: Location) { - debug!("UseFactsExtractor::insert_drop_use()"); + trace!("UseFactsExtractor::insert_drop_use()"); self.var_dropped_at.push((local, self.location_to_index(location))); } fn insert_path_access(&mut self, path: MovePathIndex, location: Location) { - debug!("UseFactsExtractor::insert_path_access({:?}, {:?})", path, location); + trace!("UseFactsExtractor::insert_path_access({:?}, {:?})", path, location); self.path_accessed_at_base.push((path, self.location_to_index(location))); } @@ -89,7 +89,7 @@ pub(super) fn populate_access_facts<'a, 'tcx>( move_data: &MoveData<'tcx>, dropped_at: &mut Vec<(Local, Location)>, ) { - debug!("populate_access_facts()"); + trace!("populate_access_facts()"); if let Some(facts) = typeck.borrowck_context.all_facts.as_mut() { let mut extractor = UseFactsExtractor { @@ -107,9 +107,10 @@ pub(super) fn populate_access_facts<'a, 'tcx>( ); for (local, local_decl) in body.local_decls.iter_enumerated() { - debug!( + trace!( "add use_of_var_derefs_origin facts - local={:?}, type={:?}", - local, local_decl.ty + local, + local_decl.ty ); let _prof_timer = typeck.infcx.tcx.prof.generic_activity("polonius_fact_generation"); let universal_regions = &typeck.borrowck_context.universal_regions; @@ -128,7 +129,7 @@ pub(super) fn add_drop_of_var_derefs_origin<'tcx>( local: Local, kind: &GenericArg<'tcx>, ) { - debug!("add_drop_of_var_derefs_origin(local={:?}, kind={:?}", local, kind); + trace!("add_drop_of_var_derefs_origin(local={:?}, kind={:?}", local, kind); if let Some(facts) = typeck.borrowck_context.all_facts.as_mut() { let _prof_timer = typeck.infcx.tcx.prof.generic_activity("polonius_fact_generation"); let universal_regions = &typeck.borrowck_context.universal_regions; diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index eb02604b9d925..966880e534bd6 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -46,7 +46,7 @@ pub(super) fn trace<'mir, 'tcx>( boring_locals: Vec, polonius_drop_used: Option>, ) { - debug!("trace()"); + trace!("trace()"); let local_use_map = &LocalUseMap::build(&relevant_live_locals, elements, body); @@ -212,7 +212,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { /// Adds the definitions of `local` into `self.defs`. fn add_defs_for(&mut self, local: Local) { for def in self.cx.local_use_map.defs(local) { - debug!("- defined at {:?}", def); + trace!("- defined at {:?}", def); self.defs.insert(def); } } @@ -224,7 +224,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { /// /// Requires `add_defs_for(local)` to have been executed. fn compute_use_live_points_for(&mut self, local: Local) { - debug!("compute_use_live_points_for(local={:?})", local); + trace!("compute_use_live_points_for(local={:?})", local); self.stack.extend(self.cx.local_use_map.uses(local)); while let Some(p) = self.stack.pop() { @@ -278,10 +278,10 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { /// Requires `compute_use_live_points_for` and `add_defs_for` to /// have been executed. fn compute_drop_live_points_for(&mut self, local: Local) { - debug!("compute_drop_live_points_for(local={:?})", local); + trace!("compute_drop_live_points_for(local={:?})", local); let mpi = self.cx.move_data.rev_lookup.find_local(local); - debug!("compute_drop_live_points_for: mpi = {:?}", mpi); + trace!("compute_drop_live_points_for: mpi = {:?}", mpi); // Find the drops where `local` is initialized. for drop_point in self.cx.local_use_map.drops(local) { @@ -296,7 +296,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { } } - debug!("compute_drop_live_points_for: drop_locations={:?}", self.drop_locations); + trace!("compute_drop_live_points_for: drop_locations={:?}", self.drop_locations); // Reverse DFS. But for drops, we do it a bit differently. // The stack only ever stores *terminators of blocks*. Within @@ -318,7 +318,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { /// where applicable -- pushes the terminators of preceding blocks /// onto `self.stack`. fn compute_drop_live_points_for_block(&mut self, mpi: MovePathIndex, term_point: PointIndex) { - debug!( + trace!( "compute_drop_live_points_for_block(mpi={:?}, term_point={:?})", self.cx.move_data.move_paths[mpi].place, self.cx.elements.to_location(term_point), @@ -336,27 +336,27 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { let block = term_location.block; let entry_point = self.cx.elements.entry_point(term_location.block); for p in (entry_point..term_point).rev() { - debug!("compute_drop_live_points_for_block: p = {:?}", self.cx.elements.to_location(p)); + trace!("compute_drop_live_points_for_block: p = {:?}", self.cx.elements.to_location(p)); if self.defs.contains(p) { - debug!("compute_drop_live_points_for_block: def site"); + trace!("compute_drop_live_points_for_block: def site"); return; } if self.use_live_at.contains(p) { - debug!("compute_drop_live_points_for_block: use-live at {:?}", p); + trace!("compute_drop_live_points_for_block: use-live at {:?}", p); return; } if !self.drop_live_at.insert(p) { - debug!("compute_drop_live_points_for_block: already drop-live"); + trace!("compute_drop_live_points_for_block: already drop-live"); return; } } let body = self.cx.body; for &pred_block in body.basic_blocks.predecessors()[block].iter() { - debug!("compute_drop_live_points_for_block: pred_block = {:?}", pred_block,); + trace!("compute_drop_live_points_for_block: pred_block = {:?}", pred_block,); // Check whether the variable is (at least partially) // initialized at the exit of this predecessor. If so, we @@ -377,7 +377,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { // a *definition* of the variable, in which case we want // to stop the search anyhow. (But see Note 1 below.) if !self.cx.initialized_at_exit(pred_block, mpi) { - debug!("compute_drop_live_points_for_block: not initialized"); + trace!("compute_drop_live_points_for_block: not initialized"); continue; } @@ -387,19 +387,19 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> { // If the terminator of this predecessor either *assigns* // our value or is a "normal use", then stop. if self.defs.contains(pred_term_point) { - debug!("compute_drop_live_points_for_block: defined at {:?}", pred_term_loc); + trace!("compute_drop_live_points_for_block: defined at {:?}", pred_term_loc); continue; } if self.use_live_at.contains(pred_term_point) { - debug!("compute_drop_live_points_for_block: use-live at {:?}", pred_term_loc); + trace!("compute_drop_live_points_for_block: use-live at {:?}", pred_term_loc); continue; } // Otherwise, we are drop-live on entry to the terminator, // so walk it. if self.drop_live_at.insert(pred_term_point) { - debug!("compute_drop_live_points_for_block: pushed to stack"); + trace!("compute_drop_live_points_for_block: pushed to stack"); self.stack.push(pred_term_point); } } @@ -480,7 +480,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { value: impl TypeVisitable>, live_at: &IntervalSet, ) { - debug!("add_use_live_facts_for(value={:?})", value); + trace!("add_use_live_facts_for(value={:?})", value); Self::make_all_regions_live(self.elements, &mut self.typeck, value, live_at) } @@ -497,7 +497,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { drop_locations: &[Location], live_at: &IntervalSet, ) { - debug!( + trace!( "add_drop_live_constraint(\ dropped_local={:?}, \ dropped_ty={:?}, \ @@ -545,8 +545,8 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { value: impl TypeVisitable>, live_at: &IntervalSet, ) { - debug!("make_all_regions_live(value={:?})", value); - debug!( + trace!("make_all_regions_live(value={:?})", value); + trace!( "make_all_regions_live: live_at={}", values::location_set_str(elements, live_at.iter()), ); @@ -567,7 +567,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { typeck: &mut TypeChecker<'_, 'tcx>, dropped_ty: Ty<'tcx>, ) -> DropData<'tcx> { - debug!("compute_drop_data(dropped_ty={:?})", dropped_ty,); + trace!("compute_drop_data(dropped_ty={:?})", dropped_ty,); match typeck .param_env diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 03f933681bc24..cd9c3efa2d1c7 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -162,7 +162,7 @@ pub(crate) fn type_check<'mir, 'tcx>( &mut constraints, ); - debug!(?normalized_inputs_and_output); + trace!(?normalized_inputs_and_output); for u in ty::UniverseIndex::ROOT..=infcx.universe() { constraints.universe_causes.insert(u, UniverseInfo::other()); @@ -311,7 +311,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { } fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) { - debug!(?constant, ?location, "visit_constant"); + trace!(?constant, ?location, "visit_constant"); self.super_constant(constant, location); let ty = self.sanitize_type(constant, constant.literal.ty()); @@ -519,7 +519,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { location: Location, context: PlaceContext, ) -> PlaceTy<'tcx> { - debug!("sanitize_place: {:?}", place); + trace!("sanitize_place: {:?}", place); let mut place_ty = PlaceTy::from_ty(self.body().local_decls[place.local].ty); @@ -623,7 +623,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn sanitize_projection( &mut self, base: PlaceTy<'tcx>, @@ -632,7 +632,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { location: Location, context: PlaceContext, ) -> PlaceTy<'tcx> { - debug!("sanitize_projection: {:?} {:?} {:?}", base, pi, place); + trace!("sanitize_projection: {:?} {:?} {:?}", base, pi, place); let tcx = self.tcx(); let base_ty = base.ty; match pi { @@ -708,7 +708,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { match self.field_ty(place, base, field, location) { Ok(ty) => { let ty = self.cx.normalize(ty, location); - debug!(?fty, ?ty); + trace!(?fty, ?ty); if let Err(terr) = self.cx.relate_types( ty, @@ -1094,9 +1094,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } /// Equate the inferred type and the annotated type for user type annotations - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn check_user_type_annotations(&mut self) { - debug!(?self.user_type_annotations); + trace!(?self.user_type_annotations); for user_annotation in self.user_type_annotations { let CanonicalUserTypeAnnotation { span, ref user_ty, inferred_ty } = *user_annotation; let annotation = self.instantiate_canonical_with_fresh_inference_vars(span, user_ty); @@ -1104,14 +1104,14 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } } - #[instrument(skip(self, data), level = "debug")] + #[instrument(skip(self, data), level = "trace")] fn push_region_constraints( &mut self, locations: Locations, category: ConstraintCategory<'tcx>, data: &QueryRegionConstraints<'tcx>, ) { - debug!("constraints generated: {:#?}", data); + trace!("constraints generated: {:#?}", data); constraint_conversion::ConstraintConversion::new( self.infcx, @@ -1140,7 +1140,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { self.relate_types(sup, ty::Variance::Contravariant, sub, locations, category) } - #[instrument(skip(self, category), level = "debug")] + #[instrument(skip(self, category), level = "trace")] fn eq_types( &mut self, expected: Ty<'tcx>, @@ -1151,7 +1151,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { self.relate_types(expected, ty::Variance::Invariant, found, locations, category) } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn relate_type_and_user_type( &mut self, a: Ty<'tcx>, @@ -1197,10 +1197,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { self.infcx.tcx } - #[instrument(skip(self, body, location), level = "debug")] + #[instrument(skip(self, body, location), level = "trace")] fn check_stmt(&mut self, body: &Body<'tcx>, stmt: &Statement<'tcx>, location: Location) { let tcx = self.tcx(); - debug!("stmt kind: {:?}", stmt.kind); + trace!("stmt kind: {:?}", stmt.kind); match &stmt.kind { StatementKind::Assign(box (place, rv)) => { // Assignments to temporaries are not "interesting"; @@ -1230,20 +1230,20 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } _ => ConstraintCategory::Assignment, }; - debug!( + trace!( "assignment category: {:?} {:?}", category, place.as_local().map(|l| &body.local_decls[l]) ); let place_ty = place.ty(body, tcx).ty; - debug!(?place_ty); + trace!(?place_ty); let place_ty = self.normalize(place_ty, location); - debug!("place_ty normalized: {:?}", place_ty); + trace!("place_ty normalized: {:?}", place_ty); let rv_ty = rv.ty(body, tcx); - debug!(?rv_ty); + trace!(?rv_ty); let rv_ty = self.normalize(rv_ty, location); - debug!("normalized rv_ty: {:?}", rv_ty); + trace!("normalized rv_ty: {:?}", rv_ty); if let Err(terr) = self.sub_types(rv_ty, place_ty, location.to_locations(), category) { @@ -1334,7 +1334,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } } - #[instrument(skip(self, body, term_location), level = "debug")] + #[instrument(skip(self, body, term_location), level = "trace")] fn check_terminator( &mut self, body: &Body<'tcx>, @@ -1342,7 +1342,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { term_location: Location, ) { let tcx = self.tcx(); - debug!("terminator kind: {:?}", term.kind); + trace!("terminator kind: {:?}", term.kind); match &term.kind { TerminatorKind::Goto { .. } | TerminatorKind::Resume @@ -1373,7 +1373,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } let func_ty = func.ty(body, tcx); - debug!("func_ty.kind: {:?}", func_ty.kind()); + trace!("func_ty.kind: {:?}", func_ty.kind()); let sig = match func_ty.kind() { ty::FnDef(..) | ty::FnPtr(_) => func_ty.fn_sig(tcx), @@ -1405,7 +1405,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { region_ctxt_fn, ) }); - debug!(?sig); + trace!(?sig); // IMPORTANT: We have to prove well formed for the function signature before // we normalize it, as otherwise types like `<&'a &'b () as Trait>::Assoc` // get normalized away, causing us to ignore the `'b: 'a` bound used by the function. @@ -1569,7 +1569,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { term_location: Location, from_hir_call: bool, ) { - debug!("check_call_inputs({:?}, {:?})", sig, args); + trace!("check_call_inputs({:?}, {:?})", sig, args); if args.len() < sig.inputs().len() || (args.len() > sig.inputs().len() && !sig.c_variadic) { span_mirbug!(self, term, "call to {:?} with wrong # of args", sig); } @@ -1579,7 +1579,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } else { None }; - debug!(?func_ty); + trace!(?func_ty); for (n, (fn_arg, op_arg)) in iter::zip(sig.inputs(), args).enumerate() { let op_arg_ty = op_arg.ty(body, self.tcx()); @@ -1801,7 +1801,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } fn check_operand(&mut self, op: &Operand<'tcx>, location: Location) { - debug!(?op, ?location, "check_operand"); + trace!(?op, ?location, "check_operand"); if let Operand::Constant(constant) = op { let maybe_uneval = match constant.literal { @@ -1828,7 +1828,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } } - #[instrument(skip(self, body), level = "debug")] + #[instrument(skip(self, body), level = "trace")] fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) { let tcx = self.tcx(); let span = body.source_info(location).span; @@ -2490,9 +2490,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // *p`, where the `p` has type `&'b mut Foo`, for example, we // need to ensure that `'b: 'a`. - debug!( + trace!( "add_reborrow_constraint({:?}, {:?}, {:?})", - location, borrow_region, borrowed_place + location, + borrow_region, + borrowed_place ); let mut cursor = borrowed_place.projection.as_ref(); @@ -2512,13 +2514,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { while let [proj_base @ .., elem] = cursor { cursor = proj_base; - debug!("add_reborrow_constraint - iteration {:?}", elem); + trace!("add_reborrow_constraint - iteration {:?}", elem); match elem { ProjectionElem::Deref => { let base_ty = Place::ty_from(borrowed_place.local, proj_base, body, tcx).ty; - debug!("add_reborrow_constraint - base_ty = {:?}", base_ty); + trace!("add_reborrow_constraint - base_ty = {:?}", base_ty); match base_ty.kind() { ty::Ref(ref_region, _, mutbl) => { constraints.outlives_constraints.push(OutlivesConstraint { @@ -2592,9 +2594,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ) { let tcx = self.tcx(); - debug!( + trace!( "prove_aggregate_predicates(aggregate_kind={:?}, location={:?})", - aggregate_kind, location + aggregate_kind, + location ); let (def_id, instantiated_predicates) = match *aggregate_kind { @@ -2695,10 +2698,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { tcx.predicates_of(def_id).instantiate(tcx, substs) } - #[instrument(skip(self, body), level = "debug")] + #[instrument(skip(self, body), level = "trace")] fn typeck_mir(&mut self, body: &Body<'tcx>) { self.last_span = body.span; - debug!(?body.span); + trace!(?body.span); for (local, local_decl) in body.local_decls.iter_enumerated() { self.check_local(&body, local, local_decl); diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index c871703429a5e..0377c569a2914 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -396,10 +396,10 @@ const FR: NllRegionVariableOrigin = NllRegionVariableOrigin::FreeRegion; impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { fn build(self) -> UniversalRegions<'tcx> { - debug!("build(mir_def={:?})", self.mir_def); + trace!("build(mir_def={:?})", self.mir_def); let param_env = self.param_env; - debug!("build: param_env={:?}", param_env); + trace!("build: param_env={:?}", param_env); assert_eq!(FIRST_GLOBAL_INDEX, self.infcx.num_region_vars()); @@ -412,10 +412,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { let first_extern_index = self.infcx.num_region_vars(); let defining_ty = self.defining_ty(); - debug!("build: defining_ty={:?}", defining_ty); + trace!("build: defining_ty={:?}", defining_ty); let mut indices = self.compute_indices(fr_static, defining_ty); - debug!("build: indices={:?}", indices); + trace!("build: indices={:?}", indices); let typeck_root_def_id = self.infcx.tcx.typeck_root_def_id(self.mir_def.to_def_id()); @@ -435,7 +435,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { self.infcx.tcx, self.infcx.tcx.local_parent(self.mir_def), |r| { - debug!(?r); + trace!(?r); if !indices.indices.contains_key(&r) { let region_vid = { let name = r.get_name_or_anon(); @@ -444,7 +444,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { }) }; - debug!(?region_vid); + trace!(?region_vid); indices.insert_late_bound_region(r, region_vid.as_var()); } }, @@ -469,7 +469,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { // Converse of above, if this is a function/closure then the late-bound regions declared on its // signature are local. for_each_late_bound_region_in_item(self.infcx.tcx, self.mir_def, |r| { - debug!(?r); + trace!(?r); if !indices.indices.contains_key(&r) { let region_vid = { let name = r.get_name_or_anon(); @@ -478,7 +478,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { }) }; - debug!(?region_vid); + trace!(?region_vid); indices.insert_late_bound_region(r, region_vid.as_var()); } }); @@ -517,9 +517,9 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { let num_universals = self.infcx.num_region_vars(); - debug!("build: global regions = {}..{}", FIRST_GLOBAL_INDEX, first_extern_index); - debug!("build: extern regions = {}..{}", first_extern_index, first_local_index); - debug!("build: local regions = {}..{}", first_local_index, num_universals); + trace!("build: global regions = {}..{}", FIRST_GLOBAL_INDEX, first_extern_index); + trace!("build: extern regions = {}..{}", first_extern_index, first_local_index); + trace!("build: local regions = {}..{}", first_local_index, num_universals); let yield_ty = match defining_ty { DefiningTy::Generator(_, substs, _) => Some(substs.as_generator().yield_ty()), @@ -550,7 +550,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { BodyOwnerKind::Closure | BodyOwnerKind::Fn => { let defining_ty = tcx.type_of(self.mir_def).subst_identity(); - debug!("defining_ty (pre-replacement): {:?}", defining_ty); + trace!("defining_ty (pre-replacement): {:?}", defining_ty); let defining_ty = self.infcx.replace_free_regions_with_nll_infer_vars(FR, defining_ty); @@ -748,7 +748,7 @@ trait InferCtxtExt<'tcx> { } impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn replace_free_regions_with_nll_infer_vars( &self, origin: NllRegionVariableOrigin, @@ -759,13 +759,13 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { { self.infcx.tcx.fold_regions(value, |region, _depth| { let name = region.get_name_or_anon(); - debug!(?region, ?name); + trace!(?region, ?name); self.next_nll_region_var(origin, || RegionCtxt::Free(name)) }) } - #[instrument(level = "debug", skip(self, indices))] + #[instrument(level = "trace", skip(self, indices))] fn replace_bound_regions_with_nll_infer_vars( &self, origin: NllRegionVariableOrigin, @@ -777,7 +777,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { T: TypeFoldable>, { let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| { - debug!(?br); + trace!(?br); let liberated_region = ty::Region::new_free(self.tcx, all_outlive_scope.to_def_id(), br.kind); let region_vid = { @@ -790,7 +790,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { }; indices.insert_late_bound_region(liberated_region, region_vid.as_var()); - debug!(?liberated_region, ?region_vid); + trace!(?liberated_region, ?region_vid); region_vid }); value @@ -812,7 +812,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { indices: &mut UniversalRegionIndices<'tcx>, ) { for_each_late_bound_region_in_recursive_scope(self.tcx, mir_def_id, |r| { - debug!(?r); + trace!(?r); if !indices.indices.contains_key(&r) { let region_vid = { let name = r.get_name_or_anon(); @@ -821,7 +821,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { }) }; - debug!(?region_vid); + trace!(?region_vid); indices.insert_late_bound_region(r, region_vid.as_var()); } }); @@ -834,7 +834,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { indices: &mut UniversalRegionIndices<'tcx>, ) { for_each_late_bound_region_in_item(self.tcx, mir_def_id, |r| { - debug!(?r); + trace!(?r); if !indices.indices.contains_key(&r) { let region_vid = { let name = r.get_name_or_anon(); @@ -856,7 +856,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> { /// insert the `ReFree` version of those into the map as /// well. These are used for error reporting. fn insert_late_bound_region(&mut self, r: ty::Region<'tcx>, vid: ty::RegionVid) { - debug!("insert_late_bound_region({:?}, {:?})", r, vid); + trace!("insert_late_bound_region({:?}, {:?})", r, vid); self.indices.insert(r, vid); } diff --git a/compiler/rustc_borrowck/src/used_muts.rs b/compiler/rustc_borrowck/src/used_muts.rs index c5991e0bc254e..7e07d2bac6c3d 100644 --- a/compiler/rustc_borrowck/src/used_muts.rs +++ b/compiler/rustc_borrowck/src/used_muts.rs @@ -40,7 +40,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Take the union of the existed `used_mut` set with those variables we've found were // never initialized. - debug!("gather_used_muts: never_initialized_mut_locals={:?}", never_initialized_mut_locals); + trace!("gather_used_muts: never_initialized_mut_locals={:?}", never_initialized_mut_locals); self.used_mut = self.used_mut.union(&never_initialized_mut_locals).cloned().collect(); } } @@ -66,7 +66,7 @@ impl GatherUsedMutsVisitor<'_, '_, '_> { impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tcx> { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { - debug!("visit_terminator: terminator={:?}", terminator); + trace!("visit_terminator: terminator={:?}", terminator); match &terminator.kind { TerminatorKind::Call { destination, .. } => { self.remove_never_initialized_mut_locals(*destination); @@ -79,10 +79,12 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { if let StatementKind::Assign(box (into, _)) = &statement.kind { - debug!( + trace!( "visit_statement: statement={:?} local={:?} \ never_initialized_mut_locals={:?}", - statement, into.local, self.never_initialized_mut_locals + statement, + into.local, + self.never_initialized_mut_locals ); self.remove_never_initialized_mut_locals(*into); } @@ -96,9 +98,11 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc for moi in &self.mbcx.move_data.loc_map[location] { let mpi = &self.mbcx.move_data.moves[*moi].path; let path = &self.mbcx.move_data.move_paths[*mpi]; - debug!( + trace!( "assignment of {:?} to {:?}, adding {:?} to used mutable set", - path.place, local, path.place + path.place, + local, + path.place ); if let Some(user_local) = path.place.as_local() { self.mbcx.used_mut.insert(user_local); diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 046d2052968a3..096291b0b8e4e 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -32,7 +32,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( cid: GlobalId<'tcx>, body: &'mir mir::Body<'tcx>, ) -> InterpResult<'tcx, MPlaceTy<'tcx>> { - debug!("eval_body_using_ecx: {:?}, {:?}", cid, ecx.param_env); + trace!("eval_body_using_ecx: {:?}, {:?}", cid, ecx.param_env); let tcx = *ecx.tcx; assert!( cid.promoted.is_some() @@ -81,7 +81,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( intern_const_alloc_recursive(ecx, intern_kind, &ret)?; // we leave alignment checks off, since this `ecx` will not be used for further evaluation anyway - debug!("eval_body_using_ecx done: {:?}", *ret); + trace!("eval_body_using_ecx done: {:?}", *ret); Ok(ret) } @@ -98,7 +98,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>( param_env: ty::ParamEnv<'tcx>, can_access_statics: bool, ) -> CompileTimeEvalContext<'mir, 'tcx> { - debug!("mk_eval_cx: {:?}", param_env); + trace!("mk_eval_cx: {:?}", param_env); InterpCx::new( tcx, root_span, @@ -109,7 +109,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>( /// This function converts an interpreter value into a constant that is meant for use in the /// type system. -#[instrument(skip(ecx), level = "debug")] +#[instrument(skip(ecx), level = "trace")] pub(super) fn op_to_const<'tcx>( ecx: &CompileTimeEvalContext<'_, 'tcx>, op: &OpTy<'tcx>, @@ -144,11 +144,11 @@ pub(super) fn op_to_const<'tcx>( op.as_mplace_or_imm() }; - debug!(?immediate); + trace!(?immediate); // We know `offset` is relative to the allocation, so we can use `into_parts`. let to_const_value = |mplace: &MPlaceTy<'_>| { - debug!("to_const_value(mplace: {:?})", mplace); + trace!("to_const_value(mplace: {:?})", mplace); match mplace.ptr.into_parts() { (Some(alloc_id), offset) => { let alloc = ecx.tcx.global_alloc(alloc_id).unwrap_memory(); @@ -173,7 +173,7 @@ pub(super) fn op_to_const<'tcx>( _ if imm.layout.is_zst() => ConstValue::ZeroSized, Immediate::Scalar(x) => ConstValue::Scalar(x), Immediate::ScalarPair(a, b) => { - debug!("ScalarPair(a: {:?}, b: {:?})", a, b); + trace!("ScalarPair(a: {:?}, b: {:?})", a, b); // We know `offset` is relative to the allocation, so we can use `into_parts`. let (data, start) = match a.to_pointer(ecx).unwrap().into_parts() { (Some(alloc_id), offset) => { @@ -196,7 +196,7 @@ pub(super) fn op_to_const<'tcx>( } } -#[instrument(skip(tcx), level = "debug", ret)] +#[instrument(skip(tcx), level = "trace", ret)] pub(crate) fn turn_into_const_value<'tcx>( tcx: TyCtxt<'tcx>, constant: ConstAlloc<'tcx>, @@ -226,7 +226,7 @@ pub(crate) fn turn_into_const_value<'tcx>( op_to_const(&ecx, &mplace.into()) } -#[instrument(skip(tcx), level = "debug")] +#[instrument(skip(tcx), level = "trace")] pub fn eval_to_const_value_raw_provider<'tcx>( tcx: TyCtxt<'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, @@ -261,7 +261,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>( tcx.eval_to_allocation_raw(key).map(|val| turn_into_const_value(tcx, val, key)) } -#[instrument(skip(tcx), level = "debug")] +#[instrument(skip(tcx), level = "trace")] pub fn eval_to_allocation_raw_provider<'tcx>( tcx: TyCtxt<'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, diff --git a/compiler/rustc_driver_impl/Cargo.toml b/compiler/rustc_driver_impl/Cargo.toml index 67352c55c9019..92423c0b8eea2 100644 --- a/compiler/rustc_driver_impl/Cargo.toml +++ b/compiler/rustc_driver_impl/Cargo.toml @@ -64,7 +64,7 @@ features = [ [features] llvm = ['rustc_interface/llvm'] -max_level_info = ['rustc_log/max_level_info'] +max_level_debug = ['rustc_log/max_level_debug'] rustc_use_parallel_compiler = [ 'rustc_data_structures/rustc_use_parallel_compiler', 'rustc_interface/rustc_use_parallel_compiler', diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index fff417fcb2909..5451a1980b3d2 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -149,11 +149,11 @@ fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) { /// We do this check as a pre-pass before checking fn bodies because if these constraints are /// not included it frequently leads to confusing errors in fn bodies. So it's better to check /// the types first. -#[instrument(skip(tcx), level = "debug")] +#[instrument(skip(tcx), level = "trace")] fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) { let def_id = item.owner_id.def_id; - debug!( + trace!( ?item.owner_id, item.name = ? tcx.def_path_str(def_id) ); @@ -249,7 +249,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) { fn check_foreign_item(tcx: TyCtxt<'_>, item: &hir::ForeignItem<'_>) { let def_id = item.owner_id.def_id; - debug!( + trace!( ?item.owner_id, item.name = ? tcx.def_path_str(def_id) ); @@ -405,7 +405,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe for (gat_def_id, required_bounds) in required_bounds_by_item { let gat_item_hir = tcx.hir().expect_trait_item(gat_def_id.def_id); - debug!(?required_bounds); + trace!(?required_bounds); let param_env = tcx.param_env(gat_def_id); let mut unsatisfied_bounds: Vec<_> = required_bounds @@ -546,8 +546,8 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable>>( for (ty, ty_idx) in &types { // In our example, requires that `Self: 'a` if ty_known_to_outlive(tcx, item_def_id.def_id, param_env, &wf_tys, *ty, *region_a) { - debug!(?ty_idx, ?region_a_idx); - debug!("required clause: {ty} must outlive {region_a}"); + trace!(?ty_idx, ?region_a_idx); + trace!("required clause: {ty} must outlive {region_a}"); // Translate into the generic parameters of the GAT. In // our example, the type was `Self`, which will also be // `Self` in the GAT. @@ -592,8 +592,8 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable>>( *region_a, *region_b, ) { - debug!(?region_a_idx, ?region_b_idx); - debug!("required clause: {region_a} must outlive {region_b}"); + trace!(?region_a_idx, ?region_b_idx); + trace!("required clause: {region_a} must outlive {region_b}"); // Translate into the generic parameters of the GAT. let region_a_param = gat_generics.param_at(*region_a_idx, tcx); let region_a_param = ty::Region::new_early_bound( @@ -690,7 +690,7 @@ fn resolve_regions_with_wf_tys<'tcx>( add_constraints(&infcx, region_bound_pairs); let errors = infcx.resolve_regions(&outlives_environment); - debug!(?errors, "errors"); + trace!(?errors, "errors"); // If we were able to prove that the type outlives the region without // an error, it must be because of the implied or explicit bounds... @@ -950,7 +950,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) { } } -#[instrument(level = "debug", skip(tcx, span, sig_if_method))] +#[instrument(level = "trace", skip(tcx, span, sig_if_method))] fn check_associated_item( tcx: TyCtxt<'_>, item_id: LocalDefId, @@ -1100,7 +1100,7 @@ fn check_type_defn<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'tcx>, all_sized: b #[instrument(skip(tcx, item))] fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) { - debug!(?item.owner_id); + trace!(?item.owner_id); let def_id = item.owner_id.def_id; let trait_def = tcx.trait_def(def_id); @@ -1135,7 +1135,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) { fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocItem, span: Span) { let bounds = wfcx.tcx().explicit_item_bounds(item.def_id); - debug!("check_associated_type_bounds: bounds={:?}", bounds); + trace!("check_associated_type_bounds: bounds={:?}", bounds); let wf_obligations = bounds.subst_identity_iter_copied().flat_map(|(bound, bound_span)| { let normalized_bound = wfcx.normalize(span, None, bound); traits::wf::predicate_obligations( @@ -1164,7 +1164,7 @@ fn check_item_fn( } fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_foreign_ty: bool) { - debug!("check_item_type: {:?}", item_id); + trace!("check_item_type: {:?}", item_id); enter_wf_checking_ctxt(tcx, ty_span, item_id, |wfcx| { let ty = tcx.type_of(item_id).subst_identity(); @@ -1205,7 +1205,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_fo }); } -#[instrument(level = "debug", skip(tcx, ast_self_ty, ast_trait_ref))] +#[instrument(level = "trace", skip(tcx, ast_self_ty, ast_trait_ref))] fn check_impl<'tcx>( tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>, @@ -1248,7 +1248,7 @@ fn check_impl<'tcx>( obligation.cause.span = ast_self_ty.span; } } - debug!(?obligations); + trace!(?obligations); wfcx.register_obligations(obligations); } None => { @@ -1271,7 +1271,7 @@ fn check_impl<'tcx>( } /// Checks where-clauses and inline bounds that are declared on `def_id`. -#[instrument(level = "debug", skip(wfcx))] +#[instrument(level = "trace", skip(wfcx))] fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id: LocalDefId) { let infcx = wfcx.infcx; let tcx = wfcx.tcx(); @@ -1443,7 +1443,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id let predicates = wfcx.normalize(span, None, predicates); - debug!(?predicates.predicates); + trace!(?predicates.predicates); assert_eq!(predicates.predicates.len(), predicates.spans.len()); let wf_obligations = predicates.into_iter().flat_map(|(p, sp)| { traits::wf::predicate_obligations( @@ -1458,7 +1458,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id wfcx.register_obligations(obligations); } -#[instrument(level = "debug", skip(wfcx, span, hir_decl))] +#[instrument(level = "trace", skip(wfcx, span, hir_decl))] fn check_fn_or_method<'tcx>( wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, @@ -1621,7 +1621,7 @@ const HELP_FOR_SELF_TYPE: &str = "consider changing to `self`, `&self`, `&mut se `self: Rc`, `self: Arc`, or `self: Pin

` (where P is one \ of the previous types except `Self`)"; -#[instrument(level = "debug", skip(wfcx))] +#[instrument(level = "trace", skip(wfcx))] fn check_method_receiver<'tcx>( wfcx: &WfCheckingCtxt<'_, 'tcx>, fn_sig: &hir::FnSig<'_>, @@ -1640,7 +1640,7 @@ fn check_method_receiver<'tcx>( let sig = tcx.liberate_late_bound_regions(method.def_id, sig); let sig = wfcx.normalize(span, None, sig); - debug!("check_method_receiver: sig={:?}", sig); + trace!("check_method_receiver: sig={:?}", sig); let self_ty = wfcx.normalize(span, None, self_ty); @@ -1733,9 +1733,10 @@ fn receiver_is_valid<'tcx>( // Keep dereferencing `receiver_ty` until we get to `self_ty`. loop { if let Some((potential_self_ty, _)) = autoderef.next() { - debug!( + trace!( "receiver_is_valid: potential self type `{:?}` to match `{:?}`", - potential_self_ty, self_ty + potential_self_ty, + self_ty ); if can_eq_self(potential_self_ty) { @@ -1764,7 +1765,7 @@ fn receiver_is_valid<'tcx>( } } } else { - debug!("receiver_is_valid: type `{:?}` does not deref to `{:?}`", receiver_ty, self_ty); + trace!("receiver_is_valid: type `{:?}` does not deref to `{:?}`", receiver_ty, self_ty); // If the receiver already has errors reported due to it, consider it valid to avoid // unnecessary errors (#58712). return receiver_ty.references_error(); @@ -1795,7 +1796,7 @@ fn receiver_is_implemented<'tcx>( if wfcx.infcx.predicate_must_hold_modulo_regions(&obligation) { true } else { - debug!( + trace!( "receiver_is_implemented: type `{:?}` does not implement `Receiver` trait", receiver_ty ); @@ -1897,7 +1898,7 @@ fn report_bivariance( impl<'tcx> WfCheckingCtxt<'_, 'tcx> { /// Feature gates RFC 2056 -- trivial bounds, checking for global bounds that /// aren't true. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn check_false_global_bounds(&mut self) { let tcx = self.ocx.infcx.tcx; let mut span = self.span; diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index 7d2f7e876083a..b91f02c7df2b0 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -12,7 +12,7 @@ use rustc_trait_selection::traits::{ }; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { - #[instrument(skip(self), level = "debug", ret)] + #[instrument(skip(self), level = "trace", ret)] pub fn check_match( &self, expr: &'tcx hir::Expr<'tcx>, @@ -25,7 +25,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let acrb = arms_contain_ref_bindings(arms); let scrutinee_ty = self.demand_scrutinee_type(scrut, acrb, arms.is_empty()); - debug!(?scrutinee_ty); + trace!(?scrutinee_ty); // If there are no arms, that is a diverging match; a special case. if arms.is_empty() { @@ -56,7 +56,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut all_arms_diverge = Diverges::WarnedAlways; let expected = orig_expected.adjust_for_branches(self); - debug!(?expected); + trace!(?expected); let mut coercion = { let coerce_first = match expected { diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 4389ad6ef2678..3bbcf451e35ec 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -129,7 +129,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { output } - #[instrument(level = "debug", skip(self, call_expr, callee_expr, arg_exprs, autoderef), ret)] + #[instrument(level = "trace", skip(self, call_expr, callee_expr, arg_exprs, autoderef), ret)] fn try_overloaded_call_step( &self, call_expr: &'tcx hir::Expr<'tcx>, @@ -771,7 +771,7 @@ pub struct DeferredCallResolution<'tcx> { impl<'a, 'tcx> DeferredCallResolution<'tcx> { pub fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) { - debug!("DeferredCallResolution::resolve() {:?}", self); + trace!("DeferredCallResolution::resolve() {:?}", self); // we should not be invoked until the closure kind has been // determined by upvar inference @@ -790,7 +790,7 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> { // refactor it.) let method_sig = method_callee.sig; - debug!("attempt_resolution: method_callee={:?}", method_callee); + trace!("attempt_resolution: method_callee={:?}", method_callee); for (method_arg_ty, self_arg_ty) in iter::zip(method_sig.inputs().iter().skip(1), self.fn_sig.inputs()) diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 98c683f0200a3..5fecf9af44584 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -91,7 +91,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { t: Ty<'tcx>, span: Span, ) -> Result>, ErrorGuaranteed> { - debug!("pointer_kind({:?}, {:?})", t, span); + trace!("pointer_kind({:?}, {:?})", t, span); let t = self.resolve_vars_if_possible(t); t.error_reported()?; @@ -717,12 +717,12 @@ impl<'a, 'tcx> CastCheck<'tcx> { ); } - #[instrument(skip(fcx), level = "debug")] + #[instrument(skip(fcx), level = "trace")] pub fn check(mut self, fcx: &FnCtxt<'a, 'tcx>) { self.expr_ty = fcx.structurally_resolved_type(self.expr_span, self.expr_ty); self.cast_ty = fcx.structurally_resolved_type(self.cast_span, self.cast_ty); - debug!("check_cast({}, {:?} as {:?})", self.expr.hir_id, self.expr_ty, self.cast_ty); + trace!("check_cast({}, {:?} as {:?})", self.expr.hir_id, self.expr_ty, self.cast_ty); if !fcx.type_is_sized_modulo_regions(fcx.param_env, self.cast_ty) && !self.cast_ty.has_infer_types() @@ -734,13 +734,13 @@ impl<'a, 'tcx> CastCheck<'tcx> { match self.try_coercion_cast(fcx) { Ok(()) => { self.trivial_cast_lint(fcx); - debug!(" -> CoercionCast"); + trace!(" -> CoercionCast"); fcx.typeck_results.borrow_mut().set_coercion_cast(self.expr.hir_id.local_id); } Err(_) => { match self.do_check(fcx) { Ok(k) => { - debug!(" -> {:?}", k); + trace!(" -> {:?}", k); } Err(e) => self.report_cast_error(fcx, e), }; @@ -880,7 +880,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { m_expr: ty::TypeAndMut<'tcx>, m_cast: ty::TypeAndMut<'tcx>, ) -> Result { - debug!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}", m_expr, m_cast); + trace!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}", m_expr, m_cast); // ptr-ptr cast. vtables must match. let expr_kind = fcx.pointer_kind(m_expr.ty, self.span)?; diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index bfabd44bb5792..9b489af038f27 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -24,7 +24,7 @@ use std::cell::RefCell; /// /// * ... /// * inherited: other fields inherited from the enclosing fn (if any) -#[instrument(skip(fcx, body), level = "debug")] +#[instrument(skip(fcx, body), level = "trace")] pub(super) fn check_fn<'a, 'tcx>( fcx: &mut FnCtxt<'a, 'tcx>, fn_sig: ty::FnSig<'tcx>, @@ -137,14 +137,14 @@ pub(super) fn check_fn<'a, 'tcx>( // earlier when trying to find a LUB. let coercion = fcx.ret_coercion.take().unwrap().into_inner(); let mut actual_return_ty = coercion.complete(&fcx); - debug!("actual_return_ty = {:?}", actual_return_ty); + trace!("actual_return_ty = {:?}", actual_return_ty); if let ty::Dynamic(..) = declared_ret_ty.kind() { // We have special-cased the case where the function is declared // `-> dyn Foo` and we don't actually relate it to the // `fcx.ret_coercion`, so just substitute a type variable. actual_return_ty = fcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::DynReturnFn, span }); - debug!("actual_return_ty replaced with {:?}", actual_return_ty); + trace!("actual_return_ty replaced with {:?}", actual_return_ty); } // HACK(oli-obk, compiler-errors): We should be comparing this against diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index 9659a0ec13d40..175f03a435902 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -43,7 +43,7 @@ struct ClosureSignatures<'tcx> { } impl<'a, 'tcx> FnCtxt<'a, 'tcx> { - #[instrument(skip(self, closure), level = "debug")] + #[instrument(skip(self, closure), level = "trace")] pub fn check_expr_closure( &self, closure: &hir::Closure<'tcx>, @@ -63,7 +63,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_closure(closure, expr_span, expected_kind, body, expected_sig) } - #[instrument(skip(self, closure, body), level = "debug", ret)] + #[instrument(skip(self, closure, body), level = "trace", ret)] fn check_closure( &self, closure: &hir::Closure<'tcx>, @@ -74,12 +74,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { trace!("decl = {:#?}", closure.fn_decl); let expr_def_id = closure.def_id; - debug!(?expr_def_id); + trace!(?expr_def_id); let ClosureSignatures { bound_sig, liberated_sig } = self.sig_of_closure(expr_def_id, closure.fn_decl, body, expected_sig); - debug!(?bound_sig, ?liberated_sig); + trace!(?bound_sig, ?liberated_sig); let mut fcx = FnCtxt::new(self, self.param_env.without_const(), closure.def_id); let generator_types = check_fn( @@ -136,7 +136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) }); - debug!(?sig, ?opt_kind); + trace!(?sig, ?opt_kind); let closure_kind_ty = match opt_kind { Some(kind) => kind.to_ty(self.tcx), @@ -165,7 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Given the expected type, figures out what it can about this closure we /// are about to type check: - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn deduce_closure_signature( &self, expected_ty: Ty<'tcx>, @@ -216,7 +216,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // We only care about self bounds .filter_only_self() { - debug!(?pred); + trace!(?pred); let bound_predicate = pred.kind(); // Given a Projection predicate, we can potentially infer @@ -283,7 +283,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// The `cause_span` should be the span that caused us to /// have this expected signature, or `None` if we can't readily /// know that. - #[instrument(level = "debug", skip(self, cause_span), ret)] + #[instrument(level = "trace", skip(self, cause_span), ret)] fn deduce_sig_from_projection( &self, cause_span: Option, @@ -299,21 +299,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let is_gen = gen_trait == Some(trait_def_id); if !is_fn && !is_gen { - debug!("not fn or generator"); + trace!("not fn or generator"); return None; } // Check that we deduce the signature from the `<_ as std::ops::Generator>::Return` // associated item and not yield. if is_gen && self.tcx.associated_item(projection.projection_def_id()).name != sym::Return { - debug!("not `Return` assoc item of `Generator`"); + trace!("not `Return` assoc item of `Generator`"); return None; } let input_tys = if is_fn { let arg_param_ty = projection.skip_binder().projection_ty.substs.type_at(1); let arg_param_ty = self.resolve_vars_if_possible(arg_param_ty); - debug!(?arg_param_ty); + trace!(?arg_param_ty); match arg_param_ty.kind() { &ty::Tuple(tys) => tys, @@ -328,7 +328,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Since this is a return parameter type it is safe to unwrap. let ret_param_ty = projection.skip_binder().term.ty().unwrap(); let ret_param_ty = self.resolve_vars_if_possible(ret_param_ty); - debug!(?ret_param_ty); + trace!(?ret_param_ty); let sig = projection.rebind(self.tcx.mk_fn_sig( input_tys, @@ -357,7 +357,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// If there is no expected signature, then we will convert the /// types that the user gave into a signature. - #[instrument(skip(self, expr_def_id, decl, body), level = "debug")] + #[instrument(skip(self, expr_def_id, decl, body), level = "trace")] fn sig_of_closure_no_expectation( &self, expr_def_id: LocalDefId, @@ -416,7 +416,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// - `expected_sig`: the expected signature (if any). Note that /// this is missing a binder: that is, there may be late-bound /// regions with depth 1, which are bound then by the closure. - #[instrument(skip(self, expr_def_id, decl, body), level = "debug")] + #[instrument(skip(self, expr_def_id, decl, body), level = "trace")] fn sig_of_closure_with_expectation( &self, expr_def_id: LocalDefId, @@ -512,7 +512,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Enforce the user's types against the expectation. See /// `sig_of_closure_with_expectation` for details on the overall /// strategy. - #[instrument(level = "debug", skip(self, expr_def_id, decl, body, expected_sigs))] + #[instrument(level = "trace", skip(self, expr_def_id, decl, body, expected_sigs))] fn merge_supplied_sig_with_expectation( &self, expr_def_id: LocalDefId, @@ -526,7 +526,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // meaning of these letters.) let supplied_sig = self.supplied_sig_of_closure(expr_def_id, decl, body); - debug!(?supplied_sig); + trace!(?supplied_sig); // FIXME(#45727): As discussed in [this comment][c1], naively // forcing equality here actually results in suboptimal error @@ -606,7 +606,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// types that the user gave into a signature. /// /// Also, record this closure signature for later. - #[instrument(skip(self, decl, body), level = "debug", ret)] + #[instrument(skip(self, decl, body), level = "trace", ret)] fn supplied_sig_of_closure( &self, expr_def_id: LocalDefId, @@ -616,7 +616,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let astconv: &dyn AstConv<'_> = self; trace!("decl = {:#?}", decl); - debug!(?body.generator_kind); + trace!(?body.generator_kind); let hir_id = self.tcx.hir().local_def_id_to_hir_id(expr_def_id); let bound_vars = self.tcx.late_bound_vars(hir_id); @@ -630,7 +630,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // we expect the return type of the block to match that of the enclosing // function. Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn)) => { - debug!("closure is async fn body"); + trace!("closure is async fn body"); let def_id = self.tcx.hir().body_owner_def_id(body.id()); self.deduce_future_output_from_obligations(expr_def_id, def_id).unwrap_or_else( || { @@ -674,7 +674,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// user specified. The "desugared" return type is an `impl /// Future`, so we do this by searching through the /// obligations to extract the `T`. - #[instrument(skip(self), level = "debug", ret)] + #[instrument(skip(self), level = "trace", ret)] fn deduce_future_output_from_obligations( &self, expr_def_id: LocalDefId, @@ -756,12 +756,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { cause_span: Span, predicate: ty::PolyProjectionPredicate<'tcx>, ) -> Option> { - debug!("deduce_future_output_from_projection(predicate={:?})", predicate); + trace!("deduce_future_output_from_projection(predicate={:?})", predicate); // We do not expect any bound regions in our predicate, so // skip past the bound vars. let Some(predicate) = predicate.no_bound_vars() else { - debug!("deduce_future_output_from_projection: has late-bound regions"); + trace!("deduce_future_output_from_projection: has late-bound regions"); return None; }; @@ -769,7 +769,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let trait_def_id = predicate.projection_ty.trait_def_id(self.tcx); let future_trait = self.tcx.require_lang_item(LangItem::Future, Some(cause_span)); if trait_def_id != future_trait { - debug!("deduce_future_output_from_projection: not a future"); + trace!("deduce_future_output_from_projection: not a future"); return None; } @@ -789,7 +789,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // be no bound variables in this type because the "self type" // does not have any regions in it. let output_ty = self.resolve_vars_if_possible(predicate.term); - debug!("deduce_future_output_from_projection: output_ty={:?}", output_ty); + trace!("deduce_future_output_from_projection: output_ty={:?}", output_ty); // This is a projection on a Fn trait so will always be a type. Some(output_ty.ty().unwrap()) } @@ -823,7 +823,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Abi::RustCall, )); - debug!("supplied_sig_of_closure: result={:?}", result); + trace!("supplied_sig_of_closure: result={:?}", result); result } diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 905781ec8f594..73fdf31481417 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -142,7 +142,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { } fn unify(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> { - debug!("unify(a: {:?}, b: {:?}, use_lub: {})", a, b, self.use_lub); + trace!("unify(a: {:?}, b: {:?}, use_lub: {})", a, b, self.use_lub); self.commit_if_ok(|_| { let at = self.at(&self.cause, self.fcx.param_env); @@ -184,7 +184,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // First, remove any resolved type variables (at the top level, at least): let a = self.shallow_resolve(a); let b = self.shallow_resolve(b); - debug!("Coerce.tys({:?} => {:?})", a, b); + trace!("Coerce.tys({:?} => {:?})", a, b); // Just ignore error types. if let Err(guar) = (a, b).error_reported() { @@ -217,11 +217,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let unsize = self.commit_if_ok(|_| self.coerce_unsized(a, b)); match unsize { Ok(_) => { - debug!("coerce: unsize successful"); + trace!("coerce: unsize successful"); return unsize; } Err(error) => { - debug!(?error, "coerce: unsize failed"); + trace!(?error, "coerce: unsize failed"); } } @@ -275,7 +275,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: Ty<'tcx>, make_adjustments: impl FnOnce(Ty<'tcx>) -> Vec>, ) -> CoerceResult<'tcx> { - debug!("coerce_from_inference_variable(a={:?}, b={:?})", a, b); + trace!("coerce_from_inference_variable(a={:?}, b={:?})", a, b); assert!(a.is_ty_var() && self.shallow_resolve(a) == a); assert!(self.shallow_resolve(b) == b); @@ -305,9 +305,10 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { } } - debug!( + trace!( "coerce_from_inference_variable: two inference variables, target_ty={:?}, obligations={:?}", - target_ty, obligations + target_ty, + obligations ); let adjustments = make_adjustments(target_ty); InferResult::Ok(InferOk { value: (adjustments, target_ty), obligations }) @@ -328,7 +329,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { r_b: ty::Region<'tcx>, mutbl_b: hir::Mutability, ) -> CoerceResult<'tcx> { - debug!("coerce_borrowed_pointer(a={:?}, b={:?})", a, b); + trace!("coerce_borrowed_pointer(a={:?}, b={:?})", a, b); // If we have a parameter of type `&M T_a` and the value // provided is `expr`, we will be adding an implicit borrow, @@ -469,7 +470,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // confusing. let Some(InferOk { value: ty, mut obligations }) = found else { let err = first_error.expect("coerce_borrowed_pointer had no error"); - debug!("coerce_borrowed_pointer: failed with err = {:?}", err); + trace!("coerce_borrowed_pointer: failed with err = {:?}", err); return Err(err); }; @@ -505,7 +506,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { target: ty, }); - debug!("coerce_borrowed_pointer: succeeded ty={:?} adjustments={:?}", ty, adjustments); + trace!("coerce_borrowed_pointer: succeeded ty={:?} adjustments={:?}", ty, adjustments); success(adjustments, ty, obligations) } @@ -513,28 +514,28 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // &[T; n] or &mut [T; n] -> &[T] // or &mut [T; n] -> &mut [T] // or &Concrete -> &Trait, etc. - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn coerce_unsized(&self, mut source: Ty<'tcx>, mut target: Ty<'tcx>) -> CoerceResult<'tcx> { source = self.shallow_resolve(source); target = self.shallow_resolve(target); - debug!(?source, ?target); + trace!(?source, ?target); // We don't apply any coercions incase either the source or target // aren't sufficiently well known but tend to instead just equate // them both. if source.is_ty_var() { - debug!("coerce_unsized: source is a TyVar, bailing out"); + trace!("coerce_unsized: source is a TyVar, bailing out"); return Err(TypeError::Mismatch); } if target.is_ty_var() { - debug!("coerce_unsized: target is a TyVar, bailing out"); + trace!("coerce_unsized: target is a TyVar, bailing out"); return Err(TypeError::Mismatch); } let traits = (self.tcx.lang_items().unsize_trait(), self.tcx.lang_items().coerce_unsized_trait()); let (Some(unsize_did), Some(coerce_unsized_did)) = traits else { - debug!("missing Unsize or CoerceUnsized traits"); + trace!("missing Unsize or CoerceUnsized traits"); return Err(TypeError::Mismatch); }; @@ -630,7 +631,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let traits = [coerce_unsized_did, unsize_did]; while !queue.is_empty() { let obligation = queue.remove(0); - debug!("coerce_unsized resolve step: {:?}", obligation); + trace!("coerce_unsized resolve step: {:?}", obligation); let bound_predicate = obligation.predicate.kind(); let trait_pred = match bound_predicate.skip_binder() { ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) @@ -643,11 +644,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { (self_ty.kind(), unsize_ty.kind()) && data_a.principal_def_id() != data_b.principal_def_id() { - debug!("coerce_unsized: found trait upcasting coercion"); + trace!("coerce_unsized: found trait upcasting coercion"); has_trait_upcasting_coercion = Some((self_ty, unsize_ty)); } if let ty::Tuple(..) = unsize_ty.kind() { - debug!("coerce_unsized: found unsized tuple coercion"); + trace!("coerce_unsized: found unsized tuple coercion"); has_unsized_tuple_coercion = true; } } @@ -665,12 +666,12 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let trait_pred = self.resolve_vars_if_possible(trait_pred); let self_ty = trait_pred.skip_binder().self_ty(); let unsize_ty = trait_pred.skip_binder().trait_ref.substs[1].expect_ty(); - debug!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred); + trace!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred); match (self_ty.kind(), unsize_ty.kind()) { (&ty::Infer(ty::TyVar(v)), ty::Dynamic(..)) if self.type_var_is_sized(v) => { - debug!("coerce_unsized: have sized infer {:?}", v); + trace!("coerce_unsized: have sized infer {:?}", v); coercion.obligations.push(obligation); // `$0: Unsize` where we know that `$0: Sized`, try going // for unsizing. @@ -679,17 +680,17 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // Some other case for `$0: Unsize`. Note that we // hit this case even if `Something` is a sized type, so just // don't do the coercion. - debug!("coerce_unsized: ambiguous unsize"); + trace!("coerce_unsized: ambiguous unsize"); return Err(TypeError::Mismatch); } } } else { - debug!("coerce_unsized: early return - ambiguous"); + trace!("coerce_unsized: early return - ambiguous"); return Err(TypeError::Mismatch); } } Err(traits::Unimplemented) => { - debug!("coerce_unsized: early return - can't prove obligation"); + trace!("coerce_unsized: early return - can't prove obligation"); return Err(TypeError::Mismatch); } @@ -843,7 +844,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { //! let b = self.shallow_resolve(b); - debug!("coerce_from_fn_pointer(a={:?}, b={:?})", a, b); + trace!("coerce_from_fn_pointer(a={:?}, b={:?})", a, b); self.coerce_from_safe_fn( a, @@ -861,7 +862,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let b = self.shallow_resolve(b); let InferOk { value: b, mut obligations } = self.at(&self.cause, self.param_env).normalize(b); - debug!("coerce_from_fn_item(a={:?}, b={:?})", a, b); + trace!("coerce_from_fn_item(a={:?}, b={:?})", a, b); match b.kind() { ty::FnPtr(b_sig) => { @@ -948,7 +949,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let unsafety = fn_ty.unsafety(); let pointer_ty = self.tcx.mk_fn_ptr(self.tcx.signature_unclosure(closure_sig, unsafety)); - debug!("coerce_closure_to_fn(a={:?}, b={:?}, pty={:?})", a, b, pointer_ty); + trace!("coerce_closure_to_fn(a={:?}, b={:?}, pty={:?})", a, b, pointer_ty); self.unify_and( pointer_ty, b, @@ -965,7 +966,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: Ty<'tcx>, mutbl_b: hir::Mutability, ) -> CoerceResult<'tcx> { - debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b); + trace!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b); let (is_ref, mt_a) = match *a.kind() { ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }), @@ -1008,7 +1009,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { cause: Option>, ) -> RelateResult<'tcx, Ty<'tcx>> { let source = self.resolve_vars_with_obligations(expr_ty); - debug!("coercion::try({:?}: {:?} -> {:?})", expr, source, target); + trace!("coercion::try({:?}: {:?} -> {:?})", expr, source, target); let cause = cause.unwrap_or_else(|| self.cause(expr.span, ObligationCauseCode::ExprAssignable)); @@ -1026,7 +1027,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// errors. pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool { let source = self.resolve_vars_with_obligations(expr_ty); - debug!("coercion::can_with_predicates({:?} -> {:?})", source, target); + trace!("coercion::can_with_predicates({:?} -> {:?})", source, target); let cause = self.cause(rustc_span::DUMMY_SP, ObligationCauseCode::ExprAssignable); // We don't ever need two-phase here since we throw out the result of the coercion @@ -1091,7 +1092,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { let prev_ty = self.resolve_vars_with_obligations(prev_ty); let new_ty = self.resolve_vars_with_obligations(new_ty); - debug!( + trace!( "coercion::try_find_coercion_lub({:?}, {:?}, exprs={:?} exprs)", prev_ty, new_ty, @@ -1219,9 +1220,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(ok) => { let (adjustments, target) = self.register_infer_ok_obligations(ok); self.apply_adjustments(new, adjustments); - debug!( + trace!( "coercion::try_find_coercion_lub: was able to coerce from new type {:?} to previous type {:?} ({:?})", - new_ty, prev_ty, target + new_ty, + prev_ty, + target ); return Ok(target); } @@ -1255,7 +1258,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if !noop { - debug!( + trace!( "coercion::try_find_coercion_lub: older expression {:?} had adjustments, requiring LUB", expr, ); @@ -1286,9 +1289,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expr = expr.as_coercion_site(); self.apply_adjustments(expr, adjustments.clone()); } - debug!( + trace!( "coercion::try_find_coercion_lub: was able to coerce previous type {:?} to new type {:?} ({:?})", - prev_ty, new_ty, target + prev_ty, + new_ty, + target ); Ok(target) } @@ -1441,7 +1446,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { /// The inner coercion "engine". If `expression` is `None`, this /// is a forced-unit case, and hence `expression_ty` must be /// `Nil`. - #[instrument(skip(self, fcx, augment_error, label_expression_as_expected), level = "debug")] + #[instrument(skip(self, fcx, augment_error, label_expression_as_expected), level = "trace")] pub(crate) fn coerce_inner<'a>( &mut self, fcx: &FnCtxt<'a, 'tcx>, @@ -1527,7 +1532,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { }) }; - debug!(?result); + trace!(?result); match result { Ok(v) => { self.final_ty = Some(v); diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 19ff77d8349aa..511df6ddfa2c1 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -181,7 +181,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Note that inspecting a type's structure *directly* may expose the fact /// that there are actually multiple representations for `Error`, so avoid /// that when err needs to be handled differently. - #[instrument(skip(self, expr), level = "debug")] + #[instrument(skip(self, expr), level = "trace")] pub(super) fn check_expr_with_expectation( &self, expr: &'tcx hir::Expr<'tcx>, @@ -202,13 +202,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // make this code only run with -Zverbose because it is probably slow if let Ok(lint_str) = self.tcx.sess.source_map().span_to_snippet(expr.span) { if !lint_str.contains('\n') { - debug!("expr text: {lint_str}"); + trace!("expr text: {lint_str}"); } else { let mut lines = lint_str.lines(); if let Some(line0) = lines.next() { let remaining_lines = lines.count(); - debug!("expr text: {line0}"); - debug!("expr text: ...(and {remaining_lines} more lines)"); + trace!("expr text: {line0}"); + trace!("expr text: ...(and {remaining_lines} more lines)"); } } } @@ -272,13 +272,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Combine the diverging and has_error flags. self.diverges.set(self.diverges.get() | old_diverges); - debug!("type of {} is...", self.tcx.hir().node_to_string(expr.hir_id)); - debug!("... {:?}, expected is {:?}", ty, expected); + trace!("type of {} is...", self.tcx.hir().node_to_string(expr.hir_id)); + trace!("... {:?}, expected is {:?}", ty, expected); ty } - #[instrument(skip(self, expr), level = "debug")] + #[instrument(skip(self, expr), level = "trace")] fn check_expr_kind( &self, expr: &'tcx hir::Expr<'tcx>, @@ -1287,9 +1287,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.param_env.constness(), ) { Ok(cast_check) => { - debug!( + trace!( "check_expr_cast: deferring cast from {:?} to {:?}: {:?}", - t_cast, t_expr, cast_check, + t_cast, + t_expr, + cast_check, ); deferred_cast_checks.push(cast_check); t_cast @@ -1776,7 +1778,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr_id, fru_tys); } else if adt_kind != AdtKind::Union && !remaining_fields.is_empty() { - debug!(?remaining_fields); + trace!(?remaining_fields); let private_fields: Vec<&ty::FieldDef> = variant .fields .iter() @@ -2207,16 +2209,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { field: Ident, expected: Expectation<'tcx>, ) -> Ty<'tcx> { - debug!("check_field(expr: {:?}, base: {:?}, field: {:?})", expr, base, field); + trace!("check_field(expr: {:?}, base: {:?}, field: {:?})", expr, base, field); let base_ty = self.check_expr(base); let base_ty = self.structurally_resolved_type(base.span, base_ty); let mut private_candidate = None; let mut autoderef = self.autoderef(expr.span, base_ty); while let Some((deref_base_ty, _)) = autoderef.next() { - debug!("deref_base_ty: {:?}", deref_base_ty); + trace!("deref_base_ty: {:?}", deref_base_ty); match deref_base_ty.kind() { ty::Adt(base_def, substs) if !base_def.is_enum() => { - debug!("struct named {:?}", deref_base_ty); + trace!("struct named {:?}", deref_base_ty); let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id); let (ident, def_scope) = self.tcx.adjust_ident_and_get_scope(field, base_def.did(), body_hir_id); @@ -2403,9 +2405,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &'tcx hir::Expr<'tcx>, base_ty: Ty<'tcx>, ) -> ErrorGuaranteed { - debug!( + trace!( "ban_nonexisting_field: field={:?}, base={:?}, expr={:?}, base_ty={:?}", - ident, base, expr, base_ty + ident, + base, + expr, + base_ty ); let mut err = self.no_such_field_err(ident, base_ty, base.hir_id); @@ -2649,7 +2654,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { id: HirId, ) -> DiagnosticBuilder<'_, ErrorGuaranteed> { let span = field.span; - debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t); + trace!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t); let mut err = type_error_struct!( self.tcx().sess, @@ -2726,7 +2731,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { base_ty: Ty<'tcx>, mod_id: DefId, ) -> Option<(impl Iterator + 'tcx, SubstsRef<'tcx>)> { - debug!("get_field_candidates(span: {:?}, base_t: {:?}", span, base_ty); + trace!("get_field_candidates(span: {:?}, base_t: {:?}", span, base_ty); for (base_t, _) in self.autoderef(span, base_ty) { match base_t.kind() { @@ -2765,9 +2770,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { mut field_path: Vec, mod_id: DefId, ) -> Option> { - debug!( + trace!( "check_for_nested_field_satisfying(span: {:?}, candidate_field: {:?}, field_path: {:?}", - span, candidate_field, field_path + span, + candidate_field, + field_path ); if field_path.len() > 3 { diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index e14e8ac2ce000..3317589636073 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -109,7 +109,7 @@ macro_rules! return_if_err { match $inp { Ok(v) => v, Err(()) => { - debug!("mc reported err"); + trace!("mc reported err"); return; } } @@ -136,11 +136,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub fn consume_body(&mut self, body: &hir::Body<'_>) { for param in body.params { let param_ty = return_if_err!(self.mc.pat_ty_adjusted(param.pat)); - debug!("consume_body: param_ty = {:?}", param_ty); + trace!("consume_body: param_ty = {:?}", param_ty); let param_place = self.mc.cat_rvalue(param.hir_id, param.pat.span, param_ty); @@ -165,7 +165,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } pub fn consume_expr(&mut self, expr: &hir::Expr<'_>) { - debug!("consume_expr(expr={:?})", expr); + trace!("consume_expr(expr={:?})", expr); let place_with_id = return_if_err!(self.mc.cat_expr(expr)); self.delegate_consume(&place_with_id, place_with_id.hir_id); @@ -179,7 +179,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } fn borrow_expr(&mut self, expr: &hir::Expr<'_>, bk: ty::BorrowKind) { - debug!("borrow_expr(expr={:?}, bk={:?})", expr, bk); + trace!("borrow_expr(expr={:?}, bk={:?})", expr, bk); let place_with_id = return_if_err!(self.mc.cat_expr(expr)); self.delegate.borrow(&place_with_id, place_with_id.hir_id, bk); @@ -192,7 +192,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } pub fn walk_expr(&mut self, expr: &hir::Expr<'_>) { - debug!("walk_expr(expr={:?})", expr); + trace!("walk_expr(expr={:?})", expr); self.walk_adjustment(expr); @@ -507,7 +507,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { /// Indicates that the value of `blk` will be consumed, meaning either copied or moved /// depending on its type. fn walk_block(&mut self, blk: &hir::Block<'_>) { - debug!("walk_block(blk.hir_id={})", blk.hir_id); + trace!("walk_block(blk.hir_id={})", blk.hir_id); for stmt in blk.stmts { self.walk_stmt(stmt); @@ -585,7 +585,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { let adjustments = self.mc.typeck_results.expr_adjustments(expr); let mut place_with_id = return_if_err!(self.mc.cat_expr_unadjusted(expr)); for adjustment in adjustments { - debug!("walk_adjustment expr={:?} adj={:?}", expr, adjustment); + trace!("walk_adjustment expr={:?} adj={:?}", expr, adjustment); match adjustment.kind { adjustment::Adjust::NeverToAny | adjustment::Adjust::Pointer(_) @@ -625,9 +625,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { base_place: &PlaceWithHirId<'tcx>, autoref: &adjustment::AutoBorrow<'tcx>, ) { - debug!( + trace!( "walk_autoref(expr.hir_id={} base_place={:?} autoref={:?})", - expr.hir_id, base_place, autoref + expr.hir_id, + base_place, + autoref ); match *autoref { @@ -640,7 +642,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } adjustment::AutoBorrow::RawPtr(m) => { - debug!("walk_autoref: expr.hir_id={} base_place={:?}", expr.hir_id, base_place); + trace!("walk_autoref: expr.hir_id={} base_place={:?}", expr.hir_id, base_place); self.delegate.borrow(base_place, base_place.hir_id, ty::BorrowKind::from_mutbl(m)); } @@ -692,21 +694,21 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { pat: &hir::Pat<'_>, has_guard: bool, ) { - debug!("walk_pat(discr_place={:?}, pat={:?}, has_guard={:?})", discr_place, pat, has_guard); + trace!("walk_pat(discr_place={:?}, pat={:?}, has_guard={:?})", discr_place, pat, has_guard); let tcx = self.tcx(); let ExprUseVisitor { ref mc, body_owner: _, ref mut delegate } = *self; return_if_err!(mc.cat_pattern(discr_place.clone(), pat, |place, pat| { if let PatKind::Binding(_, canonical_id, ..) = pat.kind { - debug!("walk_pat: binding place={:?} pat={:?}", place, pat); + trace!("walk_pat: binding place={:?} pat={:?}", place, pat); if let Some(bm) = mc.typeck_results.extract_binding_mode(tcx.sess, pat.hir_id, pat.span) { - debug!("walk_pat: pat.hir_id={:?} bm={:?}", pat.hir_id, bm); + trace!("walk_pat: pat.hir_id={:?} bm={:?}", pat.hir_id, bm); // pat_ty: the type of the binding being produced. let pat_ty = return_if_err!(mc.node_ty(pat.hir_id)); - debug!("walk_pat: pat_ty={:?}", pat_ty); + trace!("walk_pat: pat_ty={:?}", pat_ty); let def = Res::Local(canonical_id); if let Ok(ref binding_place) = mc.cat_res(pat.hir_id, pat.span, pat_ty, def) { @@ -730,7 +732,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { delegate.borrow(place, discr_place.hir_id, bk); } ty::BindByValue(..) => { - debug!("walk_pat binding consuming pat"); + trace!("walk_pat binding consuming pat"); delegate_consume(mc, *delegate, place, discr_place.hir_id); } } @@ -767,7 +769,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { upvars.map(|upvars| !upvars.contains_key(&upvar_id)).unwrap_or(body_owner_is_closure) } - debug!("walk_captures({:?})", closure_expr); + trace!("walk_captures({:?})", closure_expr); let tcx = self.tcx(); let closure_def_id = closure_expr.def_id; @@ -889,7 +891,7 @@ fn delegate_consume<'a, 'tcx>( place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId, ) { - debug!("delegate_consume(place_with_id={:?})", place_with_id); + trace!("delegate_consume(place_with_id={:?})", place_with_id); let mode = copy_or_move(mc, place_with_id); diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs index b7ae621c6859f..8d87e9491c3a0 100644 --- a/compiler/rustc_hir_typeck/src/fallback.rs +++ b/compiler/rustc_hir_typeck/src/fallback.rs @@ -10,7 +10,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { /// Performs type inference fallback, setting `FnCtxt::fallback_has_occurred` /// if fallback has occurred. pub(super) fn type_inference_fallback(&self) { - debug!( + trace!( "type-inference-fallback start obligations: {:#?}", self.fulfillment_cx.borrow_mut().pending_obligations() ); @@ -18,7 +18,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { // All type checking constraints were added, try to fallback unsolved variables. self.select_obligations_where_possible(|_| {}); - debug!( + trace!( "type-inference-fallback post selection obligations: {:#?}", self.fulfillment_cx.borrow_mut().pending_obligations() ); @@ -35,7 +35,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { // better error messages. // The first time, we do *not* replace opaque types. for ty in unsolved_variables { - debug!("unsolved_variable = {:?}", ty); + trace!("unsolved_variable = {:?}", ty); self.fallback_if_possible(ty, &diverging_fallback); } @@ -112,7 +112,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { None => return, }, }; - debug!("fallback_if_possible(ty={:?}): defaulting to `{:?}`", ty, fallback); + trace!("fallback_if_possible(ty={:?}): defaulting to `{:?}`", ty, fallback); let span = self .infcx @@ -194,7 +194,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { &self, unsolved_variables: &[Ty<'tcx>], ) -> FxHashMap, Ty<'tcx>> { - debug!("calculate_diverging_fallback({:?})", unsolved_variables); + trace!("calculate_diverging_fallback({:?})", unsolved_variables); // Construct a coercion graph where an edge `A -> B` indicates // a type variable is that is coerced @@ -218,11 +218,11 @@ impl<'tcx> FnCtxt<'_, 'tcx> { .filter_map(|ty| ty.ty_vid()) .map(|vid| self.root_var(vid)) .collect(); - debug!( + trace!( "calculate_diverging_fallback: diverging_type_vars={:?}", self.diverging_type_vars.borrow() ); - debug!("calculate_diverging_fallback: diverging_roots={:?}", diverging_roots); + trace!("calculate_diverging_fallback: diverging_roots={:?}", diverging_roots); // Find all type variables that are reachable from a diverging // type variable. These will typically default to `!`, unless @@ -233,7 +233,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { let mut non_diverging_vids = vec![]; for unsolved_vid in unsolved_vids { let root_vid = self.root_var(unsolved_vid); - debug!( + trace!( "calculate_diverging_fallback: unsolved_vid={:?} root_vid={:?} diverges={:?}", unsolved_vid, root_vid, @@ -243,7 +243,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { diverging_vids.push(unsolved_vid); roots_reachable_from_diverging.push_start_node(root_vid); - debug!( + trace!( "calculate_diverging_fallback: root_vid={:?} reaches {:?}", root_vid, coercion_graph.depth_first_search(root_vid).collect::>() @@ -256,7 +256,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { } } - debug!( + trace!( "calculate_diverging_fallback: roots_reachable_from_diverging={:?}", roots_reachable_from_diverging, ); @@ -274,12 +274,12 @@ impl<'tcx> FnCtxt<'_, 'tcx> { roots_reachable_from_non_diverging.push_start_node(root_vid); roots_reachable_from_non_diverging.complete_search(); } - debug!( + trace!( "calculate_diverging_fallback: roots_reachable_from_non_diverging={:?}", roots_reachable_from_non_diverging, ); - debug!("obligations: {:#?}", self.fulfillment_cx.borrow_mut().pending_obligations()); + trace!("obligations: {:#?}", self.fulfillment_cx.borrow_mut().pending_obligations()); // For each diverging variable, figure out whether it can // reach a member of N. If so, it falls back to `()`. Else @@ -327,13 +327,13 @@ impl<'tcx> FnCtxt<'_, 'tcx> { // For details on the requirements for these relationships to be // set, see the relationship finding module in // compiler/rustc_trait_selection/src/traits/relationships.rs. - debug!("fallback to () - found trait and projection: {:?}", diverging_vid); + trace!("fallback to () - found trait and projection: {:?}", diverging_vid); diverging_fallback.insert(diverging_ty, self.tcx.types.unit); } else if can_reach_non_diverging { - debug!("fallback to () - reached non-diverging: {:?}", diverging_vid); + trace!("fallback to () - reached non-diverging: {:?}", diverging_vid); diverging_fallback.insert(diverging_ty, self.tcx.types.unit); } else { - debug!("fallback to ! - all diverging: {:?}", diverging_vid); + trace!("fallback to ! - all diverging: {:?}", diverging_vid); diverging_fallback.insert(diverging_ty, self.tcx.mk_diverging_default()); } } @@ -345,7 +345,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { /// an edge `?A -> ?B` indicates that the variable `?A` is coerced to `?B`. fn create_coercion_graph(&self) -> VecGraph { let pending_obligations = self.fulfillment_cx.borrow_mut().pending_obligations(); - debug!("create_coercion_graph: pending_obligations={:?}", pending_obligations); + trace!("create_coercion_graph: pending_obligations={:?}", pending_obligations); let coercion_edges: Vec<(ty::TyVid, ty::TyVid)> = pending_obligations .into_iter() .filter_map(|obligation| { @@ -380,7 +380,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { Some((a_vid, b_vid)) }) .collect(); - debug!("create_coercion_graph: coercion_edges={:?}", coercion_edges); + trace!("create_coercion_graph: coercion_edges={:?}", coercion_edges); let num_ty_vars = self.num_ty_vars(); VecGraph::new(num_ty_vars, coercion_edges) } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 38ddb7e760410..09f09e410917b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -59,7 +59,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { self.diverges.set(Diverges::WarnedAlways); - debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind); + trace!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind); let msg = format!("unreachable {}", kind); self.tcx().struct_span_lint_hir( @@ -87,7 +87,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.resolve_vars_with_obligations_and_mutate_fulfillment(ty, |_| {}) } - #[instrument(skip(self, mutate_fulfillment_errors), level = "debug", ret)] + #[instrument(skip(self, mutate_fulfillment_errors), level = "trace", ret)] pub(in super::super) fn resolve_vars_with_obligations_and_mutate_fulfillment( &self, mut ty: Ty<'tcx>, @@ -95,14 +95,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { // No Infer()? Nothing needs doing. if !ty.has_non_region_infer() { - debug!("no inference var, nothing needs doing"); + trace!("no inference var, nothing needs doing"); return ty; } // If `ty` is a type variable, see whether we already know what it is. ty = self.resolve_vars_if_possible(ty); if !ty.has_non_region_infer() { - debug!(?ty); + trace!(?ty); return ty; } @@ -143,7 +143,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[inline] pub fn write_ty(&self, id: hir::HirId, ty: Ty<'tcx>) { - debug!("write_ty({:?}, {:?}) in fcx {}", id, self.resolve_vars_if_possible(ty), self.tag()); + trace!("write_ty({:?}, {:?}) in fcx {}", id, self.resolve_vars_if_possible(ty), self.tag()); self.typeck_results.borrow_mut().node_types_mut().insert(id, ty); if let Err(e) = ty.error_reported() { @@ -155,7 +155,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.typeck_results.borrow_mut().field_indices_mut().insert(hir_id, index); } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(in super::super) fn write_resolution( &self, hir_id: hir::HirId, @@ -164,7 +164,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.typeck_results.borrow_mut().type_dependent_defs_mut().insert(hir_id, r); } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub fn write_method_call(&self, hir_id: hir::HirId, method: MethodCallee<'tcx>) { self.write_resolution(hir_id, Ok((DefKind::AssocFn, method.def_id))); self.write_substs(hir_id, method.substs); @@ -172,7 +172,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn write_substs(&self, node_id: hir::HirId, substs: SubstsRef<'tcx>) { if !substs.is_empty() { - debug!("write_substs({:?}, {:?}) in fcx {}", node_id, substs, self.tag()); + trace!("write_substs({:?}, {:?}) in fcx {}", node_id, substs, self.tag()); self.typeck_results.borrow_mut().node_substs_mut().insert(node_id, substs); } @@ -185,7 +185,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// This should be invoked **before any unifications have /// occurred**, so that annotations like `Vec<_>` are preserved /// properly. - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub fn write_user_type_annotation_from_substs( &self, hir_id: hir::HirId, @@ -193,25 +193,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { substs: SubstsRef<'tcx>, user_self_ty: Option>, ) { - debug!("fcx {}", self.tag()); + trace!("fcx {}", self.tag()); if Self::can_contain_user_lifetime_bounds((substs, user_self_ty)) { let canonicalized = self.canonicalize_user_type_annotation(UserType::TypeOf( def_id, UserSubsts { substs, user_self_ty }, )); - debug!(?canonicalized); + trace!(?canonicalized); self.write_user_type_annotation(hir_id, canonicalized); } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub fn write_user_type_annotation( &self, hir_id: hir::HirId, canonical_user_type_annotation: CanonicalUserType<'tcx>, ) { - debug!("fcx {}", self.tag()); + trace!("fcx {}", self.tag()); if !canonical_user_type_annotation.is_identity() { self.typeck_results @@ -219,13 +219,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .user_provided_types_mut() .insert(hir_id, canonical_user_type_annotation); } else { - debug!("skipping identity substs"); + trace!("skipping identity substs"); } } - #[instrument(skip(self, expr), level = "debug")] + #[instrument(skip(self, expr), level = "trace")] pub fn apply_adjustments(&self, expr: &hir::Expr<'_>, adj: Vec>) { - debug!("expr = {:#?}", expr); + trace!("expr = {:#?}", expr); if adj.is_empty() { return; @@ -235,7 +235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Adjust::NeverToAny = a.kind { if a.target.is_ty_var() { self.diverging_type_vars.borrow_mut().insert(a.target); - debug!("apply_adjustments: adding `{:?}` as diverging type var", a.target); + trace!("apply_adjustments: adding `{:?}` as diverging type var", a.target); } } } @@ -255,7 +255,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { entry.insert(adj); } Entry::Occupied(mut entry) => { - debug!(" - composing on top of {:?}", entry.get()); + trace!(" - composing on top of {:?}", entry.get()); match (&entry.get()[..], &adj[..]) { // Applying any adjustment on top of a NeverToAny // is a valid NeverToAny adjustment, because it can't @@ -309,7 +309,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let bounds = self.tcx.predicates_of(def_id); let result = bounds.instantiate(self.tcx, substs); let result = self.normalize(span, result); - debug!("instantiate_bounds(bounds={:?}, substs={:?}) = {:?}", bounds, substs, result); + trace!("instantiate_bounds(bounds={:?}, substs={:?}) = {:?}", bounds, substs, result); result } @@ -384,11 +384,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn to_ty_saving_user_provided_ty(&self, ast_ty: &hir::Ty<'_>) -> Ty<'tcx> { let ty = self.to_ty(ast_ty); - debug!("to_ty_saving_user_provided_ty: ty={:?}", ty); + trace!("to_ty_saving_user_provided_ty: ty={:?}", ty); if Self::can_contain_user_lifetime_bounds(ty.raw) { let c_ty = self.canonicalize_response(UserType::Ty(ty.raw)); - debug!("to_ty_saving_user_provided_ty: c_ty={:?}", c_ty); + trace!("to_ty_saving_user_provided_ty: c_ty={:?}", c_ty); self.typeck_results.borrow_mut().user_provided_types_mut().insert(ast_ty.hir_id, c_ty); } @@ -538,7 +538,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// /// We must not attempt to select obligations after this method has run, or risk query cycle /// ICE. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn save_generator_interior_predicates(&self, def_id: DefId) { // Try selecting all obligations that are not blocked on inference variables. // Once we start unifying generator witnesses, trying to select obligations on them will @@ -546,10 +546,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.select_obligations_where_possible(|_| {}); let generators = std::mem::take(&mut *self.deferred_generator_interiors.borrow_mut()); - debug!(?generators); + trace!(?generators); for &(expr_def_id, body_id, interior, _) in generators.iter() { - debug!(?expr_def_id); + trace!(?expr_def_id); // Create the `GeneratorWitness` type that we will unify with `interior`. let substs = ty::InternalSubsts::identity_for_item( @@ -571,7 +571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .extend(self.fulfillment_cx.borrow_mut().drain_unstalled_obligations(&self.infcx)); let obligations = obligations.into_iter().map(|o| (o.predicate, o.cause)).collect(); - debug!(?obligations); + trace!(?obligations); self.typeck_results .borrow_mut() .generator_interior_predicates @@ -579,7 +579,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(in super::super) fn report_ambiguity_errors(&self) { let mut errors = self.fulfillment_cx.borrow_mut().collect_remaining_errors(self); @@ -617,24 +617,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ret_ty.builtin_deref(true).unwrap() } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn self_type_matches_expected_vid(&self, self_ty: Ty<'tcx>, expected_vid: ty::TyVid) -> bool { let self_ty = self.shallow_resolve(self_ty); - debug!(?self_ty); + trace!(?self_ty); match *self_ty.kind() { ty::Infer(ty::TyVar(found_vid)) => { // FIXME: consider using `sub_root_var` here so we // can see through subtyping. let found_vid = self.root_var(found_vid); - debug!("self_type_matches_expected_vid - found_vid={:?}", found_vid); + trace!("self_type_matches_expected_vid - found_vid={:?}", found_vid); expected_vid == found_vid } _ => false, } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(in super::super) fn obligations_for_self_ty<'b>( &'b self, self_ty: ty::TyVid, @@ -707,7 +707,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Unifies the output type with the expected type early, for more coercions /// and forward type information on the input expressions. - #[instrument(skip(self, call_span), level = "debug")] + #[instrument(skip(self, call_span), level = "trace")] pub(in super::super) fn expected_inputs_for_expected_output( &self, call_span: Span, @@ -763,7 +763,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(Some(formal_args.iter().map(|&ty| self.resolve_vars_if_possible(ty)).collect())) }) .unwrap_or_default(); - debug!(?formal_args, ?formal_ret, ?expect_args, ?expected_ret); + trace!(?formal_args, ?formal_ret, ?expect_args, ?expected_ret); expect_args } @@ -816,9 +816,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir_id: hir::HirId, span: Span, ) -> (Res, Option>, &'tcx [hir::PathSegment<'tcx>]) { - debug!( + trace!( "resolve_ty_and_res_fully_qualified_call: qpath={:?} hir_id={:?} span={:?}", - qpath, hir_id, span + qpath, + hir_id, + span ); let (ty, qself, item_segment) = match *qpath { QPath::Resolved(ref opt_qself, ref path) => { @@ -1076,7 +1078,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Instantiates the given path, which must refer to an item with the given // number of type parameters and type. - #[instrument(skip(self, span), level = "debug")] + #[instrument(skip(self, span), level = "trace")] pub fn instantiate_value_path( &self, segments: &[hir::PathSegment<'_>], @@ -1113,7 +1115,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let assoc_item = tcx.associated_item(def_id); let container = assoc_item.container; let container_id = assoc_item.container_id(tcx); - debug!(?def_id, ?container, ?container_id); + trace!(?def_id, ?container, ?container_id); match container { ty::TraitContainer => { callee::check_legal_trait_for_method_call(tcx, span, None, span, container_id) @@ -1416,7 +1418,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - debug!("instantiate_value_path: type of {:?} is {:?}", hir_id, ty_substituted); + trace!("instantiate_value_path: type of {:?} is {:?}", hir_id, ty_substituted); self.write_substs(hir_id, substs); (ty_substituted, res) @@ -1439,7 +1441,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }) } - #[instrument(level = "debug", skip(self, code, span, substs))] + #[instrument(level = "trace", skip(self, code, span, substs))] fn add_required_obligations_with_code( &self, span: Span, diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 72c42f8e78952..302671a75621b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -43,7 +43,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // when writing to `self.param_env`. let mut deferred_cast_checks = mem::take(&mut *self.deferred_cast_checks.borrow_mut()); - debug!("FnCtxt::check_casts: {} deferred checks", deferred_cast_checks.len()); + trace!("FnCtxt::check_casts: {} deferred checks", deferred_cast_checks.len()); for cast in deferred_cast_checks.drain(..) { let prev_env = self.param_env; self.param_env = self.param_env.with_constness(cast.constness); @@ -58,7 +58,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn check_transmutes(&self) { let mut deferred_transmute_checks = self.deferred_transmute_checks.borrow_mut(); - debug!("FnCtxt::check_transmutes: {} deferred checks", deferred_transmute_checks.len()); + trace!("FnCtxt::check_transmutes: {} deferred checks", deferred_transmute_checks.len()); for (from, to, hir_id) in deferred_transmute_checks.drain(..) { self.check_transmute(from, to, hir_id); } @@ -66,7 +66,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn check_asms(&self) { let mut deferred_asm_checks = self.deferred_asm_checks.borrow_mut(); - debug!("FnCtxt::check_asm: {} deferred checks", deferred_asm_checks.len()); + trace!("FnCtxt::check_asm: {} deferred checks", deferred_asm_checks.len()); for (asm, hir_id) in deferred_asm_checks.drain(..) { let enclosing_id = self.tcx.hir().enclosing_body_owner(hir_id); let get_operand_ty = |expr| { @@ -246,7 +246,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expected_input_ty: Ty<'tcx> = expected_input_tys[idx]; let provided_arg = &provided_args[idx]; - debug!("checking argument {}: {:?} = {:?}", idx, provided_arg, formal_input_ty); + trace!("checking argument {}: {:?} = {:?}", idx, provided_arg, formal_input_ty); // We're on the happy path here, so we'll do a more involved check and write back types // To check compatibility, we'll do 3 things: @@ -1341,7 +1341,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if let Some((variant, did, ty::UserSubsts { substs, user_self_ty })) = variant { - debug!("check_struct_path: did={:?} substs={:?}", did, substs); + trace!("check_struct_path: did={:?} substs={:?}", did, substs); // Register type annotation. self.write_user_type_annotation_from_substs(hir_id, did, substs, user_self_ty); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index c4add4dbdfb2f..c2a5c9c63c1bb 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -534,7 +534,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match expected.kind() { ty::Adt(def, _) if Some(def.did()) == pin_did => { if self.can_coerce(pin_box_found, expected) { - debug!("can coerce {:?} to {:?}, suggesting Box::pin", pin_box_found, expected); + trace!("can coerce {:?} to {:?}, suggesting Box::pin", pin_box_found, expected); match found.kind() { ty::Adt(def, _) if def.is_box() => { err.help("use `Box::pin`"); @@ -719,7 +719,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { // Check if async function's return type was omitted. // Don't emit suggestions if the found type is `impl Future<...>`. - debug!(?found); + trace!(?found); if found.is_suggestable(self.tcx, false) { if term.span.is_empty() { err.subdiagnostic(AddReturnTypeSuggestion::Add { span, found: found.to_string() }); @@ -732,10 +732,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Only point to return type if the expected type is the return type, as if they // are not, the expectation must have been caused by something else. - debug!("return type {:?}", hir_ty); + trace!("return type {:?}", hir_ty); let ty = self.astconv().ast_ty_to_ty(hir_ty); - debug!("return type {:?}", ty); - debug!("expected type {:?}", expected); + trace!("return type {:?}", ty); + trace!("expected type {:?}", expected); let bound_vars = self.tcx.late_bound_vars(hir_ty.hir_id.owner.into()); let ty = Binder::bind_with_vars(ty, bound_vars); let ty = self.normalize(span, ty); @@ -774,7 +774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Suggest: // - Changing the return type to be `impl ` - debug!("try_suggest_return_impl_trait, expected = {:?}, found = {:?}", expected, found); + trace!("try_suggest_return_impl_trait, expected = {:?}, found = {:?}", expected, found); let ty::Param(expected_ty_as_param) = expected.kind() else { return }; diff --git a/compiler/rustc_hir_typeck/src/gather_locals.rs b/compiler/rustc_hir_typeck/src/gather_locals.rs index 38445f2844052..d8b61bb057930 100644 --- a/compiler/rustc_hir_typeck/src/gather_locals.rs +++ b/compiler/rustc_hir_typeck/src/gather_locals.rs @@ -80,7 +80,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> { let c_ty = self.fcx.inh.infcx.canonicalize_user_type_annotation(UserType::Ty(o_ty.raw)); - debug!("visit_local: ty.hir_id={:?} o_ty={:?} c_ty={:?}", ty.hir_id, o_ty, c_ty); + trace!("visit_local: ty.hir_id={:?} o_ty={:?} c_ty={:?}", ty.hir_id, o_ty, c_ty); self.fcx .typeck_results .borrow_mut() @@ -93,7 +93,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> { }; self.assign(decl.span, decl.hir_id, local_ty); - debug!( + trace!( "local variable {:?} is assigned type {}", decl.pat, self.fcx.ty_to_string(self.fcx.locals.borrow().get(&decl.hir_id).unwrap().decl_ty) @@ -138,7 +138,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { } } - debug!( + trace!( "pattern binding {} is assigned to {} with type {:?}", ident, self.fcx.ty_to_string(self.fcx.locals.borrow().get(&p.hir_id).unwrap().decl_ty), diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs index e4a62ec05aef1..7f3cbfa950085 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs @@ -109,7 +109,7 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> { places: ConsumedAndBorrowedPlaces, num_exprs: usize, ) -> Self { - debug!("consumed_places: {:?}", places.consumed); + trace!("consumed_places: {:?}", places.consumed); let drop_ranges = DropRangesBuilder::new( places.consumed.iter().flat_map(|(_, places)| places.iter().cloned()), infcx.tcx.hir(), @@ -132,9 +132,9 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> { fn record_drop(&mut self, value: TrackedValue) { if self.places.borrowed.contains(&value) { - debug!("not marking {:?} as dropped because it is borrowed at some point", value); + trace!("not marking {:?} as dropped because it is borrowed at some point", value); } else { - debug!("marking {:?} as dropped at {:?}", value, self.expr_index); + trace!("marking {:?} as dropped at {:?}", value, self.expr_index); let count = self.expr_index; self.drop_ranges.drop_at(value, count); } @@ -143,7 +143,7 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> { /// ExprUseVisitor's consume callback doesn't go deep enough for our purposes in all /// expressions. This method consumes a little deeper into the expression when needed. fn consume_expr(&mut self, expr: &hir::Expr<'_>) { - debug!("consuming expr {:?}, count={:?}", expr.kind, self.expr_index); + trace!("consuming expr {:?}, count={:?}", expr.kind, self.expr_index); let places = self .places .consumed @@ -179,7 +179,7 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> { // This is the base case, where we have found an actual named variable. let location = self.expr_index; - debug!("reinitializing {:?} at {:?}", hir_id, location); + trace!("reinitializing {:?} at {:?}", hir_id, location); self.drop_ranges.reinit_at(TrackedValue::Variable(*hir_id), location); } @@ -535,7 +535,7 @@ impl DropRangesBuilder { } }); } - debug!("hir_id_map: {:#?}", tracked_value_map); + trace!("hir_id_map: {:#?}", tracked_value_map); let num_values = tracked_value_map.len(); Self { tracked_value_map, diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs index ecafbd668e22d..6af2a98a1213f 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs @@ -53,7 +53,7 @@ pub fn compute_drop_ranges<'a, 'tcx>( drop_ranges.propagate_to_fixpoint(); - debug!("borrowed_temporaries = {borrowed_temporaries:?}"); + trace!("borrowed_temporaries = {borrowed_temporaries:?}"); DropRanges { tracked_value_map: drop_ranges.tracked_value_map, nodes: drop_ranges.nodes, @@ -170,7 +170,7 @@ impl TryFrom<&PlaceWithHirId<'_>> for TrackedValue { fn try_from(place_with_id: &PlaceWithHirId<'_>) -> Result { if !place_with_id.place.projections.is_empty() { - debug!( + trace!( "TrackedValue from PlaceWithHirId: {:?} has projections, which are not supported.", place_with_id ); diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs index 8ab0bd535d6fd..326e0379e2362 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs @@ -77,7 +77,7 @@ impl<'tcx> ExprUseDelegate<'tcx> { fn mark_consumed(&mut self, consumer: HirId, target: TrackedValue) { self.places.consumed.entry(consumer).or_insert_with(|| <_>::default()); - debug!(?consumer, ?target, "mark_consumed"); + trace!(?consumer, ?target, "mark_consumed"); self.places.consumed.get_mut(&consumer).map(|places| places.insert(target)); } @@ -144,7 +144,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { Some(parent) => parent, None => place_with_id.hir_id, }; - debug!( + trace!( "consume {:?}; diag_expr_id={}, using parent {}", place_with_id, hir.node_to_string(diag_expr_id), @@ -161,7 +161,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { diag_expr_id: HirId, bk: rustc_middle::ty::BorrowKind, ) { - debug!( + trace!( "borrow: place_with_id = {place_with_id:#?}, diag_expr_id={diag_expr_id:#?}, \ borrow_kind={bk:#?}" ); @@ -174,7 +174,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>, _diag_expr_id: HirId, ) { - debug!("copy: place_with_id = {place_with_id:?}"); + trace!("copy: place_with_id = {place_with_id:?}"); self.places .borrowed @@ -189,7 +189,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { assignee_place: &expr_use_visitor::PlaceWithHirId<'tcx>, diag_expr_id: HirId, ) { - debug!("mutate {assignee_place:?}; diag_expr_id={diag_expr_id:?}"); + trace!("mutate {assignee_place:?}; diag_expr_id={diag_expr_id:?}"); if assignee_place.place.base == PlaceBase::Rvalue && assignee_place.place.projections.is_empty() @@ -219,7 +219,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { binding_place: &expr_use_visitor::PlaceWithHirId<'tcx>, diag_expr_id: HirId, ) { - debug!("bind {binding_place:?}; diag_expr_id={diag_expr_id:?}"); + trace!("bind {binding_place:?}; diag_expr_id={diag_expr_id:?}"); } fn fake_read( @@ -228,7 +228,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { cause: rustc_middle::mir::FakeReadCause, diag_expr_id: HirId, ) { - debug!( + trace!( "fake_read place_with_id={place_with_id:?}; cause={cause:?}; diag_expr_id={diag_expr_id:?}" ); diff --git a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs index fb28233bfb1c2..323f4097e32cb 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs @@ -48,9 +48,14 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { let ty = self.fcx.resolve_vars_if_possible(ty); - debug!( + trace!( "attempting to record type ty={:?}; hir_id={:?}; scope={:?}; expr={:?}; source_span={:?}; expr_count={:?}", - ty, hir_id, scope, expr, source_span, self.expr_count, + ty, + hir_id, + scope, + expr, + source_span, + self.expr_count, ); let live_across_yield = scope @@ -66,15 +71,17 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { yield_data .iter() .find(|yield_data| { - debug!( + trace!( "comparing counts yield: {} self: {}, source_span = {:?}", - yield_data.expr_and_pat_count, self.expr_count, source_span + yield_data.expr_and_pat_count, + self.expr_count, + source_span ); if self .is_dropped_at_yield_location(hir_id, yield_data.expr_and_pat_count) { - debug!("value is dropped at yield point; not recording"); + trace!("value is dropped at yield point; not recording"); return false; } @@ -91,9 +98,13 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { }); if let Some(yield_data) = live_across_yield { - debug!( + trace!( "type in expr = {:?}, scope = {:?}, type = {:?}, count = {}, yield_span = {:?}", - expr, scope, ty, self.expr_count, yield_data.span + expr, + scope, + ty, + self.expr_count, + yield_data.span ); if let Some((unresolved_term, unresolved_type_span)) = @@ -154,7 +165,7 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { }); } } else { - debug!( + trace!( "no type in expr = {:?}, count = {:?}, span = {:?}", expr, self.expr_count, @@ -163,9 +174,10 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { if let Some((unresolved_type, unresolved_type_span)) = self.fcx.first_unresolved_const_or_ty_var(&ty) { - debug!( + trace!( "remained unresolved_type = {:?}, unresolved_type_span: {:?}", - unresolved_type, unresolved_type_span + unresolved_type, + unresolved_type_span ); self.prev_unresolved_span = unresolved_type_span; } @@ -223,7 +235,7 @@ pub fn resolve_interior<'a, 'tcx>( // if a Sync generator contains an &'α T, we need to check whether &'α T: Sync), // so knowledge of the exact relationships between them isn't particularly important. - debug!("types in generator {:?}, span = {:?}", types, body.value.span); + trace!("types in generator {:?}, span = {:?}", types, body.value.span); // We want to deduplicate if the lifetimes are the same modulo some non-informative counter. // So, we need to actually do two passes: first by type to anonymize (preserving information @@ -319,9 +331,10 @@ pub fn resolve_interior<'a, 'tcx>( fcx.inh.typeck_results.borrow_mut().generator_interior_types = ty::Binder::bind_with_vars(type_causes, bound_vars); - debug!( + trace!( "types in generator after region replacement {:?}, span = {:?}", - witness, body.value.span + witness, + body.value.span ); // Unify the type variable inside the generator with the new witness @@ -441,7 +454,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { self.expr_count += 1; - debug!("is_borrowed_temporary: {:?}", self.drop_ranges.is_borrowed_temporary(expr)); + trace!("is_borrowed_temporary: {:?}", self.drop_ranges.is_borrowed_temporary(expr)); let ty = self.fcx.typeck_results.borrow().expr_ty_adjusted_opt(expr); @@ -483,7 +496,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { .parent_iter(expr.hir_id) .find(|(_, node)| matches!(node, hir::Node::Expr(_))) .map(|(id, _)| id); - debug!("parent_expr: {:?}", parent_expr); + trace!("parent_expr: {:?}", parent_expr); match parent_expr { Some(parent) => Some(Scope { id: parent.local_id, data: ScopeData::Node }), None => { @@ -563,7 +576,7 @@ fn check_must_not_suspend_ty<'tcx>( let plural_suffix = pluralize!(data.plural_len); - debug!("Checking must_not_suspend for {}", ty); + trace!("Checking must_not_suspend for {}", ty); match *ty.kind() { ty::Adt(..) if ty.is_box() => { diff --git a/compiler/rustc_hir_typeck/src/inherited.rs b/compiler/rustc_hir_typeck/src/inherited.rs index 294c3bb78a5ba..17819256a1dc3 100644 --- a/compiler/rustc_hir_typeck/src/inherited.rs +++ b/compiler/rustc_hir_typeck/src/inherited.rs @@ -100,7 +100,7 @@ impl<'tcx> Inherited<'tcx> { } } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(super) fn register_predicate(&self, obligation: traits::PredicateObligation<'tcx>) { if obligation.has_escaping_bound_vars() { span_bug!(obligation.cause.span, "escaping bound vars in predicate {:?}", obligation); @@ -158,7 +158,7 @@ impl<'tcx> Inherited<'tcx> { // If the projection predicate (Foo::Bar == X) has X as a non-TyVid, // we need to make it into one. if let Some(vid) = predicate.term.ty().and_then(|ty| ty.ty_vid()) { - debug!("infer_var_info: {:?}.output = true", vid); + trace!("infer_var_info: {:?}.output = true", vid); infer_var_info.entry(vid).or_default().output = true; } } diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index b97b55d8f7ee8..88f01fbdf4317 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -167,7 +167,7 @@ fn diagnostic_only_typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::T typeck_with_fallback(tcx, def_id, fallback) } -#[instrument(level = "debug", skip(tcx, fallback), ret)] +#[instrument(level = "trace", skip(tcx, fallback), ret)] fn typeck_with_fallback<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, @@ -289,12 +289,12 @@ fn typeck_with_fallback<'tcx>( fcx.select_obligations_where_possible(|_| {}); - debug!(pending_obligations = ?fcx.fulfillment_cx.borrow().pending_obligations()); + trace!(pending_obligations = ?fcx.fulfillment_cx.borrow().pending_obligations()); // This must be the last thing before `report_ambiguity_errors`. fcx.resolve_generator_interiors(def_id.to_def_id()); - debug!(pending_obligations = ?fcx.fulfillment_cx.borrow().pending_obligations()); + trace!(pending_obligations = ?fcx.fulfillment_cx.borrow().pending_obligations()); if let None = fcx.infcx.tainted_by_errors() { fcx.report_ambiguity_errors(); diff --git a/compiler/rustc_hir_typeck/src/mem_categorization.rs b/compiler/rustc_hir_typeck/src/mem_categorization.rs index 78171e0b20e8c..a9240099d495d 100644 --- a/compiler/rustc_hir_typeck/src/mem_categorization.rs +++ b/compiler/rustc_hir_typeck/src/mem_categorization.rs @@ -143,7 +143,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { Some(ty) => { let ty = self.resolve_vars_if_possible(ty); if ty.references_error() || ty.is_ty_var() { - debug!("resolve_type_vars_or_error: error from {:?}", ty); + trace!("resolve_type_vars_or_error: error from {:?}", ty); Err(()) } else { Ok(ty) @@ -189,7 +189,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { // that aims to account for `ref x`. if let Some(vec) = self.typeck_results.pat_adjustments().get(pat.hir_id) { if let Some(first_ty) = vec.first() { - debug!("pat_ty(pat={:?}) found adjusted ty `{:?}`", pat, first_ty); + trace!("pat_ty(pat={:?}) found adjusted ty `{:?}`", pat, first_ty); return Ok(*first_ty); } } @@ -200,7 +200,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { /// Like `pat_ty`, but ignores implicit `&` patterns. fn pat_ty_unadjusted(&self, pat: &hir::Pat<'_>) -> McResult> { let base_ty = self.node_ty(pat.hir_id)?; - debug!("pat_ty(pat={:?}) base_ty={:?}", pat, base_ty); + trace!("pat_ty(pat={:?}) base_ty={:?}", pat, base_ty); // This code detects whether we are looking at a `ref x`, // and if so, figures out what the type *being borrowed* is. @@ -219,7 +219,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { match base_ty.builtin_deref(false) { Some(t) => t.ty, None => { - debug!("By-ref binding of non-derefable type {:?}", base_ty); + trace!("By-ref binding of non-derefable type {:?}", base_ty); return Err(()); } } @@ -229,7 +229,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { } _ => base_ty, }; - debug!("pat_ty(pat={:?}) ret_ty={:?}", pat, ret_ty); + trace!("pat_ty(pat={:?}) ret_ty={:?}", pat, ret_ty); Ok(ret_ty) } @@ -262,7 +262,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { self.cat_expr_adjusted_with(expr, || Ok(previous), adjustment) } - #[instrument(level = "debug", skip(self, previous))] + #[instrument(level = "trace", skip(self, previous))] fn cat_expr_adjusted_with( &self, expr: &hir::Expr<'_>, @@ -297,12 +297,12 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { } } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(crate) fn cat_expr_unadjusted( &self, expr: &hir::Expr<'_>, ) -> McResult> { - debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr); + trace!("cat_expr: id={} expr={:?}", expr.hir_id, expr); let expr_ty = self.expr_ty(expr)?; match expr.kind { @@ -317,7 +317,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { hir::ExprKind::Field(ref base, _) => { let base = self.cat_expr(base)?; - debug!("cat_expr(cat_field): id={} expr={:?} base={:?}", expr.hir_id, expr, base); + trace!("cat_expr(cat_field): id={} expr={:?} base={:?}", expr.hir_id, expr, base); let field_idx = self .typeck_results @@ -386,7 +386,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { } } - #[instrument(level = "debug", skip(self, span))] + #[instrument(level = "trace", skip(self, span))] pub(crate) fn cat_res( &self, hir_id: hir::HirId, @@ -438,7 +438,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { let ret = PlaceWithHirId::new(hir_id, var_ty, PlaceBase::Upvar(upvar_id), Vec::new()); - debug!("cat_upvar ret={:?}", ret); + trace!("cat_upvar ret={:?}", ret); Ok(ret) } @@ -448,9 +448,9 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { span: Span, expr_ty: Ty<'tcx>, ) -> PlaceWithHirId<'tcx> { - debug!("cat_rvalue hir_id={:?}, expr_ty={:?}, span={:?}", hir_id, expr_ty, span); + trace!("cat_rvalue hir_id={:?}, expr_ty={:?}, span={:?}", hir_id, expr_ty, span); let ret = PlaceWithHirId::new(hir_id, expr_ty, PlaceBase::Rvalue, Vec::new()); - debug!("cat_rvalue ret={:?}", ret); + trace!("cat_rvalue ret={:?}", ret); ret } @@ -469,11 +469,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { base_place.place.base, projections, ); - debug!("cat_field ret {:?}", ret); + trace!("cat_field ret {:?}", ret); ret } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn cat_overloaded_place( &self, expr: &hir::Expr<'_>, @@ -494,7 +494,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { self.cat_deref(expr, base) } - #[instrument(level = "debug", skip(self, node))] + #[instrument(level = "trace", skip(self, node))] fn cat_deref( &self, node: &impl HirNode, @@ -504,7 +504,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { let deref_ty = match base_curr_ty.builtin_deref(true) { Some(mt) => mt.ty, None => { - debug!("explicit deref of non-derefable type: {:?}", base_curr_ty); + trace!("explicit deref of non-derefable type: {:?}", base_curr_ty); return Err(()); } }; @@ -517,7 +517,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { base_place.place.base, projections, ); - debug!("cat_deref ret {:?}", ret); + trace!("cat_deref ret {:?}", ret); Ok(ret) } @@ -616,7 +616,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { // constructing a `PlaceWithHirId` that represents the path that will be taken // to reach the value being matched. - debug!("cat_pattern(pat={:?}, place_with_id={:?})", pat, place_with_id); + trace!("cat_pattern(pat={:?}, place_with_id={:?})", pat, place_with_id); // If (pattern) adjustments are active for this pattern, adjust the `PlaceWithHirId` correspondingly. // `PlaceWithHirId`s are constructed differently from patterns. For example, in @@ -651,11 +651,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { // `deref { deref { place_foo }}` instead of `place_foo` since the pattern is now `Some(x,)` // and not `&&Some(x,)`, even though its assigned type is that of `&&Some(x,)`. for _ in 0..self.typeck_results.pat_adjustments().get(pat.hir_id).map_or(0, |v| v.len()) { - debug!("cat_pattern: applying adjustment to place_with_id={:?}", place_with_id); + trace!("cat_pattern: applying adjustment to place_with_id={:?}", place_with_id); place_with_id = self.cat_deref(pat, place_with_id)?; } let place_with_id = place_with_id; // lose mutability - debug!("cat_pattern: applied adjustment derefs to get place_with_id={:?}", place_with_id); + trace!("cat_pattern: applied adjustment derefs to get place_with_id={:?}", place_with_id); // Invoke the callback, but only now, after the `place_with_id` has adjusted. // @@ -743,7 +743,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { PatKind::Slice(before, ref slice, after) => { let Some(element_ty) = place_with_id.place.ty().builtin_index() else { - debug!("explicit index of non-indexable type {:?}", place_with_id); + trace!("explicit index of non-indexable type {:?}", place_with_id); return Err(()); }; let elt_place = self.cat_projection( diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 98529b66602fa..a0f85570f2aac 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -51,9 +51,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pick: &probe::Pick<'tcx>, segment: &hir::PathSegment<'_>, ) -> ConfirmResult<'tcx> { - debug!( + trace!( "confirm(unadjusted_self_ty={:?}, pick={:?}, generic_args={:?})", - unadjusted_self_ty, pick, segment.args, + unadjusted_self_ty, + pick, + segment.args, ); let mut confirm_cx = ConfirmContext::new(self, span, self_expr, call_expr); @@ -84,7 +86,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let rcvr_substs = self.fresh_receiver_substs(self_ty, &pick); let all_substs = self.instantiate_method_substs(&pick, segment, rcvr_substs); - debug!("rcvr_substs={rcvr_substs:?}, all_substs={all_substs:?}"); + trace!("rcvr_substs={rcvr_substs:?}, all_substs={all_substs:?}"); // Create the final signature for the method, replacing late-bound regions. let (method_sig, method_predicates) = self.instantiate_method_sig(&pick, all_substs); @@ -110,9 +112,12 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // could alter our Self-type, except for normalizing the receiver from the // signature (which is also done during probing). let method_sig_rcvr = self.normalize(self.span, method_sig.inputs()[0]); - debug!( + trace!( "confirm: self_ty={:?} method_sig_rcvr={:?} method_sig={:?} method_predicates={:?}", - self_ty, method_sig_rcvr, method_sig, method_predicates + self_ty, + method_sig_rcvr, + method_sig, + method_predicates ); self.unify_receivers(self_ty, method_sig_rcvr, &pick, all_substs); @@ -263,9 +268,11 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let upcast_poly_trait_ref = this.upcast(original_poly_trait_ref, trait_def_id); let upcast_trait_ref = this.instantiate_binder_with_fresh_vars(upcast_poly_trait_ref); - debug!( + trace!( "original_poly_trait_ref={:?} upcast_trait_ref={:?} target_trait={:?}", - original_poly_trait_ref, upcast_trait_ref, trait_def_id + original_poly_trait_ref, + upcast_trait_ref, + trait_def_id ); upcast_trait_ref.substs }) @@ -452,7 +459,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { )) }); - debug!("instantiate_method_substs: user_type_annotation={:?}", user_type_annotation); + trace!("instantiate_method_substs: user_type_annotation={:?}", user_type_annotation); self.fcx.write_user_type_annotation(self.call_expr.hir_id, user_type_annotation); } @@ -466,9 +473,12 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { pick: &probe::Pick<'tcx>, substs: SubstsRef<'tcx>, ) { - debug!( + trace!( "unify_receivers: self_ty={:?} method_self_ty={:?} span={:?} pick={:?}", - self_ty, method_self_ty, self.span, pick + self_ty, + method_self_ty, + self.span, + pick ); let cause = self.cause( self.self_expr.span, @@ -510,7 +520,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { pick: &probe::Pick<'tcx>, all_substs: SubstsRef<'tcx>, ) -> (ty::FnSig<'tcx>, ty::InstantiatedPredicates<'tcx>) { - debug!("instantiate_method_sig(pick={:?}, all_substs={:?})", pick, all_substs); + trace!("instantiate_method_sig(pick={:?}, all_substs={:?})", pick, all_substs); // Instantiate the bounds on the method with the // type/early-bound-regions substitutions performed. There can @@ -518,13 +528,13 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let def_id = pick.item.def_id; let method_predicates = self.tcx.predicates_of(def_id).instantiate(self.tcx, all_substs); - debug!("method_predicates after subst = {:?}", method_predicates); + trace!("method_predicates after subst = {:?}", method_predicates); let sig = self.tcx.fn_sig(def_id).subst(self.tcx, all_substs); - debug!("type scheme substituted, sig={:?}", sig); + trace!("type scheme substituted, sig={:?}", sig); let sig = self.instantiate_binder_with_fresh_vars(sig); - debug!("late-bound lifetimes from method instantiated, sig={:?}", sig); + trace!("late-bound lifetimes from method instantiated, sig={:?}", sig); (sig, method_predicates) } @@ -536,9 +546,12 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { method_predicates: ty::InstantiatedPredicates<'tcx>, def_id: DefId, ) { - debug!( + trace!( "add_obligations: fty={:?} all_substs={:?} method_predicates={:?} def_id={:?}", - fty, all_substs, method_predicates, def_id + fty, + all_substs, + method_predicates, + def_id ); // FIXME: could replace with the following, but we already calculated `method_predicates`, diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index 6f4d674ba103b..a6bc668832870 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -91,7 +91,7 @@ pub enum CandidateSource { impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Determines whether the type `self_ty` supports a method name `method_name` or not. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub fn method_exists( &self, method_name: Ident, @@ -126,7 +126,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } /// Adds a suggestion to call the given method to the provided diagnostic. - #[instrument(level = "debug", skip(self, err, call_expr))] + #[instrument(level = "trace", skip(self, err, call_expr))] pub(crate) fn suggest_method_call( &self, err: &mut Diagnostic, @@ -175,7 +175,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// * `call_expr`: the complete method call: (`foo.bar::(...)`) /// * `self_expr`: the self expression (`foo`) /// * `args`: the expressions of the arguments (`a, b + 1, ...`) - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub fn lookup_method( &self, self_ty: Ty<'tcx>, @@ -191,7 +191,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.lint_dot_call_from_2018(self_ty, segment, span, call_expr, self_expr, &pick, args); for import_id in &pick.import_ids { - debug!("used_trait_import: {:?}", import_id); + trace!("used_trait_import: {:?}", import_id); Lrc::get_mut(&mut self.typeck_results.borrow_mut().used_trait_imports) .unwrap() .insert(*import_id); @@ -200,7 +200,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx.check_stability(pick.item.def_id, Some(call_expr.hir_id), span, None); let result = self.confirm_method(span, self_expr, call_expr, self_ty, &pick, segment); - debug!("result = {:?}", result); + trace!("result = {:?}", result); if let Some(span) = result.illegal_sized_bound { let mut needs_mut = false; @@ -254,7 +254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(result.callee) } - #[instrument(level = "debug", skip(self, call_expr))] + #[instrument(level = "trace", skip(self, call_expr))] pub fn lookup_probe( &self, method_name: Ident, @@ -337,7 +337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// In particular, it doesn't really do any probing: it simply constructs /// an obligation for a particular trait with the given self type and checks /// whether that trait is implemented. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(super) fn lookup_method_in_trait( &self, cause: ObligationCause<'tcx>, @@ -361,11 +361,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { obligation: traits::PredicateObligation<'tcx>, substs: &'tcx ty::List>, ) -> Option>> { - debug!(?obligation); + trace!(?obligation); // Now we want to know if this can be matched if !self.predicate_may_hold(&obligation) { - debug!("--> Cannot match obligation"); + trace!("--> Cannot match obligation"); // Cannot be matched, no such method resolution is possible. return None; } @@ -396,7 +396,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }); } - debug!("lookup_in_trait_adjusted: method_item={:?}", method_item); + trace!("lookup_in_trait_adjusted: method_item={:?}", method_item); let mut obligations = vec![]; // Instantiate late-bound regions and substitute the trait @@ -444,9 +444,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Also add an obligation for the method type being well-formed. let method_ty = tcx.mk_fn_ptr(ty::Binder::dummy(fn_sig)); - debug!( + trace!( "lookup_in_trait_adjusted: matched method method_ty={:?} obligation={:?}", - method_ty, obligation + method_ty, + obligation ); obligations.push(traits::Obligation::new( tcx, @@ -457,7 +458,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let callee = MethodCallee { def_id, substs, sig: fn_sig }; - debug!("callee = {:?}", callee); + trace!("callee = {:?}", callee); Some(InferOk { obligations, value: callee }) } @@ -478,7 +479,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// * `self_ty`: the type to search within (`Foo`) /// * `self_ty_span` the span for the type being searched within (span of `Foo`) /// * `expr_id`: the [`hir::HirId`] of the expression composing the entire call - #[instrument(level = "debug", skip(self), ret)] + #[instrument(level = "trace", skip(self), ret)] pub fn resolve_fully_qualified_call( &self, span: Span, @@ -539,12 +540,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &pick, ); - debug!(?pick); + trace!(?pick); { let mut typeck_results = self.typeck_results.borrow_mut(); let used_trait_imports = Lrc::get_mut(&mut typeck_results.used_trait_imports).unwrap(); for import_id in pick.import_ids { - debug!(used_trait_import=?import_id); + trace!(used_trait_import=?import_id); used_trait_imports.insert(import_id); } } diff --git a/compiler/rustc_hir_typeck/src/method/prelude2021.rs b/compiler/rustc_hir_typeck/src/method/prelude2021.rs index ec4e7f7f88af5..867268f7f621a 100644 --- a/compiler/rustc_hir_typeck/src/method/prelude2021.rs +++ b/compiler/rustc_hir_typeck/src/method/prelude2021.rs @@ -26,9 +26,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pick: &Pick<'tcx>, args: &'tcx [hir::Expr<'tcx>], ) { - debug!( + trace!( "lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})", - segment.ident, self_ty, call_expr, self_expr + segment.ident, + self_ty, + call_expr, + self_expr ); // Rust 2021 and later is already using the new prelude diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 9f3d35a77dc75..f138735421824 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -257,7 +257,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// would result in an error (basically, the same criteria we /// would use to decide if a method is a plausible fit for /// ambiguity purposes). - #[instrument(level = "debug", skip(self, candidate_filter))] + #[instrument(level = "trace", skip(self, candidate_filter))] pub fn probe_for_return_type( &self, span: Span, @@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .collect() } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub fn probe_for_name( &self, mode: Mode, @@ -324,7 +324,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(crate) fn probe_for_name_many( &self, mode: Mode, @@ -390,9 +390,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span, ¶m_env_and_self_ty, ); - debug!( + trace!( "probe_op: Mode::Path, param_env_and_self_ty={:?} self_ty={:?}", - param_env_and_self_ty, self_ty + param_env_and_self_ty, + self_ty ); MethodAutoderefStepsResult { steps: infcx.tcx.arena.alloc_from_iter([CandidateStep { @@ -432,7 +433,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(bad_ty) = &steps.opt_bad_ty { if is_suggestion.0 { // Ambiguity was encountered during a suggestion. Just keep going. - debug!("ProbeContext: encountered ambiguity in suggestion"); + trace!("ProbeContext: encountered ambiguity in suggestion"); } else if bad_ty.reached_raw_pointer && !self.tcx.features().arbitrary_self_types { // this case used to be allowed by the compiler, // so we do a future-compat lint here for the 2015 edition @@ -468,7 +469,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - debug!("ProbeContext: steps for self_ty={:?} are {:?}", self_ty, steps); + trace!("ProbeContext: steps for self_ty={:?} are {:?}", self_ty, steps); // this creates one big transaction so that all type variables etc // that we create during the probe process are removed later @@ -504,7 +505,7 @@ fn method_autoderef_steps<'tcx>( tcx: TyCtxt<'tcx>, goal: CanonicalTyGoal<'tcx>, ) -> MethodAutoderefStepsResult<'tcx> { - debug!("method_autoderef_steps({:?})", goal); + trace!("method_autoderef_steps({:?})", goal); let (ref infcx, goal, inference_vars) = tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &goal); let ParamEnvAnd { param_env, value: self_ty } = goal; @@ -557,7 +558,7 @@ fn method_autoderef_steps<'tcx>( _ => None, }; - debug!("method_autoderef_steps: steps={:?} opt_bad_ty={:?}", steps, opt_bad_ty); + trace!("method_autoderef_steps: steps={:?} opt_bad_ty={:?}", steps, opt_bad_ty); MethodAutoderefStepsResult { steps: tcx.arena.alloc_from_iter(steps), @@ -637,7 +638,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { } fn assemble_probe(&mut self, self_ty: &Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>) { - debug!("assemble_probe: self_ty={:?}", self_ty); + trace!("assemble_probe: self_ty={:?}", self_ty); let raw_self_ty = self_ty.value.value; match *raw_self_ty.kind() { ty::Dynamic(data, ..) if let Some(p) = data.principal() => { @@ -721,7 +722,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { return; // already visited } - debug!("assemble_inherent_impl_probe {:?}", impl_def_id); + trace!("assemble_inherent_impl_probe {:?}", impl_def_id); for item in self.impl_or_trait_item(impl_def_id) { if !self.has_applicable_self(&item) { @@ -733,11 +734,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let (impl_ty, impl_substs) = self.impl_ty_and_substs(impl_def_id); let impl_ty = impl_ty.subst(self.tcx, impl_substs); - debug!("impl_ty: {:?}", impl_ty); + trace!("impl_ty: {:?}", impl_ty); // Determine the receiver type that the method itself expects. let (xform_self_ty, xform_ret_ty) = self.xform_self_ty(item, impl_ty, impl_substs); - debug!("xform_self_ty: {:?}, xform_ret_ty: {:?}", xform_self_ty, xform_ret_ty); + trace!("xform_self_ty: {:?}, xform_ret_ty: {:?}", xform_self_ty, xform_ret_ty); // We can't use normalize_associated_types_in as it will pollute the // fcx's fulfillment context after this probe is over. @@ -752,9 +753,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let InferOk { value: xform_self_ty, obligations } = self.fcx.at(&cause, self.param_env).normalize(xform_self_ty); - debug!( + trace!( "assemble_inherent_impl_probe after normalization: xform_self_ty = {:?}/{:?}", - xform_self_ty, xform_ret_ty + xform_self_ty, + xform_ret_ty ); self.push_candidate( @@ -771,7 +773,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { } fn assemble_inherent_candidates_from_object(&mut self, self_ty: Ty<'tcx>) { - debug!("assemble_inherent_candidates_from_object(self_ty={:?})", self_ty); + trace!("assemble_inherent_candidates_from_object(self_ty={:?})", self_ty); let principal = match self_ty.kind() { ty::Dynamic(ref data, ..) => Some(data), @@ -821,7 +823,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) { // FIXME: do we want to commit to this behavior for param bounds? - debug!("assemble_inherent_candidates_from_param(param_ty={:?})", param_ty); + trace!("assemble_inherent_candidates_from_param(param_ty={:?})", param_ty); let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| { let bound_predicate = predicate.kind(); @@ -885,7 +887,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { { let tcx = self.tcx; for bound_trait_ref in traits::transitive_bounds(tcx, bounds) { - debug!("elaborate_bounds(bound_trait_ref={:?})", bound_trait_ref); + trace!("elaborate_bounds(bound_trait_ref={:?})", bound_trait_ref); for item in self.impl_or_trait_item(bound_trait_ref.def_id()) { if !self.has_applicable_self(&item) { self.record_static_candidate(CandidateSource::Trait(bound_trait_ref.def_id())); @@ -953,7 +955,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { import_ids: &SmallVec<[LocalDefId; 1]>, trait_def_id: DefId, ) { - debug!("assemble_extension_candidates_for_trait(trait_def_id={:?})", trait_def_id); + trace!("assemble_extension_candidates_for_trait(trait_def_id={:?})", trait_def_id); let trait_substs = self.fresh_item_substs(trait_def_id); let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, trait_substs); @@ -999,7 +1001,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { for item in self.impl_or_trait_item(trait_def_id) { // Check whether `trait_def_id` defines a method with suitable name. if !self.has_applicable_self(&item) { - debug!("method has inapplicable self"); + trace!("method has inapplicable self"); self.record_static_candidate(CandidateSource::Trait(trait_def_id)); continue; } @@ -1065,7 +1067,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { return r; } - debug!("pick: actual search failed, assemble diagnostics"); + trace!("pick: actual search failed, assemble diagnostics"); let static_candidates = std::mem::take(self.static_candidates.get_mut()); let private_candidate = self.private_candidate.take(); @@ -1126,7 +1128,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { self.steps .iter() .filter(|step| { - debug!("pick_all_method: step={:?}", step); + trace!("pick_all_method: step={:?}", step); // skip types that are from a type error or that would require dereferencing // a raw pointer !step.self_ty.references_error() && !step.from_unsafe_deref @@ -1260,14 +1262,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { self_ty: Ty<'tcx>, mut unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>, ) -> Option> { - debug!("pick_method(self_ty={})", self.ty_to_string(self_ty)); + trace!("pick_method(self_ty={})", self.ty_to_string(self_ty)); let mut possibly_unsatisfied_predicates = Vec::new(); for (kind, candidates) in &[("inherent", &self.inherent_candidates), ("extension", &self.extension_candidates)] { - debug!("searching {} candidates", kind); + trace!("searching {} candidates", kind); let res = self.consider_candidates( self_ty, candidates, @@ -1306,7 +1308,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { .filter(|&(_, status)| status != ProbeResult::NoMatch) .collect(); - debug!("applicable_candidates: {:?}", applicable_candidates); + trace!("applicable_candidates: {:?}", applicable_candidates); if applicable_candidates.len() > 1 { if let Some(pick) = @@ -1482,7 +1484,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { Option>, )>, ) -> ProbeResult { - debug!("consider_probe: self_ty={:?} probe={:?}", self_ty, probe); + trace!("consider_probe: self_ty={:?} probe={:?}", self_ty, probe); self.probe(|_| { // First check that the self type can be related. @@ -1493,14 +1495,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { ) { Ok(InferOk { obligations, value: () }) => obligations, Err(err) => { - debug!("--> cannot relate self-types {:?}", err); + trace!("--> cannot relate self-types {:?}", err); return ProbeResult::NoMatch; } }; let mut result = ProbeResult::Match; let mut xform_ret_ty = probe.xform_ret_ty; - debug!(?xform_ret_ty); + trace!(?xform_ret_ty); let cause = traits::ObligationCause::misc(self.span, self.body_id); @@ -1520,7 +1522,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { obligations: normalization_obligations, } = self.fcx.at(&cause, self.param_env).normalize(xform_ret_ty); xform_ret_ty = normalized_xform_ret_ty; - debug!("xform_ret_ty after normalization: {:?}", xform_ret_ty); + trace!("xform_ret_ty after normalization: {:?}", xform_ret_ty); // Check whether the impl imposes obligations we have to worry about. let impl_def_id = probe.item.container_id(self.tcx); @@ -1677,7 +1679,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { obligations: normalization_obligations, } = self.fcx.at(&cause, self.param_env).normalize(xform_ret_ty); xform_ret_ty = normalized_xform_ret_ty; - debug!("xform_ret_ty after normalization: {:?}", xform_ret_ty); + trace!("xform_ret_ty after normalization: {:?}", xform_ret_ty); // Evaluate those obligations to see if they might possibly hold. for o in normalization_obligations { let o = self.resolve_vars_if_possible(o); @@ -1692,7 +1694,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { } } - debug!( + trace!( "comparing return_ty {:?} with xform ret ty {:?}", return_ty, xform_ret_ty ); @@ -1758,7 +1760,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { /// candidate method where the method name may have been misspelled. Similarly to other /// edit distance based suggestions, we provide at most one such suggestion. fn probe_for_similar_candidate(&mut self) -> Result, MethodError<'tcx>> { - debug!("probing for method names similar to {:?}", self.method_name); + trace!("probing for method names similar to {:?}", self.method_name); self.probe(|_| { let mut pcx = ProbeContext::new( @@ -1839,7 +1841,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { self.static_candidates.borrow_mut().push(source); } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn xform_self_ty( &self, item: ty::AssocItem, @@ -1854,10 +1856,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { } } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn xform_method_sig(&self, method: DefId, substs: SubstsRef<'tcx>) -> ty::FnSig<'tcx> { let fn_sig = self.tcx.fn_sig(method); - debug!(?fn_sig); + trace!(?fn_sig); assert!(!substs.has_escaping_bound_vars()); diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 9ee967dc7a97e..f2d9501c0c6d3 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -105,7 +105,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.autoderef(span, ty).any(|(ty, _)| matches!(ty.kind(), ty::Slice(..) | ty::Array(..))) } - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub fn report_method_error( &self, span: Span, @@ -1692,7 +1692,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// if `rect` is a local variable and `area` is a valid assoc method for it, /// we try to suggest `rect.area()` pub(crate) fn suggest_assoc_method_call(&self, segs: &[PathSegment<'_>]) { - debug!("suggest_assoc_method_call segs: {:?}", segs); + trace!("suggest_assoc_method_call segs: {:?}", segs); let [seg1, seg2] = segs else { return; }; let Some(mut diag) = self.tcx.sess.diagnostic().steal_diagnostic(seg1.ident.span, StashKey::CallAssocMethod) @@ -2281,7 +2281,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let method_exists = self.method_exists(item_name, output_ty, call.hir_id, true, return_type); - debug!("suggest_await_before_method: is_method_exist={}", method_exists); + trace!("suggest_await_before_method: is_method_exist={}", method_exists); if method_exists { err.span_suggestion_verbose( span.shrink_to_lo(), @@ -2399,9 +2399,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let mut alt_rcvr_sugg = false; if let (SelfSource::MethodCall(rcvr), false) = (source, unsatisfied_bounds) { - debug!( + trace!( "suggest_traits_to_import: span={:?}, item_name={:?}, rcvr_ty={:?}, rcvr={:?}", - span, item_name, rcvr_ty, rcvr + span, + item_name, + rcvr_ty, + rcvr ); let skippable = [ self.tcx.lang_items().clone_trait(), @@ -2465,7 +2468,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return_type, ) { - debug!("try_alt_rcvr: pick candidate {:?}", pick); + trace!("try_alt_rcvr: pick candidate {:?}", pick); let did = Some(pick.item.container_id(self.tcx)); // We don't want to suggest a container type when the missing // method is `.clone()` or `.deref()` otherwise we'd suggest diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index b8bf2b6912039..e28f858e4ac26 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -93,9 +93,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { let tcx = self.tcx; - debug!( + trace!( "check_binop(expr.hir_id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})", - expr.hir_id, expr, op, lhs_expr, rhs_expr + expr.hir_id, + expr, + op, + lhs_expr, + rhs_expr ); match BinOpCategory::from(op) { @@ -205,9 +209,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { is_assign: IsAssign, expected: Expectation<'tcx>, ) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) { - debug!( + trace!( "check_overloaded_binop(expr.hir_id={}, op={:?}, is_assign={:?})", - expr.hir_id, op, is_assign + expr.hir_id, + op, + is_assign ); let lhs_ty = match is_assign { @@ -727,9 +733,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return Err(vec![]); }; - debug!( + trace!( "lookup_op_method(lhs_ty={:?}, op={:?}, opname={:?}, trait_did={:?})", - lhs_ty, op, opname, trait_did + lhs_ty, + op, + opname, + trait_did ); // Catches cases like #83893, where a lang item is declared with the diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 5af955d313482..23448e0a73c9c 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -151,7 +151,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// /// Outside of this module, `check_pat_top` should always be used. /// Conversely, inside this module, `check_pat_top` should never be used. - #[instrument(level = "debug", skip(self, ti))] + #[instrument(level = "trace", skip(self, ti))] fn check_pat( &self, pat: &'tcx Pat<'tcx>, @@ -347,9 +347,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // See the examples in `ui/match-defbm*.rs`. let mut pat_adjustments = vec![]; while let ty::Ref(_, inner_ty, inner_mutability) = *expected.kind() { - debug!("inspecting {:?}", expected); + trace!("inspecting {:?}", expected); - debug!("current discriminant is Ref, inserting implicit deref"); + trace!("current discriminant is Ref, inserting implicit deref"); // Preserve the reference type. We'll need it later during THIR lowering. pat_adjustments.push(expected); @@ -367,7 +367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if !pat_adjustments.is_empty() { - debug!("default binding mode is now {:?}", def_bm); + trace!("default binding mode is now {:?}", def_bm); self.inh .typeck_results .borrow_mut() @@ -592,7 +592,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // ...and store it in a side table: self.inh.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm); - debug!("check_pat_ident: pat.hir_id={:?} bm={:?}", pat.hir_id, bm); + trace!("check_pat_ident: pat.hir_id={:?} bm={:?}", pat.hir_id, bm); let local_ty = self.local_ty(pat.span, pat.hir_id).decl_ty; let eq_ty = match bm { @@ -703,7 +703,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && let PatKind::Binding(_, _, binding, ..) = inner.kind { let binding_parent_id = tcx.hir().parent_id(pat.hir_id); let binding_parent = tcx.hir().get(binding_parent_id); - debug!(?inner, ?pat, ?binding_parent); + trace!(?inner, ?pat, ?binding_parent); let mutability = match mutbl { ast::Mutability::Mut => "mut", @@ -1984,7 +1984,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Take region, inner-type from expected type if we can, // to avoid creating needless variables. This also helps with // the bad interactions of the given hack detailed in (note_1). - debug!("check_pat_ref: expected={:?}", expected); + trace!("check_pat_ref: expected={:?}", expected); match *expected.kind() { ty::Ref(_, r_ty, r_mutbl) if r_mutbl == mutbl => (expected, r_ty), _ => { @@ -1993,7 +1993,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span: inner.span, }); let ref_ty = self.new_ref_ty(pat.span, mutbl, inner_ty); - debug!("check_pat_ref: demanding {:?} = {:?}", expected, ref_ty); + trace!("check_pat_ref: demanding {:?} = {:?}", expected, ref_ty); let err = self.demand_eqtype_pat_diag(pat.span, expected, ref_ty, ti); // Look for a case like `fn foo(&foo: u32)` and suggest diff --git a/compiler/rustc_hir_typeck/src/place_op.rs b/compiler/rustc_hir_typeck/src/place_op.rs index e2b1dc007ba6d..bbb454f41ded1 100644 --- a/compiler/rustc_hir_typeck/src/place_op.rs +++ b/compiler/rustc_hir_typeck/src/place_op.rs @@ -108,10 +108,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> { let adjusted_ty = self.structurally_resolved_type(autoderef.span(), autoderef.final_ty(false)); - debug!( + trace!( "try_index_step(expr={:?}, base_expr={:?}, adjusted_ty={:?}, \ index_ty={:?})", - expr, base_expr, adjusted_ty, index_ty + expr, + base_expr, + adjusted_ty, + index_ty ); if let hir::ExprKind::Unary( @@ -155,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.try_overloaded_place_op(expr.span, self_ty, &[input_ty], PlaceOp::Index); if let Some(result) = method { - debug!("try_index_step: success, using overloaded indexing"); + trace!("try_index_step: success, using overloaded indexing"); let method = self.register_infer_ok_obligations(result); let mut adjustments = self.adjust_steps(autoderef); @@ -198,7 +201,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { arg_tys: &[Ty<'tcx>], op: PlaceOp, ) -> Option>> { - debug!("try_overloaded_place_op({:?},{:?},{:?})", span, base_ty, op); + trace!("try_overloaded_place_op({:?},{:?},{:?})", span, base_ty, op); let (Some(imm_tr), imm_op) = (match op { PlaceOp::Deref => (self.tcx.lang_items().deref_trait(), sym::deref), @@ -238,7 +241,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { arg_tys: &[Ty<'tcx>], op: PlaceOp, ) -> Option>> { - debug!("try_mutable_overloaded_place_op({:?},{:?},{:?})", span, base_ty, op); + trace!("try_mutable_overloaded_place_op({:?},{:?},{:?})", span, base_ty, op); let (Some(mut_tr), mut_op) = (match op { PlaceOp::Deref => (self.tcx.lang_items().deref_mut_trait(), sym::deref_mut), @@ -289,12 +292,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { exprs.push(expr); } - debug!("convert_place_derefs_to_mutable: exprs={:?}", exprs); + trace!("convert_place_derefs_to_mutable: exprs={:?}", exprs); // Fix up autoderefs and derefs. let mut inside_union = false; for (i, &expr) in exprs.iter().rev().enumerate() { - debug!("convert_place_derefs_to_mutable: i={} expr={:?}", i, expr); + trace!("convert_place_derefs_to_mutable: i={} expr={:?}", i, expr); let mut source = self.node_ty(expr.hir_id); if matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::Deref, _)) { @@ -365,9 +368,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &hir::Expr<'_>, base_expr: &hir::Expr<'_>, ) { - debug!("convert_place_op_to_mutable({:?}, {:?}, {:?})", op, expr, base_expr); + trace!("convert_place_op_to_mutable({:?}, {:?}, {:?})", op, expr, base_expr); if !self.typeck_results.borrow().is_method_call(expr) { - debug!("convert_place_op_to_mutable - builtin, nothing to do"); + trace!("convert_place_op_to_mutable - builtin, nothing to do"); return; } @@ -402,7 +405,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // current, immutable version. None => return, }; - debug!("convert_place_op_to_mutable: method={:?}", method); + trace!("convert_place_op_to_mutable: method={:?}", method); self.write_method_call(expr.hir_id, method); let ty::Ref(region, _, hir::Mutability::Mut) = method.sig.inputs()[0].kind() else { @@ -418,7 +421,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut source = base_expr_ty; for adjustment in &mut adjustments[..] { if let Adjust::Borrow(AutoBorrow::Ref(..)) = adjustment.kind { - debug!("convert_place_op_to_mutable: converting autoref {:?}", adjustment); + trace!("convert_place_op_to_mutable: converting autoref {:?}", adjustment); let mutbl = AutoBorrowMutability::Mut { // Deref/indexing can be desugared to a method call, // so maybe we could use two-phase here. diff --git a/compiler/rustc_hir_typeck/src/rvalue_scopes.rs b/compiler/rustc_hir_typeck/src/rvalue_scopes.rs index 22c9e7961070c..c0442ef00db2e 100644 --- a/compiler/rustc_hir_typeck/src/rvalue_scopes.rs +++ b/compiler/rustc_hir_typeck/src/rvalue_scopes.rs @@ -54,7 +54,7 @@ fn record_rvalue_scope( expr: &hir::Expr<'_>, candidate: &RvalueCandidateType, ) { - debug!("resolve_rvalue_scope(expr={expr:?}, candidate={candidate:?})"); + trace!("resolve_rvalue_scope(expr={expr:?}, candidate={candidate:?})"); match candidate { RvalueCandidateType::Borrow { lifetime, .. } | RvalueCandidateType::Pattern { lifetime, .. } => { @@ -71,8 +71,8 @@ pub fn resolve_rvalue_scopes<'a, 'tcx>( let tcx = &fcx.tcx; let hir_map = tcx.hir(); let mut rvalue_scopes = RvalueScopes::new(); - debug!("start resolving rvalue scopes, def_id={def_id:?}"); - debug!("rvalue_scope: rvalue_candidates={:?}", scope_tree.rvalue_candidates); + trace!("start resolving rvalue scopes, def_id={def_id:?}"); + trace!("rvalue_scope: rvalue_candidates={:?}", scope_tree.rvalue_candidates); for (&hir_id, candidate) in &scope_tree.rvalue_candidates { let Some(Node::Expr(expr)) = hir_map.find(hir_id) else { bug!("hir node does not exist") diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 9458099f56ff9..6f1070edaa5bb 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -157,7 +157,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, 'tcx> { impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Analysis starting point. - #[instrument(skip(self, body), level = "debug")] + #[instrument(skip(self, body), level = "trace")] fn analyze_closure( &self, closure_hir_id: hir::HirId, @@ -208,9 +208,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) .consume_body(body); - debug!( + trace!( "For closure={:?}, capture_information={:#?}", - closure_def_id, delegate.capture_information + closure_def_id, + delegate.capture_information ); self.log_capture_analysis_first_pass(closure_def_id, &delegate.capture_information, span); @@ -237,7 +238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for var_hir_id in upvars.keys() { let place = self.place_for_root_variable(closure_def_id, *var_hir_id); - debug!("seed place {:?}", place); + trace!("seed place {:?}", place); let capture_kind = self.init_capture_kind_for_place(&place, capture_clause); let fake_info = ty::CaptureInfo { @@ -293,9 +294,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Equate the type variables for the upvars with the actual types. let final_upvar_tys = self.final_upvar_tys(closure_def_id); - debug!( + trace!( "analyze_closure: id={:?} substs={:?} final_upvar_tys={:?}", - closure_hir_id, substs, final_upvar_tys + closure_hir_id, + substs, + final_upvar_tys ); // Build a tuple (U0..Un) of the final upvar types U0..Un @@ -337,9 +340,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let upvar_ty = captured_place.place.ty(); let capture = captured_place.info.capture_kind; - debug!( + trace!( "final_upvar_tys: place={:?} upvar_ty={:?} capture={:?}, mutability={:?}", - captured_place.place, upvar_ty, capture, captured_place.mutability, + captured_place.place, + upvar_ty, + capture, + captured_place.mutability, ); apply_capture_kind_on_capture_ty(self.tcx, upvar_ty, capture, captured_place.region) @@ -654,9 +660,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - debug!( + trace!( "For closure={:?}, min_captures before sorting={:?}", - closure_def_id, root_var_min_capture_list + closure_def_id, + root_var_min_capture_list ); // Now that we have the minimized list of captures, sort the captures by field id. @@ -722,9 +729,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }); } - debug!( + trace!( "For closure={:?}, min_captures after sorting={:#?}", - closure_def_id, root_var_min_capture_list + closure_def_id, + root_var_min_capture_list ); typeck_results.closure_min_captures.insert(closure_def_id, root_var_min_capture_list); } @@ -1037,7 +1045,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// /// This function only returns a HashSet of CapturesInfo for significant drops. If there /// are no significant drops than None is returned - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn compute_2229_migrations_for_drop( &self, closure_def_id: LocalDefId, @@ -1049,7 +1057,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ty = self.resolve_vars_if_possible(self.node_ty(var_hir_id)); if !ty.has_significant_drop(self.tcx, self.tcx.param_env(closure_def_id)) { - debug!("does not have significant drop"); + trace!("does not have significant drop"); return None; } @@ -1062,7 +1070,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // let _ = y; // }); // ``` - debug!("no path starting from it is used"); + trace!("no path starting from it is used"); match closure_clause { @@ -1079,7 +1087,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return None; }; - debug!(?root_var_min_capture_list); + trace!(?root_var_min_capture_list); let mut projections_list = Vec::new(); let mut diagnostics_info = FxHashSet::default(); @@ -1098,15 +1106,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - debug!(?projections_list); - debug!(?diagnostics_info); + trace!(?projections_list); + trace!(?diagnostics_info); let is_moved = !projections_list.is_empty(); - debug!(?is_moved); + trace!(?is_moved); let is_not_completely_captured = root_var_min_capture_list.iter().any(|capture| !capture.place.projections.is_empty()); - debug!(?is_not_completely_captured); + trace!(?is_not_completely_captured); if is_moved && is_not_completely_captured @@ -1139,7 +1147,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Returns a tuple containing a vector of MigrationDiagnosticInfo, as well as a String /// containing the reason why root variables whose HirId is contained in the vector should /// be captured - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn compute_2229_migrations( &self, closure_def_id: LocalDefId, @@ -1630,14 +1638,14 @@ fn restrict_repr_packed_field_ref_capture<'tcx>( Ok(layout) if layout.align.abi.bytes() == 1 => { // if the alignment is 1, the type can't be further // disaligned. - debug!( + trace!( "restrict_repr_packed_field_ref_capture: ({:?}) - align = 1", place ); false } _ => { - debug!("restrict_repr_packed_field_ref_capture: ({:?}) - true", place); + trace!("restrict_repr_packed_field_ref_capture: ({:?}) - true", place); true } } @@ -1753,7 +1761,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { self.fake_reads.push((place, cause, diag_expr_id)); } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) { let PlaceBase::Upvar(upvar_id) = place_with_id.place.base else { return }; assert_eq!(self.closure_def_id, upvar_id.closure_expr_id); @@ -1768,7 +1776,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { )); } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn borrow( &mut self, place_with_id: &PlaceWithHirId<'tcx>, @@ -1806,7 +1814,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> { )); } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) { self.borrow(assignee_place, diag_expr_id, ty::BorrowKind::MutBorrow); } @@ -1996,7 +2004,7 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { tcx.hir().name(var_hir_id) } -#[instrument(level = "debug", skip(tcx))] +#[instrument(level = "trace", skip(tcx))] fn should_do_rust_2021_incompatible_closure_captures_analysis( tcx: TyCtxt<'_>, closure_id: hir::HirId, diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index 0f21fc1e66238..d3f1bc032f013 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -76,13 +76,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let used_trait_imports = mem::take(&mut self.typeck_results.borrow_mut().used_trait_imports); - debug!("used_trait_imports({:?}) = {:?}", item_def_id, used_trait_imports); + trace!("used_trait_imports({:?}) = {:?}", item_def_id, used_trait_imports); wbcx.typeck_results.used_trait_imports = used_trait_imports; wbcx.typeck_results.treat_byte_string_as_slice = mem::take(&mut self.typeck_results.borrow_mut().treat_byte_string_as_slice); - debug!("writeback: typeck results for {:?} are {:#?}", item_def_id, wbcx.typeck_results); + trace!("writeback: typeck results for {:?} are {:#?}", item_def_id, wbcx.typeck_results); self.tcx.arena.alloc(wbcx.typeck_results) } @@ -136,7 +136,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) { - debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty); + trace!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty); assert!(!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions()); self.typeck_results.node_types_mut().insert(hir_id, ty); } @@ -555,7 +555,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn visit_opaque_types(&mut self) { let opaque_types = self.fcx.infcx.take_opaque_types(); for (opaque_type_key, decl) in opaque_types { @@ -613,7 +613,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } } - #[instrument(skip(self, span), level = "debug")] + #[instrument(skip(self, span), level = "trace")] fn visit_node_id(&mut self, span: Span, hir_id: hir::HirId) { // Export associated path extensions and method resolutions. if let Some(def) = @@ -629,44 +629,44 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { let n_ty = self.fcx.node_ty(hir_id); let n_ty = self.resolve(n_ty, &span); self.write_ty_to_typeck_results(hir_id, n_ty); - debug!(?n_ty); + trace!(?n_ty); // Resolve any substitutions if let Some(substs) = self.fcx.typeck_results.borrow().node_substs_opt(hir_id) { let substs = self.resolve(substs, &span); - debug!("write_substs_to_tcx({:?}, {:?})", hir_id, substs); + trace!("write_substs_to_tcx({:?}, {:?})", hir_id, substs); assert!(!substs.has_infer() && !substs.has_placeholders()); self.typeck_results.node_substs_mut().insert(hir_id, substs); } } - #[instrument(skip(self, span), level = "debug")] + #[instrument(skip(self, span), level = "trace")] fn visit_adjustments(&mut self, span: Span, hir_id: hir::HirId) { let adjustment = self.fcx.typeck_results.borrow_mut().adjustments_mut().remove(hir_id); match adjustment { None => { - debug!("no adjustments for node"); + trace!("no adjustments for node"); } Some(adjustment) => { let resolved_adjustment = self.resolve(adjustment, &span); - debug!(?resolved_adjustment); + trace!(?resolved_adjustment); self.typeck_results.adjustments_mut().insert(hir_id, resolved_adjustment); } } } - #[instrument(skip(self, span), level = "debug")] + #[instrument(skip(self, span), level = "trace")] fn visit_pat_adjustments(&mut self, span: Span, hir_id: hir::HirId) { let adjustment = self.fcx.typeck_results.borrow_mut().pat_adjustments_mut().remove(hir_id); match adjustment { None => { - debug!("no pat_adjustments for node"); + trace!("no pat_adjustments for node"); } Some(adjustment) => { let resolved_adjustment = self.resolve(adjustment, &span); - debug!(?resolved_adjustment); + trace!(?resolved_adjustment); self.typeck_results.pat_adjustments_mut().insert(hir_id, resolved_adjustment); } } @@ -830,7 +830,7 @@ impl<'cx, 'tcx> TypeFolder> for Resolver<'cx, 'tcx> { EraseEarlyRegions { tcx: self.fcx.tcx }.fold_ty(t) } Err(_) => { - debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t); + trace!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t); let e = self.report_error(t); self.replaced_with_error = Some(e); self.fcx.tcx.ty_error(e) @@ -847,7 +847,7 @@ impl<'cx, 'tcx> TypeFolder> for Resolver<'cx, 'tcx> { match self.fcx.fully_resolve(ct) { Ok(ct) => self.fcx.tcx.erase_regions(ct), Err(_) => { - debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct); + trace!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct); let e = self.report_error(ct); self.replaced_with_error = Some(e); self.fcx.tcx.const_error(ct.ty(), e) diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index bf53a73f3983c..599416cda945f 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -358,7 +358,7 @@ impl<'cx, 'tcx> TypeFolder> for Canonicalizer<'cx, 'tcx> { .borrow_mut() .unwrap_region_constraints() .opportunistic_resolve_var(self.tcx, vid); - debug!( + trace!( "canonical: region var found with vid {vid:?}, \ opportunistically resolved to {resolved:?}", ); @@ -386,11 +386,11 @@ impl<'cx, 'tcx> TypeFolder> for Canonicalizer<'cx, 'tcx> { vid = root_vid; } - debug!("canonical: type var found with vid {:?}", vid); + trace!("canonical: type var found with vid {:?}", vid); match self.infcx.probe_ty_var(vid) { // `t` could be a float / int variable; canonicalize that instead. Ok(t) => { - debug!("(resolved to {:?})", t); + trace!("(resolved to {:?})", t); self.fold_ty(t) } @@ -501,10 +501,10 @@ impl<'cx, 'tcx> TypeFolder> for Canonicalizer<'cx, 'tcx> { vid = root_vid; } - debug!("canonical: const var found with vid {:?}", vid); + trace!("canonical: const var found with vid {:?}", vid); match self.infcx.probe_const_var(vid) { Ok(c) => { - debug!("(resolved to {:?})", c); + trace!("(resolved to {:?})", c); return self.fold_const(c); } diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 2cf8d8c702d46..bbeee9f16b1ca 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -63,9 +63,9 @@ impl<'tcx> InferCtxt<'tcx> { Canonical<'tcx, QueryResponse<'tcx, T>>: ArenaAllocatable<'tcx>, { let query_response = self.make_query_response(inference_vars, answer, fulfill_cx)?; - debug!("query_response = {:#?}", query_response); + trace!("query_response = {:#?}", query_response); let canonical_result = self.canonicalize_response(query_response); - debug!("canonical_result = {:#?}", canonical_result); + trace!("canonical_result = {:#?}", canonical_result); Ok(self.tcx.arena.alloc(canonical_result)) } @@ -98,7 +98,7 @@ impl<'tcx> InferCtxt<'tcx> { /// Helper for `make_canonicalized_query_response` that does /// everything up until the final canonicalization. - #[instrument(skip(self, fulfill_cx), level = "debug")] + #[instrument(skip(self, fulfill_cx), level = "trace")] fn make_query_response( &self, inference_vars: CanonicalVarValues<'tcx>, @@ -112,20 +112,20 @@ impl<'tcx> InferCtxt<'tcx> { // Select everything, returning errors. let true_errors = fulfill_cx.select_where_possible(self); - debug!("true_errors = {:#?}", true_errors); + trace!("true_errors = {:#?}", true_errors); if !true_errors.is_empty() { // FIXME -- we don't indicate *why* we failed to solve - debug!("make_query_response: true_errors={:#?}", true_errors); + trace!("make_query_response: true_errors={:#?}", true_errors); return Err(NoSolution); } // Anything left unselected *now* must be an ambiguity. let ambig_errors = fulfill_cx.select_all_or_error(self); - debug!("ambig_errors = {:#?}", ambig_errors); + trace!("ambig_errors = {:#?}", ambig_errors); let region_obligations = self.take_registered_region_obligations(); - debug!(?region_obligations); + trace!(?region_obligations); let region_constraints = self.with_region_constraints(|region_constraints| { make_query_region_constraints( tcx, @@ -135,7 +135,7 @@ impl<'tcx> InferCtxt<'tcx> { region_constraints, ) }); - debug!(?region_constraints); + trace!(?region_constraints); let certainty = if ambig_errors.is_empty() { Certainty::Proven } else { Certainty::Ambiguous }; @@ -368,9 +368,10 @@ impl<'tcx> InferCtxt<'tcx> { where R: Debug + TypeFoldable>, { - debug!( + trace!( "query_response_substitution(original_values={:#?}, query_response={:#?})", - original_values, query_response, + original_values, + query_response, ); let mut value = self.query_response_substitution_guess( @@ -403,7 +404,7 @@ impl<'tcx> InferCtxt<'tcx> { /// will instantiate fresh inference variables for each canonical /// variable instead. Therefore, the result of this method must be /// properly unified - #[instrument(level = "debug", skip(self, cause, param_env))] + #[instrument(level = "trace", skip(self, cause, param_env))] fn query_response_substitution_guess( &self, cause: &ObligationCause<'tcx>, @@ -508,7 +509,7 @@ impl<'tcx> InferCtxt<'tcx> { for &(a, b) in &query_response.value.opaque_types { let a = substitute_value(self.tcx, &result_subst, a); let b = substitute_value(self.tcx, &result_subst, b); - debug!(?a, ?b, "constrain opaque type"); + trace!(?a, ?b, "constrain opaque type"); // We use equate here instead of, for example, just registering the // opaque type's hidden value directly, because we may be instantiating // a query response that was canonicalized in an InferCtxt that had @@ -660,7 +661,7 @@ pub fn make_query_region_constraints<'tcx>( assert!(verifys.is_empty()); - debug!(?constraints); + trace!(?constraints); let outlives: Vec<_> = constraints .iter() diff --git a/compiler/rustc_log/Cargo.toml b/compiler/rustc_log/Cargo.toml index 7f955b0a75090..797fa1d87db73 100644 --- a/compiler/rustc_log/Cargo.toml +++ b/compiler/rustc_log/Cargo.toml @@ -13,4 +13,4 @@ tracing-core = "0.1.28" rustc_span = { path = "../rustc_span" } [features] -max_level_info = ['tracing/max_level_info'] +max_level_debug = ['tracing/max_level_debug'] diff --git a/compiler/rustc_mir_build/src/build/block.rs b/compiler/rustc_mir_build/src/build/block.rs index ab4cd24881f6a..8326342794d73 100644 --- a/compiler/rustc_mir_build/src/build/block.rs +++ b/compiler/rustc_mir_build/src/build/block.rs @@ -331,7 +331,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block.unit() })); - debug!("ast_block_stmts: pattern={:?}", pattern); + trace!("ast_block_stmts: pattern={:?}", pattern); this.visit_primary_bindings( pattern, UserTypeProjections::none(), @@ -396,7 +396,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// If we are entering an unsafe block, create a new source scope fn update_source_scope_for_safety_mode(&mut self, span: Span, safety_mode: BlockSafety) { - debug!("update_source_scope_for({:?}, {:?})", span, safety_mode); + trace!("update_source_scope_for({:?}, {:?})", span, safety_mode); let new_unsafety = match safety_mode { BlockSafety::Safe => return, BlockSafety::BuiltinUnsafe => Safety::BuiltinUnsafe, diff --git a/compiler/rustc_mir_build/src/build/cfg.rs b/compiler/rustc_mir_build/src/build/cfg.rs index 4f1623b4c6a7c..4df07777ec246 100644 --- a/compiler/rustc_mir_build/src/build/cfg.rs +++ b/compiler/rustc_mir_build/src/build/cfg.rs @@ -27,7 +27,7 @@ impl<'tcx> CFG<'tcx> { } pub(crate) fn push(&mut self, block: BasicBlock, statement: Statement<'tcx>) { - debug!("push({:?}, {:?})", block, statement); + trace!("push({:?}, {:?})", block, statement); self.block_data_mut(block).statements.push(statement); } @@ -107,7 +107,7 @@ impl<'tcx> CFG<'tcx> { source_info: SourceInfo, kind: TerminatorKind<'tcx>, ) { - debug!("terminating block {:?} <- {:?}", block, kind); + trace!("terminating block {:?} <- {:?}", block, kind); debug_assert!( self.block_data(block).terminator.is_none(), "terminate: block {:?}={:?} already has a terminator set", diff --git a/compiler/rustc_mir_build/src/build/custom/parse.rs b/compiler/rustc_mir_build/src/build/custom/parse.rs index 803207d9dc664..0d721e35ff181 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse.rs @@ -34,7 +34,7 @@ macro_rules! parse_by_kind { ) => {{ let expr_id = $self.preparse($expr_id); let expr = &$self.thir[expr_id]; - debug!("Trying to parse {:?} as {}", expr.kind, $expected); + trace!("Trying to parse {:?} as {}", expr.kind, $expected); let $expr_name = expr; match &expr.kind { $( diff --git a/compiler/rustc_mir_build/src/build/expr/as_operand.rs b/compiler/rustc_mir_build/src/build/expr/as_operand.rs index 744111edb84e4..25fdd374ed551 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_operand.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_operand.rs @@ -96,7 +96,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// Like `as_local_call_operand`, except that the argument will /// not be valid once `scope` ends. - #[instrument(level = "debug", skip(self, scope))] + #[instrument(level = "trace", skip(self, scope))] pub(crate) fn as_operand( &mut self, mut block: BasicBlock, @@ -116,7 +116,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } let category = Category::of(&expr.kind).unwrap(); - debug!(?category, ?expr.kind); + trace!(?category, ?expr.kind); match category { Category::Constant if matches!(needs_temporary, NeedsTemporary::No) @@ -146,7 +146,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scope: Option, expr: &Expr<'tcx>, ) -> BlockAnd> { - debug!("as_call_operand(block={:?}, expr={:?})", block, expr); + trace!("as_call_operand(block={:?}, expr={:?})", block, expr); let this = self; if let ExprKind::Scope { region_scope, lint_level, value } = expr.kind { diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index 7ec57add66b59..886ce43d997db 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -189,7 +189,7 @@ fn to_upvars_resolved_place_builder<'tcx>( projection ) } else { - debug!( + trace!( "No associated capture found for {:?}[{:#?}]", var_hir_id, projection, ); @@ -408,7 +408,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { mutability: Mutability, fake_borrow_temps: Option<&mut Vec>, ) -> BlockAnd> { - debug!("expr_as_place(block={:?}, expr={:?}, mutability={:?})", block, expr, mutability); + trace!("expr_as_place(block={:?}, expr={:?}, mutability={:?})", block, expr, mutability); let this = self; let expr_span = expr.span; diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 3742d640e3b58..d63593c07b423 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -42,7 +42,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scope: Option, expr: &Expr<'tcx>, ) -> BlockAnd> { - debug!("expr_as_rvalue(block={:?}, scope={:?}, expr={:?})", block, scope, expr); + trace!("expr_as_rvalue(block={:?}, scope={:?}, expr={:?})", block, scope, expr); let this = self; let expr_span = expr.span; @@ -296,7 +296,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }; let from_ty = CastTy::from_ty(ty); let cast_ty = CastTy::from_ty(expr.ty); - debug!("ExprKind::Cast from_ty={from_ty:?}, cast_ty={:?}/{cast_ty:?}", expr.ty,); + trace!("ExprKind::Cast from_ty={from_ty:?}, cast_ty={:?}/{cast_ty:?}", expr.ty,); let cast_kind = mir_cast_kind(ty, expr.ty); block.and(Rvalue::Cast(cast_kind, source, expr.ty)) } diff --git a/compiler/rustc_mir_build/src/build/expr/as_temp.rs b/compiler/rustc_mir_build/src/build/expr/as_temp.rs index c8910c272b1bb..ea6cee5170c8c 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_temp.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_temp.rs @@ -23,7 +23,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ensure_sufficient_stack(|| self.as_temp_inner(block, temp_lifetime, expr, mutability)) } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn as_temp_inner( &mut self, mut block: BasicBlock, @@ -48,7 +48,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { local_decl = local_decl.immutable(); } - debug!("creating temp {:?} with block_context: {:?}", local_decl, this.block_context); + trace!("creating temp {:?} with block_context: {:?}", local_decl, this.block_context); let local_info = match expr.kind { ExprKind::StaticRef { def_id, .. } => { assert!(!this.tcx.is_thread_local_static(def_id)); diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 29ff916d2cc9c..13241f52a93d9 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -14,7 +14,7 @@ use std::iter; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr`, storing the result into `destination`, which /// is assumed to be uninitialized. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] pub(crate) fn expr_into_dest( &mut self, destination: Place<'tcx>, @@ -259,7 +259,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { this.record_operands_moved(&args); - debug!("expr_into_dest: fn_span={:?}", fn_span); + trace!("expr_into_dest: fn_span={:?}", fn_span); this.cfg.terminate( block, diff --git a/compiler/rustc_mir_build/src/build/expr/stmt.rs b/compiler/rustc_mir_build/src/build/expr/stmt.rs index ea5aeb67d8576..5b6ff770e16b6 100644 --- a/compiler/rustc_mir_build/src/build/expr/stmt.rs +++ b/compiler/rustc_mir_build/src/build/expr/stmt.rs @@ -34,7 +34,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // is better for borrowck interaction with overloaded // operators like x[j] = x[i]. - debug!("stmt_expr Assign block_context.push(SubExpr) : {:?}", expr); + trace!("stmt_expr Assign block_context.push(SubExpr) : {:?}", expr); this.block_context.push(BlockFrame::SubExpr); // Generate better code for things that don't need to be @@ -65,7 +65,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let rhs = &this.thir[rhs]; let lhs_ty = lhs.ty; - debug!("stmt_expr AssignOp block_context.push(SubExpr) : {:?}", expr); + trace!("stmt_expr AssignOp block_context.push(SubExpr) : {:?}", expr); this.block_context.push(BlockFrame::SubExpr); // As above, RTL. diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 6df06df5c60f4..fc81c869729bc 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -155,7 +155,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// * From each pre-binding block to the next pre-binding block. /// * From each otherwise block to the next pre-binding block. - #[instrument(level = "debug", skip(self, arms))] + #[instrument(level = "trace", skip(self, arms))] pub(crate) fn match_expr( &mut self, destination: Place<'tcx>, @@ -327,7 +327,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let arm_end_blocks: Vec<_> = arm_candidates .into_iter() .map(|(arm, candidate)| { - debug!("lowering arm {:?}\ncandidate = {:?}", arm, candidate); + trace!("lowering arm {:?}\ncandidate = {:?}", arm, candidate); let arm_source_info = self.source_info(arm.span); let arm_scope = (arm.scope, arm_source_info); @@ -636,7 +636,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// scope for the bindings in these patterns, if such a scope had to be /// created. NOTE: Declaring the bindings should always be done in their /// drop scope. - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] pub(crate) fn declare_bindings( &mut self, mut visibility_scope: Option, @@ -726,9 +726,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { UserTypeProjections, ), ) { - debug!( + trace!( "visit_primary_bindings: pattern={:?} pattern_user_ty={:?}", - pattern, pattern_user_ty + pattern, + pattern_user_ty ); match pattern.kind { PatKind::Binding { @@ -799,7 +800,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { PatKind::Leaf { ref subpatterns } => { for subpattern in subpatterns { let subpattern_user_ty = pattern_user_ty.clone().leaf(subpattern.field); - debug!("visit_primary_bindings: subpattern_user_ty={:?}", subpattern_user_ty); + trace!("visit_primary_bindings: subpattern_user_ty={:?}", subpattern_user_ty); self.visit_primary_bindings(&subpattern.pattern, subpattern_user_ty, f); } } @@ -1039,7 +1040,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// if `x.0` matches `false` (for the third arm). In the (impossible at /// runtime) case when `x.0` is now `true`, we branch to /// `otherwise_block`. - #[instrument(skip(self, fake_borrows), level = "debug")] + #[instrument(skip(self, fake_borrows), level = "trace")] fn match_candidates<'pat>( &mut self, span: Span, @@ -1100,7 +1101,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // higher priority candidates (and hence at the front of the slice) // have satisfied all their match pairs. let fully_matched = candidates.iter().take_while(|c| c.match_pairs.is_empty()).count(); - debug!("match_candidates: {:?} candidates fully matched", fully_matched); + trace!("match_candidates: {:?} candidates fully matched", fully_matched); let (matched_candidates, unmatched_candidates) = candidates.split_at_mut(fully_matched); let block = if !matched_candidates.is_empty() { @@ -1239,7 +1240,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - debug!( + trace!( "match_candidates: add pre_binding_blocks for unreachable {:?}", unreachable_candidates, ); @@ -1368,7 +1369,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { #[instrument( skip(self, otherwise, or_span, place, fake_borrows, candidate, pats), - level = "debug" + level = "trace" )] fn test_or_pattern<'pat>( &mut self, @@ -1379,7 +1380,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { place: &PlaceBuilder<'tcx>, fake_borrows: &mut Option>>, ) { - debug!("candidate={:#?}\npats={:#?}", candidate, pats); + trace!("candidate={:#?}\npats={:#?}", candidate, pats); let mut or_candidates: Vec<_> = pats .iter() .map(|pat| Candidate::new(place.clone(), pat, candidate.has_guard, self)) @@ -1604,7 +1605,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // those N possible outcomes, create a (initially empty) // vector of candidates. Those are the candidates that still // apply if the test has that particular outcome. - debug!("test_candidates: test={:?} match_pair={:?}", test, match_pair); + trace!("test_candidates: test={:?} match_pair={:?}", test, match_pair); let mut target_candidates: Vec>> = vec![]; target_candidates.resize_with(test.targets(), Default::default); @@ -1629,8 +1630,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { total_candidate_count, candidates ); - debug!("tested_candidates: {}", total_candidate_count - candidates.len()); - debug!("untested_candidates: {}", candidates.len()); + trace!("tested_candidates: {}", total_candidate_count - candidates.len()); + trace!("untested_candidates: {}", candidates.len()); // HACK(matthewjasper) This is a closure so that we can let the test // create its blocks before the rest of the match. This currently @@ -1716,7 +1717,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) -> Vec<(Place<'tcx>, Local)> { let tcx = self.tcx; - debug!("add_fake_borrows fake_borrows = {:?}", fake_borrows); + trace!("add_fake_borrows fake_borrows = {:?}", fake_borrows); let mut all_fake_borrows = Vec::with_capacity(fake_borrows.len()); @@ -1741,7 +1742,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let mut dedup = FxHashSet::default(); all_fake_borrows.retain(|b| dedup.insert(*b)); - debug!("add_fake_borrows all_fake_borrows = {:?}", all_fake_borrows); + trace!("add_fake_borrows all_fake_borrows = {:?}", all_fake_borrows); all_fake_borrows .into_iter() @@ -1831,7 +1832,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { schedule_drops: bool, storages_alive: bool, ) -> BasicBlock { - debug!("bind_and_guard_matched_candidate(candidate={:?})", candidate); + trace!("bind_and_guard_matched_candidate(candidate={:?})", candidate); debug_assert!(candidate.match_pairs.is_empty()); @@ -1953,7 +1954,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let guard_frame = GuardFrame { locals: bindings.map(|b| GuardFrameLocal::new(b.var_id, b.binding_mode)).collect(), }; - debug!("entering guard building context: {:?}", guard_frame); + trace!("entering guard building context: {:?}", guard_frame); self.guard_context.push(guard_frame); let re_erased = tcx.lifetimes.re_erased; @@ -1988,7 +1989,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let source_info = self.source_info(guard_span); let guard_end = self.source_info(tcx.sess.source_map().end_point(guard_span)); let guard_frame = self.guard_context.pop().unwrap(); - debug!("Exiting guard building context with locals: {:?}", guard_frame); + trace!("Exiting guard building context with locals: {:?}", guard_frame); for &(_, temp) in fake_borrows { let cause = FakeReadCause::ForMatchGuard; @@ -2106,14 +2107,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) where 'tcx: 'b, { - debug!("bind_matched_candidate_for_guard(block={:?})", block); + trace!("bind_matched_candidate_for_guard(block={:?})", block); // Assign each of the bindings. Since we are binding for a // guard expression, this will never trigger moves out of the // candidate. let re_erased = self.tcx.lifetimes.re_erased; for binding in bindings { - debug!("bind_matched_candidate_for_guard(binding={:?})", binding); + trace!("bind_matched_candidate_for_guard(binding={:?})", binding); let source_info = self.source_info(binding.span); // For each pattern ident P of type T, `ref_for_guard` is @@ -2159,7 +2160,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) where 'tcx: 'b, { - debug!("bind_matched_candidate_for_arm_body(block={:?})", block); + trace!("bind_matched_candidate_for_arm_body(block={:?})", block); let re_erased = self.tcx.lifetimes.re_erased; // Assign each of the bindings. This may trigger moves out of the candidate. @@ -2197,7 +2198,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// first local is a binding for occurrences of `var` in the guard, which /// will have type `&T`. The second local is a binding for occurrences of /// `var` in the arm body, which will have type `T`. - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn declare_binding( &mut self, source_info: SourceInfo, @@ -2269,7 +2270,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } else { LocalsForNode::One(for_arm_body) }; - debug!(?locals); + trace!(?locals); self.var_indices.insert(var_id, locals); } diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index f6b1955fdec4d..e60728d15724d 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -37,13 +37,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// only generates a single switch. If this happens this method returns /// `true`. - #[instrument(skip(self, candidate), level = "debug")] + #[instrument(skip(self, candidate), level = "trace")] pub(super) fn simplify_candidate<'pat>( &mut self, candidate: &mut Candidate<'pat, 'tcx>, ) -> bool { // repeatedly simplify match pairs until fixed point is reached - debug!("{candidate:#?}"); + trace!("{candidate:#?}"); // existing_bindings and new_bindings exists to keep the semantics in order. // Reversing the binding order for bindings after `@` changes the binding order in places @@ -114,7 +114,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { candidate .match_pairs .sort_by_key(|pair| matches!(pair.pattern.kind, PatKind::Or { .. })); - debug!(simplified = ?candidate, "simplify_candidate"); + trace!(simplified = ?candidate, "simplify_candidate"); return false; // if we were not able to simplify any, done. } } diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index dbdb5b4a9a179..efe65423d2a17 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -144,7 +144,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - #[instrument(skip(self, make_target_blocks, place_builder), level = "debug")] + #[instrument(skip(self, make_target_blocks, place_builder), level = "trace")] pub(super) fn perform_test( &mut self, match_start_span: Span, @@ -156,7 +156,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) { let place = place_builder.to_place(self); let place_ty = place.ty(&self.local_decls, self.tcx); - debug!(?place, ?place_ty,); + trace!(?place, ?place_ty,); let source_info = self.source_info(test.span); match test.kind { @@ -189,7 +189,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }), otherwise_block, ); - debug!("num_enum_variants: {}, variants: {:?}", num_enum_variants, variants); + trace!("num_enum_variants: {}, variants: {:?}", num_enum_variants, variants); let discr_ty = adt_def.repr().discr_type().to_ty(tcx); let discr = self.temp(discr_ty, test.span); self.cfg.push_assign( diff --git a/compiler/rustc_mir_build/src/build/misc.rs b/compiler/rustc_mir_build/src/build/misc.rs index 90d78658f9683..3696efdf92b54 100644 --- a/compiler/rustc_mir_build/src/build/misc.rs +++ b/compiler/rustc_mir_build/src/build/misc.rs @@ -19,7 +19,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // user's code resulting in ICEs from the generator transform. let temp = self.local_decls.push(LocalDecl::new(ty, span).internal()); let place = Place::from(temp); - debug!("temp: created temp {:?} with type {:?}", place, self.local_decls[temp].ty); + trace!("temp: created temp {:?} with type {:?}", place, self.local_decls[temp].ty); place } diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 7c0fbc6f81c94..1439c74fe139d 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -283,7 +283,7 @@ impl DropTree { cfg: &mut CFG<'tcx>, blocks: &mut IndexVec>, ) { - debug!("DropTree::build_mir(drops = {:#?})", self); + trace!("DropTree::build_mir(drops = {:#?})", self); assert_eq!(blocks.len(), self.drops.len()); self.assign_blocks::(cfg, blocks); @@ -353,7 +353,7 @@ impl DropTree { } } - debug!("assign_blocks: blocks = {:#?}", blocks); + trace!("assign_blocks: blocks = {:#?}", blocks); assert!(entry_points.is_empty()); } @@ -411,7 +411,7 @@ impl<'tcx> Scopes<'tcx> { } fn push_scope(&mut self, region_scope: (region::Scope, SourceInfo), vis_scope: SourceScope) { - debug!("push_scope({:?})", region_scope); + trace!("push_scope({:?})", region_scope); self.scopes.push(Scope { source_scope: vis_scope, region_scope: region_scope.0, @@ -543,7 +543,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { where F: FnOnce(&mut Builder<'a, 'tcx>) -> BlockAnd, { - debug!("in_opt_scope(opt_scope={:?})", opt_scope); + trace!("in_opt_scope(opt_scope={:?})", opt_scope); if let Some(region_scope) = opt_scope { self.push_scope(region_scope); } @@ -552,13 +552,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let Some(region_scope) = opt_scope { unpack!(block = self.pop_scope(region_scope, block)); } - debug!("in_scope: exiting opt_scope={:?} block={:?}", opt_scope, block); + trace!("in_scope: exiting opt_scope={:?} block={:?}", opt_scope, block); block.and(rv) } /// Convenience wrapper that pushes a scope and then executes `f` /// to build its contents, popping the scope afterwards. - #[instrument(skip(self, f), level = "debug")] + #[instrument(skip(self, f), level = "trace")] pub(crate) fn in_scope( &mut self, region_scope: (region::Scope, SourceInfo), @@ -579,7 +579,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let rv = unpack!(block = f(self)); unpack!(block = self.pop_scope(region_scope, block)); self.source_scope = source_scope; - debug!(?block); + trace!(?block); block.and(rv) } @@ -599,7 +599,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { region_scope: (region::Scope, SourceInfo), mut block: BasicBlock, ) -> BlockAnd<()> { - debug!("pop_scope({:?}, {:?})", region_scope, block); + trace!("pop_scope({:?}, {:?})", region_scope, block); block = self.leave_top_scope(block); @@ -647,7 +647,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { match (destination, value) { (Some(destination), Some(value)) => { - debug!("stmt_expr Break val block_context.push(SubExpr)"); + trace!("stmt_expr Break val block_context.push(SubExpr)"); self.block_context.push(BlockFrame::SubExpr); unpack!(block = self.expr_into_dest(destination, block, value)); self.block_context.pop(); @@ -790,7 +790,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { safety: Option, ) -> SourceScope { let parent = self.source_scope; - debug!( + trace!( "new_source_scope({:?}, {:?}, {:?}) - parent({:?})={:?}", span, lint_level, @@ -1208,7 +1208,7 @@ fn build_scope_drops<'tcx>( storage_dead_on_unwind: bool, arg_count: usize, ) -> BlockAnd<()> { - debug!("build_scope_drops({:?} -> {:?})", block, scope); + trace!("build_scope_drops({:?} -> {:?})", block, scope); // Build up the drops in evaluation order. The end result will // look like: diff --git a/compiler/rustc_mir_build/src/thir/cx/block.rs b/compiler/rustc_mir_build/src/thir/cx/block.rs index a46ad6423a037..67e96ba02d9c2 100644 --- a/compiler/rustc_mir_build/src/thir/cx/block.rs +++ b/compiler/rustc_mir_build/src/thir/cx/block.rs @@ -79,13 +79,13 @@ impl<'tcx> Cx<'tcx> { let else_block = local.els.map(|els| self.mirror_block(els)); let mut pattern = self.pattern_from_hir(local.pat); - debug!(?pattern); + trace!(?pattern); if let Some(ty) = &local.ty { if let Some(&user_ty) = self.typeck_results.user_provided_types().get(ty.hir_id) { - debug!("mirror_stmts: user_ty={:?}", user_ty); + trace!("mirror_stmts: user_ty={:?}", user_ty); let annotation = CanonicalUserTypeAnnotation { user_ty: Box::new(user_ty), span: ty.span, diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index b20495d602e59..3dceb2a9b72b6 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -262,7 +262,7 @@ impl<'tcx> Cx<'tcx> { } } - #[instrument(level = "debug", skip(self), ret)] + #[instrument(level = "trace", skip(self), ret)] fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> { let tcx = self.tcx; let expr_ty = self.typeck_results().expr_ty(expr); @@ -374,7 +374,7 @@ impl<'tcx> Cx<'tcx> { } Box::new(u_ty) }); - debug!("make_mirror_unadjusted: (call) user_ty={:?}", user_ty); + trace!("make_mirror_unadjusted: (call) user_ty={:?}", user_ty); let field_refs = args .iter() @@ -508,7 +508,7 @@ impl<'tcx> Cx<'tcx> { AdtKind::Struct | AdtKind::Union => { let user_provided_types = self.typeck_results().user_provided_types(); let user_ty = user_provided_types.get(expr.hir_id).copied().map(Box::new); - debug!("make_mirror_unadjusted: (struct/union) user_ty={:?}", user_ty); + trace!("make_mirror_unadjusted: (struct/union) user_ty={:?}", user_ty); ExprKind::Adt(Box::new(AdtExpr { adt_def: *adt, variant_index: FIRST_VARIANT, @@ -535,7 +535,7 @@ impl<'tcx> Cx<'tcx> { self.typeck_results().user_provided_types(); let user_ty = user_provided_types.get(expr.hir_id).copied().map(Box::new); - debug!("make_mirror_unadjusted: (variant) user_ty={:?}", user_ty); + trace!("make_mirror_unadjusted: (variant) user_ty={:?}", user_ty); ExprKind::Adt(Box::new(AdtExpr { adt_def: *adt, variant_index: index, @@ -749,9 +749,11 @@ impl<'tcx> Cx<'tcx> { let user_provided_types = self.typeck_results.user_provided_types(); let user_ty = user_provided_types.get(cast_ty.hir_id); - debug!( + trace!( "cast({:?}) has ty w/ hir_id {:?} and user provided ty {:?}", - expr, cast_ty.hir_id, user_ty, + expr, + cast_ty.hir_id, + user_ty, ); let cast = self.mirror_expr_cast(*source, temp_lifetime, expr.span); @@ -765,7 +767,7 @@ impl<'tcx> Cx<'tcx> { span: expr.span, kind: cast, }); - debug!("make_mirror_unadjusted: (cast) user_ty={:?}", user_ty); + trace!("make_mirror_unadjusted: (cast) user_ty={:?}", user_ty); ExprKind::ValueTypeAscription { source: cast_expr, @@ -778,7 +780,7 @@ impl<'tcx> Cx<'tcx> { hir::ExprKind::Type(ref source, ref ty) => { let user_provided_types = self.typeck_results.user_provided_types(); let user_ty = user_provided_types.get(ty.hir_id).copied().map(Box::new); - debug!("make_mirror_unadjusted: (type) user_ty={:?}", user_ty); + trace!("make_mirror_unadjusted: (type) user_ty={:?}", user_ty); let mirrored = self.mirror_expr(source); if source.is_syntactic_place_expr() { ExprKind::PlaceTypeAscription { source: mirrored, user_ty } @@ -806,7 +808,7 @@ impl<'tcx> Cx<'tcx> { hir_id: hir::HirId, res: Res, ) -> Option>> { - debug!("user_substs_applied_to_res: res={:?}", res); + trace!("user_substs_applied_to_res: res={:?}", res); let user_provided_type = match res { // A reference to something callable -- e.g., a fn, method, or // a tuple-struct or tuple-variant. This has the type of a @@ -832,7 +834,7 @@ impl<'tcx> Cx<'tcx> { _ => bug!("user_substs_applied_to_res: unexpected res {:?} at {:?}", res, hir_id), }; - debug!("user_substs_applied_to_res: user_provided_type={:?}", user_provided_type); + trace!("user_substs_applied_to_res: user_provided_type={:?}", user_provided_type); user_provided_type } @@ -852,7 +854,7 @@ impl<'tcx> Cx<'tcx> { span_bug!(expr.span, "no type-dependent def for method callee") }); let user_ty = self.user_substs_applied_to_res(expr.hir_id, Res::Def(kind, def_id)); - debug!("method_callee: user_ty={:?}", user_ty); + trace!("method_callee: user_ty={:?}", user_ty); ( self.tcx().mk_fn_def(def_id, self.typeck_results().node_substs(expr.hir_id)), user_ty, @@ -909,7 +911,7 @@ impl<'tcx> Cx<'tcx> { Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id) => { let user_provided_types = self.typeck_results.user_provided_types(); let user_ty = user_provided_types.get(expr.hir_id).copied().map(Box::new); - debug!("convert_path_expr: user_ty={:?}", user_ty); + trace!("convert_path_expr: user_ty={:?}", user_ty); let ty = self.typeck_results().node_type(expr.hir_id); match ty.kind() { // A unit struct/variant which is used as a value. @@ -958,9 +960,11 @@ impl<'tcx> Cx<'tcx> { .upvars_mentioned(self.body_owner) .is_some_and(|upvars| upvars.contains_key(&var_hir_id)); - debug!( + trace!( "convert_var({:?}): is_upvar={}, body_owner={:?}", - var_hir_id, is_upvar, self.body_owner + var_hir_id, + is_upvar, + self.body_owner ); if is_upvar { diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index edddfda624242..d37c6b6c2c8a4 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -92,20 +92,20 @@ impl SerializedDepGraph { impl<'a, K: DepKind + Decodable>> Decodable> for SerializedDepGraph { - #[instrument(level = "debug", skip(d))] + #[instrument(level = "trace", skip(d))] fn decode(d: &mut MemDecoder<'a>) -> SerializedDepGraph { // The last 16 bytes are the node count and edge count. - debug!("position: {:?}", d.position()); + trace!("position: {:?}", d.position()); let (node_count, edge_count) = d.with_position(d.len() - 2 * IntEncodedWithFixedSize::ENCODED_SIZE, |d| { - debug!("position: {:?}", d.position()); + trace!("position: {:?}", d.position()); let node_count = IntEncodedWithFixedSize::decode(d).0 as usize; let edge_count = IntEncodedWithFixedSize::decode(d).0 as usize; (node_count, edge_count) }); - debug!("position: {:?}", d.position()); + trace!("position: {:?}", d.position()); - debug!(?node_count, ?edge_count); + trace!(?node_count, ?edge_count); let mut nodes = IndexVec::with_capacity(node_count); let mut fingerprints = IndexVec::with_capacity(node_count); @@ -207,11 +207,11 @@ impl EncoderState { let node_count = total_node_count.try_into().unwrap(); let edge_count = total_edge_count.try_into().unwrap(); - debug!(?node_count, ?edge_count); - debug!("position: {:?}", encoder.position()); + trace!(?node_count, ?edge_count); + trace!("position: {:?}", encoder.position()); IntEncodedWithFixedSize(node_count).encode(&mut encoder); IntEncodedWithFixedSize(edge_count).encode(&mut encoder); - debug!("position: {:?}", encoder.position()); + trace!("position: {:?}", encoder.position()); // Drop the encoder so that nothing is written after the counts. let result = encoder.finish(); if let Ok(position) = result { diff --git a/compiler/rustc_traits/src/evaluate_obligation.rs b/compiler/rustc_traits/src/evaluate_obligation.rs index f5b2753b7973d..286d8739ffc3f 100644 --- a/compiler/rustc_traits/src/evaluate_obligation.rs +++ b/compiler/rustc_traits/src/evaluate_obligation.rs @@ -17,14 +17,14 @@ fn evaluate_obligation<'tcx>( canonical_goal: CanonicalPredicateGoal<'tcx>, ) -> Result { assert!(!tcx.trait_solver_next()); - debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal); + trace!("evaluate_obligation(canonical_goal={:#?})", canonical_goal); // HACK This bubble is required for this tests to pass: // impl-trait/issue99642.rs let (ref infcx, goal, _canonical_inference_vars) = tcx .infer_ctxt() .with_opaque_type_inference(DefiningAnchor::Bubble) .build_with_canonical(DUMMY_SP, &canonical_goal); - debug!("evaluate_obligation: goal={:#?}", goal); + trace!("evaluate_obligation: goal={:#?}", goal); let ParamEnvAnd { param_env, value: predicate } = goal; let mut selcx = SelectionContext::with_query_mode(&infcx, TraitQueryMode::Canonical); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f7d30de67ebab..2157783e95fee 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -767,7 +767,7 @@ impl Build { // if its unset, if debug_assertions is on, then debug_logging will also be on // as well as tracing *ignoring* this feature when debug_assertions is on if !self.config.rust_debug_logging { - features.push("max_level_info"); + features.push("max_level_debug"); } features.join(" ")