Skip to content

Conversation

@Lysxia
Copy link
Collaborator

@Lysxia Lysxia commented Oct 27, 2025

Weird: I'm getting warnings about unused variables for all logic functions. Reason: the unused variables lint now works on MIR rust-lang/rust#142390

@jhjourdan
Copy link
Collaborator

Are you sure adding the allow attribute is the right solution?

@jhjourdan
Copy link
Collaborator

I mean, this implies that we will never leverage unused warnings in pearlite.

@Lysxia
Copy link
Collaborator Author

Lysxia commented Oct 27, 2025

No I'm not sure yet. I'm still just trying stuff out.

@Lysxia
Copy link
Collaborator Author

Lysxia commented Oct 28, 2025

My current plan is to make Pearlite go through the liveness analysis in MIR. The challenge is to dodge the borrow checker. We currently do that by removing the code of Pearlite closures, but now I need to find a way to put it back.

@jhjourdan
Copy link
Collaborator

Could you explain the problem?

@Lysxia
Copy link
Collaborator Author

Lysxia commented Oct 28, 2025

The liveness analysis is what enables the unused_variables warning. Before, it was performed on HIR (or THIR, I'm not sure), but now it is performed on MIR, after borrow checking. Since we remove Pearlite code from MIR before borrow checking, all Pearlite variables are now considered unused. This includes parameters of all logic functions. This results in a lot of spurious warnings.

@xldenis
Copy link
Collaborator

xldenis commented Oct 28, 2025

it seems like it should be possible to perform the lowering to mir, run the liveness analysis ourselves for error reporting but then continue to no-op the body in queries to trick borrowck.

@jhjourdan
Copy link
Collaborator

Is that liveness analysis the same as the one used in borrowck? If so, we should be careful not to break borrowck by providing it inconsistent information.

@Lysxia
Copy link
Collaborator Author

Lysxia commented Oct 29, 2025

No it happens after mir_borrowck

@Lysxia Lysxia force-pushed the toolchain-2025-10-27 branch 3 times, most recently from 9f0d531 to dd87ed6 Compare November 5, 2025 08:28
@Lysxia
Copy link
Collaborator Author

Lysxia commented Nov 5, 2025

I've got a working fix for the unused variable warnings, but it currently relies on exposing the private definition of Steal with a very unsafe transmute. I've sent a PR to rust to expose the method I actually need.

@Lysxia Lysxia force-pushed the toolchain-2025-10-27 branch from dd87ed6 to 429b789 Compare November 13, 2025 15:20
@Lysxia Lysxia changed the title Update toolchain Update toolchain to 2025-11-13 Nov 13, 2025
@Lysxia Lysxia marked this pull request as ready for review November 13, 2025 15:20
// This is a terrible hack but it shouldn't affect correctness:
// we've already copied MIR bodies right after borrow checking.
// This is only used for warnings about unused variables.
let mut mir = mir.risky_hack_borrow_mut();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shiny new hack that was merged in rustc this week!

@Lysxia Lysxia merged commit 988a04c into master Nov 13, 2025
8 checks passed
@Lysxia Lysxia deleted the toolchain-2025-10-27 branch November 13, 2025 15:56
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.

4 participants