Skip to content

refactor: In alter_ty_path, return on failed unpack#1820

Open
Rua wants to merge 1 commit into
immunant:masterfrom
Rua:unpack-else
Open

refactor: In alter_ty_path, return on failed unpack#1820
Rua wants to merge 1 commit into
immunant:masterfrom
Rua:unpack-else

Conversation

@Rua
Copy link
Copy Markdown
Contributor

@Rua Rua commented May 22, 2026

This is a fix, but I don't know if it's actually the correct fix.

}

unpack!([&mut t.kind] TyKind::Path(qself, path));
unpack!([&mut t.kind] TyKind::Path(qself, path); return);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silencing errors isn't really the way to fix issues, let's investigate this.

Any idea why a type would appear as hir::TyKind::Path in the HIR, but as an Rptr in the AST? Maybe an alias? Could you print out which type this is?

Copy link
Copy Markdown
Contributor Author

@Rua Rua May 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I printed out qpath when t.kind isn't TyKind::Path:

if !matches!(t.kind, TyKind::Path(..)) {
    panic!("{qpath:?}");
}

and got:

Resolved(
    None,
    Path {
        span: Span {
            lo: BytePos(129233),
            hi: BytePos(129242),
            ctxt: #57
        },
        res: PrimTy(
            Bool
        ),
        segments: [
            PathSegment {
                ident: bool#57,
                hir_id: HirId {
                    owner: OwnerId {
                        def_id: DefId {
                            krate: crate0,
                            index: DefIndex(
                                50254
                            )
                        }
                    },
                    local_id: 25
                },
                res: PrimTy(
                    Bool
                ),
                args: None,
                infer_args: false
            }
        ]
    }
)

So it's... bool? Not sure how to make sense of that one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random thought: if the refactorer is making modifications to the AST, what happens to the HIR? Is it modified in parallel? If not, what keeps the two in sync? Could that be the issue here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactorer crashes if the processed code has derive(PartialEq, Eq)

2 participants