Skip to content

trait_sel: resolve vars in host effects - #137604

Merged
bors merged 1 commit into
rust-lang:masterfrom
davidtwco:host-effect-resolve-vars
Feb 26, 2025
Merged

trait_sel: resolve vars in host effects#137604
bors merged 1 commit into
rust-lang:masterfrom
davidtwco:host-effect-resolve-vars

Conversation

@davidtwco

Copy link
Copy Markdown
Member

In the standard library, the Extend impl for Iterator (specialised with TrustedLen) has a parameter which is constrained by a projection predicate. This projection predicate provides a value for an inference variable but - if the default bound is const Sized instead of Sized - host effect evaluation wasn't resolving variables first. Added a test that doesn't depend on a rust-lang/rfcs#3729 implementation.

Adding the extra resolve can the number of errors in some tests when they gain host effect predicates, but this is not unexpected as calls to resolve_vars_if_possible can cause more error tainting to happen.

In the standard library, the `Extend` impl for `Iterator` (specialised
with `TrustedLen`) has a parameter which is constrained by a projection
predicate. This projection predicate provides a value for an inference
variable but host effect evaluation wasn't resolving variables first.
Adding the extra resolve can the number of errors in some tests when they
gain host effect predicates, but this is not unexpected as calls to
`resolve_vars_if_possible` can cause more error tainting to happen.
Co-authored-by: Boxy <rust@boxyuwu.dev>
@rustbot

This comment was marked as outdated.

@rustbotrustbot 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. labels Feb 25, 2025
@jieyouxu

Copy link
Copy Markdown
Member

r? types

@rustbotrustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Feb 25, 2025
@rustbotrustbot assigned oli-obk and unassigned jieyouxuFeb 25, 2025

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.

On nightly this emits

error[E0283]: type annotations needed: cannot satisfy `Iter: Tr`
--> src/lib.rs:31:33
|
31 | impl<A: const Foo, Iter> Tr for Iter
| ^^^^
|
note: multiple `impl`s satisfying `Iter: Tr` found
--> src/lib.rs:24:1
|
24 | / impl<A: const Foo, Iter> Tr for Iter
25 | | where
26 | | Iter: Iterator<Item = A>,
| |_________________________________^
...
31 | / impl<A: const Foo, Iter> Tr for Iter
32 | | where
33 | | Iter: MoreSpecificThanIterator<Item = A>,
| |_________________________________________________^

Comment threadtests/ui/traits/const-traits/unconstrained-var-specialization.rs Outdated
@davidtwco
davidtwcoforce-pushed the host-effect-resolve-vars branch from 1898267 to 21d41b0CompareFebruary 25, 2025 12:11
@davidtwco

Copy link
Copy Markdown
MemberAuthor

Also added @BoxyUwU as a co-author on the commit as I wouldn't have solved this one without their help at Rust Nation.

@compiler-errors

Copy link
Copy Markdown
Contributor

Yeah, the implementation of the old trait solver's const predicates kinda sucks.

r? compiler-errors @bors r+ rollup

@bors

bors commented Feb 25, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 21d41b0 has been approved by compiler-errors

It is now in the queue for this repository.

@borsbors 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2025
fmease added a commit to fmease/rust that referenced this pull request Feb 26, 2025
…, r=compiler-errors
trait_sel: resolve vars in host effects
In the standard library, the `Extend` impl for `Iterator` (specialised with `TrustedLen`) has a parameter which is constrained by a projection predicate. This projection predicate provides a value for an inference variable but - if the default bound is `const Sized` instead of `Sized` - host effect evaluation wasn't resolving variables first. Added a test that doesn't depend on a rust-lang/rfcs#3729 implementation.
Adding the extra resolve can the number of errors in some tests when they gain host effect predicates, but this is not unexpected as calls to `resolve_vars_if_possible` can cause more error tainting to happen.
@fmeasefmease mentioned this pull request Feb 26, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2025
Rollup of 13 pull requests
Successful merges:
- rust-lang#136576 (pass optimization level to llvm-bitcode-linker)
- rust-lang#137320 (fix(rustdoc): Fixed stability version in rustdoc)
- rust-lang#137502 (Don't include global asm in `mir_keys`, fix error body synthesis)
- rust-lang#137529 (remove few unused args)
- rust-lang#137544 (tests: Add regression test for derive token invalidation (rust-lang#81099))
- rust-lang#137559 (run some tests on emscripten again)
- rust-lang#137601 (ssa/mono: deduplicate `type_has_metadata`)
- rust-lang#137603 (codegen_llvm: avoid `Deref` impls w/ extern type)
- rust-lang#137604 (trait_sel: resolve vars in host effects)
- rust-lang#137609 (Complete the list of resources used in rustdoc output)
- rust-lang#137613 (hir_analysis: skip self type of host effect preds in variances_of)
- rust-lang#137614 (fix doc in library/core/src/pin.rs)
- rust-lang#137622 (fix attribute-related ICE when parsing macro on the rhs of a name-value attribute)
r? `@ghost`
`@rustbot` modify labels: rollup
@fmeasefmease mentioned this pull request Feb 26, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2025
Rollup of 14 pull requests
Successful merges:
- rust-lang#136576 (pass optimization level to llvm-bitcode-linker)
- rust-lang#137154 (Add UTF-8 validation fast paths in `Wtf8Buf`)
- rust-lang#137311 (Enable `f16` for MIPS)
- rust-lang#137320 (fix(rustdoc): Fixed stability version in rustdoc)
- rust-lang#137529 (remove few unused args)
- rust-lang#137544 (tests: Add regression test for derive token invalidation (rust-lang#81099))
- rust-lang#137559 (run some tests on emscripten again)
- rust-lang#137601 (ssa/mono: deduplicate `type_has_metadata`)
- rust-lang#137603 (codegen_llvm: avoid `Deref` impls w/ extern type)
- rust-lang#137604 (trait_sel: resolve vars in host effects)
- rust-lang#137609 (Complete the list of resources used in rustdoc output)
- rust-lang#137613 (hir_analysis: skip self type of host effect preds in variances_of)
- rust-lang#137614 (fix doc in library/core/src/pin.rs)
- rust-lang#137622 (fix attribute-related ICE when parsing macro on the rhs of a name-value attribute)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 677295a into rust-lang:masterFeb 26, 2025
@rustbotrustbot added this to the 1.87.0 milestone Feb 26, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2025
Rollup merge of rust-lang#137604 - davidtwco:host-effect-resolve-vars, r=compiler-errors
trait_sel: resolve vars in host effects
In the standard library, the `Extend` impl for `Iterator` (specialised with `TrustedLen`) has a parameter which is constrained by a projection predicate. This projection predicate provides a value for an inference variable but - if the default bound is `const Sized` instead of `Sized` - host effect evaluation wasn't resolving variables first. Added a test that doesn't depend on a rust-lang/rfcs#3729 implementation.
Adding the extra resolve can the number of errors in some tests when they gain host effect predicates, but this is not unexpected as calls to `resolve_vars_if_possible` can cause more error tainting to happen.
@davidtwco
davidtwco deleted the host-effect-resolve-vars branch February 26, 2025 10:30
@oli-obkoli-obk mentioned this pull request May 27, 2025
@davidtwcodavidtwco mentioned this pull request Jul 24, 2025
22 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant 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.

6 participants

@davidtwco@rustbot@jieyouxu@compiler-errors@bors@oli-obk