Reading issue
rust-lang / rust · Issue No. 160542
Reproduced on the recent main (1ed2df61a19042f231709eb05d032ae9e2cb2084).
In mentioned file, in resolve_implementation function I did the following changes:
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs
index fc723586c1a..1e8126dc2b0 100644
--- a/compiler/rustc_resolve/src/late.rs
+++ b/compiler/rustc_resolve/src/late.rs
@@ -3501,7 +3501,7 @@ fn resolve_implementation(
) {
debug!("resolve_implementation");
// If applicable, create a rib for the type parameters.
- self.with_generic_param_rib(
+ self. with_generic_param_rib(
&generics.params,
RibKind::Item(HasGenericParams::Yes(generics.span), self.r.tcx.def_kind(self.r.current_owner.def_id)),
item_id,
Next, I run ./x t tidy (and with --bless flag) but this formatting error is not fixed or spotted.
Building bootstrap
Finished `dev` profile [unoptimized] target(s) in 0.07s
Building stage1 tidy (stage0 -> stage1, x86_64-pc-windows-msvc)
Finished `release` profile [optimized + debuginfo] target(s) in 0.27s
fmt check
fmt: checked modified file compiler\rustc_resolve\src\late.rs
tidy check
tidy: All tidy checks succeeded
x.py completions check
x.py help check
Build completed successfully in 0:00:07
If nesting of this function is reduced then it works fine:
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs
index fc723586c1a..f7808e10100 100644
--- a/compiler/rustc_resolve/src/late.rs
+++ b/compiler/rustc_resolve/src/late.rs
@@ -3501,21 +3501,13 @@ fn resolve_implementation(
) {
debug!("resolve_implementation");
// If applicable, create a rib for the type parameters.
- self.with_generic_param_rib(
+ self. with_generic_param_rib(
&generics.params,
RibKind::Item(HasGenericParams::Yes(generics.span), self.r.tcx.def_kind(self.r.current_owner.def_id)),
item_id,
LifetimeBinderKind::ImplBlock,
generics.span,
|this| {
- // Dummy self type for better errors if `Self` is used in the trait path.
- this.with_self_rib(Res::SelfTyParam { trait_: LOCAL_CRATE.as_def_id() }, |this| {
- this.with_lifetime_rib(
- LifetimeRibKind::AnonymousCreateParameter {
- binder: item_id,
- report_in_path: true
- },
- |this| {
// Resolve the trait reference, if necessary.
this.with_optional_trait_ref(
of_trait.map(|t| &t.trait_ref),
@@ -3566,9 +3558,6 @@ fn resolve_implementation(
)
},
);
- });
- },
- );
}
fn resolve_impl_item(
Output of `./x t tidy`Building bootstrap
Finished `dev` profile [unoptimized] target(s) in 0.10s
Building stage1 tidy (stage0 -> stage1, x86_64-pc-windows-msvc)
Finished `release` profile [optimized + debuginfo] target(s) in 0.31s
fmt check
fmt: checked modified file compiler\rustc_resolve\src\late.rs
Diff in \\?\C:\work\rust\compiler\rustc_resolve\src\late.rs:3501:
) {
debug!("resolve_implementation");
// If applicable, create a rib for the type parameters.
- self. with_generic_param_rib(
+ self.with_generic_param_rib(
&generics.params,
- RibKind::Item(HasGenericParams::Yes(generics.span), self.r.tcx.def_kind(self.r.current_owner.def_id)),
+ RibKind::Item(
+ HasGenericParams::Yes(generics.span),
+ self.r.tcx.def_kind(self.r.current_owner.def_id),
+ ),
item_id,
LifetimeBinderKind::ImplBlock,
generics.span,
Diff in \\?\C:\work\rust\compiler\rustc_resolve\src\late.rs:3510:
|this| {
- // Resolve the trait reference, if necessary.
- this.with_optional_trait_ref(
- of_trait.map(|t| &t.trait_ref),
- self_type,
- |this, trait_id| {
- this.resolve_doc_links(attrs, MaybeExported::Impl(trait_id));
+ // Resolve the trait reference, if necessary.
+ this.with_optional_trait_ref(
+ of_trait.map(|t| &t.trait_ref),
+ self_type,
+ |this, trait_id| {
+ this.resolve_doc_links(attrs, MaybeExported::Impl(trait_id));
- let item_def_id = this.r.current_owner.def_id;
+ let item_def_id = this.r.current_owner.def_id;
- // Register the trait definitions from here.
- if let Some(trait_id) = trait_id {
- this.r
- .trait_impls
- .entry(trait_id)
- .or_default()
- .push(item_def_id);
- }
+ // Register the trait definitions from here.
+ if let Some(trait_id) = trait_id {
+ this.r.trait_impls.entry(trait_id).or_default().push(item_def_id);
+ }
- let item_def_id = item_def_id.to_def_id();
- let res = Res::SelfTyAlias {
- alias_to: item_def_id,
- is_trait_impl: trait_id.is_some(),
- };
- this.with_self_rib(res, |this| {
- if let Some(of_trait) = of_trait {
- // Resolve type arguments in the trait path.
- visit::walk_trait_ref(this, &of_trait.trait_ref);
- }
- // Resolve the self type.
- this.visit_ty(self_type);
- // Resolve the generic parameters.
- this.visit_generics(generics);
+ let item_def_id = item_def_id.to_def_id();
+ let res = Res::SelfTyAlias {
+ alias_to: item_def_id,
+ is_trait_impl: trait_id.is_some(),
+ };
+ this.with_self_rib(res, |this| {
+ if let Some(of_trait) = of_trait {
+ // Resolve type arguments in the trait path.
+ visit::walk_trait_ref(this, &of_trait.trait_ref);
+ }
+ // Resolve the self type.
+ this.visit_ty(self_type);
+ // Resolve the generic parameters.
+ this.visit_generics(generics);
- // Resolve the items within the impl.
- this.with_current_self_type(self_type, |this| {
- this.with_self_rib_ns(ValueNS, Res::SelfCtor(item_def_id), |this| {
- debug!("resolve_implementation with_self_rib_ns(ValueNS, ...)");
- let mut seen_trait_items = Default::default();
- for item in impl_items {
- with_owner(this, item.id, |this| {
- this.resolve_impl_item(&**item, &mut seen_trait_items, trait_id, of_trait.is_some());
- })
- }
- });
- });
- });
- },
- )
- },
- );
+ // Resolve the items within the impl.
+ this.with_current_self_type(self_type, |this| {
+ this.with_self_rib_ns(
+ ValueNS,
+ Res::SelfCtor(item_def_id),
+ |this| {
+ debug!(
+ "resolve_implementation with_self_rib_ns(ValueNS, ...)"
+ );
+ let mut seen_trait_items = Default::default();
+ for item in impl_items {
+ with_owner(this, item.id, |this| {
+ this.resolve_impl_item(
+ &**item,
+ &mut seen_trait_items,
+ trait_id,
+ of_trait.is_some(),
+ );
+ })
+ }
+ },
+ );
+ });
+ });
+ },
+ )
+ },
+ );
}
fn resolve_impl_item(
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.