Add DesugaringKind::FormatLiteral#142594
Conversation
|
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
|
Some changes occurred in compiler/rustc_ast_lowering/src/format.rs cc @m-ou-se |
|
We might want to block this on #140748, I'm relatively sure. Just FYI |
|
Why is that? |
|
Idk, if it's not conflicting according to git and if it's not stepping on each other's toes in other ways, I guess it's fine — I only skimmed boths diffs. Mara's PR will likely get approved soon anyway. |
compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
Show resolved
Hide resolved
0cd0b91 to
3858b2c
Compare
SparrowLii
left a comment
There was a problem hiding this comment.
This is very meaningful and the impl looks fine. But adding a new desugaringKind for diagnostics needs some opinions IMO
r? diagnostics
| | | ||
| LL | println!("{:?} {:?}", Foo, Bar); | ||
| | ^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` | ||
| | ---- ^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` |
There was a problem hiding this comment.
It doesn't, but it does make that PR easier to implement; they can simply replace all of the diagnostic item stuff with a matches!(span.desugaring_kind(), Some(rustc_span::DesugaringKind::FormatLiteral {..}))
| | ----- in this derive macro expansion | ||
| LL | struct Outer<T>(Inner<T>); | ||
| | ^^^^^^^^ `a::Inner<T>` cannot be formatted using `{:?}` | ||
| | ^^^^^^^^ the trait `Debug` is not implemented for `a::Inner<T>` |
There was a problem hiding this comment.
I'm neutral about this change. Maybe some beginners need to know the relationship between Debug and {:?}. I am not sure about this.
|
Looks ok for me. @bors delegate+ |
|
✌️ @mejrs, you can now approve this pull request! If @chenyukang told you to " |
Add DesugaringKind::FormatLiteral Implements `DesugaringKind::FormatLiteral` to mark the FormatArgs desugaring of format literals. The main use for this is to stop yapping about about formatting parameters if we're not anywhere near a format literal. The other use case is to fix suggestions such as rust-lang#141350. It might also be useful for new or existing diagnostics that check whether they're in a format-like macro. cc `@xizheyin` `@fmease`
Rollup of 10 pull requests Successful merges: - #140254 (Pass -Cpanic=abort for the panic_abort crate) - #142594 (Add DesugaringKind::FormatLiteral) - #142600 (Port `#[rustc_pub_transparent]` to the new attribute system) - #142617 (improve search graph docs, reset `encountered_overflow` between reruns) - #142641 (Generate symbols.o for proc-macros too) - #142747 (rustdoc_json: conversion cleanups) - #142776 (All HIR attributes are outer) - #142800 (integer docs: remove extraneous text) - #142850 (remove asm_goto feature annotation, for it is now stabilized) - #142860 (Notify me on tidy changes) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - #142458 (Merge unboxed trait object error suggestion into regular dyn incompat error) - #142593 (Add a warning to LateContext::get_def_path) - #142594 (Add DesugaringKind::FormatLiteral) - #142740 (Clean-up `FnCtxt::is_destruct_assignment_desugaring`) - #142780 (Port `#[must_use]` to new attribute parsing infrastructure) - #142798 (Don't fail to parse a struct if a semicolon is used to separate fields) - #142856 (Add a few inline directives in rustc_serialize.) - #142868 (remove few allow(dead_code)) - #142874 (cranelift: fix target feature name typo: "fxsr") - #142877 (Document why tidy checks if `eslint` is installed via `npm`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #142594 - mejrs:new_desugaring, r=chenyukang Add DesugaringKind::FormatLiteral Implements `DesugaringKind::FormatLiteral` to mark the FormatArgs desugaring of format literals. The main use for this is to stop yapping about about formatting parameters if we're not anywhere near a format literal. The other use case is to fix suggestions such as #141350. It might also be useful for new or existing diagnostics that check whether they're in a format-like macro. cc `@xizheyin` `@fmease`
|
I've found that #141350 can't be solved directly using PR, as the ast lowering phase comes after name resolving, and I'm now not quite sure where I should mark span using |
Add DesugaringKind::FormatLiteral Implements `DesugaringKind::FormatLiteral` to mark the FormatArgs desugaring of format literals. The main use for this is to stop yapping about about formatting parameters if we're not anywhere near a format literal. The other use case is to fix suggestions such as rust-lang#141350. It might also be useful for new or existing diagnostics that check whether they're in a format-like macro. cc `@xizheyin` `@fmease`
Rollup of 10 pull requests Successful merges: - rust-lang/rust#142458 (Merge unboxed trait object error suggestion into regular dyn incompat error) - rust-lang/rust#142593 (Add a warning to LateContext::get_def_path) - rust-lang/rust#142594 (Add DesugaringKind::FormatLiteral) - rust-lang/rust#142740 (Clean-up `FnCtxt::is_destruct_assignment_desugaring`) - rust-lang/rust#142780 (Port `#[must_use]` to new attribute parsing infrastructure) - rust-lang/rust#142798 (Don't fail to parse a struct if a semicolon is used to separate fields) - rust-lang/rust#142856 (Add a few inline directives in rustc_serialize.) - rust-lang/rust#142868 (remove few allow(dead_code)) - rust-lang/rust#142874 (cranelift: fix target feature name typo: "fxsr") - rust-lang/rust#142877 (Document why tidy checks if `eslint` is installed via `npm`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - rust-lang/rust#142458 (Merge unboxed trait object error suggestion into regular dyn incompat error) - rust-lang/rust#142593 (Add a warning to LateContext::get_def_path) - rust-lang/rust#142594 (Add DesugaringKind::FormatLiteral) - rust-lang/rust#142740 (Clean-up `FnCtxt::is_destruct_assignment_desugaring`) - rust-lang/rust#142780 (Port `#[must_use]` to new attribute parsing infrastructure) - rust-lang/rust#142798 (Don't fail to parse a struct if a semicolon is used to separate fields) - rust-lang/rust#142856 (Add a few inline directives in rustc_serialize.) - rust-lang/rust#142868 (remove few allow(dead_code)) - rust-lang/rust#142874 (cranelift: fix target feature name typo: "fxsr") - rust-lang/rust#142877 (Document why tidy checks if `eslint` is installed via `npm`) r? `@ghost` `@rustbot` modify labels: rollup
Implements
DesugaringKind::FormatLiteralto mark the FormatArgs desugaring of format literals. The main use for this is to stop yapping about about formatting parameters if we're not anywhere near a format literal. The other use case is to fix suggestions such as #141350. It might also be useful for new or existing diagnostics that check whether they're in a format-like macro.cc @xizheyin @fmease