- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
          Add rc_buffer lint for checking Rc<String> and friends
          #6044
        
          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
      
      
    
  
     Merged
                    Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      1b5317f
              
                Add rc_buffer lint for Rc<String> and other buffer types
              
              
                rschoon 2dd7175
              
                Apply rc_buffer lint to Arc<T>
              
              
                rschoon d0ddbb9
              
                Extend testing of rc_buffer lint
              
              
                rschoon 2720085
              
                Move rc_buffer lint into perf category
              
              
                rschoon 6c056d3
              
                Satisfy rc_buffer lint in Constant::Binary byte string by copying data
              
              
                rschoon 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
  
    
      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,13 @@ | ||
| use std::ffi::OsString; | ||
| use std::path::PathBuf; | ||
| use std::rc::Rc; | ||
|  | ||
| #[warn(clippy::rc_buffer)] | ||
| struct S { | ||
|         
                  yaahc marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| a: Rc<String>, | ||
| b: Rc<PathBuf>, | ||
| c: Rc<Vec<u8>>, | ||
| d: Rc<OsString>, | ||
| } | ||
|  | ||
| fn main() {} | ||
  
    
      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,28 @@ | ||
| error: usage of `Rc<T>` when T is a buffer type | ||
| --> $DIR/rc_buffer.rs:7:8 | ||
| | | ||
| LL | a: Rc<String>, | ||
| | ^^^^^^^^^^ help: try: `Rc<str>` | ||
| | | ||
| = note: `-D clippy::rc-buffer` implied by `-D warnings` | ||
|  | ||
| error: usage of `Rc<T>` when T is a buffer type | ||
| --> $DIR/rc_buffer.rs:8:8 | ||
| | | ||
| LL | b: Rc<PathBuf>, | ||
| | ^^^^^^^^^^^ help: try: `Rc<std::path::Path>` | ||
|  | ||
| error: usage of `Rc<T>` when T is a buffer type | ||
| --> $DIR/rc_buffer.rs:9:8 | ||
| | | ||
| LL | c: Rc<Vec<u8>>, | ||
| | ^^^^^^^^^^^ help: try: `Rc<[u8]>` | ||
|  | ||
| error: usage of `Rc<T>` when T is a buffer type | ||
| --> $DIR/rc_buffer.rs:10:8 | ||
| | | ||
| LL | d: Rc<OsString>, | ||
| | ^^^^^^^^^^^^ help: try: `Rc<std::ffi::OsStr>` | ||
|  | ||
| error: aborting due to 4 previous errors | ||
|  | 
  
    
      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,13 @@ | ||
| use std::ffi::OsString; | ||
| use std::path::PathBuf; | ||
| use std::sync::Arc; | ||
|  | ||
| #[warn(clippy::rc_buffer)] | ||
| struct S { | ||
| a: Arc<String>, | ||
| b: Arc<PathBuf>, | ||
| c: Arc<Vec<u8>>, | ||
| d: Arc<OsString>, | ||
| } | ||
|  | ||
| fn main() {} | 
  
    
      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,28 @@ | ||
| error: usage of `Arc<T>` when T is a buffer type | ||
| --> $DIR/rc_buffer_arc.rs:7:8 | ||
| | | ||
| LL | a: Arc<String>, | ||
| | ^^^^^^^^^^^ help: try: `Arc<str>` | ||
| | | ||
| = note: `-D clippy::rc-buffer` implied by `-D warnings` | ||
|  | ||
| error: usage of `Arc<T>` when T is a buffer type | ||
| --> $DIR/rc_buffer_arc.rs:8:8 | ||
| | | ||
| LL | b: Arc<PathBuf>, | ||
| | ^^^^^^^^^^^^ help: try: `Arc<std::path::Path>` | ||
|  | ||
| error: usage of `Arc<T>` when T is a buffer type | ||
| --> $DIR/rc_buffer_arc.rs:9:8 | ||
| | | ||
| LL | c: Arc<Vec<u8>>, | ||
| | ^^^^^^^^^^^^ help: try: `Arc<[u8]>` | ||
|  | ||
| error: usage of `Arc<T>` when T is a buffer type | ||
| --> $DIR/rc_buffer_arc.rs:10:8 | ||
| | | ||
| LL | d: Arc<OsString>, | ||
| | ^^^^^^^^^^^^^ help: try: `Arc<std::ffi::OsStr>` | ||
|  | ||
| error: aborting due to 4 previous errors | ||
|  | 
  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.