-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress type errors that come from private fields
- Loading branch information
1 parent
fa51fc0
commit 59aa421
Showing
5 changed files
with
38 additions
and
11 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
fn main() { | ||
let x = foo::Foo::default(); | ||
if x.len { | ||
//~^ ERROR field `len` of struct `Foo` is private | ||
println!("foo"); | ||
} | ||
} | ||
|
||
mod foo { | ||
#[derive(Default)] | ||
pub struct Foo { | ||
len: String, | ||
} | ||
|
||
impl Foo { | ||
pub fn len(&self) -> usize { | ||
42 | ||
} | ||
} | ||
} |
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,14 @@ | ||
error[E0616]: field `len` of struct `Foo` is private | ||
--> $DIR/private-field-ty-err.rs:3:10 | ||
| | ||
LL | if x.len { | ||
| ^^^ private field | ||
| | ||
help: a method `len` also exists, call it with parentheses | ||
| | ||
LL | if x.len() { | ||
| ++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0616`. |