Skip unstable fields when suggesting wrapping expression in structs
This commit is contained in:
parent
5e39b35a2f
commit
1c2ea78f29
1 changed files with 4 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
use crate::check::FnCtxt;
|
use crate::check::FnCtxt;
|
||||||
use rustc_infer::infer::InferOk;
|
use rustc_infer::infer::InferOk;
|
||||||
|
use rustc_middle::middle::stability::EvalResult;
|
||||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::traits::ObligationCause;
|
use rustc_trait_selection::traits::ObligationCause;
|
||||||
|
|
||||||
|
@ -374,7 +375,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let field_is_local = sole_field.did.is_local();
|
let field_is_local = sole_field.did.is_local();
|
||||||
let field_is_accessible =
|
let field_is_accessible =
|
||||||
sole_field.vis.is_accessible_from(expr.hir_id.owner.to_def_id(), self.tcx);
|
sole_field.vis.is_accessible_from(expr.hir_id.owner.to_def_id(), self.tcx)
|
||||||
|
// Skip suggestions for unstable public fields (for example `Pin::pointer`)
|
||||||
|
&& matches!(self.tcx.eval_stability(sole_field.did, None, expr.span, None), EvalResult::Allow | EvalResult::Unmarked);
|
||||||
|
|
||||||
if !field_is_local && !field_is_accessible {
|
if !field_is_local && !field_is_accessible {
|
||||||
return None;
|
return None;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue