Skip to content

Commit 1c2ea78

Browse files
committed
Skip unstable fields when suggesting wrapping expression in structs
1 parent 5e39b35 commit 1c2ea78

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_typeck/src/check/demand.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::check::FnCtxt;
22
use rustc_infer::infer::InferOk;
3+
use rustc_middle::middle::stability::EvalResult;
34
use rustc_trait_selection::infer::InferCtxtExt as _;
45
use rustc_trait_selection::traits::ObligationCause;
56

@@ -374,7 +375,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
374375

375376
let field_is_local = sole_field.did.is_local();
376377
let field_is_accessible =
377-
sole_field.vis.is_accessible_from(expr.hir_id.owner.to_def_id(), self.tcx);
378+
sole_field.vis.is_accessible_from(expr.hir_id.owner.to_def_id(), self.tcx)
379+
// Skip suggestions for unstable public fields (for example `Pin::pointer`)
380+
&& matches!(self.tcx.eval_stability(sole_field.did, None, expr.span, None), EvalResult::Allow | EvalResult::Unmarked);
378381

379382
if !field_is_local && !field_is_accessible {
380383
return None;

0 commit comments

Comments
 (0)