- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          [diagnostics] Add mentions to Copy types being valid for union fields
          #94031
        
          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
danielhenrymantilla:diagnostics/union-drop-suggest-copy-bound-alternative
  
      
      
   
  Feb 17, 2022 
      
    
                
     Merged
            
            
  
    [diagnostics] Add mentions to Copy types being valid for union fields
  
  #94031
              
                    bors
  merged 1 commit into
  rust-lang:master
from
danielhenrymantilla:diagnostics/union-drop-suggest-copy-bound-alternative
  
      
      
   
  Feb 17, 2022 
              
            Conversation
  
    
      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
    
  
  
    
    | r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) | 
5a023ee    to
    9cc597b      
    Compare
  
    
              
                    davidtwco
  
              
              approved these changes
              
                  
                    Feb 16, 2022 
                  
              
              
            
            
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 looks like a straight forward improvement to me, r=me once my nittiest of nitpicks is resolved.
4657f1c    to
    43e6df1      
    Compare
  
    43e6df1    to
    6d2cdbe      
    Compare
  
    | @bors r+ | 
| 📌 Commit 6d2cdbe has been approved by  | 
    
  matthiaskrgr 
      added a commit
        to matthiaskrgr/rust
      that referenced
      this pull request
    
      Feb 16, 2022 
    
    
      
  
    
      
    
  
…on-drop-suggest-copy-bound-alternative, r=davidtwco [diagnostics] Add mentions to `Copy` types being valid for `union` fields This came up from some user on Discord which was using a `T : PrimitiveInt` generic type, and they wanted to use in a `union`. Rather than adding a `Copy` bound, they started pondering about the `ManuallyDrop<T>` road, and how to correctly use `unsafe` to perform the drops. <img width="648" alt="Screen Shot 2022-02-15 at 22 28 34" src="https://user-images.githubusercontent.com/9920355/154152496-8f9be74b-ad59-4724-8f9e-48b446774e06.png"> - [Discord link](https://discord.com/channels/442252698964721669/443150878111694848/943092778534072320) So, it seemed like the error message for types with potential drop glue on `union` fields could be improved to also mention the `Copy` alternative, since in many cases where `union`s are concerned, people are dealing with PODs / `Copy` types anyways 🙂 ___ `@rustbot` modify labels: +A-diagnostics +D-terse
    
  bors 
      added a commit
        to rust-lang-ci/rust
      that referenced
      this pull request
    
      Feb 17, 2022 
    
    
      
  
    
      
    
  
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#89869 (Add documentation to more `From::from` implementations.) - rust-lang#93479 (Use `optflag` for `--report-time`) - rust-lang#93693 (Suggest deriving required supertraits) - rust-lang#93981 (Fix suggestion to slice if scurtinee is a reference to `Result` or `Option`) - rust-lang#93996 (Do not suggest "is a function" for free variables) - rust-lang#94030 (Correctly mark the span of captured arguments in `format_args!()`) - rust-lang#94031 ([diagnostics] Add mentions to `Copy` types being valid for `union` fields) - rust-lang#94064 (Update dist-x86_64-musl to Ubuntu 20.04) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      Labels
      
    A-diagnostics
  Area: Messages for errors, warnings, and lints 
  
    D-terse
  Diagnostics: An error or lint that doesn't give enough information about the problem at hand. 
  
    S-waiting-on-bors
  Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 
  
    T-compiler
  Relevant to the compiler team, which will review and decide on the PR/issue. 
  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.
  
    
  
    
This came up from some user on Discord which was using a
T : PrimitiveIntgeneric type, and they wanted to use in aunion. Rather than adding aCopybound, they started pondering about theManuallyDrop<T>road, and how to correctly useunsafeto perform the drops.So, it seemed like the error message for types with potential drop glue on
unionfields could be improved to also mention theCopyalternative, since in many cases whereunions are concerned, people are dealing with PODs /Copytypes anyways 🙂@rustbot modify labels: +A-diagnostics +D-terse