Remove BorrowckErrors trait
Its methods are now inherent methods of `MirBorrowckCtxt`
This commit is contained in:
parent
37a99038d0
commit
2cc2b942cf
@ -22,7 +22,7 @@ use super::{InitializationRequiringAction, PrefixSet};
|
||||
use super::error_reporting::{IncludingDowncast, UseSpans};
|
||||
use crate::dataflow::drop_flag_effects;
|
||||
use crate::dataflow::indexes::{MovePathIndex, MoveOutIndex};
|
||||
use crate::util::borrowck_errors::BorrowckErrors;
|
||||
use crate::util::borrowck_errors;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct MoveSite {
|
||||
@ -89,7 +89,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
Some(name) => format!("`{}`", name),
|
||||
None => "value".to_owned(),
|
||||
};
|
||||
let mut err = self.infcx.tcx.cannot_act_on_uninitialized_variable(
|
||||
let mut err = self.cannot_act_on_uninitialized_variable(
|
||||
span,
|
||||
desired_action.as_noun(),
|
||||
&self.describe_place_with_options(moved_place, IncludingDowncast(true))
|
||||
@ -119,7 +119,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
|
||||
let msg = ""; //FIXME: add "partially " or "collaterally "
|
||||
|
||||
let mut err = self.infcx.tcx.cannot_act_on_moved_value(
|
||||
let mut err = self.cannot_act_on_moved_value(
|
||||
span,
|
||||
desired_action.as_noun(),
|
||||
msg,
|
||||
@ -265,7 +265,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
"report_move_out_while_borrowed: location={:?} place={:?} span={:?} borrow={:?}",
|
||||
location, place, span, borrow
|
||||
);
|
||||
let tcx = self.infcx.tcx;
|
||||
let value_msg = match self.describe_place(place) {
|
||||
Some(name) => format!("`{}`", name),
|
||||
None => "value".to_owned(),
|
||||
@ -281,7 +280,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
let move_spans = self.move_spans(place, location);
|
||||
let span = move_spans.args_or_use();
|
||||
|
||||
let mut err = tcx.cannot_move_when_borrowed(
|
||||
let mut err = self.cannot_move_when_borrowed(
|
||||
span,
|
||||
&self.describe_place(place).unwrap_or_else(|| "_".to_owned()),
|
||||
);
|
||||
@ -312,8 +311,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
(place, _span): (&Place<'tcx>, Span),
|
||||
borrow: &BorrowData<'tcx>,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
let borrow_spans = self.retrieve_borrow_spans(borrow);
|
||||
let borrow_span = borrow_spans.args_or_use();
|
||||
|
||||
@ -322,7 +319,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
let use_spans = self.move_spans(place, location);
|
||||
let span = use_spans.var_or_use();
|
||||
|
||||
let mut err = tcx.cannot_use_when_mutably_borrowed(
|
||||
let mut err = self.cannot_use_when_mutably_borrowed(
|
||||
span,
|
||||
&self.describe_place(place).unwrap_or_else(|| "_".to_owned()),
|
||||
borrow_span,
|
||||
@ -372,7 +369,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
};
|
||||
|
||||
// FIXME: supply non-"" `opt_via` when appropriate
|
||||
let tcx = self.infcx.tcx;
|
||||
let first_borrow_desc;
|
||||
let mut err = match (
|
||||
gen_borrow_kind,
|
||||
@ -384,7 +380,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
) {
|
||||
(BorrowKind::Shared, lft, _, BorrowKind::Mut { .. }, _, rgt) => {
|
||||
first_borrow_desc = "mutable ";
|
||||
tcx.cannot_reborrow_already_borrowed(
|
||||
self.cannot_reborrow_already_borrowed(
|
||||
span,
|
||||
&desc_place,
|
||||
&msg_place,
|
||||
@ -398,7 +394,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
(BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => {
|
||||
first_borrow_desc = "immutable ";
|
||||
tcx.cannot_reborrow_already_borrowed(
|
||||
self.cannot_reborrow_already_borrowed(
|
||||
span,
|
||||
&desc_place,
|
||||
&msg_place,
|
||||
@ -413,7 +409,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
|
||||
(BorrowKind::Mut { .. }, _, _, BorrowKind::Mut { .. }, _, _) => {
|
||||
first_borrow_desc = "first ";
|
||||
tcx.cannot_mutably_borrow_multiply(
|
||||
self.cannot_mutably_borrow_multiply(
|
||||
span,
|
||||
&desc_place,
|
||||
&msg_place,
|
||||
@ -425,7 +421,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
|
||||
(BorrowKind::Unique, _, _, BorrowKind::Unique, _, _) => {
|
||||
first_borrow_desc = "first ";
|
||||
tcx.cannot_uniquely_borrow_by_two_closures(
|
||||
self.cannot_uniquely_borrow_by_two_closures(
|
||||
span,
|
||||
&desc_place,
|
||||
issued_span,
|
||||
@ -435,7 +431,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
|
||||
(BorrowKind::Mut { .. }, _, _, BorrowKind::Shallow, _, _)
|
||||
| (BorrowKind::Unique, _, _, BorrowKind::Shallow, _, _) => {
|
||||
let mut err = tcx.cannot_mutate_in_match_guard(
|
||||
let mut err = self.cannot_mutate_in_match_guard(
|
||||
span,
|
||||
issued_span,
|
||||
&desc_place,
|
||||
@ -453,7 +449,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
|
||||
(BorrowKind::Unique, _, _, _, _, _) => {
|
||||
first_borrow_desc = "first ";
|
||||
tcx.cannot_uniquely_borrow_by_one_closure(
|
||||
self.cannot_uniquely_borrow_by_one_closure(
|
||||
span,
|
||||
container_name,
|
||||
&desc_place,
|
||||
@ -467,7 +463,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
|
||||
(BorrowKind::Shared, lft, _, BorrowKind::Unique, _, _) => {
|
||||
first_borrow_desc = "first ";
|
||||
tcx.cannot_reborrow_already_uniquely_borrowed(
|
||||
self.cannot_reborrow_already_uniquely_borrowed(
|
||||
span,
|
||||
container_name,
|
||||
&desc_place,
|
||||
@ -482,7 +478,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
|
||||
(BorrowKind::Mut { .. }, _, lft, BorrowKind::Unique, _, _) => {
|
||||
first_borrow_desc = "first ";
|
||||
tcx.cannot_reborrow_already_uniquely_borrowed(
|
||||
self.cannot_reborrow_already_uniquely_borrowed(
|
||||
span,
|
||||
container_name,
|
||||
&desc_place,
|
||||
@ -821,7 +817,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let mut err = self.infcx.tcx.path_does_not_live_long_enough(
|
||||
let mut err = self.path_does_not_live_long_enough(
|
||||
borrow_span,
|
||||
&format!("`{}`", name),
|
||||
);
|
||||
@ -912,9 +908,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
let borrow_spans = self.retrieve_borrow_spans(borrow);
|
||||
let borrow_span = borrow_spans.var_or_use();
|
||||
|
||||
let mut err = self.infcx
|
||||
.tcx
|
||||
.cannot_borrow_across_destructor(borrow_span);
|
||||
let mut err = self.cannot_borrow_across_destructor(borrow_span);
|
||||
|
||||
let what_was_dropped = match self.describe_place(place) {
|
||||
Some(name) => format!("`{}`", name.as_str()),
|
||||
@ -965,9 +959,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
drop_span, borrow_span
|
||||
);
|
||||
|
||||
let mut err = self.infcx
|
||||
.tcx
|
||||
.thread_local_value_does_not_live_long_enough(borrow_span);
|
||||
let mut err = self.thread_local_value_does_not_live_long_enough(borrow_span);
|
||||
|
||||
err.span_label(
|
||||
borrow_span,
|
||||
@ -1011,8 +1003,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let tcx = self.infcx.tcx;
|
||||
let mut err = tcx.temporary_value_borrowed_for_too_long(proper_span);
|
||||
let mut err = self.temporary_value_borrowed_for_too_long(proper_span);
|
||||
err.span_label(
|
||||
proper_span,
|
||||
"creates a temporary which is freed while still in use",
|
||||
@ -1055,8 +1046,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
category: ConstraintCategory,
|
||||
opt_place_desc: Option<&String>,
|
||||
) -> Option<DiagnosticBuilder<'cx>> {
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
let return_kind = match category {
|
||||
ConstraintCategory::Return => "return",
|
||||
ConstraintCategory::Yield => "yield",
|
||||
@ -1119,7 +1108,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
};
|
||||
|
||||
let mut err = tcx.cannot_return_reference_to_local(
|
||||
let mut err = self.cannot_return_reference_to_local(
|
||||
return_span,
|
||||
return_kind,
|
||||
reference_desc,
|
||||
@ -1144,7 +1133,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
let mut err = tcx.cannot_capture_in_long_lived_closure(
|
||||
let mut err = self.cannot_capture_in_long_lived_closure(
|
||||
args_span,
|
||||
captured_var,
|
||||
var_span,
|
||||
@ -1203,7 +1192,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
"function"
|
||||
};
|
||||
|
||||
let mut err = tcx.borrowed_data_escapes_closure(escape_span, escapes_from);
|
||||
let mut err = borrowck_errors::borrowed_data_escapes_closure(
|
||||
tcx,
|
||||
escape_span,
|
||||
escapes_from,
|
||||
);
|
||||
|
||||
err.span_label(
|
||||
upvar_span,
|
||||
@ -1345,9 +1338,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
let loan_spans = self.retrieve_borrow_spans(loan);
|
||||
let loan_span = loan_spans.args_or_use();
|
||||
|
||||
let tcx = self.infcx.tcx;
|
||||
if loan.kind == BorrowKind::Shallow {
|
||||
let mut err = tcx.cannot_mutate_in_match_guard(
|
||||
let mut err = self.cannot_mutate_in_match_guard(
|
||||
span,
|
||||
loan_span,
|
||||
&self.describe_place(place).unwrap_or_else(|| "_".to_owned()),
|
||||
@ -1363,7 +1355,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut err = tcx.cannot_assign_to_borrowed(
|
||||
let mut err = self.cannot_assign_to_borrowed(
|
||||
span,
|
||||
loan_span,
|
||||
&self.describe_place(place).unwrap_or_else(|| "_".to_owned()),
|
||||
@ -1427,7 +1419,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
Some(decl) => (self.describe_place(err_place), decl.source_info.span),
|
||||
};
|
||||
|
||||
let mut err = self.infcx.tcx.cannot_reassign_immutable(
|
||||
let mut err = self.cannot_reassign_immutable(
|
||||
span,
|
||||
place_description.as_ref().map(AsRef::as_ref).unwrap_or("_"),
|
||||
from_arg,
|
||||
|
@ -41,7 +41,6 @@ use crate::dataflow::MoveDataParamEnv;
|
||||
use crate::dataflow::{do_dataflow, DebugFormatted};
|
||||
use crate::dataflow::EverInitializedPlaces;
|
||||
use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||
use crate::util::borrowck_errors::BorrowckErrors;
|
||||
|
||||
use self::borrow_set::{BorrowData, BorrowSet};
|
||||
use self::flows::Flows;
|
||||
@ -423,7 +422,7 @@ fn downgrade_if_error(diag: &mut Diagnostic) {
|
||||
}
|
||||
|
||||
pub struct MirBorrowckCtxt<'cx, 'tcx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
pub(crate) infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
body: &'cx Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
move_data: &'cx MoveData<'tcx>,
|
||||
@ -1499,8 +1498,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
debug!("check_for_local_borrow({:?})", borrow);
|
||||
|
||||
if borrow_of_local_data(&borrow.borrowed_place) {
|
||||
let err = self.infcx.tcx
|
||||
.cannot_borrow_across_generator_yield(
|
||||
let err = self.cannot_borrow_across_generator_yield(
|
||||
self.retrieve_borrow_spans(borrow).var_or_use(),
|
||||
yield_span,
|
||||
);
|
||||
|
@ -12,7 +12,6 @@ use crate::dataflow::move_paths::{
|
||||
IllegalMoveOrigin, IllegalMoveOriginKind,
|
||||
LookupResult, MoveError, MovePathIndex,
|
||||
};
|
||||
use crate::util::borrowck_errors::BorrowckErrors;
|
||||
|
||||
// Often when desugaring a pattern match we may have many individual moves in
|
||||
// MIR that are all part of one operation from the user's point-of-view. For
|
||||
@ -254,11 +253,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
)
|
||||
}
|
||||
IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } => {
|
||||
self.infcx.tcx
|
||||
.cannot_move_out_of_interior_of_drop(span, ty)
|
||||
self.cannot_move_out_of_interior_of_drop(span, ty)
|
||||
}
|
||||
IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } =>
|
||||
self.infcx.tcx.cannot_move_out_of_interior_noncopy(
|
||||
self.cannot_move_out_of_interior_noncopy(
|
||||
span, ty, Some(*is_index),
|
||||
),
|
||||
},
|
||||
@ -293,7 +291,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
)
|
||||
};
|
||||
|
||||
self.infcx.tcx.cannot_move_out_of(span, &description)
|
||||
self.cannot_move_out_of(span, &description)
|
||||
}
|
||||
|
||||
fn report_cannot_move_from_borrowed_content(
|
||||
@ -317,7 +315,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
if let Place::Base(PlaceBase::Local(local)) = *deref_base {
|
||||
let decl = &self.body.local_decls[local];
|
||||
if decl.is_ref_for_guard() {
|
||||
let mut err = self.infcx.tcx.cannot_move_out_of(
|
||||
let mut err = self.cannot_move_out_of(
|
||||
span,
|
||||
&format!("`{}` in pattern guard", decl.name.unwrap()),
|
||||
);
|
||||
@ -331,7 +329,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
debug!("report: ty={:?}", ty);
|
||||
let mut err = match ty.sty {
|
||||
ty::Array(..) | ty::Slice(..) =>
|
||||
self.infcx.tcx.cannot_move_out_of_interior_noncopy(span, ty, None),
|
||||
self.cannot_move_out_of_interior_noncopy(span, ty, None),
|
||||
ty::Closure(def_id, closure_substs)
|
||||
if def_id == self.mir_def_id && upvar_field.is_some()
|
||||
=> {
|
||||
@ -373,7 +371,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
closure_kind_ty, closure_kind, place_description,
|
||||
);
|
||||
|
||||
let mut diag = self.infcx.tcx.cannot_move_out_of(span, &place_description);
|
||||
let mut diag = self.cannot_move_out_of(span, &place_description);
|
||||
|
||||
diag.span_label(upvar_span, "captured outer variable");
|
||||
|
||||
@ -383,13 +381,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
let source = self.borrowed_content_source(deref_base);
|
||||
match (self.describe_place(move_place), source.describe_for_named_place()) {
|
||||
(Some(place_desc), Some(source_desc)) => {
|
||||
self.infcx.tcx.cannot_move_out_of(
|
||||
self.cannot_move_out_of(
|
||||
span,
|
||||
&format!("`{}` which is behind a {}", place_desc, source_desc),
|
||||
)
|
||||
}
|
||||
(_, _) => {
|
||||
self.infcx.tcx.cannot_move_out_of(
|
||||
self.cannot_move_out_of(
|
||||
span,
|
||||
&source.describe_for_unnamed_place(),
|
||||
)
|
||||
|
@ -9,7 +9,6 @@ use syntax_pos::symbol::kw;
|
||||
|
||||
use crate::borrow_check::MirBorrowckCtxt;
|
||||
use crate::borrow_check::error_reporting::BorrowedContentSource;
|
||||
use crate::util::borrowck_errors::BorrowckErrors;
|
||||
use crate::util::collect_writes::FindAssignments;
|
||||
use crate::util::suggest_ref_mut;
|
||||
use rustc_errors::Applicability;
|
||||
@ -161,13 +160,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
|
||||
let span = match error_access {
|
||||
AccessKind::Move => {
|
||||
err = self.infcx.tcx.cannot_move_out_of(span, &(item_msg + &reason));
|
||||
err = self.cannot_move_out_of(span, &(item_msg + &reason));
|
||||
err.span_label(span, "cannot move");
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
return;
|
||||
}
|
||||
AccessKind::Mutate => {
|
||||
err = self.infcx.tcx.cannot_assign(span, &(item_msg + &reason));
|
||||
err = self.cannot_assign(span, &(item_msg + &reason));
|
||||
act = "assign";
|
||||
acted_on = "written";
|
||||
span
|
||||
@ -178,7 +177,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
|
||||
let borrow_spans = self.borrow_spans(span, location);
|
||||
let borrow_span = borrow_spans.args_or_use();
|
||||
err = self.infcx.tcx.cannot_borrow_path_as_mutable_because(
|
||||
err = self.cannot_borrow_path_as_mutable_because(
|
||||
borrow_span,
|
||||
&item_msg,
|
||||
&reason,
|
||||
|
@ -4,8 +4,8 @@ use crate::borrow_check::nll::region_infer::RegionInferenceContext;
|
||||
use crate::borrow_check::nll::type_check::Locations;
|
||||
use crate::borrow_check::nll::universal_regions::DefiningTy;
|
||||
use crate::borrow_check::nll::ConstraintDescription;
|
||||
use crate::util::borrowck_errors::BorrowckErrors;
|
||||
use crate::borrow_check::Upvar;
|
||||
use crate::util::borrowck_errors;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use rustc::infer::InferCtxt;
|
||||
@ -487,9 +487,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
);
|
||||
}
|
||||
|
||||
let mut diag = infcx
|
||||
.tcx
|
||||
.borrowed_data_escapes_closure(span, escapes_from);
|
||||
let mut diag = borrowck_errors::borrowed_data_escapes_closure(
|
||||
infcx.tcx,
|
||||
span,
|
||||
escapes_from,
|
||||
);
|
||||
|
||||
if let Some((Some(outlived_fr_name), outlived_fr_span)) = outlived_fr_name_and_span {
|
||||
diag.span_label(
|
||||
|
@ -2,18 +2,9 @@ use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
|
||||
use syntax_pos::{MultiSpan, Span};
|
||||
|
||||
pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
fn struct_span_err_with_code<S: Into<MultiSpan>>(
|
||||
self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'cx>;
|
||||
|
||||
fn struct_span_err<S: Into<MultiSpan>>(self, sp: S, msg: &str) -> DiagnosticBuilder<'cx>;
|
||||
|
||||
fn cannot_move_when_borrowed(
|
||||
self,
|
||||
impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
pub(crate) fn cannot_move_when_borrowed(
|
||||
&self,
|
||||
span: Span,
|
||||
desc: &str,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
@ -26,8 +17,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
)
|
||||
}
|
||||
|
||||
fn cannot_use_when_mutably_borrowed(
|
||||
self,
|
||||
pub(crate) fn cannot_use_when_mutably_borrowed(
|
||||
&self,
|
||||
span: Span,
|
||||
desc: &str,
|
||||
borrow_span: Span,
|
||||
@ -49,8 +40,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_act_on_uninitialized_variable(
|
||||
self,
|
||||
pub(crate) fn cannot_act_on_uninitialized_variable(
|
||||
&self,
|
||||
span: Span,
|
||||
verb: &str,
|
||||
desc: &str,
|
||||
@ -65,8 +56,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
)
|
||||
}
|
||||
|
||||
fn cannot_mutably_borrow_multiply(
|
||||
self,
|
||||
pub(crate) fn cannot_mutably_borrow_multiply(
|
||||
&self,
|
||||
new_loan_span: Span,
|
||||
desc: &str,
|
||||
opt_via: &str,
|
||||
@ -114,8 +105,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_uniquely_borrow_by_two_closures(
|
||||
self,
|
||||
pub(crate) fn cannot_uniquely_borrow_by_two_closures(
|
||||
&self,
|
||||
new_loan_span: Span,
|
||||
desc: &str,
|
||||
old_loan_span: Span,
|
||||
@ -143,8 +134,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_uniquely_borrow_by_one_closure(
|
||||
self,
|
||||
pub(crate) fn cannot_uniquely_borrow_by_one_closure(
|
||||
&self,
|
||||
new_loan_span: Span,
|
||||
container_name: &str,
|
||||
desc_new: &str,
|
||||
@ -174,8 +165,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_reborrow_already_uniquely_borrowed(
|
||||
self,
|
||||
pub(crate) fn cannot_reborrow_already_uniquely_borrowed(
|
||||
&self,
|
||||
new_loan_span: Span,
|
||||
container_name: &str,
|
||||
desc_new: &str,
|
||||
@ -210,8 +201,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_reborrow_already_borrowed(
|
||||
self,
|
||||
pub(crate) fn cannot_reborrow_already_borrowed(
|
||||
&self,
|
||||
span: Span,
|
||||
desc_new: &str,
|
||||
msg_new: &str,
|
||||
@ -263,8 +254,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_assign_to_borrowed(
|
||||
self,
|
||||
pub(crate) fn cannot_assign_to_borrowed(
|
||||
&self,
|
||||
span: Span,
|
||||
borrow_span: Span,
|
||||
desc: &str,
|
||||
@ -285,8 +276,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_reassign_immutable(
|
||||
self,
|
||||
pub(crate) fn cannot_reassign_immutable(
|
||||
&self,
|
||||
span: Span,
|
||||
desc: &str,
|
||||
is_arg: bool,
|
||||
@ -306,12 +297,12 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
)
|
||||
}
|
||||
|
||||
fn cannot_assign(self, span: Span, desc: &str) -> DiagnosticBuilder<'cx> {
|
||||
pub(crate) fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'cx> {
|
||||
struct_span_err!(self, span, E0594, "cannot assign to {}", desc)
|
||||
}
|
||||
|
||||
fn cannot_move_out_of(
|
||||
self,
|
||||
pub(crate) fn cannot_move_out_of(
|
||||
&self,
|
||||
move_from_span: Span,
|
||||
move_from_desc: &str,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
@ -327,8 +318,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
/// Signal an error due to an attempt to move out of the interior
|
||||
/// of an array or slice. `is_index` is None when error origin
|
||||
/// didn't capture whether there was an indexing operation or not.
|
||||
fn cannot_move_out_of_interior_noncopy(
|
||||
self,
|
||||
pub(crate) fn cannot_move_out_of_interior_noncopy(
|
||||
&self,
|
||||
move_from_span: Span,
|
||||
ty: Ty<'_>,
|
||||
is_index: Option<bool>,
|
||||
@ -350,8 +341,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_move_out_of_interior_of_drop(
|
||||
self,
|
||||
pub(crate) fn cannot_move_out_of_interior_of_drop(
|
||||
&self,
|
||||
move_from_span: Span,
|
||||
container_ty: Ty<'_>,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
@ -366,8 +357,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_act_on_moved_value(
|
||||
self,
|
||||
pub(crate) fn cannot_act_on_moved_value(
|
||||
&self,
|
||||
use_span: Span,
|
||||
verb: &str,
|
||||
optional_adverb_for_moved: &str,
|
||||
@ -388,8 +379,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
)
|
||||
}
|
||||
|
||||
fn cannot_borrow_path_as_mutable_because(
|
||||
self,
|
||||
pub(crate) fn cannot_borrow_path_as_mutable_because(
|
||||
&self,
|
||||
span: Span,
|
||||
path: &str,
|
||||
reason: &str,
|
||||
@ -404,8 +395,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
)
|
||||
}
|
||||
|
||||
fn cannot_mutate_in_match_guard(
|
||||
self,
|
||||
pub(crate) fn cannot_mutate_in_match_guard(
|
||||
&self,
|
||||
mutate_span: Span,
|
||||
match_span: Span,
|
||||
match_place: &str,
|
||||
@ -424,8 +415,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_borrow_across_generator_yield(
|
||||
self,
|
||||
pub(crate) fn cannot_borrow_across_generator_yield(
|
||||
&self,
|
||||
span: Span,
|
||||
yield_span: Span,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
@ -439,8 +430,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_borrow_across_destructor(
|
||||
self,
|
||||
pub(crate) fn cannot_borrow_across_destructor(
|
||||
&self,
|
||||
borrow_span: Span,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
struct_span_err!(
|
||||
@ -451,8 +442,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
)
|
||||
}
|
||||
|
||||
fn path_does_not_live_long_enough(
|
||||
self,
|
||||
pub(crate) fn path_does_not_live_long_enough(
|
||||
&self,
|
||||
span: Span,
|
||||
path: &str,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
@ -465,8 +456,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
)
|
||||
}
|
||||
|
||||
fn cannot_return_reference_to_local(
|
||||
self,
|
||||
pub(crate) fn cannot_return_reference_to_local(
|
||||
&self,
|
||||
span: Span,
|
||||
return_kind: &str,
|
||||
reference_desc: &str,
|
||||
@ -490,8 +481,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn cannot_capture_in_long_lived_closure(
|
||||
self,
|
||||
pub(crate) fn cannot_capture_in_long_lived_closure(
|
||||
&self,
|
||||
closure_span: Span,
|
||||
borrowed_path: &str,
|
||||
capture_span: Span,
|
||||
@ -513,22 +504,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
err
|
||||
}
|
||||
|
||||
fn borrowed_data_escapes_closure(
|
||||
self,
|
||||
escape_span: Span,
|
||||
escapes_from: &str,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
struct_span_err!(
|
||||
self,
|
||||
escape_span,
|
||||
E0521,
|
||||
"borrowed data escapes outside of {}",
|
||||
escapes_from,
|
||||
)
|
||||
}
|
||||
|
||||
fn thread_local_value_does_not_live_long_enough(
|
||||
self,
|
||||
pub(crate) fn thread_local_value_does_not_live_long_enough(
|
||||
&self,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
struct_span_err!(
|
||||
@ -539,8 +516,8 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
)
|
||||
}
|
||||
|
||||
fn temporary_value_borrowed_for_too_long(
|
||||
self,
|
||||
pub(crate) fn temporary_value_borrowed_for_too_long(
|
||||
&self,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
struct_span_err!(
|
||||
@ -550,19 +527,27 @@ pub(crate) trait BorrowckErrors<'cx>: Sized + Copy {
|
||||
"temporary value dropped while borrowed",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl BorrowckErrors<'tcx> for TyCtxt<'tcx> {
|
||||
fn struct_span_err_with_code<S: Into<MultiSpan>>(
|
||||
self,
|
||||
&self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
self.sess.struct_span_err_with_code(sp, msg, code)
|
||||
self.infcx.tcx.sess.struct_span_err_with_code(sp, msg, code)
|
||||
}
|
||||
}
|
||||
|
||||
fn struct_span_err<S: Into<MultiSpan>>(self, sp: S, msg: &str) -> DiagnosticBuilder<'tcx> {
|
||||
self.sess.struct_span_err(sp, msg)
|
||||
}
|
||||
pub(crate) fn borrowed_data_escapes_closure<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
escape_span: Span,
|
||||
escapes_from: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
escape_span,
|
||||
E0521,
|
||||
"borrowed data escapes outside of {}",
|
||||
escapes_from,
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user