- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1 #100814
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
          
     Merged
      
      
            bors
  merged 1 commit into
  rust-lang:master
from
gabrielbusta:port_trait_selection_diagnostics
  
      
      
   
  Sep 2, 2022 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            26 changes: 26 additions & 0 deletions
          
          26 
        
  compiler/rustc_error_messages/locales/en-US/trait_selection.ftl
  
  
      
      
   
        
      
      
    
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| trait_selection_dump_vtable_entries = vtable entries for `{$trait_ref}`: {$entries} | ||
|  | ||
| trait_selection_unable_to_construct_constant_value = unable to construct a constant value for the unevaluated constant {$unevaluated} | ||
|  | ||
| trait_selection_auto_deref_reached_recursion_limit = reached the recursion limit while auto-dereferencing `{$ty}` | ||
| .label = deref recursion limit reached | ||
| .help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` attribute to your crate (`{$crate_name}`) | ||
|  | ||
| trait_selection_empty_on_clause_in_rustc_on_unimplemented = empty `on`-clause in `#[rustc_on_unimplemented]` | ||
| .label = empty on-clause here | ||
|  | ||
| trait_selection_invalid_on_clause_in_rustc_on_unimplemented = invalid `on`-clause in `#[rustc_on_unimplemented]` | ||
| .label = invalid on-clause here | ||
|  | ||
| trait_selection_no_value_in_rustc_on_unimplemented = this attribute must have a valid value | ||
| .label = expected value here | ||
| .note = eg `#[rustc_on_unimplemented(message="foo")]` | ||
|  | ||
| trait_selection_negative_positive_conflict = found both positive and negative implementation of trait `{$trait_desc}`{$self_desc -> | ||
| [none] {""} | ||
| *[default] {" "}for type `{$self_desc}` | ||
| }: | ||
| .negative_implementation_here = negative implementation here | ||
| .negative_implementation_in_crate = negative implementation in crate `{$negative_impl_cname}` | ||
| .positive_implementation_here = positive implementation here | ||
| .positive_implementation_in_crate = positive implementation in crate `{$positive_impl_cname}` | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| use rustc_errors::{fluent, ErrorGuaranteed}; | ||
| use rustc_macros::SessionDiagnostic; | ||
| use rustc_middle::ty::{PolyTraitRef, Ty, Unevaluated}; | ||
| use rustc_session::{parse::ParseSess, Limit, SessionDiagnostic}; | ||
| use rustc_span::{Span, Symbol}; | ||
|  | ||
| #[derive(SessionDiagnostic)] | ||
| #[diag(trait_selection::dump_vtable_entries)] | ||
| pub struct DumpVTableEntries<'a> { | ||
| #[primary_span] | ||
| pub span: Span, | ||
| pub trait_ref: PolyTraitRef<'a>, | ||
| pub entries: String, | ||
| } | ||
|  | ||
| #[derive(SessionDiagnostic)] | ||
| #[diag(trait_selection::unable_to_construct_constant_value)] | ||
| pub struct UnableToConstructConstantValue<'a> { | ||
| #[primary_span] | ||
| pub span: Span, | ||
| pub unevaluated: Unevaluated<'a>, | ||
| } | ||
|  | ||
| #[derive(SessionDiagnostic)] | ||
| #[help] | ||
| #[diag(trait_selection::auto_deref_reached_recursion_limit, code = "E0055")] | ||
| pub struct AutoDerefReachedRecursionLimit<'a> { | ||
| #[primary_span] | ||
| #[label] | ||
| pub span: Span, | ||
| pub ty: Ty<'a>, | ||
| pub suggested_limit: Limit, | ||
| pub crate_name: Symbol, | ||
| } | ||
|  | ||
| #[derive(SessionDiagnostic)] | ||
| #[diag(trait_selection::empty_on_clause_in_rustc_on_unimplemented, code = "E0232")] | ||
| pub struct EmptyOnClauseInOnUnimplemented { | ||
| #[primary_span] | ||
| #[label] | ||
| pub span: Span, | ||
| } | ||
|  | ||
| #[derive(SessionDiagnostic)] | ||
| #[diag(trait_selection::invalid_on_clause_in_rustc_on_unimplemented, code = "E0232")] | ||
| pub struct InvalidOnClauseInOnUnimplemented { | ||
| #[primary_span] | ||
| #[label] | ||
| pub span: Span, | ||
| } | ||
|  | ||
| #[derive(SessionDiagnostic)] | ||
| #[diag(trait_selection::no_value_in_rustc_on_unimplemented, code = "E0232")] | ||
| #[note] | ||
| pub struct NoValueInOnUnimplemented { | ||
| #[primary_span] | ||
| #[label] | ||
| pub span: Span, | ||
| } | ||
|  | ||
| pub struct NegativePositiveConflict<'a> { | ||
| pub impl_span: Span, | ||
| pub trait_desc: &'a str, | ||
| pub self_desc: &'a Option<String>, | ||
| pub negative_impl_span: Result<Span, Symbol>, | ||
| pub positive_impl_span: Result<Span, Symbol>, | ||
| } | ||
|  | ||
| impl SessionDiagnostic<'_> for NegativePositiveConflict<'_> { | ||
| fn into_diagnostic( | ||
| self, | ||
| sess: &ParseSess, | ||
| ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> { | ||
| let mut diag = sess.struct_err(fluent::trait_selection::negative_positive_conflict); | ||
| diag.set_arg("trait_desc", self.trait_desc); | ||
| diag.set_arg( | ||
| "self_desc", | ||
| self.self_desc.clone().map_or_else(|| String::from("none"), |ty| ty), | ||
| ); | ||
| diag.set_span(self.impl_span); | ||
| diag.code(rustc_errors::error_code!(E0751)); | ||
| match self.negative_impl_span { | ||
| Ok(span) => { | ||
| diag.span_label(span, fluent::trait_selection::negative_implementation_here); | ||
| } | ||
| Err(cname) => { | ||
| diag.note(fluent::trait_selection::negative_implementation_in_crate); | ||
| diag.set_arg("negative_impl_cname", cname.to_string()); | ||
| } | ||
| } | ||
| match self.positive_impl_span { | ||
| Ok(span) => { | ||
| diag.span_label(span, fluent::trait_selection::positive_implementation_here); | ||
| } | ||
| Err(cname) => { | ||
| diag.note(fluent::trait_selection::positive_implementation_in_crate); | ||
| diag.set_arg("positive_impl_cname", cname.to_string()); | ||
| } | ||
| } | ||
| diag | ||
| } | ||
| } | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.