1
Fork 0

Do not report errors from move path builder.

This commit is contained in:
Camille GILLOT 2023-09-30 15:14:07 +00:00
parent a8e56d0b0b
commit 8d535070a2
11 changed files with 305 additions and 172 deletions

View file

@ -18,7 +18,6 @@ struct MoveDataBuilder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
data: MoveData<'tcx>,
errors: Vec<(Place<'tcx>, MoveError<'tcx>)>,
}
impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> {
@ -31,7 +30,6 @@ impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> {
body,
tcx,
param_env,
errors: Vec::new(),
data: MoveData {
moves: IndexVec::new(),
loc_map: LocationMap::new(body),
@ -287,11 +285,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
}
}
pub type MoveDat<'tcx> =
Result<MoveData<'tcx>, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)>;
impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> {
fn finalize(self) -> MoveDat<'tcx> {
fn finalize(self) -> MoveData<'tcx> {
debug!("{}", {
debug!("moves for {:?}:", self.body.span);
for (j, mo) in self.data.moves.iter_enumerated() {
@ -304,7 +299,7 @@ impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> {
"done dumping moves"
});
if self.errors.is_empty() { Ok(self.data) } else { Err((self.data, self.errors)) }
self.data
}
}
@ -312,7 +307,7 @@ pub(super) fn gather_moves<'tcx>(
body: &Body<'tcx>,
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> MoveDat<'tcx> {
) -> MoveData<'tcx> {
let mut builder = MoveDataBuilder::new(body, tcx, param_env);
builder.gather_args();
@ -551,8 +546,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
self.record_move(place, path);
return;
}
Err(error @ MoveError::IllegalMove { .. }) => {
self.builder.errors.push((base_place, error));
Err(MoveError::IllegalMove { .. }) => {
return;
}
};
@ -573,9 +567,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
} else {
match self.move_path_for(place) {
Ok(path) | Err(MoveError::UnionMove { path }) => self.record_move(place, path),
Err(error @ MoveError::IllegalMove { .. }) => {
self.builder.errors.push((place, error));
}
Err(MoveError::IllegalMove { .. }) => {}
};
}
}

View file

@ -1,4 +1,3 @@
use crate::move_paths::builder::MoveDat;
use crate::un_derefer::UnDerefer;
use rustc_data_structures::fx::FxHashMap;
use rustc_index::{IndexSlice, IndexVec};
@ -377,7 +376,7 @@ pub enum MoveError<'tcx> {
}
impl<'tcx> MoveError<'tcx> {
fn cannot_move_out_of(location: Location, kind: IllegalMoveOriginKind<'tcx>) -> Self {
pub fn cannot_move_out_of(location: Location, kind: IllegalMoveOriginKind<'tcx>) -> Self {
let origin = IllegalMoveOrigin { location, kind };
MoveError::IllegalMove { cannot_move_out_of: origin }
}
@ -388,7 +387,7 @@ impl<'tcx> MoveData<'tcx> {
body: &Body<'tcx>,
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
) -> MoveDat<'tcx> {
) -> MoveData<'tcx> {
builder::gather_moves(body, tcx, param_env)
}