diagnostics: port more diagnostics to derive + add support for Vec fields#96760
Merged
bors merged 4 commits intorust-lang:masterfrom May 7, 2022
Merged
diagnostics: port more diagnostics to derive + add support for Vec fields#96760bors merged 4 commits intorust-lang:masterfrom
Vec fields#96760bors merged 4 commits intorust-lang:masterfrom
Conversation
Port the "unconstrained opaque type" diagnostic to using the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
Diagnostics can have multiple primary spans, or have subdiagnostics repeated at multiple locations, so support `Vec<..>` fields in the diagnostic derive which become loops in the generated code. Signed-off-by: David Wood <david.wood@huawei.com>
Currently, the only API for creating errors from a diagnostic derive
will emit it immediately. This makes it difficult to add subdiagnostics
to diagnostics from the derive, so add `create_{err,warning}` functions
that return the diagnostic without emitting it.
Signed-off-by: David Wood <david.wood@huawei.com>
Port the "explicit generic arguments with impl trait" diagnostic to using the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
oli-obk
approved these changes
May 6, 2022
| pub(crate) fn option_inner_ty(ty: &Type) -> Option<&Type> { | ||
| if type_matches_path(ty, &["std", "option", "Option"]) { | ||
| /// Inner type of a field and type of wrapper. | ||
| pub(crate) enum FieldInnerTy<'ty> { |
Contributor
There was a problem hiding this comment.
This is ok for now, it's just inside rustc after all, but in the future we should probably invent a new trait that we can auto-impl for all subdiagnostics and manually impl for vec and option. The problem with the current approach is that it's dependent on exact names in the source, without actually tying them to the type we expect.
Contributor
|
@bors r+ |
Collaborator
|
📌 Commit af47257 has been approved by |
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
May 6, 2022
…c, r=oli-obk
diagnostics: port more diagnostics to derive + add support for `Vec` fields
- Port "unconstrained opaque type" diagnostic to using the derive.
- Allow `Vec` fields in diagnostic derive - enables support for diagnostics that have multiple primary spans, or have subdiagnostics repeated at multiple locations. `Vec<..>` fields in the diagnostic derive become loops in the generated code.
- Add `create_{err,warning}` - there wasn't a way to create a diagnostic from a struct and not emit it straight away.
- Port "explicit generic args w/ impl trait" diagnostic to using the derive.
r? `@oli-obk`
cc `@pvdrz`
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
May 6, 2022
…c, r=oli-obk
diagnostics: port more diagnostics to derive + add support for `Vec` fields
- Port "unconstrained opaque type" diagnostic to using the derive.
- Allow `Vec` fields in diagnostic derive - enables support for diagnostics that have multiple primary spans, or have subdiagnostics repeated at multiple locations. `Vec<..>` fields in the diagnostic derive become loops in the generated code.
- Add `create_{err,warning}` - there wasn't a way to create a diagnostic from a struct and not emit it straight away.
- Port "explicit generic args w/ impl trait" diagnostic to using the derive.
r? ``@oli-obk``
cc ``@pvdrz``
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
May 6, 2022
…c, r=oli-obk
diagnostics: port more diagnostics to derive + add support for `Vec` fields
- Port "unconstrained opaque type" diagnostic to using the derive.
- Allow `Vec` fields in diagnostic derive - enables support for diagnostics that have multiple primary spans, or have subdiagnostics repeated at multiple locations. `Vec<..>` fields in the diagnostic derive become loops in the generated code.
- Add `create_{err,warning}` - there wasn't a way to create a diagnostic from a struct and not emit it straight away.
- Port "explicit generic args w/ impl trait" diagnostic to using the derive.
r? ```@oli-obk```
cc ```@pvdrz```
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
May 7, 2022
…c, r=oli-obk
diagnostics: port more diagnostics to derive + add support for `Vec` fields
- Port "unconstrained opaque type" diagnostic to using the derive.
- Allow `Vec` fields in diagnostic derive - enables support for diagnostics that have multiple primary spans, or have subdiagnostics repeated at multiple locations. `Vec<..>` fields in the diagnostic derive become loops in the generated code.
- Add `create_{err,warning}` - there wasn't a way to create a diagnostic from a struct and not emit it straight away.
- Port "explicit generic args w/ impl trait" diagnostic to using the derive.
r? ````@oli-obk````
cc ````@pvdrz````
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 7, 2022
…laumeGomez Rollup of 7 pull requests Successful merges: - rust-lang#96581 (make Size and Align debug-printing a bit more compact) - rust-lang#96636 (Fix jump to def regression) - rust-lang#96760 (diagnostics: port more diagnostics to derive + add support for `Vec` fields) - rust-lang#96788 (Improve validator around field projections and checked bin ops) - rust-lang#96805 (Change eslint rules from configuration comments to configuration file) - rust-lang#96807 (update Miri) - rust-lang#96811 (Fix a minor typo in the description of Formatter) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 12, 2022
…-and-more-porting, r=oli-obk diagnostics: port more diagnostics to derive + support for `()` fields - Extend diagnostic derive so that spanless subdiagnostics (e.g. some uses of `help`/`note`) can be applied via attributes to fields of type `()` (currently spanless subdiagnostics are applied via attributes on the diagnostic struct itself). A consequence of this is that `Option<()>` fields can be used to represent optional spanless subdiagnostics, which are sometimes useful (e.g. for a `help` that should only show on nightly builds). - Simplify the "explicit generic args with impl trait" diagnostic struct (from rust-lang#96760) using support for `Option<()>` spanless subdiagnostics. - Change `DiagnosticBuilder::set_arg`, used to provide context for Fluent messages, so that it takes anything that implements `IntoDiagnosticArg`, rather than `DiagnosticArgValue` - this improves the ergonomics of manual implementations of `SessionDiagnostic` which are translatable. - Port "the type parameter `T` must be explicitly specified", "manual implementations of `X` are experimental", "could not resolve substs on overridden impl" diagnostics to diagnostic structs. - When testing macros from `rustc_macros` in `ui-fulldeps` tests, sometimes paths from the compiler source tree can be shown in error messages - these need to be normalized in `compiletest`. r? `@oli-obk` cc `@pvdrz`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vecfields in diagnostic derive - enables support for diagnostics that have multiple primary spans, or have subdiagnostics repeated at multiple locations.Vec<..>fields in the diagnostic derive become loops in the generated code.create_{err,warning}- there wasn't a way to create a diagnostic from a struct and not emit it straight away.r? @oli-obk
cc @pvdrz