-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip over structs with no private fields that impl Deref
- Loading branch information
1 parent
2a3fd50
commit 603ffeb
Showing
3 changed files
with
57 additions
and
3 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
35 changes: 35 additions & 0 deletions
35
src/test/ui/suggestions/field-access-considering-privacy.rs
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 @@ | ||
use a::TyCtxt; | ||
|
||
mod a { | ||
use std::ops::Deref; | ||
pub struct TyCtxt<'tcx> { | ||
gcx: &'tcx GlobalCtxt<'tcx>, | ||
} | ||
|
||
impl<'tcx> Deref for TyCtxt<'tcx> { | ||
type Target = &'tcx GlobalCtxt<'tcx>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.gcx | ||
} | ||
} | ||
|
||
pub struct GlobalCtxt<'tcx> { | ||
pub sess: &'tcx Session, | ||
_t: &'tcx (), | ||
} | ||
|
||
pub struct Session { | ||
pub opts: (), | ||
} | ||
} | ||
|
||
mod b { | ||
fn foo<'tcx>(tcx: crate::TyCtxt<'tcx>) { | ||
tcx.opts; | ||
//~^ ERROR no field `opts` on type `TyCtxt<'tcx>` | ||
//~| HELP one of the expressions' fields has a field of the same name | ||
} | ||
} | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/suggestions/field-access-considering-privacy.stderr
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[E0609]: no field `opts` on type `TyCtxt<'tcx>` | ||
--> $DIR/field-access-considering-privacy.rs:29:13 | ||
| | ||
LL | tcx.opts; | ||
| ^^^^ unknown field | ||
| | ||
help: one of the expressions' fields has a field of the same name | ||
| | ||
LL | tcx.sess.opts; | ||
| +++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0609`. |