-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Types borrow box #1501
Merged
Merged
Types borrow box #1501
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
711cad1
check for borrowed box types
a4c4da1
Fix typo in types check
80cb48c
Actually fix the lint applied
e6eaa72
Recurse into inner type when not `&Box<T>`
c061464
Add more exhaustive tests for borrow_box
663688f
Move old-style test to examples
deef81a
Use span_suggestion in borrowed_box lint
c29f5ea
Commit updated example stderr
74ebe6e
Add `check_local` to `TypePass` for `BORROWED_BOX`
54b5205
Test for local types in `LINKEDLIST` and `BOX_VEC`
49bba31
Merge nested `if` into adjacent `if_let_chain!`
1a50755
Document `check_ty` and its new `is_local` arg.
5db8647
Test for trait method decl/impl for borrowed box.
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 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 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 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 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 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,34 @@ | ||
#![feature(plugin)] | ||
#![plugin(clippy)] | ||
|
||
#![deny(borrowed_box)] | ||
#![allow(blacklisted_name)] | ||
#![allow(unused_variables)] | ||
#![allow(dead_code)] | ||
|
||
pub fn test1(foo: &mut Box<bool>) { | ||
println!("{:?}", foo) | ||
} | ||
|
||
pub fn test2() { | ||
let foo: &Box<bool>; | ||
} | ||
|
||
struct Test3<'a> { | ||
foo: &'a Box<bool> | ||
} | ||
|
||
trait Test4 { | ||
fn test4(a: &Box<bool>); | ||
} | ||
|
||
impl<'a> Test4 for Test3<'a> { | ||
fn test4(a: &Box<bool>) { | ||
unimplemented!(); | ||
} | ||
} | ||
|
||
fn main(){ | ||
test1(&mut Box::new(false)); | ||
test2(); | ||
} |
This file contains 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,35 @@ | ||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` | ||
--> borrow_box.rs:9:19 | ||
| | ||
9 | pub fn test1(foo: &mut Box<bool>) { | ||
| ^^^^^^^^^^^^^^ help: try `&mut bool` | ||
| | ||
note: lint level defined here | ||
--> borrow_box.rs:4:9 | ||
| | ||
4 | #![deny(borrowed_box)] | ||
| ^^^^^^^^^^^^ | ||
|
||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` | ||
--> borrow_box.rs:14:14 | ||
| | ||
14 | let foo: &Box<bool>; | ||
| ^^^^^^^^^^ help: try `&bool` | ||
|
||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` | ||
--> borrow_box.rs:18:10 | ||
| | ||
18 | foo: &'a Box<bool> | ||
| ^^^^^^^^^^^^^ help: try `&'a bool` | ||
|
||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` | ||
--> borrow_box.rs:22:17 | ||
| | ||
22 | fn test4(a: &Box<bool>); | ||
| ^^^^^^^^^^ help: try `&bool` | ||
|
||
error: aborting due to previous error(s) | ||
|
||
error: Could not compile `clippy_tests`. | ||
|
||
To learn more, run the command again with --verbose. |
This file contains 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 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.
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 you add a trait method taking a box reference and an impl to show that only the trait is linted and not the impl?