Skip to content

Don't emit no-op &T → &T reborrows, take 2 - #165830

Open
Jules-Bertholet wants to merge 1 commit into
rust-lang:mainfrom
Jules-Bertholet:no-noop-reborrows-2-electric-boogaloo
Open

Jules-Bertholet wants to merge 1 commit into
rust-lang:mainfrom
Jules-Bertholet:no-noop-reborrows-2-electric-boogaloo

Conversation

@Jules-Bertholet

@Jules-Bertholet Jules-Bertholet commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Re-applies #164014 which was reverted because FCP was improperly skipped.


The compiler currently emits a no-op reborrowing coercion in HIR between reference types differing only in their lifetime annotations. This PR stops emitting such coercions, except inside closures where they can affect capture behavior.

The following goes from compile fail → pass (though only outside a closure):

fn main() {
    let x: &'static ();
    let _: &_ = /* there used to be an implicit reborrow here */ x;
}

Note that the following compiles today:

fn main() {
    let x: &'static ();
    let _ = x;
}

This is the first step of a plan to eliminate all HIR reborrow coercions between identical-modulo-lifetimes types.

The other steps are:

Zulip thread

Is this OK?


@rustbot label A-coercions T-types needs-fcp I-types-nominated

r? @oli-obk

@rustbot

rustbot commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 11, 2026
@rustbot rustbot added A-coercions Area: implicit and explicit `expr as Type` coercions I-types-nominated Nominated for discussion during a types team meeting. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. T-types Relevant to the types team, which will review and decide on the PR/issue. labels Nov 11, 2026
@rustbot

rustbot commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

🤖 A dedicated #t-types/nominated topic has been opened for humans to discuss this issue 🤖

@oli-obk oli-obk added S-waiting-on-t-types Status: Awaiting decision from T-types and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 19, 2026

This branch has not been deployed

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

Labels

A-coercions Area: implicit and explicit `expr as Type` coercions I-types-nominated Nominated for discussion during a types team meeting. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-t-types Status: Awaiting decision from T-types T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants