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

Manually walk into WF obligations in BestObligation proof tree visitor #135900

Merged
merged 2 commits into from
Feb 1, 2025

Conversation

compiler-errors
Copy link
Member

When we encounter a WellFormed obligation in the BestObligation proof tree visitor, ignore the proof tree and call wf::unnormalized_obligations to derive well-formed obligations with the correct cause codes. This is to avoid having to replicate the somewhat delicate logic that wf.rs does to set up its obligation causes... Don't see a better way to do this.

vibes?? r? lcnr

@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. labels Jan 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 22, 2025

Some changes occurred to the core trait solver

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

changes to the core type system

cc @compiler-errors, @lcnr

@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Jan 22, 2025
@bors
Copy link
Contributor

bors commented Jan 22, 2025

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

Comment on lines 321 to 315
// HACK: We walk the nested obligations for a well-formed arg manually,
// since there's nontrivial logic in `wf.rs` to set up an obligation cause.
// Ideally we'd be able to track this better.
Copy link
Contributor

Choose a reason for hiding this comment

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

doc comment on visit_well_formed_goal instead

Comment on lines 256 to 258
match self.consider_ambiguities {
true if matches!(
nested_goal.result(),
Ok(Certainty::Maybe(MaybeCause::Ambiguity))
) => {}
false if matches!(nested_goal.result(), Err(_)) => {}
_ => continue,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

match (self.condider_ambiguities, nested_goal.result())

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

that's a fun solution 😁

r=me after nits

@compiler-errors compiler-errors force-pushed the derive-wf branch 2 times, most recently from 3568624 to 5f76f1a Compare January 29, 2025 00:27
@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Jan 29, 2025

📌 Commit 5f76f1a has been approved by lcnr

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-review Status: Awaiting review from the assignee but also interested parties. labels Jan 29, 2025
@rust-log-analyzer

This comment has been minimized.

Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 29, 2025
Manually walk into WF obligations in `BestObligation` proof tree visitor

When we encounter a `WellFormed` obligation in the `BestObligation` proof tree visitor, ignore the proof tree and call `wf::unnormalized_obligations` to derive well-formed obligations with the correct cause codes. This is to avoid having to replicate the somewhat delicate logic that `wf.rs` does to set up its obligation causes... Don't see a better way to do this.

vibes?? r? lcnr
@fmease
Copy link
Member

fmease commented Jan 29, 2025

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 29, 2025
@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Jan 29, 2025

📌 Commit 94ef5cf has been approved by lcnr

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, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 30, 2025
Manually walk into WF obligations in `BestObligation` proof tree visitor

When we encounter a `WellFormed` obligation in the `BestObligation` proof tree visitor, ignore the proof tree and call `wf::unnormalized_obligations` to derive well-formed obligations with the correct cause codes. This is to avoid having to replicate the somewhat delicate logic that `wf.rs` does to set up its obligation causes... Don't see a better way to do this.

vibes?? r? lcnr
@matthiaskrgr
Copy link
Member

failed locally in #136276 I think, may need rebase or something

---- [ui] tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs#next stdout ----
Saved the actual stderr to "/home/matthias/vcs/github/rust/build/x86_64-unknown-linux-gnu/test/ui/typeck/issue-114918/const-in-impl-fn-return-type.next/const-in-impl-fn-return-type.next.stderr"
diff of stderr:

9	   |
10	LL |     fn func<const N: u32>() -> [(); N];
11	   |                                ^^^^^^^ expected `usize`, found `u32`
+	   |
+	   = note: the length of array `[(); N]` must be type `usize`
12	
13	error: aborting due to 2 previous errors
14	


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args typeck/issue-114918/const-in-impl-fn-return-type.rs`

error in revision `next`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/home/matthias/vcs/github/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/home/matthias/vcs/github/rust/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/matthias/.cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/matthias/vcs/github/rust/vendor" "--sysroot" "/home/matthias/vcs/github/rust/build/x86_64-unknown-linux-gnu/stage1" "--target=x86_64-unknown-linux-gnu" "--cfg" "next" "--check-cfg" "cfg(test,FALSE,current,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/home/matthias/vcs/github/rust/build/x86_64-unknown-linux-gnu/test/ui/typeck/issue-114918/const-in-impl-fn-return-type.next" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/home/matthias/vcs/github/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Znext-solver"
stdout: none
--- stderr -------------------------------
error[E0308]: mismatched types
  --> /home/matthias/vcs/github/rust/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs:20:39
   |
LL |     fn func<const N: u32>() -> [(); { () }] {
   |                                       ^^ expected `usize`, found `()`

error: the constant `N` is not of type `usize`
  --> /home/matthias/vcs/github/rust/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs:12:32
   |
LL |     fn func<const N: u32>() -> [(); N];
   |                                ^^^^^^^ expected `usize`, found `u32`
   |
   = note: the length of array `[(); N]` must be type `usize`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
------------------------------------------



failures:
    [ui] tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs#next

test result: FAILED. 18207 passed; 1 failed; 181 ignored; 0 measured; 0 filtered out; finished in 353.09s

@compiler-errors
Copy link
Member Author

ya needs rebase

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 30, 2025
@bors
Copy link
Contributor

bors commented Jan 31, 2025

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

@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Jan 31, 2025

📌 Commit 304b3cf has been approved by lcnr

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 31, 2025
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jan 31, 2025
Manually walk into WF obligations in `BestObligation` proof tree visitor

When we encounter a `WellFormed` obligation in the `BestObligation` proof tree visitor, ignore the proof tree and call `wf::unnormalized_obligations` to derive well-formed obligations with the correct cause codes. This is to avoid having to replicate the somewhat delicate logic that `wf.rs` does to set up its obligation causes... Don't see a better way to do this.

vibes?? r? lcnr
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 31, 2025
…kingjubilee

Rollup of 16 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#135768 (tests: Port `symbol-mangling-hashed` to rmake.rs)
 - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL)
 - rust-lang#135840 (omit unused args warnings for intrinsics without body)
 - rust-lang#135900 (Manually walk into WF obligations in `BestObligation` proof tree visitor)
 - rust-lang#136146 (Explicitly choose x86 softfloat/hardfloat ABI)
 - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
 - rust-lang#136163 (Fix off-by-one error causing slice::sort to abort the program)
 - rust-lang#136266 (fix broken release notes id)
 - rust-lang#136283 (Update encode_utf16 to mention it is native endian)
 - rust-lang#136309 (set rustc dylib on manually constructed rustc command)
 - rust-lang#136314 (Use proper type when applying deref adjustment in const)
 - rust-lang#136339 (CompileTest: Add Directives to Ignore `arm-unknown-*` Targets)
 - rust-lang#136348 (miri: make float min/max non-deterministic)
 - rust-lang#136351 (Add documentation for derive(CoercePointee))
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)

Failed merges:

 - rust-lang#135994 (Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptr)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#135840 (omit unused args warnings for intrinsics without body)
 - rust-lang#135900 (Manually walk into WF obligations in `BestObligation` proof tree visitor)
 - rust-lang#136163 (Fix off-by-one error causing slice::sort to abort the program)
 - rust-lang#136266 (fix broken release notes id)
 - rust-lang#136314 (Use proper type when applying deref adjustment in const)
 - rust-lang#136348 (miri: make float min/max non-deterministic)
 - rust-lang#136351 (Add documentation for derive(CoercePointee))

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3c4b912 into rust-lang:master Feb 1, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Feb 1, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
Rollup merge of rust-lang#135900 - compiler-errors:derive-wf, r=lcnr

Manually walk into WF obligations in `BestObligation` proof tree visitor

When we encounter a `WellFormed` obligation in the `BestObligation` proof tree visitor, ignore the proof tree and call `wf::unnormalized_obligations` to derive well-formed obligations with the correct cause codes. This is to avoid having to replicate the somewhat delicate logic that `wf.rs` does to set up its obligation causes... Don't see a better way to do this.

vibes?? r? lcnr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants