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

Pretty print async fn sugar in opaques and trait bounds #132911

Merged
merged 2 commits into from
Nov 23, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Nov 11, 2024

sudo r? fmease

@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 Nov 11, 2024
@rustbot
Copy link
Collaborator

rustbot commented Nov 11, 2024

Could not assign reviewer from: fmease.
User(s) fmease are either the PR author, already assigned, or on vacation, and there are no other candidates.
Use r? to specify someone else to assign.

let generics = tcx.generics_of(trait_ref.def_id);
let own_args = generics.own_args_no_defaults(tcx, trait_ref.args);

match (entry.return_ty, own_args[0].expect_ty()) {
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 have noooooooOOoOooooooo idea wtf was going on here lmao

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, something about this part was load-bearing, cf. #133597

@@ -1230,51 +1206,48 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
/// traits map or fn_traits map, depending on if the trait is in the Fn* family of traits.
fn insert_trait_and_projection(
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'm pretty disappointed with how sensitive to bound var renumbering this is... but 🤷

if let Some(return_ty) = entry.return_ty {
self.wrap_binder(&bound_args, |args, cx| {
define_scoped_cx!(cx);
p!(write("{}", tcx.item_name(trait_def_id)));
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 very easily start making this print like async Fn in the future.

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Thanks, one small suggestion

@@ -1007,24 +1007,22 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}

self.insert_trait_and_projection(
trait_ref,
pred.polarity,
bound_predicate.rebind(pred),
Copy link
Member

@fmease fmease Nov 21, 2024

Choose a reason for hiding this comment

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

As a nice consequence, now the

let trait_ref = bound_predicate.rebind(pred.trait_ref);
// ...
if tcx.is_lang_item(trait_ref.def_id(), LangItem::Sized) {

a few lines above can be simplified to

// ...
if tcx.is_lang_item(pred.def_id(), LangItem::Sized) {

(GH doesn't let me comment directly on those lines)

@fmease
Copy link
Member

fmease commented Nov 22, 2024

Then r=me @bors rollup

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member Author

@bors r=fmease rollup

@bors
Copy link
Contributor

bors commented Nov 22, 2024

📌 Commit 4c53ad5 has been approved by fmease

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 Nov 22, 2024
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Nov 22, 2024
…fmease

Pretty print async fn sugar in opaques and trait bounds

sudo r? fmease
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 23, 2024
…mpiler-errors

Rollup of 8 pull requests

Successful merges:

 - rust-lang#131505 (use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on Darwin)
 - rust-lang#131859 (Update TRPL to add new Chapter 17: Async and Await)
 - rust-lang#132090 (Stop being so bail-y in candidate assembly)
 - rust-lang#132597 (btree: don't leak value if destructor of key panics)
 - rust-lang#132911 (Pretty print async fn sugar in opaques and trait bounds)
 - rust-lang#133159 (Don't allow `-Zunstable-options` to take a value )
 - rust-lang#133247 (Reduce integer `Display` implementation size)
 - rust-lang#133286 (Re-delay a resolve `bug` related to `Self`-ctor in patterns)

Failed merges:

 - rust-lang#133215 (Fix missing submodule in `./x vendor`)

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

Rollup of 8 pull requests

Successful merges:

 - rust-lang#132090 (Stop being so bail-y in candidate assembly)
 - rust-lang#132658 (Detect const in pattern with typo)
 - rust-lang#132911 (Pretty print async fn sugar in opaques and trait bounds)
 - rust-lang#133102 (aarch64 softfloat target: always pass floats in int registers)
 - rust-lang#133159 (Don't allow `-Zunstable-options` to take a value )
 - rust-lang#133208 (generate-copyright: Now generates a library file too.)
 - rust-lang#133215 (Fix missing submodule in `./x vendor`)
 - rust-lang#133264 (implement OsString::truncate)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2a94e1c into rust-lang:master Nov 23, 2024
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Nov 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 23, 2024
Rollup merge of rust-lang#132911 - compiler-errors:async-fn-sugar, r=fmease

Pretty print async fn sugar in opaques and trait bounds

sudo r? fmease
traits.insert(
bound_args.map_bound(|args| ty::TraitPredicate {
polarity: ty::PredicatePolarity::Positive,
trait_ref: ty::TraitRef::new(tcx, trait_def_id, [Ty::new_tup(tcx, args)]),
Copy link
Member

@fmease fmease Nov 29, 2024

Choose a reason for hiding this comment

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

Ah, this is missing the self ty.

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.

6 participants