Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only assemble alias bound candidates for rigid aliases #119744

Merged
merged 2 commits into from Jan 30, 2024

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jan 8, 2024

fixes rust-lang/trait-system-refactor-initiative#77

This also causes <Wrapper<?0> as Trait>::Unwrap: Trait to always be ambig, as we now normalize the self type before checking whether it is an inference variable.

I cannot think of an approach to the underlying issues here which does not require the "may-define means must-define" restriction for opaque types. Going to go ahead with this and added this restriction to the tracking issue for the new solver to make sure we don't stabilize it without getting types + lang signoff here.

r? @compiler-errors

@rustbot rustbot added 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative labels Jan 8, 2024
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

compiler-errors commented Jan 8, 2024

This PR ensures that the code I extracted from gimli works:

trait Reader: Default {
    fn read_u8_array<A>(&self) -> Result<A, ()>
    {
        todo!()
    }

    fn read_u8(&self) -> Result<u8, ()> {
        let a: [u8; 1] = self.read_u8_array::<_>()?;
        Ok(a[0])
    }
}

fn main() {}

Plz add it as a test, whether you want to minimize it further or not is up to you.

This has to do with taking <Result<?0, ()> as Try>::Residual: Sized and eagerly unifying it against Self: Sized in the param-env incompletely -- the old solver doesn't do this since it'll normalize <Result<?0, ()> as Try>::Residual to ?0 and the sized predicate will stall before erroneous inference is done to it.

@compiler-errors
Copy link
Member

@rustbot author until it's ready for review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2024
@lcnr lcnr marked this pull request as ready for review January 26, 2024 15:32
@rustbot
Copy link
Collaborator

rustbot commented Jan 26, 2024

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 26, 2024
always normalize `LoweredTy` in the new solver

I currently expect us to stop using alias bound candidates of normalizable aliases due to rust-lang/trait-system-refactor-initiative#77 by landing rust-lang#119744. At this point it mostly doesn't matter whether we eagerly normalize (and replace with infer vars in case of ambiguity). cc rust-lang#113473 previous attempt

The infer var replacement for ambiguous projections can in very rare cases:
- weaken inference rust-lang/trait-system-refactor-initiative#81
- strengthen inference rust-lang/trait-system-refactor-initiative#7

I do not expect this impact on inference to significantly affect real crates.

r? `@compiler-errors`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 26, 2024
always normalize `LoweredTy` in the new solver

I currently expect us to stop using alias bound candidates of normalizable aliases due to rust-lang/trait-system-refactor-initiative#77 by landing rust-lang#119744. At this point it mostly doesn't matter whether we eagerly normalize (and replace with infer vars in case of ambiguity). cc rust-lang#113473 previous attempt

The infer var replacement for ambiguous projections can in very rare cases:
- weaken inference rust-lang/trait-system-refactor-initiative#81
- strengthen inference rust-lang/trait-system-refactor-initiative#7

I do not expect this impact on inference to significantly affect real crates.

r? ``@compiler-errors``
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 27, 2024
Rollup merge of rust-lang#120378 - lcnr:normalize-ast, r=compiler-errors

always normalize `LoweredTy` in the new solver

I currently expect us to stop using alias bound candidates of normalizable aliases due to rust-lang/trait-system-refactor-initiative#77 by landing rust-lang#119744. At this point it mostly doesn't matter whether we eagerly normalize (and replace with infer vars in case of ambiguity). cc rust-lang#113473 previous attempt

The infer var replacement for ambiguous projections can in very rare cases:
- weaken inference rust-lang/trait-system-refactor-initiative#81
- strengthen inference rust-lang/trait-system-refactor-initiative#7

I do not expect this impact on inference to significantly affect real crates.

r? ``@compiler-errors``
@bors
Copy link
Contributor

bors commented Jan 27, 2024

☔ The latest upstream changes (presumably #120401) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jan 29, 2024

📌 Commit ea4e5b8 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 29, 2024
@bors
Copy link
Contributor

bors commented Jan 30, 2024

⌛ Testing commit ea4e5b8 with merge c401f09...

@bors
Copy link
Contributor

bors commented Jan 30, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing c401f09 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 30, 2024
@bors bors merged commit c401f09 into rust-lang:master Jan 30, 2024
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 30, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c401f09): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.8% [-4.8%, -2.0%] 15
Improvements ✅
(secondary)
-3.0% [-6.7%, -0.8%] 66
All ❌✅ (primary) -2.8% [-4.8%, -2.0%] 15

Cycles

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

Binary size

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

Bootstrap: 662.576s -> 660.86s (-0.26%)
Artifact size: 308.05 MiB -> 308.08 MiB (0.01%)

@lcnr lcnr deleted the assemble-only-rigid branch January 30, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

Successfully merging this pull request may close these issues.

alias-bounds for normalizable alias + deeply normalize ~> MIR typeck ICE
6 participants