Rollup merge of #103960 - AndyJado:var_path_only_diag, r=davidtwco
piece of diagnostic migrate r? `@davidtwco`
This commit is contained in:
commit
a13809ae51
32 changed files with 262 additions and 61 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use crate::nll::ToRegionVid;
|
use crate::nll::ToRegionVid;
|
||||||
use crate::path_utils::allow_two_phase_borrow;
|
use crate::path_utils::allow_two_phase_borrow;
|
||||||
use crate::place_ext::PlaceExt;
|
use crate::place_ext::PlaceExt;
|
||||||
|
|
|
@ -8,9 +8,18 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
pub(crate) fn cannot_move_when_borrowed(
|
pub(crate) fn cannot_move_when_borrowed(
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
desc: &str,
|
borrow_span: Span,
|
||||||
|
place: &str,
|
||||||
|
borrow_place: &str,
|
||||||
|
value_place: &str,
|
||||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||||
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
|
self.infcx.tcx.sess.create_err(crate::session_diagnostics::MoveBorrow {
|
||||||
|
place,
|
||||||
|
span,
|
||||||
|
borrow_place,
|
||||||
|
value_place,
|
||||||
|
borrow_span,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cannot_use_when_mutably_borrowed(
|
pub(crate) fn cannot_use_when_mutably_borrowed(
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_infer::infer::InferCtxt;
|
use rustc_infer::infer::InferCtxt;
|
||||||
use rustc_middle::mir::visit::TyContext;
|
use rustc_middle::mir::visit::TyContext;
|
||||||
use rustc_middle::mir::visit::Visitor;
|
use rustc_middle::mir::visit::Visitor;
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
|
||||||
use rustc_data_structures::graph::scc::Sccs;
|
use rustc_data_structures::graph::scc::Sccs;
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_middle::mir::ConstraintCategory;
|
use rustc_middle::mir::ConstraintCategory;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
//! This file provides API for compiler consumers.
|
//! This file provides API for compiler consumers.
|
||||||
|
|
||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_index::bit_set::BitSet;
|
use rustc_index::bit_set::BitSet;
|
||||||
use rustc_middle::mir::{self, BasicBlock, Body, Location, Place};
|
use rustc_middle::mir::{self, BasicBlock, Body, Location, Place};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_middle::mir::visit::{
|
use rustc_middle::mir::visit::{
|
||||||
MutatingUseContext, NonMutatingUseContext, NonUseContext, PlaceContext,
|
MutatingUseContext, NonMutatingUseContext, NonUseContext, PlaceContext,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
|
||||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||||
use rustc_infer::infer::canonical::Canonical;
|
use rustc_infer::infer::canonical::Canonical;
|
||||||
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;
|
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||||
|
|
|
@ -224,10 +224,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use_spans.var_span_label_path_only(
|
use_spans.var_path_only_subdiag(&mut err, desired_action);
|
||||||
&mut err,
|
|
||||||
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
|
|
||||||
);
|
|
||||||
|
|
||||||
if !is_loop_move {
|
if !is_loop_move {
|
||||||
err.span_label(
|
err.span_label(
|
||||||
|
@ -404,10 +401,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let used = desired_action.as_general_verb_in_past_tense();
|
let used = desired_action.as_general_verb_in_past_tense();
|
||||||
let mut err =
|
let mut err =
|
||||||
struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
|
struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
|
||||||
use_spans.var_span_label_path_only(
|
use_spans.var_path_only_subdiag(&mut err, desired_action);
|
||||||
&mut err,
|
|
||||||
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
|
|
||||||
);
|
|
||||||
|
|
||||||
if let InitializationRequiringAction::PartialAssignment
|
if let InitializationRequiringAction::PartialAssignment
|
||||||
| InitializationRequiringAction::Assignment = desired_action
|
| InitializationRequiringAction::Assignment = desired_action
|
||||||
|
@ -673,16 +667,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let move_spans = self.move_spans(place.as_ref(), location);
|
let move_spans = self.move_spans(place.as_ref(), location);
|
||||||
let span = move_spans.args_or_use();
|
let span = move_spans.args_or_use();
|
||||||
|
|
||||||
let mut err =
|
let mut err = self.cannot_move_when_borrowed(
|
||||||
self.cannot_move_when_borrowed(span, &self.describe_any_place(place.as_ref()));
|
span,
|
||||||
err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_msg));
|
borrow_span,
|
||||||
err.span_label(span, format!("move out of {} occurs here", value_msg));
|
&self.describe_any_place(place.as_ref()),
|
||||||
|
&borrow_msg,
|
||||||
borrow_spans.var_span_label_path_only(
|
&value_msg,
|
||||||
&mut err,
|
|
||||||
format!("borrow occurs due to use{}", borrow_spans.describe()),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
borrow_spans.var_path_only_subdiag(&mut err, crate::InitializationRequiringAction::Borrow);
|
||||||
|
|
||||||
move_spans.var_span_label(
|
move_spans.var_span_label(
|
||||||
&mut err,
|
&mut err,
|
||||||
format!("move occurs due to use{}", move_spans.describe()),
|
format!("move occurs due to use{}", move_spans.describe()),
|
||||||
|
@ -724,22 +718,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
borrow_span,
|
borrow_span,
|
||||||
&self.describe_any_place(borrow.borrowed_place.as_ref()),
|
&self.describe_any_place(borrow.borrowed_place.as_ref()),
|
||||||
);
|
);
|
||||||
borrow_spans.var_subdiag(
|
borrow_spans.var_subdiag(&mut err, Some(borrow.kind), |kind, var_span| {
|
||||||
&mut err,
|
use crate::session_diagnostics::CaptureVarCause::*;
|
||||||
|var_span| {
|
let place = &borrow.borrowed_place;
|
||||||
use crate::session_diagnostics::CaptureVarCause::*;
|
let desc_place = self.describe_any_place(place.as_ref());
|
||||||
let place = &borrow.borrowed_place;
|
match kind {
|
||||||
let desc_place = self.describe_any_place(place.as_ref());
|
Some(_) => BorrowUsePlaceGenerator { place: desc_place, var_span },
|
||||||
match borrow_spans {
|
None => BorrowUsePlaceClosure { place: desc_place, var_span },
|
||||||
UseSpans::ClosureUse { generator_kind, .. } => match generator_kind {
|
}
|
||||||
Some(_) => BorrowUsePlaceGenerator { place: desc_place, var_span },
|
});
|
||||||
None => BorrowUsePlaceClosure { place: desc_place, var_span },
|
|
||||||
},
|
|
||||||
_ => BorrowUsePlace { place: desc_place, var_span },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mutable",
|
|
||||||
);
|
|
||||||
|
|
||||||
self.explain_why_borrow_contains_point(location, borrow, None)
|
self.explain_why_borrow_contains_point(location, borrow, None)
|
||||||
.add_explanation_to_diagnostic(
|
.add_explanation_to_diagnostic(
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
|
@ -595,11 +595,34 @@ impl UseSpans<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a span label to the use of the captured variable, if it exists.
|
/// Add a span label to the use of the captured variable, if it exists.
|
||||||
// only adds label to the `path_span`
|
/// only adds label to the `path_span`
|
||||||
pub(super) fn var_span_label_path_only(self, err: &mut Diagnostic, message: impl Into<String>) {
|
pub(super) fn var_path_only_subdiag(
|
||||||
if let UseSpans::ClosureUse { path_span, .. } = self {
|
self,
|
||||||
err.span_label(path_span, message);
|
err: &mut Diagnostic,
|
||||||
|
action: crate::InitializationRequiringAction,
|
||||||
|
) {
|
||||||
|
use crate::session_diagnostics::CaptureVarPathUseCause::*;
|
||||||
|
use crate::InitializationRequiringAction::*;
|
||||||
|
if let UseSpans::ClosureUse { generator_kind, path_span, .. } = self {
|
||||||
|
match generator_kind {
|
||||||
|
Some(_) => {
|
||||||
|
err.subdiagnostic(match action {
|
||||||
|
Borrow => BorrowInGenerator { path_span },
|
||||||
|
MatchOn | Use => UseInGenerator { path_span },
|
||||||
|
Assignment => AssignInGenerator { path_span },
|
||||||
|
PartialAssignment => AssignPartInGenerator { path_span },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
err.subdiagnostic(match action {
|
||||||
|
Borrow => BorrowInClosure { path_span },
|
||||||
|
MatchOn | Use => UseInClosure { path_span },
|
||||||
|
Assignment => AssignInClosure { path_span },
|
||||||
|
PartialAssignment => AssignPartInClosure { path_span },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,19 +650,28 @@ impl UseSpans<'_> {
|
||||||
pub(super) fn var_subdiag(
|
pub(super) fn var_subdiag(
|
||||||
self,
|
self,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
f: impl Fn(Span) -> crate::session_diagnostics::CaptureVarCause,
|
kind: Option<rustc_middle::mir::BorrowKind>,
|
||||||
kind_desc: impl Into<String>,
|
f: impl Fn(Option<GeneratorKind>, Span) -> crate::session_diagnostics::CaptureVarCause,
|
||||||
) {
|
) {
|
||||||
if let UseSpans::ClosureUse { capture_kind_span, path_span, .. } = self {
|
use crate::session_diagnostics::CaptureVarKind::*;
|
||||||
if capture_kind_span == path_span {
|
if let UseSpans::ClosureUse { generator_kind, capture_kind_span, path_span, .. } = self {
|
||||||
err.subdiagnostic(f(capture_kind_span));
|
if capture_kind_span != path_span {
|
||||||
} else {
|
err.subdiagnostic(match kind {
|
||||||
err.subdiagnostic(crate::session_diagnostics::CaptureVarKind {
|
Some(kd) => match kd {
|
||||||
kind_desc: kind_desc.into(),
|
rustc_middle::mir::BorrowKind::Shared
|
||||||
kind_span: capture_kind_span,
|
| rustc_middle::mir::BorrowKind::Shallow
|
||||||
|
| rustc_middle::mir::BorrowKind::Unique => {
|
||||||
|
Immute { kind_span: capture_kind_span }
|
||||||
|
}
|
||||||
|
|
||||||
|
rustc_middle::mir::BorrowKind::Mut { .. } => {
|
||||||
|
Mut { kind_span: capture_kind_span }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => Move { kind_span: capture_kind_span },
|
||||||
});
|
});
|
||||||
err.subdiagnostic(f(path_span));
|
};
|
||||||
}
|
err.subdiagnostic(f(generator_kind, path_span));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
|
||||||
use crate::Upvar;
|
use crate::Upvar;
|
||||||
use crate::{nll::ToRegionVid, region_infer::RegionInferenceContext};
|
use crate::{nll::ToRegionVid, region_infer::RegionInferenceContext};
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::{Idx, IndexVec};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use crate::location::{LocationIndex, LocationTable};
|
use crate::location::{LocationIndex, LocationTable};
|
||||||
use crate::BorrowIndex;
|
use crate::BorrowIndex;
|
||||||
use polonius_engine::AllFacts as PoloniusFacts;
|
use polonius_engine::AllFacts as PoloniusFacts;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_data_structures::graph::dominators::Dominators;
|
use rustc_data_structures::graph::dominators::Dominators;
|
||||||
use rustc_middle::mir::visit::Visitor;
|
use rustc_middle::mir::visit::Visitor;
|
||||||
use rustc_middle::mir::{self, BasicBlock, Body, Location, NonDivergingIntrinsic, Place, Rvalue};
|
use rustc_middle::mir::{self, BasicBlock, Body, Location, NonDivergingIntrinsic, Place, Rvalue};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::{Idx, IndexVec};
|
||||||
use rustc_middle::mir::{BasicBlock, Body, Location};
|
use rustc_middle::mir::{BasicBlock, Body, Location};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_data_structures::captures::Captures;
|
use rustc_data_structures::captures::Captures;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
//! The entry point of the NLL borrow checker.
|
//! The entry point of the NLL borrow checker.
|
||||||
|
|
||||||
use rustc_data_structures::vec_map::VecMap;
|
use rustc_data_structures::vec_map::VecMap;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
|
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
|
||||||
use crate::places_conflict;
|
use crate::places_conflict;
|
||||||
use crate::AccessDepth;
|
use crate::AccessDepth;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use crate::borrow_set::LocalsStateAtExit;
|
use crate::borrow_set::LocalsStateAtExit;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::mir::ProjectionElem;
|
use rustc_middle::mir::ProjectionElem;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use crate::ArtificialField;
|
use crate::ArtificialField;
|
||||||
use crate::Overlap;
|
use crate::Overlap;
|
||||||
use crate::{AccessDepth, Deep, Shallow};
|
use crate::{AccessDepth, Deep, Shallow};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
//! From the NLL RFC: "The deep [aka 'supporting'] prefixes for an
|
//! From the NLL RFC: "The deep [aka 'supporting'] prefixes for an
|
||||||
//! place are formed by stripping away fields and derefs, except that
|
//! place are formed by stripping away fields and derefs, except that
|
||||||
//! we stop when we reach the deref of a shared reference. [...] "
|
//! we stop when we reach the deref of a shared reference. [...] "
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
//! As part of generating the regions, if you enable `-Zdump-mir=nll`,
|
//! As part of generating the regions, if you enable `-Zdump-mir=nll`,
|
||||||
//! we will generate an annotated copy of the MIR that includes the
|
//! we will generate an annotated copy of the MIR that includes the
|
||||||
//! state of region inference. This code handles emitting the region
|
//! state of region inference. This code handles emitting the region
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
//! This module provides linkage between RegionInferenceContext and
|
//! This module provides linkage between RegionInferenceContext and
|
||||||
//! `rustc_graphviz` traits, specialized to attaching borrowck analysis
|
//! `rustc_graphviz` traits, specialized to attaching borrowck analysis
|
||||||
//! data to rendered labels.
|
//! data to rendered labels.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use crate::constraints::ConstraintSccIndex;
|
use crate::constraints::ConstraintSccIndex;
|
||||||
use crate::RegionInferenceContext;
|
use crate::RegionInferenceContext;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_index::bit_set::SparseBitMatrix;
|
use rustc_index::bit_set::SparseBitMatrix;
|
||||||
use rustc_index::interval::IntervalSet;
|
use rustc_index::interval::IntervalSet;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
|
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
|
||||||
use rustc_middle::mir::visit::{MutVisitor, TyContext};
|
use rustc_middle::mir::visit::{MutVisitor, TyContext};
|
||||||
|
|
|
@ -150,21 +150,70 @@ pub(crate) enum RequireStaticErr {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
#[label(borrowck_capture_kind_label)]
|
pub(crate) enum CaptureVarPathUseCause {
|
||||||
pub(crate) struct CaptureVarKind {
|
#[label(borrowck_borrow_due_to_use_generator)]
|
||||||
pub kind_desc: String,
|
BorrowInGenerator {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub kind_span: Span,
|
path_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_use_due_to_use_generator)]
|
||||||
|
UseInGenerator {
|
||||||
|
#[primary_span]
|
||||||
|
path_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_assign_due_to_use_generator)]
|
||||||
|
AssignInGenerator {
|
||||||
|
#[primary_span]
|
||||||
|
path_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_assign_part_due_to_use_generator)]
|
||||||
|
AssignPartInGenerator {
|
||||||
|
#[primary_span]
|
||||||
|
path_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_borrow_due_to_use_closure)]
|
||||||
|
BorrowInClosure {
|
||||||
|
#[primary_span]
|
||||||
|
path_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_use_due_to_use_closure)]
|
||||||
|
UseInClosure {
|
||||||
|
#[primary_span]
|
||||||
|
path_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_assign_due_to_use_closure)]
|
||||||
|
AssignInClosure {
|
||||||
|
#[primary_span]
|
||||||
|
path_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_assign_part_due_to_use_closure)]
|
||||||
|
AssignPartInClosure {
|
||||||
|
#[primary_span]
|
||||||
|
path_span: Span,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
pub(crate) enum CaptureVarKind {
|
||||||
|
#[label(borrowck_capture_immute)]
|
||||||
|
Immute {
|
||||||
|
#[primary_span]
|
||||||
|
kind_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_capture_mut)]
|
||||||
|
Mut {
|
||||||
|
#[primary_span]
|
||||||
|
kind_span: Span,
|
||||||
|
},
|
||||||
|
#[label(borrowck_capture_move)]
|
||||||
|
Move {
|
||||||
|
#[primary_span]
|
||||||
|
kind_span: Span,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub(crate) enum CaptureVarCause {
|
pub(crate) enum CaptureVarCause {
|
||||||
#[label(borrowck_var_borrow_by_use_place)]
|
|
||||||
BorrowUsePlace {
|
|
||||||
place: String,
|
|
||||||
#[primary_span]
|
|
||||||
var_span: Span,
|
|
||||||
},
|
|
||||||
#[label(borrowck_var_borrow_by_use_place_in_generator)]
|
#[label(borrowck_var_borrow_by_use_place_in_generator)]
|
||||||
BorrowUsePlaceGenerator {
|
BorrowUsePlaceGenerator {
|
||||||
place: String,
|
place: String,
|
||||||
|
@ -178,3 +227,16 @@ pub(crate) enum CaptureVarCause {
|
||||||
var_span: Span,
|
var_span: Span,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(borrowck_cannot_move_when_borrowed, code = "E0505")]
|
||||||
|
pub(crate) struct MoveBorrow<'a> {
|
||||||
|
pub place: &'a str,
|
||||||
|
pub borrow_place: &'a str,
|
||||||
|
pub value_place: &'a str,
|
||||||
|
#[primary_span]
|
||||||
|
#[label(move_label)]
|
||||||
|
pub span: Span,
|
||||||
|
#[label]
|
||||||
|
pub borrow_span: Span,
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
//! This pass type-checks the MIR to ensure it is not broken.
|
//! This pass type-checks the MIR to ensure it is not broken.
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
||||||
use rustc_middle::mir::{
|
use rustc_middle::mir::{
|
||||||
|
|
|
@ -70,3 +70,56 @@ borrowck_var_borrow_by_use_place_in_closure =
|
||||||
|
|
||||||
borrowck_var_borrow_by_use_place =
|
borrowck_var_borrow_by_use_place =
|
||||||
borrow occurs due to use of {$place}
|
borrow occurs due to use of {$place}
|
||||||
|
|
||||||
|
borrowck_borrow_due_to_use_generator =
|
||||||
|
borrow occurs due to use in generator
|
||||||
|
|
||||||
|
borrowck_use_due_to_use_generator =
|
||||||
|
use occurs due to use in generator
|
||||||
|
|
||||||
|
borrowck_assign_due_to_use_generator =
|
||||||
|
assign occurs due to use in generator
|
||||||
|
|
||||||
|
borrowck_assign_part_due_to_use_generator =
|
||||||
|
assign to part occurs due to use in generator
|
||||||
|
|
||||||
|
borrowck_borrow_due_to_use_closure =
|
||||||
|
borrow occurs due to use in closure
|
||||||
|
|
||||||
|
borrowck_use_due_to_use_closure =
|
||||||
|
use occurs due to use in closure
|
||||||
|
|
||||||
|
borrowck_assign_due_to_use_closure =
|
||||||
|
assign occurs due to use in closure
|
||||||
|
|
||||||
|
borrowck_assign_part_due_to_use_closure =
|
||||||
|
assign to part occurs due to use in closure
|
||||||
|
|
||||||
|
borrowck_capture_immute =
|
||||||
|
capture is immutable because of use here
|
||||||
|
|
||||||
|
borrowck_capture_mut =
|
||||||
|
capture is mutable because of use here
|
||||||
|
|
||||||
|
borrowck_capture_move =
|
||||||
|
capture is moved because of use here
|
||||||
|
|
||||||
|
borrowck_var_move_by_use_place_in_generator =
|
||||||
|
move occurs due to use of {$place} in generator
|
||||||
|
|
||||||
|
borrowck_var_move_by_use_place_in_closure =
|
||||||
|
move occurs due to use of {$place} in closure
|
||||||
|
|
||||||
|
borrowck_cannot_move_when_borrowed =
|
||||||
|
cannot move out of {$place ->
|
||||||
|
[value] value
|
||||||
|
*[other] {$place}
|
||||||
|
} because it is borrowed
|
||||||
|
.label = borrow of {$borrow_place ->
|
||||||
|
[value] value
|
||||||
|
*[other] {$borrow_place}
|
||||||
|
} occurs here
|
||||||
|
.move_label = move out of {$value_place ->
|
||||||
|
[value] value
|
||||||
|
*[other] {$value_place}
|
||||||
|
} occurs here
|
||||||
|
|
|
@ -1957,6 +1957,7 @@ impl BorrowKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: won't be used after diagnostic migration
|
||||||
pub fn describe_mutability(&self) -> &str {
|
pub fn describe_mutability(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => "immutable",
|
BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => "immutable",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue