- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Migrate rustc_trait_selection::traits::error_reporting::suggestions to SessionDiagnostic
          #101466
        
          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
  
    Migrate rustc_trait_selection::traits::error_reporting::suggestions to SessionDiagnostic
  
  #101466
              Conversation
… to `SessionDiagnostic` Part of rust-lang#100717.
| r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) | 
| The job  Click to see the possible cause of the failure (guessed by this bot) | 
| r? @davidtwco | 
| ☔ The latest upstream changes (presumably #101736) made this pull request unmergeable. Please resolve the merge conflicts. | 
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.
Apologies that it took so long for me to get to this review!
| // FIXME: Ensure that the create_err() calls below are equivalent to: | ||
| // err.code(error_code!(E0746)); | ||
| // err.set_primary_message("return type cannot have an unboxed trait object"); | ||
| // err.children.clear(); | 
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.
create_err creates an entirely new error so it might not be exactly the same but if it isn't observable in testing then it's probably fine.
| err.subdiagnostic(NoteObligation::RepeatElementCopyHelpConstFn { | ||
| example_a: "const VAL: Type = const_fn();", | ||
| example_b: "let x = [VAL; 42];", | ||
| }); | 
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.
Why not just include example_a and example_b in the Fluent message?
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.
This way, the translators don't need to deal with the Rust code, we ensure that it is identical across all translations with no typos, and if the Rust code needs updating we can potentially do so without altering the translations.
| }, | ||
| ); | ||
| if ty.references_error() { | ||
| err.span_label(span, &String::new()); | 
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.
You might be able to do this with a
trait_selection_empty = {""}| assoc_span, | ||
| predicate: predicate.to_string(), | ||
| item_name, | ||
| kind: kind.to_string(), | 
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.
Can we implement IntoDiagnosticArg on this?
| _ => err.note(&msg), | ||
| _ => err.subdiagnostic(NoteObligation::ImplDerivedObligation { | ||
| ty: parent_trait_pred.skip_binder().self_ty(), | ||
| trait_path: parent_trait_pred.print_modifiers_and_trait_path().to_string(), | 
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 might be able to implement IntoDiagnosticArg for TraitPredPrintModifiersAndPath too
| Hi, I've seen you changed some diagnostic structs in your PR. After #103345, the way we refer to fluent messages changed. They are now in a flat namespace with the same identifier as in the fluent file. For example,   | 
| @str4d any updates on this? | 
| Closing this pr as inactive | 
Part of #100717.