Skip to content

Comments

Do not add implied outlives bounds containing external regions/params only#153027

Draft
ShoyuVanilla wants to merge 1 commit intorust-lang:mainfrom
ShoyuVanilla:external-implied-bounds
Draft

Do not add implied outlives bounds containing external regions/params only#153027
ShoyuVanilla wants to merge 1 commit intorust-lang:mainfrom
ShoyuVanilla:external-implied-bounds

Conversation

@ShoyuVanilla
Copy link
Member

Fixes #151637

The actuall cause wasn't that the closure's return type is wf checked.
For example, the following code is errored out as intended:

struct Wrap<T: Default>(T);

fn error<T>(x: T) {
    || Wrap(x);
    //~^ ERROR: the trait bound `T: Default` is not satisfied
}

The problem was that we are adding implied bound T: 'static even when borrowck-ing the closures.

struct Wrap<T: 'static>(T);

fn no_error<T>(x: T) {
    || Wrap(x);
}

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 23, 2026
// for it, we might fail with the type test for it, which contains the opaque type
// and therefore `'b` as well. The problem is that if the normalized opaque type doesn't
// mentions `'b`, we have no local free region constrained by it, and end up
// emitting a borrowck error instead of propagating the closure requirements.
Copy link
Member Author

@ShoyuVanilla ShoyuVanilla Feb 23, 2026

Choose a reason for hiding this comment

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

Filtering external bounds here regresses this

.map(|&n| Container::new(n, &resolver))

@ShoyuVanilla
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 23, 2026
Do not add outlives implied bounds that contains external regions/params only
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 23, 2026
@ShoyuVanilla ShoyuVanilla changed the title Do not add outlives implied bounds that contains external regions/params only Do not add outlives implied bounds containing external regions/params only Feb 23, 2026
@ShoyuVanilla ShoyuVanilla changed the title Do not add outlives implied bounds containing external regions/params only Do not add implied outlives bounds containing external regions/params only Feb 23, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 23, 2026

☀️ Try build successful (CI)
Build commit: 484ac15 (484ac156cc381bb2cfc74c800423322f261d074d, parent: eeb94be79adc9df7a09ad0b2421f16e60e6d932c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (484ac15): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (secondary 0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.4% [2.9%, 7.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.3% [-4.5%, -4.1%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 481.498s -> 479.757s (-0.36%)
Artifact size: 395.88 MiB -> 397.89 MiB (0.51%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 24, 2026
@ShoyuVanilla
Copy link
Member Author

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-153027 created and queued.
🤖 Automatically detected try build 484ac15
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 24, 2026
@ShoyuVanilla
Copy link
Member Author

This doesn't feel correct. I think I should rather add implied bounds as before and directly propagate them again as requirements.
@craterbot cancel

@craterbot
Copy link
Collaborator

🗑️ Experiment pr-153027 deleted!

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsoundness due to closure return value not being checked for WF

4 participants