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

Suggest associated type bounds on problematic associated equality bounds #122120

Merged
merged 4 commits into from
Mar 27, 2024

Conversation

fmease
Copy link
Member

@fmease fmease commented Mar 7, 2024

Fixes #105056. TL;DR: Suggest Trait<Ty: Bound> on Trait<Ty = Bound> in Rust >=2021.

Blocked on #122055 (stabilization of associated_type_bounds), I'd say. (merged)

@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 Mar 7, 2024
@fmease fmease added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 7, 2024
///
/// *Bare* trait object types are ones that aren't preceeded by the keyword `dyn`.
/// In edition 2021 and onward we emit a hard error for them.
pub(super) fn prohibit_or_lint_bare_trait_object_ty(
Copy link
Member Author

@fmease fmease Mar 7, 2024

Choose a reason for hiding this comment

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

(esthetics) moves the only non-priv item to the top; all the other items are helpers of this one

Copy link
Member Author

@fmease fmease Mar 7, 2024

Choose a reason for hiding this comment

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

new name is clearer: bare trait? bare trait object (ty); furthermore this isn't “maybe linting” but it's first & foremost prohibiting (if we assume the latest stable edition to be the canonical edition) otherwise linting — in older editions.

///
/// FIXME(alexreg): why have a separate type for the binding case,
Copy link
Member Author

@fmease fmease Mar 7, 2024

Choose a reason for hiding this comment

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

I never understood this FIXME whenever I came across these docs: The FIXME was created in the same commit as the one that introduced TypeBindingKind in favor of the now gone struct field ty: P<Ty> the FIXME mentions...

@@ -14,10 +14,6 @@ parse_array_index_offset_of = array indexing not supported in offset_of

parse_assignment_else_not_allowed = <assignment> ... else {"{"} ... {"}"} is not allowed

parse_assoc_lifetime = associated lifetimes are not supported
Copy link
Member Author

@fmease fmease Mar 7, 2024

Choose a reason for hiding this comment

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

This message was confusing imo, it talked about a “fictive” Rust feature, associated lifetimes as if that term was common knowledge. If at all, I would've expected this message to trigger on X<'a = 'static> ('a is the “associated lifetime”, 'static is the “projected lifetime”), not on X<T = 'static> as it currently does on master.

@compiler-errors
Copy link
Member

:^) thanks

compiler/rustc_hir/src/hir.rs Show resolved Hide resolved
compiler/rustc_hir_analysis/src/astconv/lint.rs Outdated Show resolved Hide resolved
Copy link
Member Author

Choose a reason for hiding this comment

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

We could think about suppressing some of the other trait object type diagnostics.

@fmease fmease added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 7, 2024
@bors

This comment was marked as resolved.

@fmease fmease force-pushed the sugg-assoc-ty-bound-on-eq-bound branch from fd3a91f to 3879acb Compare March 22, 2024 23:27
@fmease fmease 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. S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Mar 22, 2024
@fmease
Copy link
Member Author

fmease commented Mar 22, 2024

Okay, I've dialed it down. Didn't make anything translatable because if I started doing that I'd find myself in a rabbit hole of updating the neighboring code, too, since it's all interconnected in this case. I also dropped some other changes. I plan on submitting a diagnostic migration PR for rustc_hir_analysis soon anyway.

r? compiler-errors or compiler, no rush tho

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 26, 2024

📌 Commit 3879acb 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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 26, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 26, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#108675 (Document `adt_const_params` feature in Unstable Book)
 - rust-lang#122120 (Suggest associated type bounds on problematic associated equality bounds)
 - rust-lang#122589 (Fix diagnostics for async block cloning)
 - rust-lang#122835 (Require `DerefMut` and `DerefPure` on `deref!()` patterns when appropriate)
 - rust-lang#123049 (In `ConstructCoroutineInClosureShim`, pass receiver by mut ref, not mut pointer)
 - rust-lang#123055 (enable cargo miri test doctests)
 - rust-lang#123057 (unix fs: Make hurd using explicit new rather than From)
 - rust-lang#123087 (Change `f16` and `f128` clippy stubs to be nonpanicking)
 - rust-lang#123103 (Rename `Inherited` -> `TypeckRootCtxt`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ff8cdc9 into rust-lang:master Mar 27, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Mar 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 27, 2024
Rollup merge of rust-lang#122120 - fmease:sugg-assoc-ty-bound-on-eq-bound, r=compiler-errors

Suggest associated type bounds on problematic associated equality bounds

Fixes rust-lang#105056. TL;DR: Suggest `Trait<Ty: Bound>` on `Trait<Ty = Bound>` in Rust >=2021.

~~Blocked on rust-lang#122055 (stabilization of `associated_type_bounds`), I'd say.~~ (merged)
@fmease fmease deleted the sugg-assoc-ty-bound-on-eq-bound branch March 27, 2024 10:03
@jdahlstrom
Copy link

Thanks!

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest Trait<Ty: Trait2> syntax when user typed Trait<Ty = Trait2>
5 participants