-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
Could not assign reviewer from: |
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()) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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 🤷
89b92c5
to
d617f18
Compare
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))); |
There was a problem hiding this comment.
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.
d617f18
to
d460ffc
Compare
There was a problem hiding this 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), |
There was a problem hiding this comment.
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)
Then r=me @bors rollup |
d460ffc
to
f79ab27
Compare
This comment has been minimized.
This comment has been minimized.
f79ab27
to
4c53ad5
Compare
@bors r=fmease rollup |
…fmease Pretty print async fn sugar in opaques and trait bounds sudo r? fmease
…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
…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
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)]), |
There was a problem hiding this comment.
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.
sudo r? fmease