-
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.
Rollup merge of #100098 - compiler-errors:field-suggestion-fixups, r=…
…davidtwco Some "this expression has a field"-related fixes Each commit does something different and is worth reviewing, but the final diff from `master..HEAD` contains the sum of the changes to the UI tests, since some commits added UI tests "regressions" which were later removed in other commits. The only change I could see adding on top of this is suppressing `Clone::clone` from the "this expression has a field that has this method" suggestion, since it's so commonly implemented by types that it's not worthwhile suggesting in general.
- Loading branch information
Showing
8 changed files
with
117 additions
and
41 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
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
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`. |