Skip to content

Commit 4e9a2a6

Browse files
committed
Remove allow_private entirely.
1 parent 7b837e0 commit 4e9a2a6

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,13 +2310,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23102310

23112311
let guar = if field.name == kw::Empty {
23122312
self.tcx.sess.delay_span_bug(field.span, "field name with no name")
2313-
} else if self.method_exists(
2314-
field,
2315-
base_ty,
2316-
expr.hir_id,
2317-
false, // don't mention or suggest non-accessible methods
2318-
expected.only_has_type(self),
2319-
) {
2313+
} else if self.method_exists(field, base_ty, expr.hir_id, expected.only_has_type(self)) {
23202314
self.ban_take_value_of_method(expr, base_ty, field)
23212315
} else if !base_ty.is_primitive_ty() {
23222316
self.ban_nonexisting_field(field, base, expr, base_ty)
@@ -2501,7 +2495,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25012495
let mut err = self.private_field_err(field, base_did);
25022496

25032497
// Also check if an accessible method exists, which is often what is meant.
2504-
if self.method_exists(field, expr_t, expr.hir_id, false, return_ty)
2498+
if self.method_exists(field, expr_t, expr.hir_id, return_ty)
25052499
&& !self.expr_in_place(expr.hir_id)
25062500
{
25072501
self.suggest_method_call(

compiler/rustc_hir_typeck/src/method/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ pub enum CandidateSource {
8989
}
9090

9191
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
92-
/// Determines whether the type `self_ty` supports a method name `method_name` or not.
92+
/// Determines whether the type `self_ty` supports a visible method named `method_name` or not.
9393
#[instrument(level = "debug", skip(self))]
9494
pub fn method_exists(
9595
&self,
9696
method_name: Ident,
9797
self_ty: Ty<'tcx>,
9898
call_expr_id: hir::HirId,
99-
allow_private: bool,
10099
return_type: Option<Ty<'tcx>>,
101100
) -> bool {
102101
match self.probe_for_name(
@@ -118,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
118117
}
119118
Err(NoMatch(..)) => false,
120119
Err(Ambiguity(..)) => true,
121-
Err(PrivateMatch(..)) => allow_private,
120+
Err(PrivateMatch(..)) => false,
122121
Err(IllegalSizedBound { .. }) => true,
123122
Err(BadReturnType) => false,
124123
}

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,8 +2361,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23612361
Some(output_ty) => self.resolve_vars_if_possible(output_ty),
23622362
_ => return,
23632363
};
2364-
let method_exists =
2365-
self.method_exists(item_name, output_ty, call.hir_id, true, return_type);
2364+
let method_exists = self.method_exists(item_name, output_ty, call.hir_id, return_type);
23662365
debug!("suggest_await_before_method: is_method_exist={}", method_exists);
23672366
if method_exists {
23682367
err.span_suggestion_verbose(

0 commit comments

Comments
 (0)