Remove allow_private
entirely.
This commit is contained in:
parent
7b837e075a
commit
4e9a2a6ff6
@ -2310,13 +2310,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
let guar = if field.name == kw::Empty {
|
let guar = if field.name == kw::Empty {
|
||||||
self.tcx.sess.delay_span_bug(field.span, "field name with no name")
|
self.tcx.sess.delay_span_bug(field.span, "field name with no name")
|
||||||
} else if self.method_exists(
|
} else if self.method_exists(field, base_ty, expr.hir_id, expected.only_has_type(self)) {
|
||||||
field,
|
|
||||||
base_ty,
|
|
||||||
expr.hir_id,
|
|
||||||
false, // don't mention or suggest non-accessible methods
|
|
||||||
expected.only_has_type(self),
|
|
||||||
) {
|
|
||||||
self.ban_take_value_of_method(expr, base_ty, field)
|
self.ban_take_value_of_method(expr, base_ty, field)
|
||||||
} else if !base_ty.is_primitive_ty() {
|
} else if !base_ty.is_primitive_ty() {
|
||||||
self.ban_nonexisting_field(field, base, expr, base_ty)
|
self.ban_nonexisting_field(field, base, expr, base_ty)
|
||||||
@ -2501,7 +2495,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let mut err = self.private_field_err(field, base_did);
|
let mut err = self.private_field_err(field, base_did);
|
||||||
|
|
||||||
// Also check if an accessible method exists, which is often what is meant.
|
// Also check if an accessible method exists, which is often what is meant.
|
||||||
if self.method_exists(field, expr_t, expr.hir_id, false, return_ty)
|
if self.method_exists(field, expr_t, expr.hir_id, return_ty)
|
||||||
&& !self.expr_in_place(expr.hir_id)
|
&& !self.expr_in_place(expr.hir_id)
|
||||||
{
|
{
|
||||||
self.suggest_method_call(
|
self.suggest_method_call(
|
||||||
|
@ -89,14 +89,13 @@ pub enum CandidateSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
/// Determines whether the type `self_ty` supports a method name `method_name` or not.
|
/// Determines whether the type `self_ty` supports a visible method named `method_name` or not.
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
pub fn method_exists(
|
pub fn method_exists(
|
||||||
&self,
|
&self,
|
||||||
method_name: Ident,
|
method_name: Ident,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
call_expr_id: hir::HirId,
|
call_expr_id: hir::HirId,
|
||||||
allow_private: bool,
|
|
||||||
return_type: Option<Ty<'tcx>>,
|
return_type: Option<Ty<'tcx>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match self.probe_for_name(
|
match self.probe_for_name(
|
||||||
@ -118,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
Err(NoMatch(..)) => false,
|
Err(NoMatch(..)) => false,
|
||||||
Err(Ambiguity(..)) => true,
|
Err(Ambiguity(..)) => true,
|
||||||
Err(PrivateMatch(..)) => allow_private,
|
Err(PrivateMatch(..)) => false,
|
||||||
Err(IllegalSizedBound { .. }) => true,
|
Err(IllegalSizedBound { .. }) => true,
|
||||||
Err(BadReturnType) => false,
|
Err(BadReturnType) => false,
|
||||||
}
|
}
|
||||||
|
@ -2361,8 +2361,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
Some(output_ty) => self.resolve_vars_if_possible(output_ty),
|
Some(output_ty) => self.resolve_vars_if_possible(output_ty),
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
let method_exists =
|
let method_exists = self.method_exists(item_name, output_ty, call.hir_id, return_type);
|
||||||
self.method_exists(item_name, output_ty, call.hir_id, true, return_type);
|
|
||||||
debug!("suggest_await_before_method: is_method_exist={}", method_exists);
|
debug!("suggest_await_before_method: is_method_exist={}", method_exists);
|
||||||
if method_exists {
|
if method_exists {
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user