Skip to content

Change a commit_if_ok call to probe - #105292

Merged
bors merged 5 commits into
rust-lang:masterfrom
JulianKnodt:no_eager_commit
Jan 9, 2023
Merged

Change a commit_if_ok call to probe#105292
bors merged 5 commits into
rust-lang:masterfrom
JulianKnodt:no_eager_commit

Conversation

@JulianKnodt

Copy link
Copy Markdown
Contributor

Removes an over-eager commit_if_ok which makes inference worse.

I'm not entirely sure whether it's ok to remove the check that types are the same, because casting seems to cause equality checks with incorrect types?

Fixes#105037

r? @BoxyUwU

@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 Dec 5, 2022
@rust-log-analyzer

This comment has been minimized.

@compiler-errorscompiler-errors changed the title [WIP] Remove commit_if_ok[WIP] Remove a commit_if_ok callDec 5, 2022
@JulianKnodtJulianKnodt changed the title [WIP] Remove a commit_if_ok call[WIP] Change a commit_if_ok call to probeDec 5, 2022
@JulianKnodt
JulianKnodt marked this pull request as ready for review December 5, 2022 19:28
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in const_evaluatable.rs

cc @lcnr

@JulianKnodtJulianKnodt changed the title [WIP] Change a commit_if_ok call to probeChange a commit_if_ok call to probeDec 5, 2022
@bors

bors commented Dec 6, 2022

Copy link
Copy Markdown
Collaborator

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

@BoxyUwU

Copy link
Copy Markdown
Member

replacing this with a probe seems right, we dont want to constrain the infer vars in self.ct unless we're sure there are no other things that we could have unified with to consider it evaluatable. It's still not quite right though, we do have to actually constrain the infer vars that eq constraints at some point in order to ensure that the const is actually evaluatable.

What's needed is to have the visitor visit all the consts regardless of it succeeds in unifying with something, and if it succeed in unifying with something (in the probe) track that in Visitor. Once the visitor is finished you want to be able to see of all the consts that we were able to unify with, and if there was only one, redo the eq and select_all_or_error() outside of a probe.

@JulianKnodt
JulianKnodtforce-pushed the no_eager_commit branch 4 times, most recently from aaf7eb5 to 0bec1bbCompareDecember 13, 2022 10:59
@JulianKnodt

Copy link
Copy Markdown
ContributorAuthor

I updated to check for only a single match and commit the change if there is a single one, but somehow this results in an error for the original test case. Is this an issue with the way I implemented it?

@rust-log-analyzer

This comment has been minimized.

@BoxyUwU

Copy link
Copy Markdown
Member

the current code only works for a single ConstEvaluatable predicate in the paramenv, i.e. if you had where [(); N +1 + 1]: and were trying to prove ConstEvalutable(N + _) it'd avoid unifying with 1 + 1 or 1 because either would work.
The test case you're working with has two separate things in param env: ConstEvaluatable(Table1<D>) and ConstEvaluatable(Table2<D>) so you'll also have to update the for loop to make you a single Option<Result<Const<'tcx>>, ()> and do the ocx.eq stuff after the for loop instead of inside

Comment threadcompiler/rustc_trait_selection/src/traits/const_evaluatable.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@BoxyUwU

Copy link
Copy Markdown
Member

I think all the CI failures are caused by cases where we have duplicate candidates, i.e. two N + 1 in the param env, you probably want to avoid setting single_match to Err instead of Ok if the candidate that matched is == to the existing Ok

@BoxyUwU

Copy link
Copy Markdown
Member

Can you add the following as tests:


#![feature(generic_const_exprs)]#![allow(incomplete_features)]fnfoo<constN:usize>()where[();N + 1]:,[();N + 1]:,{bar::<N>();}fnbar<constN:usize>()where[();N + 1]:,{}fnmain(){}

#![feature(generic_const_exprs)]#![allow(incomplete_features)]constfnboth(_:usize,b:usize) -> usize{
b
}fnfoo<constN:usize>()where[();both(N + 1,N + 1)]:,{bar::<N>();}fnbar<constN:usize>()where[();N + 1]:,{}fnmain(){}

#![feature(generic_const_exprs)]#![allow(incomplete_features)]constfnboth(_:usize,b:usize) -> usize{
b
}fnfoo<constN:usize,constM:usize>() -> [();N + 2]where[();both(N + 1,M + 1)]:,{bar()}fnbar<constN:usize>() -> [();N]where[();N + 1]:,{[();N]}fnmain(){}

Comment threadcompiler/rustc_trait_selection/src/traits/const_evaluatable.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/const_evaluatable.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/const_evaluatable.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/const_evaluatable.rs Outdated
Comment threadcompiler/rustc_trait_selection/src/traits/const_evaluatable.rs Outdated
@BoxyUwU

Copy link
Copy Markdown
Member

will r+ this once its rebased

Instead of just switching to a probe, check for different matches, and see how many there are.
If one, unify it, otherwise return true and let it be unified later.
This prevents an ICE due to a value not actually being evaluatable later.
Simplify match statement
Add multiple tests
- 1 test for checking `N + 1 + 1` does not unify with `N+1`
- 2 tests for checking that a function that uses two parameters only returns the parameter that
is actually used.
- Check exact repeat predicates
@BoxyUwU

Copy link
Copy Markdown
Member

@bors r+ rollup

@bors

bors commented Jan 9, 2023

Copy link
Copy Markdown
Collaborator

📌 Commit 21c5ffe has been approved by BoxyUwU

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 Jan 9, 2023
JohnTitor pushed a commit to JohnTitor/rust that referenced this pull request Jan 9, 2023
…yUwU
Change a commit_if_ok call to probe
Removes an over-eager `commit_if_ok` which makes inference worse.
I'm not entirely sure whether it's ok to remove the check that types are the same, because casting seems to cause equality checks with incorrect types?
Fixesrust-lang#105037
r? `@BoxyUwU`
@JohnTitorJohnTitor mentioned this pull request Jan 9, 2023
JohnTitor pushed a commit to JohnTitor/rust that referenced this pull request Jan 9, 2023
…yUwU
Change a commit_if_ok call to probe
Removes an over-eager `commit_if_ok` which makes inference worse.
I'm not entirely sure whether it's ok to remove the check that types are the same, because casting seems to cause equality checks with incorrect types?
Fixesrust-lang#105037
r? ``@BoxyUwU``
@JohnTitorJohnTitor mentioned this pull request Jan 9, 2023
@fee1-deadfee1-dead mentioned this pull request Jan 9, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 9, 2023
…fee1-dead
Rollup of 10 pull requests
Successful merges:
- rust-lang#105292 (Change a commit_if_ok call to probe)
- rust-lang#105655 (Remove invalid case for mutable borrow suggestion)
- rust-lang#106047 (Fix ui constant tests for big-endian platforms)
- rust-lang#106061 (Enable Shadow Call Stack for Fuchsia on AArch64)
- rust-lang#106164 (Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`)
- rust-lang#106291 (Fix incorrect suggestion for extra `&` in pattern)
- rust-lang#106389 (Simplify some canonical type alias names)
- rust-lang#106468 (Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`)
- rust-lang#106549 (Use fmt named parameters in rustc_borrowck)
- rust-lang#106614 (error-code docs improvements (No. 2))
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit b7587f1 into rust-lang:masterJan 9, 2023
@rustbotrustbot added this to the 1.68.0 milestone Jan 9, 2023
@JulianKnodt
JulianKnodt deleted the no_eager_commit branch January 9, 2023 21:53
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 20, 2023
…compiler-errors
Added const-generic ui test case for issue rust-lang#106419
This PR adds a test case for rust-lang#106419 which has been fixed in master by rust-lang#105292
I also ran the test on f769d34 (the commit before rust-lang#105292 was merged)
and it did fail there with the following output.
```
--- stderr -------------------------------
error[E0308]: mismatched types
--> /home/patrikk/src/rust/src/test/ui/const-generics/issue-106419-struct-with-multiple-const-params.rs:5:10
|
LL | #[derive(Clone)]
| ^^^^^
| |
| expected `A`, found `B`
| expected `Bar<A, B>` because of return type
|
= note: expected struct `Bar<A, _>`
found struct `Bar<B, _>`
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
------------------------------------------
```
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad generic inference on very recent nightly

5 participants

@JulianKnodt@rust-log-analyzer@rustbot@bors@BoxyUwU