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

Add deeply_normalize_for_diagnostics, use it in coherence #118346

Merged

Conversation

compiler-errors
Copy link
Member

r? lcnr

Normalize trait refs used for coherence error reporting with -Ztrait-solver=next-coherence.

Two things:

  1. I said before that we can't add this to TyErrCtxt because we compute OverlapResults even if there are no diagnostics being emitted, e.g. for a reservation impl.
  2. I didn't want to add this to an InferCtxtExt trait because I felt it was unnecessary. I don't particularly care about the API though.

@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 (-Znext-solver) labels Nov 27, 2023
@rustbot
Copy link
Collaborator

rustbot commented Nov 27, 2023

Some changes occurred to the core trait solver

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

param_env: ty::ParamEnv<'tcx>,
t: T,
) -> T {
infcx
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add an assert that this is only used with the new solver or alternatively, make it a noop if it isn't?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we already assert if deep_normalize is called outside of the new solver, but I'll copy that assertion here to really make it clear 😃

) -> T {
infcx
.commit_if_ok(|_| {
deeply_normalize(infcx.at(&ObligationCause::dummy(), param_env), t.clone())
Copy link
Contributor

Choose a reason for hiding this comment

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

this would keep <() as CanNormalize>::Assoc: Trait<<() as Ambig>::Assoc> fully unnormalized. Maybe easiest to write a TypeFolder here where we call deeply_normalize and if that returns an error, super_fold_with?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's a good point -- forgot that the deep normalizer uses select_all_or_error.

@@ -1084,6 +1090,10 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> {
Ok(Ok(())) => warn!("expected an unknowable trait ref: {trait_ref:?}"),
Ok(Err(conflict)) => {
if !trait_ref.references_error() {
// Noramlize the trait ref for diagnostics, ignoring any errors if this fails.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Noramlize the trait ref for diagnostics, ignoring any errors if this fails.
// Normalize the trait ref for diagnostics, ignoring any errors if this fails.

@lcnr
Copy link
Contributor

lcnr commented Nov 28, 2023

@rustbot author

@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 Nov 28, 2023
@compiler-errors compiler-errors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 28, 2023
@rust-cloud-vms rust-cloud-vms bot force-pushed the deeply-normalize-for-diagnostic branch from a7b3d59 to 01c4e8e Compare November 28, 2023 21:48
@rust-log-analyzer

This comment has been minimized.

@rust-cloud-vms rust-cloud-vms bot force-pushed the deeply-normalize-for-diagnostic branch from 01c4e8e to 8ad9466 Compare December 5, 2023 16:38
@compiler-errors
Copy link
Member Author

@rustbot ready

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.

r=me after nit

compiler/rustc_trait_selection/src/solve/normalize.rs Outdated Show resolved Hide resolved
@rust-cloud-vms rust-cloud-vms bot force-pushed the deeply-normalize-for-diagnostic branch from 8ad9466 to 3448284 Compare December 5, 2023 16:55
@compiler-errors
Copy link
Member Author

@bors r=lcnr rollup

@bors
Copy link
Contributor

bors commented Dec 5, 2023

📌 Commit 3448284 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 Dec 5, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 5, 2023
…or-diagnostic, r=lcnr

Add `deeply_normalize_for_diagnostics`, use it in coherence

r? lcnr

Normalize trait refs used for coherence error reporting with `-Ztrait-solver=next-coherence`.

Two things:
1. I said before that we can't add this to `TyErrCtxt` because we compute `OverlapResult`s even if there are no diagnostics being emitted, e.g. for a reservation impl.
2. I didn't want to add this to an `InferCtxtExt` trait because I felt it was unnecessary. I don't particularly care about the API though.
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Dec 5, 2023
…or-diagnostic, r=lcnr

Add `deeply_normalize_for_diagnostics`, use it in coherence

r? lcnr

Normalize trait refs used for coherence error reporting with `-Ztrait-solver=next-coherence`.

Two things:
1. I said before that we can't add this to `TyErrCtxt` because we compute `OverlapResult`s even if there are no diagnostics being emitted, e.g. for a reservation impl.
2. I didn't want to add this to an `InferCtxtExt` trait because I felt it was unnecessary. I don't particularly care about the API though.
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Dec 5, 2023
…or-diagnostic, r=lcnr

Add `deeply_normalize_for_diagnostics`, use it in coherence

r? lcnr

Normalize trait refs used for coherence error reporting with `-Ztrait-solver=next-coherence`.

Two things:
1. I said before that we can't add this to `TyErrCtxt` because we compute `OverlapResult`s even if there are no diagnostics being emitted, e.g. for a reservation impl.
2. I didn't want to add this to an `InferCtxtExt` trait because I felt it was unnecessary. I don't particularly care about the API though.
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 5, 2023
…mpiler-errors

Rollup of 9 pull requests

Successful merges:

 - rust-lang#117793 (Update variable name to fix `unused_variables` warning)
 - rust-lang#118123 (Add support for making lib features internal)
 - rust-lang#118268 (Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always)
 - rust-lang#118346 (Add `deeply_normalize_for_diagnostics`, use it in coherence)
 - rust-lang#118350 (Simplify Default for tuples)
 - rust-lang#118450 (Use OnceCell in cell module documentation)
 - rust-lang#118585 (Fix parser ICE when recovering `dyn`/`impl` after `for<...>`)
 - rust-lang#118587 (Cleanup error handlers some more)
 - rust-lang#118642 (bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_expressions_from_macros`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 5, 2023
…mpiler-errors

Rollup of 9 pull requests

Successful merges:

 - rust-lang#117793 (Update variable name to fix `unused_variables` warning)
 - rust-lang#118123 (Add support for making lib features internal)
 - rust-lang#118268 (Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always)
 - rust-lang#118346 (Add `deeply_normalize_for_diagnostics`, use it in coherence)
 - rust-lang#118350 (Simplify Default for tuples)
 - rust-lang#118450 (Use OnceCell in cell module documentation)
 - rust-lang#118585 (Fix parser ICE when recovering `dyn`/`impl` after `for<...>`)
 - rust-lang#118587 (Cleanup error handlers some more)
 - rust-lang#118642 (bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_expressions_from_macros`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 6, 2023
…mpiler-errors

Rollup of 9 pull requests

Successful merges:

 - rust-lang#117793 (Update variable name to fix `unused_variables` warning)
 - rust-lang#118123 (Add support for making lib features internal)
 - rust-lang#118268 (Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always)
 - rust-lang#118346 (Add `deeply_normalize_for_diagnostics`, use it in coherence)
 - rust-lang#118350 (Simplify Default for tuples)
 - rust-lang#118450 (Use OnceCell in cell module documentation)
 - rust-lang#118585 (Fix parser ICE when recovering `dyn`/`impl` after `for<...>`)
 - rust-lang#118587 (Cleanup error handlers some more)
 - rust-lang#118642 (bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_expressions_from_macros`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 6, 2023
…mpiler-errors

Rollup of 9 pull requests

Successful merges:

 - rust-lang#117793 (Update variable name to fix `unused_variables` warning)
 - rust-lang#118123 (Add support for making lib features internal)
 - rust-lang#118268 (Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always)
 - rust-lang#118346 (Add `deeply_normalize_for_diagnostics`, use it in coherence)
 - rust-lang#118350 (Simplify Default for tuples)
 - rust-lang#118450 (Use OnceCell in cell module documentation)
 - rust-lang#118585 (Fix parser ICE when recovering `dyn`/`impl` after `for<...>`)
 - rust-lang#118587 (Cleanup error handlers some more)
 - rust-lang#118642 (bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_expressions_from_macros`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 598ca0e into rust-lang:master Dec 6, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 6, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 6, 2023
Rollup merge of rust-lang#118346 - compiler-errors:deeply-normalize-for-diagnostic, r=lcnr

Add `deeply_normalize_for_diagnostics`, use it in coherence

r? lcnr

Normalize trait refs used for coherence error reporting with `-Ztrait-solver=next-coherence`.

Two things:
1. I said before that we can't add this to `TyErrCtxt` because we compute `OverlapResult`s even if there are no diagnostics being emitted, e.g. for a reservation impl.
2. I didn't want to add this to an `InferCtxtExt` trait because I felt it was unnecessary. I don't particularly care about the API though.
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.

6 participants