Introduce #[diagnostic::on_type_error(message)]#155200
Conversation
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_hir/src/attrs |
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? estebank |
|
Before you sink more time and effort into this you should explain what you want One expectation I have is that it can specialize for different types. For example if you put this attribute on struct A but the typeerror finds a B or C instead you'll want to emit different messages for them, similar to how the filtering in I'm not convinced this attribute can be implemented in a satisfying way at this time. I'm open to being convinced otherwise though, and am happy to hear your thoughts. |
|
@mejrs two things: I agree that we want filtering in the same way as #[diagnostic::on_type_error(
note = "text",
)]
struct S<T>(T);with an eye for something along the lines of #[diagnostic::on_type_error(
on(expected="Self", found="crate::K", T = "i32", note = "a"),
on(expected="crate::K", found="Self", note = "b"),
note = "c",
)]
struct S<T>(T);some time later. I believe that having the minimal functionality at least lets crate authors include the "filtering information" in the text itself ("if this is the found type, then..." or "if type parameter T is blah, ..."), and that there are already several cases in the std of unconditional addition of notes during error reporting for given types, so I think the minimal functionality is already adding value. For the filtering I would like to share the same parser between on_type_error and on_unimplemented, as it is effectively the same functionality. |
|
Did you two have a discussion about this beforehand? I'd like to read it.
I presume you are talking about this? rust/compiler/rustc_hir_typeck/src/method/suggest.rs Lines 3156 to 3345 in e8e4541 The bit about unwrapping Option/Result is actually really impactful for learners and the way you propose the attribute it should be able to do that sort of thing (minus the inline code suggestions, obviously). So 💯 from me. Let's go for a minimal version for now, like estebank said: #[diagnostic::on_type_error(
note = "text",
)]
struct S<T>(T);I'm a bit worried about this thing being too powerful and showing up in places where authors didn't quite expect or intend. There are after all quite a few ways and places to get type errors. I think the following semantics would be reasonably useful but also restrictive enough to not spook me or the lang people.
Then in the future, when we evolve the attribute forwards, we can specify something like "if you dont supply any filter then this wrapper kind of thing is all it can do". |
There was a discussion initally, it was through video meet though, but, nothing much more than whatever is here actually.
Agreed. |
c6cbaa7 to
5b090d2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6366fc0 to
924b894
Compare
This comment has been minimized.
This comment has been minimized.
924b894 to
2392d19
Compare
This comment has been minimized.
This comment has been minimized.
Suggested-by: Esteban Küber <esteban@kuber.com.ar> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
4976718 to
78d7543
Compare
|
I think I'm just going to go ahead and merge this now. Thanks for working on this and I'm somewhat sorry it all took so long. @bors r+ rollup |
…_error, r=mejrs Introduce #[diagnostic::on_type_error(message)]
Thanks for the review and the feedback, I do really appreciate. Thanks. |
Rollup of 4 pull requests Successful merges: - #155200 (Introduce #[diagnostic::on_type_error(message)]) - #157538 (std: move `PidFd` to `sys::process`) - #157791 (Add regression test for pclmulqdq inlining across target feature) - #157867 (std: sys: xous: clamp condvar wait_timeout instead of truncating)
This comment has been minimized.
This comment has been minimized.
…ejrs Introduce #[diagnostic::on_type_error(message)]
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test for 83f3367 failed: CI. Failed job:
|
|
@bors retry |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 9ae5f52 (parent) -> 4f8ea98 (this PR) Test differencesShow 173 test diffsStage 1
Stage 2
Additionally, 128 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 4f8ea98eb3e462eec4a005a4a93dfd21b9525af2 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (4f8ea98): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -1.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.0%, secondary -2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 517.026s -> 517.813s (0.15%) |
View all comments