Auto merge of #61296 - Centril:rollup-5ad68b0, r=Centril
Rollup of 9 pull requests Successful merges: - #60742 (Allow const parameters in array sizes to be unified) - #60756 (Add better tests for hidden lifetimes in impl trait) - #60928 (Changes the type `mir::Mir` into `mir::Body`) - #61024 (tests: Centralize proc macros commonly used for testing) - #61157 (BufReader: In Seek impl, remove extra discard_buffer call) - #61195 (Special-case `.llvm` in mangler) - #61202 (Print PermissionExt::mode() in octal in Documentation Examples) - #61259 (Mailmap fixes) - #61273 (mention that MaybeUninit is a bit like Option) Failed merges: r? @ghost
This commit is contained in:
commit
4b9d80325a
242 changed files with 1579 additions and 1315 deletions
29
.mailmap
29
.mailmap
|
@ -5,8 +5,8 @@
|
|||
# email addresses.
|
||||
#
|
||||
|
||||
Aaron Todd <github@opprobrio.us>
|
||||
Aaron Power <theaaronepower@gmail.com> Erin Power <xampprocky@gmail.com>
|
||||
Aaron Todd <github@opprobrio.us>
|
||||
Abhishek Chanda <abhishek.becs@gmail.com> Abhishek Chanda <abhishek@cloudscaling.com>
|
||||
Adolfo Ochagavía <aochagavia92@gmail.com>
|
||||
Adrien Tétar <adri-from-59@hotmail.fr>
|
||||
|
@ -29,8 +29,8 @@ Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> Ariel Ben-Yehuda <ariel.byd@gmail.com>
|
|||
Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> arielb1 <arielb1@mail.tau.ac.il>
|
||||
Austin Seipp <mad.one@gmail.com> <as@hacks.yi.org>
|
||||
Aydin Kim <ladinjin@hanmail.net> aydin.kim <aydin.kim@samsung.com>
|
||||
Bastian Kauschke <bastian_kauschke@hotmail.de>
|
||||
Barosl Lee <vcs@barosl.com> Barosl LEE <github@barosl.com>
|
||||
Bastian Kauschke <bastian_kauschke@hotmail.de>
|
||||
Ben Alpert <ben@benalpert.com> <spicyjalapeno@gmail.com>
|
||||
Ben Sago <ogham@users.noreply.github.com> Ben S <ogham@bsago.me>
|
||||
Ben Sago <ogham@users.noreply.github.com> Ben S <ogham@users.noreply.github.com>
|
||||
|
@ -46,22 +46,23 @@ Brian Anderson <banderson@mozilla.com> <banderson@mozilla.org>
|
|||
Brian Dawn <brian.t.dawn@gmail.com>
|
||||
Brian Leibig <brian@brianleibig.com> Brian Leibig <brian.leibig@gmail.com>
|
||||
Carl-Anton Ingmarsson <mail@carlanton.se> <ca.ingmarsson@gmail.com>
|
||||
Carol (Nichols || Goulding) <carol.nichols@gmail.com> <193874+carols10cents@users.noreply.github.com>
|
||||
Carol (Nichols || Goulding) <carol.nichols@gmail.com> <carol.nichols@gmail.com>
|
||||
Carol (Nichols || Goulding) <carol.nichols@gmail.com> <cnichols@thinkthroughmath.com>
|
||||
Carol (Nichols || Goulding) <carol.nichols@gmail.com> Carol Nichols <carol.nichols@gmail.com>
|
||||
Carol Willing <carolcode@willingconsulting.com>
|
||||
Chris C Cerami <chrisccerami@users.noreply.github.com> Chris C Cerami <chrisccerami@gmail.com>
|
||||
Chris Pressey <cpressey@gmail.com>
|
||||
Chris Thorn <chris@thorn.co> Chris Thorn <thorn@thoughtbot.com>
|
||||
Chris Vittal <christopher.vittal@gmail.com> Christopher Vittal <christopher.vittal@gmail.com>
|
||||
Christian Poveda <christianpoveda@protonmail.com> <z1mvader@protonmail.com>
|
||||
Christian Poveda <christianpoveda@protonmail.com> <cn.poveda.ruiz@gmail.com>
|
||||
Christian Poveda <christianpoveda@protonmail.com> <z1mvader@protonmail.com>
|
||||
Clark Gaebel <cg.wowus.cg@gmail.com> <cgaebel@mozilla.com>
|
||||
Clinton Ryan <clint.ryan3@gmail.com>
|
||||
Corey Richardson <corey@octayn.net> Elaine "See More" Nemo <corey@octayn.net>
|
||||
Cyryl Płotnicki <cyplo@cyplo.net>
|
||||
Damien Schoof <damien.schoof@gmail.com>
|
||||
Daniel Ramos <dan@daramos.com>
|
||||
Daniel J Rollins <drollins@financialforce.com>
|
||||
Daniel Ramos <dan@daramos.com>
|
||||
David Klein <david.klein@baesystemsdetica.com>
|
||||
David Manescu <david.manescu@gmail.com> <dman2626@uni.sydney.edu.au>
|
||||
David Ross <daboross@daboross.net>
|
||||
|
@ -70,9 +71,9 @@ Diggory Hardy <diggory.hardy@gmail.com> Diggory Hardy <github@dhardy.name>
|
|||
Dylan Braithwaite <dylanbraithwaite1@gmail.com> <mail@dylanb.me>
|
||||
Dzmitry Malyshau <kvarkus@gmail.com>
|
||||
E. Dunham <edunham@mozilla.com> edunham <edunham@mozilla.com>
|
||||
Eduard-Mihai Burtescu <edy.burt@gmail.com>
|
||||
Eduardo Bautista <me@eduardobautista.com> <=>
|
||||
Eduardo Bautista <me@eduardobautista.com> <mail@eduardobautista.com>
|
||||
Eduard-Mihai Burtescu <edy.burt@gmail.com>
|
||||
Elliott Slaughter <elliottslaughter@gmail.com> <eslaughter@mozilla.com>
|
||||
Elly Fong-Jones <elly@leptoquark.net>
|
||||
Eric Holk <eric.holk@gmail.com> <eholk@cs.indiana.edu>
|
||||
|
@ -80,8 +81,8 @@ Eric Holk <eric.holk@gmail.com> <eholk@mozilla.com>
|
|||
Eric Holmes <eric@ejholmes.net>
|
||||
Eric Reed <ecreed@cs.washington.edu> <ereed@mozilla.com>
|
||||
Erick Tryzelaar <erick.tryzelaar@gmail.com> <etryzelaar@iqt.org>
|
||||
Esteban Küber <esteban@kuber.com.ar> <estebank@users.noreply.github.com>
|
||||
Esteban Küber <esteban@kuber.com.ar> <esteban@commure.com>
|
||||
Esteban Küber <esteban@kuber.com.ar> <estebank@users.noreply.github.com>
|
||||
Esteban Küber <esteban@kuber.com.ar> <github@kuber.com.ar>
|
||||
Evgeny Sologubov
|
||||
Falco Hirschenberger <falco.hirschenberger@gmail.com> <hirschen@itwm.fhg.de>
|
||||
|
@ -102,9 +103,9 @@ Herman J. Radtke III <herman@hermanradtke.com> Herman J. Radtke III <hermanradtk
|
|||
Ilyong Cho <ilyoan@gmail.com>
|
||||
Ivan Ivaschenko <defuz.net@gmail.com>
|
||||
J. J. Weber <jjweber@gmail.com>
|
||||
Jakub Adam Wieczorek <jakub.adam.wieczorek@gmail.com> <jakub.bukaj@yahoo.com>
|
||||
Jakub Adam Wieczorek <jakub.adam.wieczorek@gmail.com> <jakub@jakub.cc>
|
||||
Jakub Adam Wieczorek <jakub.adam.wieczorek@gmail.com> <jakubw@jakubw.net>
|
||||
Jakub Adam Wieczorek <jakub.adam.wieczorek@gmail.com> <jakub.bukaj@yahoo.com>
|
||||
James Deng <cnjamesdeng@gmail.com> <cnJamesDeng@gmail.com>
|
||||
James Miller <bladeon@gmail.com> <james@aatch.net>
|
||||
James Perry <james.austin.perry@gmail.com>
|
||||
|
@ -119,6 +120,7 @@ Jethro Beekman <github@jbeekman.nl>
|
|||
Jihyun Yu <j.yu@navercorp.com> <yjh0502@gmail.com>
|
||||
Jihyun Yu <j.yu@navercorp.com> jihyun <jihyun@nablecomm.com>
|
||||
Jihyun Yu <j.yu@navercorp.com> Jihyun Yu <jihyun@nclab.kaist.ac.kr>
|
||||
João Oliveira <hello@jxs.pt> joaoxsouls <joaoxsouls@gmail.com>
|
||||
Johann Hofmann <git@johann-hofmann.com> Johann <git@johann-hofmann.com>
|
||||
John Clements <clements@racket-lang.org> <clements@brinckerhoff.org>
|
||||
John Hodge <acessdev@gmail.com> John Hodge <tpg@mutabah.net>
|
||||
|
@ -129,7 +131,8 @@ Jonathan S <gereeter@gmail.com> Jonathan S <gereeter+code@gmail.com>
|
|||
Jonathan Turner <probata@hotmail.com>
|
||||
Jorge Aparicio <japaric@linux.com> <japaricious@gmail.com>
|
||||
Joseph Martin <pythoner6@gmail.com>
|
||||
João Oliveira <hello@jxs.pt> joaoxsouls <joaoxsouls@gmail.com>
|
||||
Joseph T. Lyons <JosephTLyons@gmail.com> <josephtlyons@gmail.com>
|
||||
Joseph T. Lyons <JosephTLyons@gmail.com> <JosephTLyons@users.noreply.github.com>
|
||||
Junyoung Cho <june0.cho@samsung.com>
|
||||
Jyun-Yan You <jyyou.tw@gmail.com> <jyyou@cs.nctu.edu.tw>
|
||||
Kang Seonghoon <kang.seonghoon@mearie.org> <public+git@mearie.org>
|
||||
|
@ -145,8 +148,6 @@ Lindsey Kuper <lindsey@composition.al> <lkuper@mozilla.com>
|
|||
Luke Metz <luke.metz@students.olin.edu>
|
||||
Luqman Aden <me@luqman.ca> <laden@csclub.uwaterloo.ca>
|
||||
Luqman Aden <me@luqman.ca> <laden@mozilla.com>
|
||||
NAKASHIMA, Makoto <makoto.nksm+github@gmail.com> <makoto.nksm@gmail.com>
|
||||
NAKASHIMA, Makoto <makoto.nksm+github@gmail.com> <makoto.nksm+github@gmail.com>
|
||||
Marcell Pardavi <marcell.pardavi@gmail.com>
|
||||
Margaret Meyerhofer <mmeyerho@andrew.cmu.edu> <mmeyerho@andrew>
|
||||
Mark Rousskov <mark.simulacrum@gmail.com>
|
||||
|
@ -167,12 +168,14 @@ Michael Woerister <michaelwoerister@posteo> <michaelwoerister@gmail>
|
|||
Mickaël Raybaud-Roig <raybaudroigm@gmail.com> m-r-r <raybaudroigm@gmail.com>
|
||||
Ms2ger <ms2ger@gmail.com> <Ms2ger@gmail.com>
|
||||
Mukilan Thiagarajan <mukilanthiagarajan@gmail.com>
|
||||
NAKASHIMA, Makoto <makoto.nksm+github@gmail.com> <makoto.nksm@gmail.com>
|
||||
NAKASHIMA, Makoto <makoto.nksm+github@gmail.com> <makoto.nksm+github@gmail.com>
|
||||
Nathan West <Lucretiel@gmail.com> <lucretiel@gmail.com>
|
||||
Nathan Wilson <wilnathan@gmail.com>
|
||||
Nathaniel Herman <nherman@post.harvard.edu> Nathaniel Herman <nherman@college.harvard.edu>
|
||||
Neil Pankey <npankey@gmail.com> <neil@wire.im>
|
||||
Nicole Mazzuca <npmazzuca@gmail.com>
|
||||
Nick Platt <platt.nicholas@gmail.com>
|
||||
Nicole Mazzuca <npmazzuca@gmail.com>
|
||||
Nif Ward <nif.ward@gmail.com>
|
||||
Oliver Schneider <oliver.schneider@kit.edu> oli-obk <github6541940@oli-obk.de>
|
||||
Oliver Schneider <oliver.schneider@kit.edu> Oliver 'ker' Schneider <rust19446194516@oli-obk.de>
|
||||
|
@ -230,8 +233,8 @@ Tim JIANG <p90eri@gmail.com>
|
|||
Tim Joseph Dumol <tim@timdumol.com>
|
||||
Torsten Weber <TorstenWeber12@gmail.com> <torstenweber12@gmail.com>
|
||||
Ty Overby <ty@pre-alpha.com>
|
||||
Ulrik Sverdrup <bluss@users.noreply.github.com> bluss <bluss>
|
||||
Ulrik Sverdrup <bluss@users.noreply.github.com> bluss <bluss@users.noreply.github.com>
|
||||
Ulrik Sverdrup <bluss@users.noreply.github.com> bluss <bluss>
|
||||
Ulrik Sverdrup <bluss@users.noreply.github.com> Ulrik Sverdrup <root@localhost>
|
||||
Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
|
||||
Vadim Petrochenkov <vadim.petrochenkov@gmail.com> petrochenkov <vadim.petrochenkov@gmail.com>
|
||||
|
|
|
@ -966,6 +966,9 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
|
|||
///
|
||||
/// The compiler then knows to not make any incorrect assumptions or optimizations on this code.
|
||||
///
|
||||
/// You can think of `MaybeUninit<T>` as being a bit like `Option<T>` but without
|
||||
/// any of the run-time tracking and without any of the safety checks.
|
||||
///
|
||||
/// ## out-pointers
|
||||
///
|
||||
/// You can use `MaybeUninit<T>` to implement "out-pointers": instead of returning data
|
||||
|
|
|
@ -652,7 +652,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
for sp in prior_arms {
|
||||
err.span_label(*sp, format!(
|
||||
"this is found to be of type `{}`",
|
||||
self.resolve_type_vars_if_possible(&last_ty),
|
||||
self.resolve_vars_if_possible(&last_ty),
|
||||
));
|
||||
}
|
||||
} else if let Some(sp) = prior_arms.last() {
|
||||
|
@ -1278,7 +1278,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
&self,
|
||||
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
|
||||
) -> Option<(DiagnosticStyledString, DiagnosticStyledString)> {
|
||||
let exp_found = self.resolve_type_vars_if_possible(exp_found);
|
||||
let exp_found = self.resolve_vars_if_possible(exp_found);
|
||||
if exp_found.references_error() {
|
||||
return None;
|
||||
}
|
||||
|
@ -1291,7 +1291,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
&self,
|
||||
exp_found: &ty::error::ExpectedFound<T>,
|
||||
) -> Option<(DiagnosticStyledString, DiagnosticStyledString)> {
|
||||
let exp_found = self.resolve_type_vars_if_possible(exp_found);
|
||||
let exp_found = self.resolve_vars_if_possible(exp_found);
|
||||
if exp_found.references_error() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
|
|||
});
|
||||
match ty_opt {
|
||||
Some(ty) => {
|
||||
let ty = self.infcx.resolve_type_vars_if_possible(&ty);
|
||||
let ty = self.infcx.resolve_vars_if_possible(&ty);
|
||||
ty.walk().any(|inner_ty| {
|
||||
inner_ty == self.target_ty || match (&inner_ty.sty, &self.target_ty.sty) {
|
||||
(&Infer(TyVar(a_vid)), &Infer(TyVar(b_vid))) => {
|
||||
|
@ -94,7 +94,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
span: Span,
|
||||
ty: Ty<'tcx>
|
||||
) -> DiagnosticBuilder<'gcx> {
|
||||
let ty = self.resolve_type_vars_if_possible(&ty);
|
||||
let ty = self.resolve_vars_if_possible(&ty);
|
||||
let name = self.extract_type_name(&ty, None);
|
||||
|
||||
let mut err_span = span;
|
||||
|
@ -166,7 +166,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
span: Span,
|
||||
ty: Ty<'tcx>
|
||||
) -> DiagnosticBuilder<'gcx> {
|
||||
let ty = self.resolve_type_vars_if_possible(&ty);
|
||||
let ty = self.resolve_vars_if_possible(&ty);
|
||||
let name = self.extract_type_name(&ty, None);
|
||||
|
||||
let mut err = struct_span_err!(self.tcx.sess,
|
||||
|
|
|
@ -210,11 +210,11 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
|
|||
_ => (),
|
||||
}
|
||||
|
||||
let expected_trait_ref = self.infcx.resolve_type_vars_if_possible(&ty::TraitRef {
|
||||
let expected_trait_ref = self.infcx.resolve_vars_if_possible(&ty::TraitRef {
|
||||
def_id: trait_def_id,
|
||||
substs: expected_substs,
|
||||
});
|
||||
let actual_trait_ref = self.infcx.resolve_type_vars_if_possible(&ty::TraitRef {
|
||||
let actual_trait_ref = self.infcx.resolve_vars_if_possible(&ty::TraitRef {
|
||||
def_id: trait_def_id,
|
||||
substs: actual_substs,
|
||||
});
|
||||
|
|
|
@ -74,7 +74,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let (mut fudger, value) = self.probe(|snapshot| {
|
||||
match f() {
|
||||
Ok(value) => {
|
||||
let value = self.resolve_type_vars_if_possible(&value);
|
||||
let value = self.resolve_vars_if_possible(&value);
|
||||
|
||||
// At this point, `value` could in principle refer
|
||||
// to inference variables that have been created during
|
||||
|
|
|
@ -1174,7 +1174,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
/// Process the region constraints and report any errors that
|
||||
/// result. After this, no more unification operations should be
|
||||
/// done -- or the compiler will panic -- but it is legal to use
|
||||
/// `resolve_type_vars_if_possible` as well as `fully_resolve`.
|
||||
/// `resolve_vars_if_possible` as well as `fully_resolve`.
|
||||
pub fn resolve_regions_and_report_errors(
|
||||
&self,
|
||||
region_context: DefId,
|
||||
|
@ -1262,7 +1262,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
|
||||
self.resolve_type_vars_if_possible(&t).to_string()
|
||||
self.resolve_vars_if_possible(&t).to_string()
|
||||
}
|
||||
|
||||
pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String {
|
||||
|
@ -1271,7 +1271,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn trait_ref_to_string(&self, t: &ty::TraitRef<'tcx>) -> String {
|
||||
self.resolve_type_vars_if_possible(t).to_string()
|
||||
self.resolve_vars_if_possible(t).to_string()
|
||||
}
|
||||
|
||||
/// If `TyVar(vid)` resolves to a type, return that type. Else, return the
|
||||
|
@ -1297,20 +1297,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
self.type_variables.borrow_mut().root_var(var)
|
||||
}
|
||||
|
||||
/// Where possible, replaces type/int/float variables in
|
||||
/// Where possible, replaces type/const variables in
|
||||
/// `value` with their final value. Note that region variables
|
||||
/// are unaffected. If a type variable has not been unified, it
|
||||
/// are unaffected. If a type/const variable has not been unified, it
|
||||
/// is left as is. This is an idempotent operation that does
|
||||
/// not affect inference state in any way and so you can do it
|
||||
/// at will.
|
||||
pub fn resolve_type_vars_if_possible<T>(&self, value: &T) -> T
|
||||
pub fn resolve_vars_if_possible<T>(&self, value: &T) -> T
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
if !value.needs_infer() {
|
||||
return value.clone(); // avoid duplicated subst-folding
|
||||
}
|
||||
let mut r = resolve::OpportunisticTypeResolver::new(self);
|
||||
let mut r = resolve::OpportunisticVarResolver::new(self);
|
||||
value.fold_with(&mut r)
|
||||
}
|
||||
|
||||
|
@ -1318,7 +1318,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
/// process of visiting `T`, this will resolve (where possible)
|
||||
/// type variables in `T`, but it never constructs the final,
|
||||
/// resolved type, so it's more efficient than
|
||||
/// `resolve_type_vars_if_possible()`.
|
||||
/// `resolve_vars_if_possible()`.
|
||||
pub fn unresolved_type_vars<T>(&self, value: &T) -> Option<(Ty<'tcx>, Option<Span>)>
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
|
@ -1389,7 +1389,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
where
|
||||
M: FnOnce(String) -> DiagnosticBuilder<'tcx>,
|
||||
{
|
||||
let actual_ty = self.resolve_type_vars_if_possible(&actual_ty);
|
||||
let actual_ty = self.resolve_vars_if_possible(&actual_ty);
|
||||
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);
|
||||
|
||||
// Don't report an error if actual type is `Error`.
|
||||
|
@ -1446,7 +1446,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
ty: Ty<'tcx>,
|
||||
span: Span,
|
||||
) -> bool {
|
||||
let ty = self.resolve_type_vars_if_possible(&ty);
|
||||
let ty = self.resolve_vars_if_possible(&ty);
|
||||
|
||||
// Even if the type may have no inference variables, during
|
||||
// type-checking closure types are in local tables only.
|
||||
|
|
|
@ -286,7 +286,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
let tcx = self.tcx;
|
||||
|
||||
let concrete_ty = self.resolve_type_vars_if_possible(&opaque_defn.concrete_ty);
|
||||
let concrete_ty = self.resolve_vars_if_possible(&opaque_defn.concrete_ty);
|
||||
|
||||
debug!("constrain_opaque_type: concrete_ty={:?}", concrete_ty);
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> {
|
|||
debug!("add_implied_bounds()");
|
||||
|
||||
for &ty in fn_sig_tys {
|
||||
let ty = infcx.resolve_type_vars_if_possible(&ty);
|
||||
let ty = infcx.resolve_vars_if_possible(&ty);
|
||||
debug!("add_implied_bounds: ty = {}", ty);
|
||||
let implied_bounds = infcx.implied_outlives_bounds(self.param_env, body_id, ty, span);
|
||||
self.add_outlives_bounds(Some(infcx), implied_bounds)
|
||||
|
|
|
@ -177,7 +177,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||
sup_type, sub_region, origin
|
||||
);
|
||||
|
||||
let sup_type = self.resolve_type_vars_if_possible(&sup_type);
|
||||
let sup_type = self.resolve_vars_if_possible(&sup_type);
|
||||
|
||||
if let Some(region_bound_pairs) = region_bound_pairs_map.get(&body_id) {
|
||||
let outlives = &mut TypeOutlives::new(
|
||||
|
@ -215,7 +215,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||
implicit_region_bound,
|
||||
param_env,
|
||||
);
|
||||
let ty = self.resolve_type_vars_if_possible(&ty);
|
||||
let ty = self.resolve_vars_if_possible(&ty);
|
||||
outlives.type_must_outlive(origin, ty, region);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
use super::{InferCtxt, FixupError, FixupResult, Span, type_variable::TypeVariableOrigin};
|
||||
use crate::mir::interpret::ConstValue;
|
||||
use crate::ty::{self, Ty, TyCtxt, TypeFoldable, InferConst};
|
||||
use crate::ty::{self, Ty, Const, TyCtxt, TypeFoldable, InferConst, TypeFlags};
|
||||
use crate::ty::fold::{TypeFolder, TypeVisitor};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// OPPORTUNISTIC TYPE RESOLVER
|
||||
// OPPORTUNISTIC VAR RESOLVER
|
||||
|
||||
/// The opportunistic type resolver can be used at any time. It simply replaces
|
||||
/// type variables that have been unified with the things they have
|
||||
/// The opportunistic resolver can be used at any time. It simply replaces
|
||||
/// type/const variables that have been unified with the things they have
|
||||
/// been unified with (similar to `shallow_resolve`, but deep). This is
|
||||
/// useful for printing messages etc but also required at various
|
||||
/// points for correctness.
|
||||
pub struct OpportunisticTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
pub struct OpportunisticVarResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
|
||||
impl<'a, 'gcx, 'tcx> OpportunisticVarResolver<'a, 'gcx, 'tcx> {
|
||||
#[inline]
|
||||
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
|
||||
OpportunisticTypeResolver { infcx }
|
||||
OpportunisticVarResolver { infcx }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
|
||||
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticVarResolver<'a, 'gcx, 'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
@ -31,8 +31,17 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeResolver<'a, 'g
|
|||
if !t.has_infer_types() {
|
||||
t // micro-optimize -- if there is nothing in this type that this fold affects...
|
||||
} else {
|
||||
let t0 = self.infcx.shallow_resolve(t);
|
||||
t0.super_fold_with(self)
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
t.super_fold_with(self)
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_const(&mut self, ct: &'tcx Const<'tcx>) -> &'tcx Const<'tcx> {
|
||||
if !ct.has_type_flags(TypeFlags::HAS_CT_INFER) {
|
||||
ct // micro-optimize -- if there is nothing in this const that this fold affects...
|
||||
} else {
|
||||
let ct = self.infcx.shallow_resolve(ct);
|
||||
ct.super_fold_with(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -458,10 +458,10 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
fn resolve_type_vars_if_possible<T>(&self, value: &T) -> T
|
||||
fn resolve_vars_if_possible<T>(&self, value: &T) -> T
|
||||
where T: TypeFoldable<'tcx>
|
||||
{
|
||||
self.infcx.map(|infcx| infcx.resolve_type_vars_if_possible(value))
|
||||
self.infcx.map(|infcx| infcx.resolve_vars_if_possible(value))
|
||||
.unwrap_or_else(|| value.clone())
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
-> McResult<Ty<'tcx>> {
|
||||
match ty {
|
||||
Some(ty) => {
|
||||
let ty = self.resolve_type_vars_if_possible(&ty);
|
||||
let ty = self.resolve_vars_if_possible(&ty);
|
||||
if ty.references_error() || ty.is_ty_var() {
|
||||
debug!("resolve_type_vars_or_error: error from {:?}", ty);
|
||||
Err(())
|
||||
|
@ -602,7 +602,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
where F: FnOnce() -> McResult<cmt_<'tcx>>
|
||||
{
|
||||
debug!("cat_expr_adjusted_with({:?}): {:?}", adjustment, expr);
|
||||
let target = self.resolve_type_vars_if_possible(&adjustment.target);
|
||||
let target = self.resolve_vars_if_possible(&adjustment.target);
|
||||
match adjustment.kind {
|
||||
adjustment::Adjust::Deref(overloaded) => {
|
||||
// Equivalent to *expr or something similar.
|
||||
|
|
|
@ -3,7 +3,7 @@ use rustc_data_structures::sync::{RwLock, MappedReadGuard, ReadGuard};
|
|||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
|
||||
StableHasherResult};
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::mir::{Mir, BasicBlock};
|
||||
use crate::mir::{Body, BasicBlock};
|
||||
|
||||
use crate::rustc_serialize as serialize;
|
||||
|
||||
|
@ -47,7 +47,7 @@ impl Cache {
|
|||
|
||||
pub fn predecessors(
|
||||
&self,
|
||||
mir: &Mir<'_>
|
||||
mir: &Body<'_>
|
||||
) -> MappedReadGuard<'_, IndexVec<BasicBlock, Vec<BasicBlock>>> {
|
||||
if self.predecessors.borrow().is_none() {
|
||||
*self.predecessors.borrow_mut() = Some(calculate_predecessors(mir));
|
||||
|
@ -57,7 +57,7 @@ impl Cache {
|
|||
}
|
||||
}
|
||||
|
||||
fn calculate_predecessors(mir: &Mir<'_>) -> IndexVec<BasicBlock, Vec<BasicBlock>> {
|
||||
fn calculate_predecessors(mir: &Body<'_>) -> IndexVec<BasicBlock, Vec<BasicBlock>> {
|
||||
let mut result = IndexVec::from_elem(vec![], mir.basic_blocks());
|
||||
for (bb, data) in mir.basic_blocks().iter_enumerated() {
|
||||
if let Some(ref term) = data.terminator {
|
||||
|
|
|
@ -47,7 +47,7 @@ pub struct GlobalId<'tcx> {
|
|||
/// For a promoted global, the `Instance` of the function they belong to.
|
||||
pub instance: ty::Instance<'tcx>,
|
||||
|
||||
/// The index for promoted globals within their function's `Mir`.
|
||||
/// The index for promoted globals within their function's `mir::Body`.
|
||||
pub promoted: Option<mir::Promoted>,
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ impl<'tcx> HasLocalDecls<'tcx> for LocalDecls<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> HasLocalDecls<'tcx> for Mir<'tcx> {
|
||||
impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> {
|
||||
fn local_decls(&self) -> &LocalDecls<'tcx> {
|
||||
&self.local_decls
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ impl MirPhase {
|
|||
|
||||
/// Lowered representation of a single function.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct Mir<'tcx> {
|
||||
pub struct Body<'tcx> {
|
||||
/// List of basic blocks. References to basic block use a newtyped index type `BasicBlock`
|
||||
/// that indexes into this vector.
|
||||
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
|
@ -107,15 +107,15 @@ pub struct Mir<'tcx> {
|
|||
pub source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
|
||||
|
||||
/// Rvalues promoted from this function, such as borrows of constants.
|
||||
/// Each of them is the Mir of a constant with the fn's type parameters
|
||||
/// Each of them is the Body of a constant with the fn's type parameters
|
||||
/// in scope, but a separate set of locals.
|
||||
pub promoted: IndexVec<Promoted, Mir<'tcx>>,
|
||||
pub promoted: IndexVec<Promoted, Body<'tcx>>,
|
||||
|
||||
/// Yields type of the function, if it is a generator.
|
||||
pub yield_ty: Option<Ty<'tcx>>,
|
||||
|
||||
/// Generator drop glue
|
||||
pub generator_drop: Option<Box<Mir<'tcx>>>,
|
||||
pub generator_drop: Option<Box<Body<'tcx>>>,
|
||||
|
||||
/// The layout of a generator. Produced by the state transformation.
|
||||
pub generator_layout: Option<GeneratorLayout<'tcx>>,
|
||||
|
@ -167,12 +167,12 @@ pub struct Mir<'tcx> {
|
|||
cache: cache::Cache,
|
||||
}
|
||||
|
||||
impl<'tcx> Mir<'tcx> {
|
||||
impl<'tcx> Body<'tcx> {
|
||||
pub fn new(
|
||||
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
||||
source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
|
||||
promoted: IndexVec<Promoted, Mir<'tcx>>,
|
||||
promoted: IndexVec<Promoted, Body<'tcx>>,
|
||||
yield_ty: Option<Ty<'tcx>>,
|
||||
local_decls: LocalDecls<'tcx>,
|
||||
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
|
||||
|
@ -189,7 +189,7 @@ impl<'tcx> Mir<'tcx> {
|
|||
local_decls.len()
|
||||
);
|
||||
|
||||
Mir {
|
||||
Body {
|
||||
phase: MirPhase::Build,
|
||||
basic_blocks,
|
||||
source_scopes,
|
||||
|
@ -423,7 +423,7 @@ pub enum Safety {
|
|||
ExplicitUnsafe(hir::HirId),
|
||||
}
|
||||
|
||||
impl_stable_hash_for!(struct Mir<'tcx> {
|
||||
impl_stable_hash_for!(struct Body<'tcx> {
|
||||
phase,
|
||||
basic_blocks,
|
||||
source_scopes,
|
||||
|
@ -442,7 +442,7 @@ impl_stable_hash_for!(struct Mir<'tcx> {
|
|||
cache
|
||||
});
|
||||
|
||||
impl<'tcx> Index<BasicBlock> for Mir<'tcx> {
|
||||
impl<'tcx> Index<BasicBlock> for Body<'tcx> {
|
||||
type Output = BasicBlockData<'tcx>;
|
||||
|
||||
#[inline]
|
||||
|
@ -451,7 +451,7 @@ impl<'tcx> Index<BasicBlock> for Mir<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> IndexMut<BasicBlock> for Mir<'tcx> {
|
||||
impl<'tcx> IndexMut<BasicBlock> for Body<'tcx> {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: BasicBlock) -> &mut BasicBlockData<'tcx> {
|
||||
&mut self.basic_blocks_mut()[index]
|
||||
|
@ -599,7 +599,7 @@ newtype_index! {
|
|||
}
|
||||
}
|
||||
|
||||
/// Classifies locals into categories. See `Mir::local_kind`.
|
||||
/// Classifies locals into categories. See `Body::local_kind`.
|
||||
#[derive(PartialEq, Eq, Debug, HashStable)]
|
||||
pub enum LocalKind {
|
||||
/// User-declared variable binding
|
||||
|
@ -2828,23 +2828,23 @@ impl<'tcx> Display for Constant<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> graph::DirectedGraph for Mir<'tcx> {
|
||||
impl<'tcx> graph::DirectedGraph for Body<'tcx> {
|
||||
type Node = BasicBlock;
|
||||
}
|
||||
|
||||
impl<'tcx> graph::WithNumNodes for Mir<'tcx> {
|
||||
impl<'tcx> graph::WithNumNodes for Body<'tcx> {
|
||||
fn num_nodes(&self) -> usize {
|
||||
self.basic_blocks.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> graph::WithStartNode for Mir<'tcx> {
|
||||
impl<'tcx> graph::WithStartNode for Body<'tcx> {
|
||||
fn start_node(&self) -> Self::Node {
|
||||
START_BLOCK
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> graph::WithPredecessors for Mir<'tcx> {
|
||||
impl<'tcx> graph::WithPredecessors for Body<'tcx> {
|
||||
fn predecessors<'graph>(
|
||||
&'graph self,
|
||||
node: Self::Node,
|
||||
|
@ -2853,7 +2853,7 @@ impl<'tcx> graph::WithPredecessors for Mir<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> graph::WithSuccessors for Mir<'tcx> {
|
||||
impl<'tcx> graph::WithSuccessors for Body<'tcx> {
|
||||
fn successors<'graph>(
|
||||
&'graph self,
|
||||
node: Self::Node,
|
||||
|
@ -2862,12 +2862,12 @@ impl<'tcx> graph::WithSuccessors for Mir<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> graph::GraphPredecessors<'b> for Mir<'a> {
|
||||
impl<'a, 'b> graph::GraphPredecessors<'b> for Body<'a> {
|
||||
type Item = BasicBlock;
|
||||
type Iter = IntoIter<BasicBlock>;
|
||||
}
|
||||
|
||||
impl<'a, 'b> graph::GraphSuccessors<'b> for Mir<'a> {
|
||||
impl<'a, 'b> graph::GraphSuccessors<'b> for Body<'a> {
|
||||
type Item = BasicBlock;
|
||||
type Iter = iter::Cloned<Successors<'b>>;
|
||||
}
|
||||
|
@ -2906,7 +2906,7 @@ impl Location {
|
|||
}
|
||||
|
||||
/// Returns `true` if `other` is earlier in the control flow graph than `self`.
|
||||
pub fn is_predecessor_of<'tcx>(&self, other: Location, mir: &Mir<'tcx>) -> bool {
|
||||
pub fn is_predecessor_of<'tcx>(&self, other: Location, mir: &Body<'tcx>) -> bool {
|
||||
// If we are in the same block as the other location and are an earlier statement
|
||||
// then we are a predecessor of `other`.
|
||||
if self.block == other.block && self.statement_index < other.statement_index {
|
||||
|
@ -3159,7 +3159,7 @@ CloneTypeFoldableAndLiftImpls! {
|
|||
}
|
||||
|
||||
BraceStructTypeFoldableImpl! {
|
||||
impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
|
||||
impl<'tcx> TypeFoldable<'tcx> for Body<'tcx> {
|
||||
phase,
|
||||
basic_blocks,
|
||||
source_scopes,
|
||||
|
|
|
@ -21,14 +21,14 @@ use super::*;
|
|||
/// A preorder traversal of this graph is either `A B D C` or `A C D B`
|
||||
#[derive(Clone)]
|
||||
pub struct Preorder<'a, 'tcx: 'a> {
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
visited: BitSet<BasicBlock>,
|
||||
worklist: Vec<BasicBlock>,
|
||||
root_is_start_block: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Preorder<'a, 'tcx> {
|
||||
pub fn new(mir: &'a Mir<'tcx>, root: BasicBlock) -> Preorder<'a, 'tcx> {
|
||||
pub fn new(mir: &'a Body<'tcx>, root: BasicBlock) -> Preorder<'a, 'tcx> {
|
||||
let worklist = vec![root];
|
||||
|
||||
Preorder {
|
||||
|
@ -40,7 +40,7 @@ impl<'a, 'tcx> Preorder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn preorder<'a, 'tcx>(mir: &'a Mir<'tcx>) -> Preorder<'a, 'tcx> {
|
||||
pub fn preorder<'a, 'tcx>(mir: &'a Body<'tcx>) -> Preorder<'a, 'tcx> {
|
||||
Preorder::new(mir, START_BLOCK)
|
||||
}
|
||||
|
||||
|
@ -99,14 +99,14 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> {
|
|||
///
|
||||
/// A Postorder traversal of this graph is `D B C A` or `D C B A`
|
||||
pub struct Postorder<'a, 'tcx: 'a> {
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
visited: BitSet<BasicBlock>,
|
||||
visit_stack: Vec<(BasicBlock, Successors<'a>)>,
|
||||
root_is_start_block: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Postorder<'a, 'tcx> {
|
||||
pub fn new(mir: &'a Mir<'tcx>, root: BasicBlock) -> Postorder<'a, 'tcx> {
|
||||
pub fn new(mir: &'a Body<'tcx>, root: BasicBlock) -> Postorder<'a, 'tcx> {
|
||||
let mut po = Postorder {
|
||||
mir,
|
||||
visited: BitSet::new_empty(mir.basic_blocks().len()),
|
||||
|
@ -194,7 +194,7 @@ impl<'a, 'tcx> Postorder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn postorder<'a, 'tcx>(mir: &'a Mir<'tcx>) -> Postorder<'a, 'tcx> {
|
||||
pub fn postorder<'a, 'tcx>(mir: &'a Body<'tcx>) -> Postorder<'a, 'tcx> {
|
||||
Postorder::new(mir, START_BLOCK)
|
||||
}
|
||||
|
||||
|
@ -252,13 +252,13 @@ impl<'a, 'tcx> Iterator for Postorder<'a, 'tcx> {
|
|||
/// to re-use the traversal
|
||||
#[derive(Clone)]
|
||||
pub struct ReversePostorder<'a, 'tcx: 'a> {
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
blocks: Vec<BasicBlock>,
|
||||
idx: usize
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ReversePostorder<'a, 'tcx> {
|
||||
pub fn new(mir: &'a Mir<'tcx>, root: BasicBlock) -> ReversePostorder<'a, 'tcx> {
|
||||
pub fn new(mir: &'a Body<'tcx>, root: BasicBlock) -> ReversePostorder<'a, 'tcx> {
|
||||
let blocks : Vec<_> = Postorder::new(mir, root).map(|(bb, _)| bb).collect();
|
||||
|
||||
let len = blocks.len();
|
||||
|
@ -276,7 +276,7 @@ impl<'a, 'tcx> ReversePostorder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
|
||||
pub fn reverse_postorder<'a, 'tcx>(mir: &'a Mir<'tcx>) -> ReversePostorder<'a, 'tcx> {
|
||||
pub fn reverse_postorder<'a, 'tcx>(mir: &'a Body<'tcx>) -> ReversePostorder<'a, 'tcx> {
|
||||
ReversePostorder::new(mir, START_BLOCK)
|
||||
}
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ macro_rules! make_mir_visitor {
|
|||
// Override these, and call `self.super_xxx` to revert back to the
|
||||
// default behavior.
|
||||
|
||||
fn visit_mir(&mut self, mir: & $($mutability)? Mir<'tcx>) {
|
||||
self.super_mir(mir);
|
||||
fn visit_body(&mut self, mir: & $($mutability)? Body<'tcx>) {
|
||||
self.super_body(mir);
|
||||
}
|
||||
|
||||
fn visit_basic_block_data(&mut self,
|
||||
|
@ -251,8 +251,8 @@ macro_rules! make_mir_visitor {
|
|||
// The `super_xxx` methods comprise the default behavior and are
|
||||
// not meant to be overridden.
|
||||
|
||||
fn super_mir(&mut self,
|
||||
mir: & $($mutability)? Mir<'tcx>) {
|
||||
fn super_body(&mut self,
|
||||
mir: & $($mutability)? Body<'tcx>) {
|
||||
if let Some(yield_ty) = &$($mutability)? mir.yield_ty {
|
||||
self.visit_ty(yield_ty, TyContext::YieldTy(SourceInfo {
|
||||
span: mir.span,
|
||||
|
@ -261,7 +261,7 @@ macro_rules! make_mir_visitor {
|
|||
}
|
||||
|
||||
// for best performance, we want to use an iterator rather
|
||||
// than a for-loop, to avoid calling Mir::invalidate for
|
||||
// than a for-loop, to avoid calling `mir::Body::invalidate` for
|
||||
// each basic block.
|
||||
macro_rules! basic_blocks {
|
||||
(mut) => (mir.basic_blocks_mut().iter_enumerated_mut());
|
||||
|
@ -825,7 +825,7 @@ macro_rules! make_mir_visitor {
|
|||
|
||||
// Convenience methods
|
||||
|
||||
fn visit_location(&mut self, mir: & $($mutability)? Mir<'tcx>, location: Location) {
|
||||
fn visit_location(&mut self, mir: & $($mutability)? Body<'tcx>, location: Location) {
|
||||
let basic_block = & $($mutability)? mir[location.block];
|
||||
if basic_block.statements.len() == location.statement_index {
|
||||
if let Some(ref $($mutability)? terminator) = basic_block.terminator {
|
||||
|
|
|
@ -88,7 +88,7 @@ rustc_queries! {
|
|||
desc { "getting a list of all mir_keys" }
|
||||
}
|
||||
|
||||
/// Maps DefId's that have an associated Mir to the result
|
||||
/// Maps DefId's that have an associated `mir::Body` to the result
|
||||
/// of the MIR qualify_consts pass. The actual meaning of
|
||||
/// the value isn't known except to the pass itself.
|
||||
query mir_const_qualif(key: DefId) -> (u8, &'tcx BitSet<mir::Local>) {
|
||||
|
@ -97,26 +97,26 @@ rustc_queries! {
|
|||
|
||||
/// Fetch the MIR for a given `DefId` right after it's built - this includes
|
||||
/// unreachable code.
|
||||
query mir_built(_: DefId) -> &'tcx Steal<mir::Mir<'tcx>> {}
|
||||
query mir_built(_: DefId) -> &'tcx Steal<mir::Body<'tcx>> {}
|
||||
|
||||
/// Fetch the MIR for a given `DefId` up till the point where it is
|
||||
/// ready for const evaluation.
|
||||
///
|
||||
/// See the README for the `mir` module for details.
|
||||
query mir_const(_: DefId) -> &'tcx Steal<mir::Mir<'tcx>> {
|
||||
query mir_const(_: DefId) -> &'tcx Steal<mir::Body<'tcx>> {
|
||||
no_hash
|
||||
}
|
||||
|
||||
query mir_validated(_: DefId) -> &'tcx Steal<mir::Mir<'tcx>> {
|
||||
query mir_validated(_: DefId) -> &'tcx Steal<mir::Body<'tcx>> {
|
||||
no_hash
|
||||
}
|
||||
|
||||
/// MIR after our optimization passes have run. This is MIR that is ready
|
||||
/// for codegen. This is also the only query that can fetch non-local MIR, at present.
|
||||
query optimized_mir(key: DefId) -> &'tcx mir::Mir<'tcx> {
|
||||
query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
|
||||
cache { key.is_local() }
|
||||
load_cached(tcx, id) {
|
||||
let mir: Option<crate::mir::Mir<'tcx>> = tcx.queries.on_disk_cache
|
||||
let mir: Option<crate::mir::Body<'tcx>> = tcx.queries.on_disk_cache
|
||||
.try_load_query_result(tcx, id);
|
||||
mir.map(|x| tcx.alloc_mir(x))
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ rustc_queries! {
|
|||
/// in the case of closures, this will be redirected to the enclosing function.
|
||||
query region_scope_tree(_: DefId) -> &'tcx region::ScopeTree {}
|
||||
|
||||
query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx> {
|
||||
query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Body<'tcx> {
|
||||
no_force
|
||||
desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
|
||||
}
|
||||
|
|
|
@ -307,9 +307,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Call infcx.resolve_type_vars_if_possible to see if we can
|
||||
// Call infcx.resolve_vars_if_possible to see if we can
|
||||
// get rid of any inference variables.
|
||||
let obligation = infcx.resolve_type_vars_if_possible(
|
||||
let obligation = infcx.resolve_vars_if_possible(
|
||||
&Obligation::new(dummy_cause.clone(), new_env, pred)
|
||||
);
|
||||
let result = select.select(&obligation);
|
||||
|
@ -642,7 +642,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
|||
fresh_preds.insert(self.clean_pred(select.infcx(), predicate));
|
||||
|
||||
// Resolve any inference variables that we can, to help selection succeed
|
||||
predicate = select.infcx().resolve_type_vars_if_possible(&predicate);
|
||||
predicate = select.infcx().resolve_vars_if_possible(&predicate);
|
||||
|
||||
// We only add a predicate as a user-displayable bound if
|
||||
// it involves a generic parameter, and doesn't contain
|
||||
|
|
|
@ -33,7 +33,7 @@ fn in_environment(
|
|||
obligation: PredicateObligation<'tcx>
|
||||
) -> InEnvironment<'tcx, PredicateObligation<'tcx>> {
|
||||
assert!(!infcx.is_in_snapshot());
|
||||
let obligation = infcx.resolve_type_vars_if_possible(&obligation);
|
||||
let obligation = infcx.resolve_vars_if_possible(&obligation);
|
||||
|
||||
let environment = match obligation.param_env.def_id {
|
||||
Some(def_id) => infcx.tcx.environment(def_id),
|
||||
|
|
|
@ -153,11 +153,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
bug!("Encountered errors `{:?}` resolving bounds after type-checking", errors);
|
||||
}
|
||||
|
||||
let result = self.resolve_type_vars_if_possible(result);
|
||||
let result = self.resolve_vars_if_possible(result);
|
||||
let result = self.tcx.erase_regions(&result);
|
||||
|
||||
self.tcx.lift_to_global(&result).unwrap_or_else(||
|
||||
bug!("Uninferred types/regions in `{:?}`", result)
|
||||
bug!("Uninferred types/regions/consts in `{:?}`", result)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ fn overlap_within_probe(
|
|||
a_impl_header.predicates
|
||||
.iter()
|
||||
.chain(&b_impl_header.predicates)
|
||||
.map(|p| infcx.resolve_type_vars_if_possible(p))
|
||||
.map(|p| infcx.resolve_vars_if_possible(p))
|
||||
.map(|p| Obligation { cause: ObligationCause::dummy(),
|
||||
param_env,
|
||||
recursion_depth: 0,
|
||||
|
@ -171,7 +171,7 @@ fn overlap_within_probe(
|
|||
return None
|
||||
}
|
||||
|
||||
let impl_header = selcx.infcx().resolve_type_vars_if_possible(&a_impl_header);
|
||||
let impl_header = selcx.infcx().resolve_vars_if_possible(&a_impl_header);
|
||||
let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes();
|
||||
debug!("overlap: intercrate_ambiguity_causes={:#?}", intercrate_ambiguity_causes);
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
error: &MismatchedProjectionTypes<'tcx>)
|
||||
{
|
||||
let predicate =
|
||||
self.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
self.resolve_vars_if_possible(&obligation.predicate);
|
||||
|
||||
if predicate.references_error() {
|
||||
return
|
||||
|
@ -531,7 +531,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
where T: fmt::Display + TypeFoldable<'tcx>
|
||||
{
|
||||
let predicate =
|
||||
self.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
self.resolve_vars_if_possible(&obligation.predicate);
|
||||
let mut err = struct_span_err!(self.tcx.sess, obligation.cause.span, E0275,
|
||||
"overflow evaluating the requirement `{}`",
|
||||
predicate);
|
||||
|
@ -553,7 +553,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
/// we do not suggest increasing the overflow limit, which is not
|
||||
/// going to help).
|
||||
pub fn report_overflow_error_cycle(&self, cycle: &[PredicateObligation<'tcx>]) -> ! {
|
||||
let cycle = self.resolve_type_vars_if_possible(&cycle.to_owned());
|
||||
let cycle = self.resolve_vars_if_possible(&cycle.to_owned());
|
||||
assert!(cycle.len() > 0);
|
||||
|
||||
debug!("report_overflow_error_cycle: cycle={:?}", cycle);
|
||||
|
@ -589,7 +589,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
fn get_parent_trait_ref(&self, code: &ObligationCauseCode<'tcx>) -> Option<String> {
|
||||
match code {
|
||||
&ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
|
||||
let parent_trait_ref = self.resolve_type_vars_if_possible(
|
||||
let parent_trait_ref = self.resolve_vars_if_possible(
|
||||
&data.parent_trait_ref);
|
||||
match self.get_parent_trait_ref(&data.parent_code) {
|
||||
Some(t) => Some(t),
|
||||
|
@ -625,7 +625,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
match obligation.predicate {
|
||||
ty::Predicate::Trait(ref trait_predicate) => {
|
||||
let trait_predicate =
|
||||
self.resolve_type_vars_if_possible(trait_predicate);
|
||||
self.resolve_vars_if_possible(trait_predicate);
|
||||
|
||||
if self.tcx.sess.has_errors() && trait_predicate.references_error() {
|
||||
return;
|
||||
|
@ -749,7 +749,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
ty::Predicate::RegionOutlives(ref predicate) => {
|
||||
let predicate = self.resolve_type_vars_if_possible(predicate);
|
||||
let predicate = self.resolve_vars_if_possible(predicate);
|
||||
let err = self.region_outlives_predicate(&obligation.cause,
|
||||
&predicate).err().unwrap();
|
||||
struct_span_err!(
|
||||
|
@ -761,7 +761,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => {
|
||||
let predicate =
|
||||
self.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
self.resolve_vars_if_possible(&obligation.predicate);
|
||||
struct_span_err!(self.tcx.sess, span, E0280,
|
||||
"the requirement `{}` is not satisfied",
|
||||
predicate)
|
||||
|
@ -852,8 +852,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
OutputTypeParameterMismatch(ref found_trait_ref, ref expected_trait_ref, _) => {
|
||||
let found_trait_ref = self.resolve_type_vars_if_possible(&*found_trait_ref);
|
||||
let expected_trait_ref = self.resolve_type_vars_if_possible(&*expected_trait_ref);
|
||||
let found_trait_ref = self.resolve_vars_if_possible(&*found_trait_ref);
|
||||
let expected_trait_ref = self.resolve_vars_if_possible(&*expected_trait_ref);
|
||||
|
||||
if expected_trait_ref.self_ty().references_error() {
|
||||
return;
|
||||
|
@ -1345,7 +1345,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
// ambiguous impls. The latter *ought* to be a
|
||||
// coherence violation, so we don't report it here.
|
||||
|
||||
let predicate = self.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
let predicate = self.resolve_vars_if_possible(&obligation.predicate);
|
||||
let span = obligation.cause.span;
|
||||
|
||||
debug!("maybe_report_ambiguity(predicate={:?}, obligation={:?})",
|
||||
|
@ -1617,7 +1617,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
err.note("shared static variables must have a type that implements `Sync`");
|
||||
}
|
||||
ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
|
||||
let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref);
|
||||
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
|
||||
let ty = parent_trait_ref.skip_binder().self_ty();
|
||||
err.note(&format!("required because it appears within the type `{}`", ty));
|
||||
obligated_types.push(ty);
|
||||
|
@ -1631,7 +1631,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
ObligationCauseCode::ImplDerivedObligation(ref data) => {
|
||||
let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref);
|
||||
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
|
||||
err.note(
|
||||
&format!("required because of the requirements on the impl of `{}` for `{}`",
|
||||
parent_trait_ref,
|
||||
|
@ -1672,7 +1672,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
obligated_types: &mut Vec<&ty::TyS<'tcx>>,
|
||||
cause_code: &ObligationCauseCode<'tcx>) -> bool {
|
||||
if let ObligationCauseCode::BuiltinDerivedObligation(ref data) = cause_code {
|
||||
let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref);
|
||||
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
|
||||
|
||||
if obligated_types.iter().any(|ot| ot == &parent_trait_ref.skip_binder().self_ty()) {
|
||||
return true;
|
||||
|
|
|
@ -178,7 +178,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
|||
{
|
||||
// this helps to reduce duplicate errors, as well as making
|
||||
// debug output much nicer to read and so on.
|
||||
let obligation = infcx.resolve_type_vars_if_possible(&obligation);
|
||||
let obligation = infcx.resolve_vars_if_possible(&obligation);
|
||||
|
||||
debug!("register_predicate_obligation(obligation={:?})", obligation);
|
||||
|
||||
|
@ -261,7 +261,7 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
|
|||
}) {
|
||||
debug!("process_predicate: pending obligation {:?} still stalled on {:?}",
|
||||
self.selcx.infcx()
|
||||
.resolve_type_vars_if_possible(&pending_obligation.obligation),
|
||||
.resolve_vars_if_possible(&pending_obligation.obligation),
|
||||
pending_obligation.stalled_on);
|
||||
return ProcessResult::Unchanged;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
|
|||
|
||||
if obligation.predicate.has_infer_types() {
|
||||
obligation.predicate =
|
||||
self.selcx.infcx().resolve_type_vars_if_possible(&obligation.predicate);
|
||||
self.selcx.infcx().resolve_vars_if_possible(&obligation.predicate);
|
||||
}
|
||||
|
||||
debug!("process_obligation: obligation = {:?}", obligation);
|
||||
|
@ -318,7 +318,7 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
|
|||
trait_ref_type_vars(self.selcx, data.to_poly_trait_ref());
|
||||
|
||||
debug!("process_predicate: pending obligation {:?} now stalled on {:?}",
|
||||
self.selcx.infcx().resolve_type_vars_if_possible(obligation),
|
||||
self.selcx.infcx().resolve_vars_if_possible(obligation),
|
||||
pending_obligation.stalled_on);
|
||||
|
||||
ProcessResult::Unchanged
|
||||
|
@ -519,7 +519,7 @@ fn trait_ref_type_vars<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 't
|
|||
{
|
||||
t.skip_binder() // ok b/c this check doesn't care about regions
|
||||
.input_types()
|
||||
.map(|t| selcx.infcx().resolve_type_vars_if_possible(&t))
|
||||
.map(|t| selcx.infcx().resolve_vars_if_possible(&t))
|
||||
.filter(|t| t.has_infer_types())
|
||||
.flat_map(|t| t.walk())
|
||||
.filter(|t| match t.sty { ty::Infer(_) => true, _ => false })
|
||||
|
|
|
@ -927,7 +927,7 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>(
|
|||
debug!("fully_normalize: select_all_or_error start");
|
||||
fulfill_cx.select_all_or_error(infcx)?;
|
||||
debug!("fully_normalize: select_all_or_error complete");
|
||||
let resolved_value = infcx.resolve_type_vars_if_possible(&normalized_value);
|
||||
let resolved_value = infcx.resolve_vars_if_possible(&normalized_value);
|
||||
debug!("fully_normalize: resolved_value={:?}", resolved_value);
|
||||
Ok(resolved_value)
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ impl<'a, 'b, 'gcx, 'tcx> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold<T:TypeFoldable<'tcx>>(&mut self, value: &T) -> T {
|
||||
let value = self.selcx.infcx().resolve_type_vars_if_possible(value);
|
||||
let value = self.selcx.infcx().resolve_vars_if_possible(value);
|
||||
|
||||
if !value.has_projections() {
|
||||
value
|
||||
|
@ -508,7 +508,7 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
|
|||
{
|
||||
let infcx = selcx.infcx();
|
||||
|
||||
let projection_ty = infcx.resolve_type_vars_if_possible(&projection_ty);
|
||||
let projection_ty = infcx.resolve_vars_if_possible(&projection_ty);
|
||||
let cache_key = ProjectionCacheKey { ty: projection_ty };
|
||||
|
||||
debug!("opt_normalize_projection_type(\
|
||||
|
@ -1614,7 +1614,7 @@ impl<'cx, 'gcx, 'tcx> ProjectionCacheKey<'tcx> {
|
|||
// from a specific call to `opt_normalize_projection_type` - if
|
||||
// there's no precise match, the original cache entry is "stranded"
|
||||
// anyway.
|
||||
ty: infcx.resolve_type_vars_if_possible(&predicate.projection_ty)
|
||||
ty: infcx.resolve_vars_if_possible(&predicate.projection_ty)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
|
|||
&orig_values,
|
||||
result)
|
||||
{
|
||||
let ty = self.infcx.resolve_type_vars_if_possible(&ty);
|
||||
let ty = self.infcx.resolve_vars_if_possible(&ty);
|
||||
let kinds = value.into_kinds_reporting_overflows(tcx, span, ty);
|
||||
return InferOk {
|
||||
value: kinds,
|
||||
|
|
|
@ -97,7 +97,7 @@ fn scrape_region_constraints<'gcx, 'tcx, R>(
|
|||
region_obligations
|
||||
.iter()
|
||||
.map(|(_, r_o)| (r_o.sup_type, r_o.sub_region))
|
||||
.map(|(ty, r)| (infcx.resolve_type_vars_if_possible(&ty), r)),
|
||||
.map(|(ty, r)| (infcx.resolve_vars_if_possible(&ty), r)),
|
||||
®ion_constraint_data,
|
||||
);
|
||||
|
||||
|
|
|
@ -1463,7 +1463,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
|
||||
let obligation = &stack.obligation;
|
||||
let predicate = self.infcx()
|
||||
.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
.resolve_vars_if_possible(&obligation.predicate);
|
||||
|
||||
// OK to skip binder because of the nature of the
|
||||
// trait-ref-is-knowable check, which does not care about
|
||||
|
@ -1621,7 +1621,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
cause: obligation.cause.clone(),
|
||||
recursion_depth: obligation.recursion_depth,
|
||||
predicate: self.infcx()
|
||||
.resolve_type_vars_if_possible(&obligation.predicate),
|
||||
.resolve_vars_if_possible(&obligation.predicate),
|
||||
};
|
||||
|
||||
if obligation.predicate.skip_binder().self_ty().is_ty_var() {
|
||||
|
@ -1737,7 +1737,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
snapshot: &CombinedSnapshot<'_, 'tcx>,
|
||||
) -> bool {
|
||||
let poly_trait_predicate = self.infcx()
|
||||
.resolve_type_vars_if_possible(&obligation.predicate);
|
||||
.resolve_vars_if_possible(&obligation.predicate);
|
||||
let (placeholder_trait_predicate, placeholder_map) = self.infcx()
|
||||
.replace_bound_vars_with_placeholders(&poly_trait_predicate);
|
||||
debug!(
|
||||
|
|
|
@ -278,7 +278,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
|||
|
||||
// Now resolve the *substitution* we built for the target earlier, replacing
|
||||
// the inference variables inside with whatever we got from fulfillment.
|
||||
Ok(infcx.resolve_type_vars_if_possible(&target_substs))
|
||||
Ok(infcx.resolve_vars_if_possible(&target_substs))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::middle::cstore::EncodedMetadata;
|
|||
use crate::middle::lang_items;
|
||||
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
|
||||
use crate::middle::stability;
|
||||
use crate::mir::{self, Mir, interpret, ProjectionKind};
|
||||
use crate::mir::{self, Body, interpret, ProjectionKind};
|
||||
use crate::mir::interpret::{ConstValue, Allocation, Scalar};
|
||||
use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, Subst};
|
||||
use crate::ty::ReprOptions;
|
||||
|
@ -103,8 +103,8 @@ pub struct GlobalArenas<'tcx> {
|
|||
generics: TypedArena<ty::Generics>,
|
||||
trait_def: TypedArena<ty::TraitDef>,
|
||||
adt_def: TypedArena<ty::AdtDef>,
|
||||
steal_mir: TypedArena<Steal<Mir<'tcx>>>,
|
||||
mir: TypedArena<Mir<'tcx>>,
|
||||
steal_mir: TypedArena<Steal<Body<'tcx>>>,
|
||||
mir: TypedArena<Body<'tcx>>,
|
||||
tables: TypedArena<ty::TypeckTables<'tcx>>,
|
||||
/// miri allocations
|
||||
const_allocs: TypedArena<interpret::Allocation>,
|
||||
|
@ -1154,11 +1154,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
self.global_arenas.generics.alloc(generics)
|
||||
}
|
||||
|
||||
pub fn alloc_steal_mir(self, mir: Mir<'gcx>) -> &'gcx Steal<Mir<'gcx>> {
|
||||
pub fn alloc_steal_mir(self, mir: Body<'gcx>) -> &'gcx Steal<Body<'gcx>> {
|
||||
self.global_arenas.steal_mir.alloc(Steal::new(mir))
|
||||
}
|
||||
|
||||
pub fn alloc_mir(self, mir: Mir<'gcx>) -> &'gcx Mir<'gcx> {
|
||||
pub fn alloc_mir(self, mir: Body<'gcx>) -> &'gcx Body<'gcx> {
|
||||
self.global_arenas.mir.alloc(mir)
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,12 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
macro_rules! pluralise {
|
||||
($x:expr) => {
|
||||
if $x != 1 { "s" } else { "" }
|
||||
};
|
||||
}
|
||||
|
||||
match *self {
|
||||
CyclicTy(_) => write!(f, "cyclic type of infinite size"),
|
||||
Mismatch => write!(f, "types differ"),
|
||||
|
@ -94,17 +100,21 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
|||
values.found)
|
||||
}
|
||||
Mutability => write!(f, "types differ in mutability"),
|
||||
FixedArraySize(values) => {
|
||||
write!(f, "expected an array with a fixed size of {} elements, \
|
||||
found one with {} elements",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
TupleSize(values) => {
|
||||
write!(f, "expected a tuple with {} elements, \
|
||||
found one with {} elements",
|
||||
write!(f, "expected a tuple with {} element{}, \
|
||||
found one with {} element{}",
|
||||
values.expected,
|
||||
values.found)
|
||||
pluralise!(values.expected),
|
||||
values.found,
|
||||
pluralise!(values.found))
|
||||
}
|
||||
FixedArraySize(values) => {
|
||||
write!(f, "expected an array with a fixed size of {} element{}, \
|
||||
found one with {} element{}",
|
||||
values.expected,
|
||||
pluralise!(values.expected),
|
||||
values.found,
|
||||
pluralise!(values.found))
|
||||
}
|
||||
ArgCount => {
|
||||
write!(f, "incorrect number of function parameters")
|
||||
|
@ -157,8 +167,9 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
|||
tcx.def_path_str(values.found))
|
||||
}),
|
||||
ProjectionBoundsLength(ref values) => {
|
||||
write!(f, "expected {} associated type bindings, found {}",
|
||||
write!(f, "expected {} associated type binding{}, found {}",
|
||||
values.expected,
|
||||
pluralise!(values.expected),
|
||||
values.found)
|
||||
},
|
||||
ExistentialMismatch(ref values) => {
|
||||
|
@ -166,7 +177,7 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
|||
&format!("trait `{}`", values.found))
|
||||
}
|
||||
ConstMismatch(ref values) => {
|
||||
write!(f, "expected `{:?}`, found `{:?}`", values.expected, values.found)
|
||||
write!(f, "expected `{}`, found `{}`", values.expected, values.found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::ich::StableHashingContext;
|
|||
use crate::infer::canonical::Canonical;
|
||||
use crate::middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem};
|
||||
use crate::middle::resolve_lifetime::ObjectLifetimeDefault;
|
||||
use crate::mir::Mir;
|
||||
use crate::mir::Body;
|
||||
use crate::mir::interpret::{GlobalId, ErrorHandled};
|
||||
use crate::mir::GeneratorLayout;
|
||||
use crate::session::CrateDisambiguator;
|
||||
|
@ -3002,7 +3002,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
/// Returns the possibly-auto-generated MIR of a `(DefId, Subst)` pair.
|
||||
pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>)
|
||||
-> &'gcx Mir<'gcx>
|
||||
-> &'gcx Body<'gcx>
|
||||
{
|
||||
match instance {
|
||||
ty::InstanceDef::Item(did) => {
|
||||
|
|
|
@ -8,9 +8,7 @@ use crate::hir::def_id::DefId;
|
|||
use crate::ty::subst::{Kind, UnpackedKind, SubstsRef};
|
||||
use crate::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
use crate::ty::error::{ExpectedFound, TypeError};
|
||||
use crate::mir::interpret::{GlobalId, ConstValue, Scalar};
|
||||
use crate::util::common::ErrorReported;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
use crate::mir::interpret::{ConstValue, Scalar, GlobalId};
|
||||
use std::rc::Rc;
|
||||
use std::iter;
|
||||
use rustc_target::spec::abi;
|
||||
|
@ -474,55 +472,19 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
(&ty::Array(a_t, sz_a), &ty::Array(b_t, sz_b)) =>
|
||||
{
|
||||
let t = relation.relate(&a_t, &b_t)?;
|
||||
let to_u64 = |x: ty::Const<'tcx>| -> Result<u64, ErrorReported> {
|
||||
match x.val {
|
||||
// FIXME(const_generics): this doesn't work right now,
|
||||
// because it tries to relate an `Infer` to a `Param`.
|
||||
ConstValue::Unevaluated(def_id, substs) => {
|
||||
// FIXME(eddyb) get the right param_env.
|
||||
let param_env = ty::ParamEnv::empty();
|
||||
if let Some(substs) = tcx.lift_to_global(&substs) {
|
||||
let instance = ty::Instance::resolve(
|
||||
tcx.global_tcx(),
|
||||
param_env,
|
||||
def_id,
|
||||
substs,
|
||||
);
|
||||
if let Some(instance) = instance {
|
||||
let cid = GlobalId {
|
||||
instance,
|
||||
promoted: None,
|
||||
};
|
||||
if let Some(s) = tcx.const_eval(param_env.and(cid))
|
||||
.ok()
|
||||
.map(|c| c.unwrap_usize(tcx)) {
|
||||
return Ok(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
tcx.sess.delay_span_bug(tcx.def_span(def_id),
|
||||
"array length could not be evaluated");
|
||||
Err(ErrorReported)
|
||||
}
|
||||
_ => x.assert_usize(tcx).ok_or_else(|| {
|
||||
tcx.sess.delay_span_bug(DUMMY_SP,
|
||||
"array length could not be evaluated");
|
||||
ErrorReported
|
||||
})
|
||||
}
|
||||
};
|
||||
match (to_u64(*sz_a), to_u64(*sz_b)) {
|
||||
(Ok(sz_a_u64), Ok(sz_b_u64)) => {
|
||||
if sz_a_u64 == sz_b_u64 {
|
||||
Ok(tcx.mk_ty(ty::Array(t, sz_a)))
|
||||
} else {
|
||||
match relation.relate(&sz_a, &sz_b) {
|
||||
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
|
||||
Err(err) => {
|
||||
// Check whether the lengths are both concrete/known values,
|
||||
// but are unequal, for better diagnostics.
|
||||
match (sz_a.assert_usize(tcx), sz_b.assert_usize(tcx)) {
|
||||
(Some(sz_a_val), Some(sz_b_val)) => {
|
||||
Err(TypeError::FixedArraySize(
|
||||
expected_found(relation, &sz_a_u64, &sz_b_u64)))
|
||||
expected_found(relation, &sz_a_val, &sz_b_val)
|
||||
))
|
||||
}
|
||||
_ => return Err(err),
|
||||
}
|
||||
// We reported an error or will ICE, so we can return Error.
|
||||
(Err(ErrorReported), _) | (_, Err(ErrorReported)) => {
|
||||
Ok(tcx.types.err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -598,11 +560,36 @@ where
|
|||
{
|
||||
let tcx = relation.tcx();
|
||||
|
||||
let eagerly_eval = |x: &'tcx ty::Const<'tcx>| {
|
||||
if let ConstValue::Unevaluated(def_id, substs) = x.val {
|
||||
// FIXME(eddyb) get the right param_env.
|
||||
let param_env = ty::ParamEnv::empty();
|
||||
if let Some(substs) = tcx.lift_to_global(&substs) {
|
||||
let instance = ty::Instance::resolve(
|
||||
tcx.global_tcx(),
|
||||
param_env,
|
||||
def_id,
|
||||
substs,
|
||||
);
|
||||
if let Some(instance) = instance {
|
||||
let cid = GlobalId {
|
||||
instance,
|
||||
promoted: None,
|
||||
};
|
||||
if let Ok(ct) = tcx.const_eval(param_env.and(cid)) {
|
||||
return ct.val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
x.val
|
||||
};
|
||||
|
||||
// Currently, the values that can be unified are those that
|
||||
// implement both `PartialEq` and `Eq`, corresponding to
|
||||
// `structural_match` types.
|
||||
// FIXME(const_generics): check for `structural_match` synthetic attribute.
|
||||
match (a.val, b.val) {
|
||||
match (eagerly_eval(a), eagerly_eval(b)) {
|
||||
(ConstValue::Infer(_), _) | (_, ConstValue::Infer(_)) => {
|
||||
// The caller should handle these cases!
|
||||
bug!("var types encountered in super_relate_consts: {:?} {:?}", a, b)
|
||||
|
@ -613,8 +600,13 @@ where
|
|||
(ConstValue::Placeholder(p1), ConstValue::Placeholder(p2)) if p1 == p2 => {
|
||||
Ok(a)
|
||||
}
|
||||
(ConstValue::Scalar(Scalar::Raw { .. }), _) if a == b => {
|
||||
Ok(a)
|
||||
(a_val @ ConstValue::Scalar(Scalar::Raw { .. }), b_val @ _)
|
||||
if a.ty == b.ty && a_val == b_val =>
|
||||
{
|
||||
Ok(tcx.mk_const(ty::Const {
|
||||
val: a_val,
|
||||
ty: a.ty,
|
||||
}))
|
||||
}
|
||||
(ConstValue::ByRef(..), _) => {
|
||||
bug!(
|
||||
|
@ -635,9 +627,7 @@ where
|
|||
}))
|
||||
}
|
||||
|
||||
_ => {
|
||||
Err(TypeError::ConstMismatch(expected_found(relation, &a, &b)))
|
||||
}
|
||||
_ => Err(TypeError::ConstMismatch(expected_found(relation, &a, &b))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ use rustc_data_structures::sync::{RwLock, ReadGuard, MappedReadGuard};
|
|||
/// optimization, but that'd be expensive. And yet we don't just want
|
||||
/// to mutate it in place, because that would spoil the idea that
|
||||
/// queries are these pure functions that produce an immutable value
|
||||
/// (since if you did the query twice, you could observe the
|
||||
/// mutations). So instead we have the query produce a `&'tcx
|
||||
/// Steal<Mir<'tcx>>` (to be very specific). Now we can read from this
|
||||
/// (since if you did the query twice, you could observe the mutations).
|
||||
/// So instead we have the query produce a `&'tcx Steal<mir::Body<'tcx>>`
|
||||
/// (to be very specific). Now we can read from this
|
||||
/// as much as we want (using `borrow()`), but you can also
|
||||
/// `steal()`. Once you steal, any further attempt to read will panic.
|
||||
/// Therefore, we know that -- assuming no ICE -- nobody is observing
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::utils::{DIB, span_start};
|
|||
use crate::llvm;
|
||||
use crate::llvm::debuginfo::{DIScope, DISubprogram};
|
||||
use crate::common::CodegenCx;
|
||||
use rustc::mir::{Mir, SourceScope};
|
||||
use rustc::mir::{Body, SourceScope};
|
||||
|
||||
use libc::c_uint;
|
||||
|
||||
|
@ -20,7 +20,7 @@ use syntax_pos::BytePos;
|
|||
/// If debuginfo is disabled, the returned vector is empty.
|
||||
pub fn create_mir_scopes(
|
||||
cx: &CodegenCx<'ll, '_>,
|
||||
mir: &Mir<'_>,
|
||||
mir: &Body<'_>,
|
||||
debug_context: &FunctionDebugContext<&'ll DISubprogram>,
|
||||
) -> IndexVec<SourceScope, MirDebugScope<&'ll DIScope>> {
|
||||
let null_scope = MirDebugScope {
|
||||
|
@ -55,7 +55,7 @@ pub fn create_mir_scopes(
|
|||
}
|
||||
|
||||
fn make_mir_scope(cx: &CodegenCx<'ll, '_>,
|
||||
mir: &Mir<'_>,
|
||||
mir: &Body<'_>,
|
||||
has_variables: &BitSet<SourceScope>,
|
||||
debug_context: &FunctionDebugContextData<&'ll DISubprogram>,
|
||||
scope: SourceScope,
|
||||
|
|
|
@ -239,7 +239,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
instance: Instance<'tcx>,
|
||||
sig: ty::FnSig<'tcx>,
|
||||
llfn: &'ll Value,
|
||||
mir: &mir::Mir<'_>,
|
||||
mir: &mir::Body<'_>,
|
||||
) -> FunctionDebugContext<&'ll DISubprogram> {
|
||||
if self.sess().opts.debuginfo == DebugInfo::None {
|
||||
return FunctionDebugContext::DebugInfoDisabled;
|
||||
|
@ -523,7 +523,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
|
||||
fn create_mir_scopes(
|
||||
&self,
|
||||
mir: &mir::Mir<'_>,
|
||||
mir: &mir::Body<'_>,
|
||||
debug_context: &mut FunctionDebugContext<&'ll DISubprogram>,
|
||||
) -> IndexVec<mir::SourceScope, MirDebugScope<&'ll DIScope>> {
|
||||
create_scope_map::create_mir_scopes(self, mir, debug_context)
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn non_ssa_locals<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
let mir = fx.mir;
|
||||
let mut analyzer = LocalAnalyzer::new(fx);
|
||||
|
||||
analyzer.visit_mir(mir);
|
||||
analyzer.visit_body(mir);
|
||||
|
||||
for (index, ty) in mir.local_decls.iter().map(|l| l.ty).enumerate() {
|
||||
let ty = fx.monomorphize(&ty);
|
||||
|
@ -272,9 +272,9 @@ impl CleanupKind {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Mir<'tcx>) -> IndexVec<mir::BasicBlock, CleanupKind> {
|
||||
pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Body<'tcx>) -> IndexVec<mir::BasicBlock, CleanupKind> {
|
||||
fn discover_masters<'tcx>(result: &mut IndexVec<mir::BasicBlock, CleanupKind>,
|
||||
mir: &mir::Mir<'tcx>) {
|
||||
mir: &mir::Body<'tcx>) {
|
||||
for (bb, data) in mir.basic_blocks().iter_enumerated() {
|
||||
match data.terminator().kind {
|
||||
TerminatorKind::Goto { .. } |
|
||||
|
@ -304,7 +304,7 @@ pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Mir<'tcx>) -> IndexVec<mir::BasicBlock
|
|||
}
|
||||
|
||||
fn propagate<'tcx>(result: &mut IndexVec<mir::BasicBlock, CleanupKind>,
|
||||
mir: &mir::Mir<'tcx>) {
|
||||
mir: &mir::Body<'tcx>) {
|
||||
let mut funclet_succs = IndexVec::from_elem(None, mir.basic_blocks());
|
||||
|
||||
let mut set_successor = |funclet: mir::BasicBlock, succ| {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
|
||||
use rustc::ty::layout::{TyLayout, HasTyCtxt, FnTypeExt};
|
||||
use rustc::mir::{self, Mir};
|
||||
use rustc::mir::{self, Body};
|
||||
use rustc::session::config::DebugInfo;
|
||||
use rustc_mir::monomorphize::Instance;
|
||||
use rustc_target::abi::call::{FnType, PassMode, IgnoreMode};
|
||||
|
@ -27,7 +27,7 @@ use self::operand::{OperandRef, OperandValue};
|
|||
pub struct FunctionCx<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> {
|
||||
instance: Instance<'tcx>,
|
||||
|
||||
mir: &'a mir::Mir<'tcx>,
|
||||
mir: &'a mir::Body<'tcx>,
|
||||
|
||||
debug_context: FunctionDebugContext<Bx::DIScope>,
|
||||
|
||||
|
@ -196,7 +196,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> LocalRef<'tcx, V> {
|
|||
pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
cx: &'a Bx::CodegenCx,
|
||||
llfn: Bx::Value,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
instance: Instance<'tcx>,
|
||||
sig: ty::FnSig<'tcx>,
|
||||
) {
|
||||
|
@ -360,7 +360,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
}
|
||||
|
||||
fn create_funclets<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
bx: &mut Bx,
|
||||
cleanup_kinds: &IndexVec<mir::BasicBlock, CleanupKind>,
|
||||
block_bxs: &IndexVec<mir::BasicBlock, Bx::BasicBlock>)
|
||||
|
|
|
@ -22,12 +22,12 @@ pub trait DebugInfoMethods<'tcx>: BackendTypes {
|
|||
instance: Instance<'tcx>,
|
||||
sig: ty::FnSig<'tcx>,
|
||||
llfn: Self::Value,
|
||||
mir: &mir::Mir<'_>,
|
||||
mir: &mir::Body<'_>,
|
||||
) -> FunctionDebugContext<Self::DIScope>;
|
||||
|
||||
fn create_mir_scopes(
|
||||
&self,
|
||||
mir: &mir::Mir<'_>,
|
||||
mir: &mir::Body<'_>,
|
||||
debug_context: &mut FunctionDebugContext<Self::DIScope>,
|
||||
) -> IndexVec<mir::SourceScope, MirDebugScope<Self::DIScope>>;
|
||||
fn extend_scope_to_file(
|
||||
|
|
|
@ -629,6 +629,9 @@ impl fmt::Write for SymbolPrinter<'_, '_> {
|
|||
// for ':' and '-'
|
||||
'-' | ':' => self.path.temp_buf.push('.'),
|
||||
|
||||
// Avoid segmentation fault on some platforms, see #60925.
|
||||
'm' if self.path.temp_buf.ends_with(".llv") => self.path.temp_buf.push_str("$6d$"),
|
||||
|
||||
// These are legal symbols
|
||||
'a'..='z' | 'A'..='Z' | '0'..='9' | '_' | '.' | '$' => self.path.temp_buf.push(c),
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use rustc::mir::interpret::AllocDecodingSession;
|
|||
use rustc::session::Session;
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc::ty::codec::TyDecoder;
|
||||
use rustc::mir::Mir;
|
||||
use rustc::mir::Body;
|
||||
use rustc::util::captures::Captures;
|
||||
|
||||
use std::io;
|
||||
|
@ -887,7 +887,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
pub fn maybe_get_optimized_mir(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: DefIndex)
|
||||
-> Option<Mir<'tcx>> {
|
||||
-> Option<Body<'tcx>> {
|
||||
match self.is_proc_macro(id) {
|
||||
true => None,
|
||||
false => self.entry(id).mir.map(|mir| mir.decode((self, tcx))),
|
||||
|
|
|
@ -1026,7 +1026,7 @@ impl EncodeContext<'_, 'tcx> {
|
|||
self.lazy_seq(param_names.iter().map(|ident| ident.name))
|
||||
}
|
||||
|
||||
fn encode_optimized_mir(&mut self, def_id: DefId) -> Option<Lazy<mir::Mir<'tcx>>> {
|
||||
fn encode_optimized_mir(&mut self, def_id: DefId) -> Option<Lazy<mir::Body<'tcx>>> {
|
||||
debug!("EntryBuilder::encode_mir({:?})", def_id);
|
||||
if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id) {
|
||||
let mir = self.tcx.optimized_mir(def_id);
|
||||
|
|
|
@ -222,7 +222,7 @@ pub struct Entry<'tcx> {
|
|||
pub predicates: Option<Lazy<ty::GenericPredicates<'tcx>>>,
|
||||
pub predicates_defined_on: Option<Lazy<ty::GenericPredicates<'tcx>>>,
|
||||
|
||||
pub mir: Option<Lazy<mir::Mir<'tcx>>>,
|
||||
pub mir: Option<Lazy<mir::Body<'tcx>>>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::dataflow::indexes::BorrowIndex;
|
|||
use crate::dataflow::move_paths::MoveData;
|
||||
use rustc::mir::traversal;
|
||||
use rustc::mir::visit::{PlaceContext, Visitor, NonUseContext, MutatingUseContext};
|
||||
use rustc::mir::{self, Location, Mir, Local};
|
||||
use rustc::mir::{self, Location, Body, Local};
|
||||
use rustc::ty::{RegionVid, TyCtxt};
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
|
@ -90,7 +90,7 @@ crate enum LocalsStateAtExit {
|
|||
impl LocalsStateAtExit {
|
||||
fn build(
|
||||
locals_are_invalidated_at_exit: bool,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
move_data: &MoveData<'tcx>
|
||||
) -> Self {
|
||||
struct HasStorageDead(BitSet<Local>);
|
||||
|
@ -107,7 +107,7 @@ impl LocalsStateAtExit {
|
|||
LocalsStateAtExit::AllAreInvalidated
|
||||
} else {
|
||||
let mut has_storage_dead = HasStorageDead(BitSet::new_empty(mir.local_decls.len()));
|
||||
has_storage_dead.visit_mir(mir);
|
||||
has_storage_dead.visit_body(mir);
|
||||
let mut has_storage_dead_or_moved = has_storage_dead.0;
|
||||
for move_out in &move_data.moves {
|
||||
if let Some(index) = move_data.base_local(move_out.path) {
|
||||
|
@ -123,7 +123,7 @@ impl LocalsStateAtExit {
|
|||
impl<'tcx> BorrowSet<'tcx> {
|
||||
pub fn build(
|
||||
tcx: TyCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
locals_are_invalidated_at_exit: bool,
|
||||
move_data: &MoveData<'tcx>
|
||||
) -> Self {
|
||||
|
@ -163,7 +163,7 @@ impl<'tcx> BorrowSet<'tcx> {
|
|||
|
||||
struct GatherBorrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
idx_vec: IndexVec<BorrowIndex, BorrowData<'tcx>>,
|
||||
location_map: FxHashMap<Location, BorrowIndex>,
|
||||
activation_map: FxHashMap<Location, Vec<BorrowIndex>>,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc::mir::{BasicBlock, Location, Mir};
|
||||
use rustc::mir::{BasicBlock, Location, Body};
|
||||
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
||||
|
||||
/// Maps between a MIR Location, which identifies a particular
|
||||
|
@ -30,7 +30,7 @@ crate enum RichLocation {
|
|||
}
|
||||
|
||||
impl LocationTable {
|
||||
crate fn new(mir: &Mir<'_>) -> Self {
|
||||
crate fn new(mir: &Body<'_>) -> Self {
|
||||
let mut num_points = 0;
|
||||
let statements_before_block = mir.basic_blocks()
|
||||
.iter()
|
||||
|
|
|
@ -10,7 +10,9 @@ use rustc::lint::builtin::{MUTABLE_BORROW_RESERVATION_CONFLICT};
|
|||
use rustc::middle::borrowck::SignalledError;
|
||||
use rustc::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind};
|
||||
use rustc::mir::{
|
||||
ClearCrossCrate, Local, Location, Mir, Mutability, Operand, Place, PlaceBase, Static, StaticKind
|
||||
ClearCrossCrate, Local, Location, Body, Mutability, Operand, Place, PlaceBase, Static,
|
||||
|
||||
StaticKind
|
||||
};
|
||||
use rustc::mir::{Field, Projection, ProjectionElem, Rvalue, Statement, StatementKind};
|
||||
use rustc::mir::{Terminator, TerminatorKind};
|
||||
|
@ -118,7 +120,7 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> BorrowC
|
|||
}
|
||||
|
||||
let opt_closure_req = tcx.infer_ctxt().enter(|infcx| {
|
||||
let input_mir: &Mir<'_> = &input_mir.borrow();
|
||||
let input_mir: &Body<'_> = &input_mir.borrow();
|
||||
do_mir_borrowck(&infcx, input_mir, def_id)
|
||||
});
|
||||
debug!("mir_borrowck done");
|
||||
|
@ -128,7 +130,7 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> BorrowC
|
|||
|
||||
fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
||||
infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
||||
input_mir: &Mir<'gcx>,
|
||||
input_mir: &Body<'gcx>,
|
||||
def_id: DefId,
|
||||
) -> BorrowCheckResult<'gcx> {
|
||||
debug!("do_mir_borrowck(def_id = {:?})", def_id);
|
||||
|
@ -175,7 +177,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||
// requires first making our own copy of the MIR. This copy will
|
||||
// be modified (in place) to contain non-lexical lifetimes. It
|
||||
// will have a lifetime tied to the inference context.
|
||||
let mut mir: Mir<'tcx> = input_mir.clone();
|
||||
let mut mir: Body<'tcx> = input_mir.clone();
|
||||
let free_regions = nll::replace_regions_in_mir(infcx, def_id, param_env, &mut mir);
|
||||
let mir = &mir; // no further changes
|
||||
let location_table = &LocationTable::new(mir);
|
||||
|
@ -451,7 +453,7 @@ fn downgrade_if_error(diag: &mut Diagnostic) {
|
|||
|
||||
pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>,
|
||||
mir: &'cx Mir<'tcx>,
|
||||
mir: &'cx Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
move_data: &'cx MoveData<'tcx>,
|
||||
|
||||
|
@ -537,7 +539,7 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
|
|||
impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
||||
type FlowState = Flows<'cx, 'gcx, 'tcx>;
|
||||
|
||||
fn mir(&self) -> &'cx Mir<'tcx> {
|
||||
fn mir(&self) -> &'cx Body<'tcx> {
|
||||
self.mir
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustc::hir;
|
||||
use rustc::hir::Node;
|
||||
use rustc::mir::{self, BindingForm, Constant, ClearCrossCrate, Local, Location, Mir};
|
||||
use rustc::mir::{self, BindingForm, Constant, ClearCrossCrate, Local, Location, Body};
|
||||
use rustc::mir::{
|
||||
Mutability, Operand, Place, PlaceBase, Projection, ProjectionElem, Static, StaticKind,
|
||||
};
|
||||
|
@ -562,7 +562,7 @@ fn suggest_ampmut_self<'cx, 'gcx, 'tcx>(
|
|||
// by trying (3.), then (2.) and finally falling back on (1.).
|
||||
fn suggest_ampmut<'cx, 'gcx, 'tcx>(
|
||||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
local: Local,
|
||||
local_decl: &mir::LocalDecl<'tcx>,
|
||||
opt_ty_info: Option<Span>,
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::borrow_check::nll::region_infer::values::LivenessValues;
|
|||
use rustc::infer::InferCtxt;
|
||||
use rustc::mir::visit::TyContext;
|
||||
use rustc::mir::visit::Visitor;
|
||||
use rustc::mir::{BasicBlock, BasicBlockData, Location, Mir, Place, PlaceBase, Rvalue};
|
||||
use rustc::mir::{BasicBlock, BasicBlockData, Location, Body, Place, PlaceBase, Rvalue};
|
||||
use rustc::mir::{SourceInfo, Statement, Terminator};
|
||||
use rustc::mir::UserTypeProjection;
|
||||
use rustc::ty::fold::TypeFoldable;
|
||||
|
@ -18,7 +18,7 @@ pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>(
|
|||
liveness_constraints: &mut LivenessValues<RegionVid>,
|
||||
all_facts: &mut Option<AllFacts>,
|
||||
location_table: &LocationTable,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
borrow_set: &BorrowSet<'tcx>,
|
||||
) {
|
||||
let mut cg = ConstraintGeneration {
|
||||
|
|
|
@ -5,12 +5,12 @@ use crate::borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
|
|||
use crate::borrow_check::nll::ToRegionVid;
|
||||
use crate::util::liveness::{self, DefUse};
|
||||
use rustc::mir::visit::{MirVisitable, PlaceContext, Visitor};
|
||||
use rustc::mir::{Local, Location, Mir};
|
||||
use rustc::mir::{Local, Location, Body};
|
||||
use rustc::ty::{RegionVid, TyCtxt};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
|
||||
crate fn find<'tcx>(
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
regioncx: &Rc<RegionInferenceContext<'tcx>>,
|
||||
tcx: TyCtxt<'_, '_, 'tcx>,
|
||||
region_vid: RegionVid,
|
||||
|
@ -28,7 +28,7 @@ crate fn find<'tcx>(
|
|||
}
|
||||
|
||||
struct UseFinder<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
|
||||
mir: &'cx Mir<'tcx>,
|
||||
mir: &'cx Body<'tcx>,
|
||||
regioncx: &'cx Rc<RegionInferenceContext<'tcx>>,
|
||||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
region_vid: RegionVid,
|
||||
|
@ -100,7 +100,7 @@ impl<'cx, 'gcx, 'tcx> UseFinder<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
struct DefUseVisitor<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
|
||||
mir: &'cx Mir<'tcx>,
|
||||
mir: &'cx Body<'tcx>,
|
||||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
region_vid: RegionVid,
|
||||
def_use_result: Option<DefUseResult>,
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::borrow_check::nll::region_infer::{Cause, RegionName};
|
|||
use crate::borrow_check::nll::ConstraintDescription;
|
||||
use crate::borrow_check::{MirBorrowckCtxt, WriteKind};
|
||||
use rustc::mir::{
|
||||
CastKind, ConstraintCategory, FakeReadCause, Local, Location, Mir, Operand, Place, PlaceBase,
|
||||
CastKind, ConstraintCategory, FakeReadCause, Local, Location, Body, Operand, Place, PlaceBase,
|
||||
Projection, ProjectionElem, Rvalue, Statement, StatementKind, TerminatorKind,
|
||||
};
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
|
@ -54,7 +54,7 @@ impl BorrowExplanation {
|
|||
pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
borrow_desc: &str,
|
||||
borrow_span: Option<Span>,
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::borrow_check::path_utils::*;
|
|||
use crate::dataflow::indexes::BorrowIndex;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::mir::visit::Visitor;
|
||||
use rustc::mir::{BasicBlock, Location, Mir, Place, PlaceBase, Rvalue};
|
||||
use rustc::mir::{BasicBlock, Location, Body, Place, PlaceBase, Rvalue};
|
||||
use rustc::mir::{Statement, StatementKind};
|
||||
use rustc::mir::TerminatorKind;
|
||||
use rustc::mir::{Operand, BorrowKind};
|
||||
|
@ -21,7 +21,7 @@ pub(super) fn generate_invalidates<'cx, 'gcx, 'tcx>(
|
|||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
all_facts: &mut Option<AllFacts>,
|
||||
location_table: &LocationTable,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
borrow_set: &BorrowSet<'tcx>,
|
||||
) {
|
||||
if all_facts.is_none() {
|
||||
|
@ -39,7 +39,7 @@ pub(super) fn generate_invalidates<'cx, 'gcx, 'tcx>(
|
|||
mir,
|
||||
dominators,
|
||||
};
|
||||
ig.visit_mir(mir);
|
||||
ig.visit_body(mir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ struct InvalidationGenerator<'cx, 'tcx: 'cx, 'gcx: 'tcx> {
|
|||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
all_facts: &'cx mut AllFacts,
|
||||
location_table: &'cx LocationTable,
|
||||
mir: &'cx Mir<'tcx>,
|
||||
mir: &'cx Body<'tcx>,
|
||||
dominators: Dominators<BasicBlock>,
|
||||
borrow_set: &'cx BorrowSet<'tcx>,
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::transform::MirSource;
|
|||
use crate::borrow_check::Upvar;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::infer::InferCtxt;
|
||||
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir};
|
||||
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Body};
|
||||
use rustc::ty::{self, RegionKind, RegionVid};
|
||||
use rustc_errors::Diagnostic;
|
||||
use std::fmt::Debug;
|
||||
|
@ -50,7 +50,7 @@ pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>(
|
|||
infcx: &InferCtxt<'cx, 'gcx, 'tcx>,
|
||||
def_id: DefId,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
mir: &mut Mir<'tcx>,
|
||||
mir: &mut Body<'tcx>,
|
||||
) -> UniversalRegions<'tcx> {
|
||||
debug!("replace_regions_in_mir(def_id={:?})", def_id);
|
||||
|
||||
|
@ -73,7 +73,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
|
|||
infcx: &InferCtxt<'cx, 'gcx, 'tcx>,
|
||||
def_id: DefId,
|
||||
universal_regions: UniversalRegions<'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
location_table: &LocationTable,
|
||||
param_env: ty::ParamEnv<'gcx>,
|
||||
|
@ -213,7 +213,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
|
|||
fn dump_mir_results<'a, 'gcx, 'tcx>(
|
||||
infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
||||
source: MirSource<'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
regioncx: &RegionInferenceContext<'_>,
|
||||
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
|
||||
) {
|
||||
|
@ -273,7 +273,7 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
|
|||
|
||||
fn dump_annotation<'a, 'gcx, 'tcx>(
|
||||
infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
regioncx: &RegionInferenceContext<'tcx>,
|
||||
closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
|
||||
|
|
|
@ -9,7 +9,7 @@ use rustc::hir::def_id::DefId;
|
|||
use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use rustc::infer::InferCtxt;
|
||||
use rustc::infer::NLLRegionVariableOrigin;
|
||||
use rustc::mir::{ConstraintCategory, Location, Mir};
|
||||
use rustc::mir::{ConstraintCategory, Location, Body};
|
||||
use rustc::ty::{self, RegionVid};
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
use rustc_errors::{Diagnostic, DiagnosticBuilder};
|
||||
|
@ -62,7 +62,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
/// path to blame.
|
||||
fn best_blame_constraint(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
from_region: RegionVid,
|
||||
target_test: impl Fn(RegionVid) -> bool,
|
||||
) -> (ConstraintCategory, bool, Span) {
|
||||
|
@ -237,7 +237,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
/// Here we would be invoked with `fr = 'a` and `outlived_fr = `'b`.
|
||||
pub(super) fn report_error(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir_def_id: DefId,
|
||||
|
@ -357,7 +357,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
/// ```
|
||||
fn report_fnmut_error(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir_def_id: DefId,
|
||||
|
@ -422,7 +422,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
/// ```
|
||||
fn report_escaping_data_error(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir_def_id: DefId,
|
||||
|
@ -514,7 +514,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
/// ```
|
||||
fn report_general_error(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir_def_id: DefId,
|
||||
|
@ -667,7 +667,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
|
||||
crate fn free_region_constraint_info(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
mir_def_id: DefId,
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
|
@ -724,7 +724,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
// Finds a good span to blame for the fact that `fr1` outlives `fr2`.
|
||||
crate fn find_outlives_blame_span(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
fr1: RegionVid,
|
||||
fr2: RegionVid,
|
||||
) -> (ConstraintCategory, Span) {
|
||||
|
@ -735,7 +735,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
|
||||
fn retrieve_closure_constraint_info(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
constraint: &OutlivesConstraint,
|
||||
) -> (ConstraintCategory, bool, Span) {
|
||||
let loc = match constraint.locations {
|
||||
|
|
|
@ -7,7 +7,7 @@ use rustc::hir;
|
|||
use rustc::hir::def::{Res, DefKind};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::infer::InferCtxt;
|
||||
use rustc::mir::Mir;
|
||||
use rustc::mir::Body;
|
||||
use rustc::ty::subst::{SubstsRef, UnpackedKind};
|
||||
use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt};
|
||||
use rustc::ty::print::RegionHighlightMode;
|
||||
|
@ -152,7 +152,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
crate fn give_region_a_name(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
mir_def_id: DefId,
|
||||
fr: RegionVid,
|
||||
|
@ -332,7 +332,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn give_name_if_anonymous_region_appears_in_arguments(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
fr: RegionVid,
|
||||
counter: &mut usize,
|
||||
|
@ -360,7 +360,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn give_name_if_we_can_match_hir_ty_from_argument(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
needle_fr: RegionVid,
|
||||
argument_ty: Ty<'tcx>,
|
||||
|
@ -406,7 +406,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn give_name_if_we_cannot_match_hir_ty(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
needle_fr: RegionVid,
|
||||
argument_ty: Ty<'tcx>,
|
||||
counter: &mut usize,
|
||||
|
@ -676,7 +676,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn give_name_if_anonymous_region_appears_in_output(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
fr: RegionVid,
|
||||
counter: &mut usize,
|
||||
|
@ -736,7 +736,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn give_name_if_anonymous_region_appears_in_yield_ty(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
fr: RegionVid,
|
||||
counter: &mut usize,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::borrow_check::nll::region_infer::RegionInferenceContext;
|
||||
use crate::borrow_check::nll::ToRegionVid;
|
||||
use crate::borrow_check::Upvar;
|
||||
use rustc::mir::{Local, Mir};
|
||||
use rustc::mir::{Local, Body};
|
||||
use rustc::ty::{RegionVid, TyCtxt};
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use syntax::source_map::Span;
|
||||
|
@ -11,7 +11,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
crate fn get_var_name_and_span_for_region(
|
||||
&self,
|
||||
tcx: TyCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
fr: RegionVid,
|
||||
) -> Option<(Option<Symbol>, Span)> {
|
||||
|
@ -120,7 +120,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
/// declared.
|
||||
crate fn get_argument_name_and_span_for_region(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
argument_index: usize,
|
||||
) -> (Option<Symbol>, Span) {
|
||||
let implicit_inputs = self.universal_regions.defining_ty.implicit_inputs();
|
||||
|
|
|
@ -13,7 +13,7 @@ use rustc::infer::region_constraints::{GenericKind, VarInfos, VerifyBound};
|
|||
use rustc::infer::{InferCtxt, NLLRegionVariableOrigin, RegionVariableOrigin};
|
||||
use rustc::mir::{
|
||||
ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureRegionRequirements,
|
||||
ConstraintCategory, Local, Location, Mir,
|
||||
ConstraintCategory, Local, Location, Body,
|
||||
};
|
||||
use rustc::ty::{self, subst::SubstsRef, RegionVid, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc::util::common::{self, ErrorReported};
|
||||
|
@ -185,7 +185,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
universal_regions: Rc<UniversalRegions<'tcx>>,
|
||||
placeholder_indices: Rc<PlaceholderIndices>,
|
||||
universal_region_relations: Rc<UniversalRegionRelations<'tcx>>,
|
||||
_mir: &Mir<'tcx>,
|
||||
_mir: &Body<'tcx>,
|
||||
outlives_constraints: ConstraintSet,
|
||||
closure_bounds_mapping: FxHashMap<
|
||||
Location,
|
||||
|
@ -400,7 +400,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
pub(super) fn solve<'gcx>(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
mir_def_id: DefId,
|
||||
errors_buffer: &mut Vec<Diagnostic>,
|
||||
|
@ -416,7 +416,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn solve_inner<'gcx>(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
mir_def_id: DefId,
|
||||
errors_buffer: &mut Vec<Diagnostic>,
|
||||
|
@ -468,7 +468,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
/// for each region variable until all the constraints are
|
||||
/// satisfied. Note that some values may grow **too** large to be
|
||||
/// feasible, but we check this later.
|
||||
fn propagate_constraints(&mut self, _mir: &Mir<'tcx>) {
|
||||
fn propagate_constraints(&mut self, _mir: &Body<'tcx>) {
|
||||
debug!("propagate_constraints()");
|
||||
|
||||
debug!("propagate_constraints: constraints={:#?}", {
|
||||
|
@ -581,7 +581,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn check_type_tests<'gcx>(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
|
||||
errors_buffer: &mut Vec<Diagnostic>,
|
||||
|
@ -725,7 +725,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn try_promote_type_test<'gcx>(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
type_test: &TypeTest<'tcx>,
|
||||
propagated_outlives_requirements: &mut Vec<ClosureOutlivesRequirement<'gcx>>,
|
||||
) -> bool {
|
||||
|
@ -944,7 +944,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn eval_verify_bound(
|
||||
&self,
|
||||
tcx: TyCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
generic_ty: Ty<'tcx>,
|
||||
lower_bound: RegionVid,
|
||||
verify_bound: &VerifyBound<'tcx>,
|
||||
|
@ -977,7 +977,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn eval_if_eq(
|
||||
&self,
|
||||
tcx: TyCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
generic_ty: Ty<'tcx>,
|
||||
lower_bound: RegionVid,
|
||||
test_ty: Ty<'tcx>,
|
||||
|
@ -1037,7 +1037,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
// Evaluate whether `sup_region: sub_region @ point`.
|
||||
fn eval_outlives(
|
||||
&self,
|
||||
_mir: &Mir<'tcx>,
|
||||
_mir: &Body<'tcx>,
|
||||
sup_region: RegionVid,
|
||||
sub_region: RegionVid,
|
||||
) -> bool {
|
||||
|
@ -1105,7 +1105,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn check_universal_regions<'gcx>(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
mir_def_id: DefId,
|
||||
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
|
||||
|
@ -1150,7 +1150,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn check_universal_region<'gcx>(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
mir_def_id: DefId,
|
||||
longer_fr: RegionVid,
|
||||
|
@ -1216,7 +1216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
longer_fr: RegionVid,
|
||||
shorter_fr: RegionVid,
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
upvars: &[Upvar],
|
||||
mir_def_id: DefId,
|
||||
propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
|
||||
|
@ -1282,7 +1282,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
fn check_bound_universal_region<'gcx>(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
_mir_def_id: DefId,
|
||||
longer_fr: RegionVid,
|
||||
placeholder: ty::PlaceholderRegion,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc::mir::{BasicBlock, Location, Mir};
|
||||
use rustc::mir::{BasicBlock, Location, Body};
|
||||
use rustc::ty::{self, RegionVid};
|
||||
use rustc_data_structures::bit_set::{HybridBitSet, SparseBitMatrix};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
|
@ -20,7 +20,7 @@ crate struct RegionValueElements {
|
|||
}
|
||||
|
||||
impl RegionValueElements {
|
||||
crate fn new(mir: &Mir<'_>) -> Self {
|
||||
crate fn new(mir: &Body<'_>) -> Self {
|
||||
let mut num_points = 0;
|
||||
let statements_before_block: IndexVec<BasicBlock, usize> = mir.basic_blocks()
|
||||
.iter()
|
||||
|
@ -92,7 +92,7 @@ impl RegionValueElements {
|
|||
/// Pushes all predecessors of `index` onto `stack`.
|
||||
crate fn push_predecessors(
|
||||
&self,
|
||||
mir: &Mir<'_>,
|
||||
mir: &Body<'_>,
|
||||
index: PointIndex,
|
||||
stack: &mut Vec<PointIndex>,
|
||||
) {
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use rustc::ty::subst::SubstsRef;
|
||||
use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable};
|
||||
use rustc::mir::{Location, Mir};
|
||||
use rustc::mir::{Location, Body};
|
||||
use rustc::mir::visit::{MutVisitor, TyContext};
|
||||
use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
|
||||
|
||||
/// Replaces all free regions appearing in the MIR with fresh
|
||||
/// inference variables, returning the number of variables created.
|
||||
pub fn renumber_mir<'tcx>(infcx: &InferCtxt<'_, '_, 'tcx>, mir: &mut Mir<'tcx>) {
|
||||
pub fn renumber_mir<'tcx>(infcx: &InferCtxt<'_, '_, 'tcx>, mir: &mut Body<'tcx>) {
|
||||
debug!("renumber_mir()");
|
||||
debug!("renumber_mir: mir.arg_count={:?}", mir.arg_count);
|
||||
|
||||
let mut visitor = NLLVisitor { infcx };
|
||||
visitor.visit_mir(mir);
|
||||
visitor.visit_body(mir);
|
||||
}
|
||||
|
||||
/// Replaces all regions appearing in `value` with fresh inference
|
||||
|
@ -47,12 +47,12 @@ impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
|
||||
fn visit_mir(&mut self, mir: &mut Mir<'tcx>) {
|
||||
fn visit_body(&mut self, mir: &mut Body<'tcx>) {
|
||||
for promoted in mir.promoted.iter_mut() {
|
||||
self.visit_mir(promoted);
|
||||
self.visit_body(promoted);
|
||||
}
|
||||
|
||||
self.super_mir(mir);
|
||||
self.super_body(mir);
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
|
||||
|
|
|
@ -20,7 +20,7 @@ use super::{Locations, TypeChecker};
|
|||
impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
pub(super) fn equate_inputs_and_outputs(
|
||||
&mut self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
universal_regions: &UniversalRegions<'tcx>,
|
||||
normalized_inputs_and_output: &[Ty<'tcx>],
|
||||
) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements};
|
||||
use crate::util::liveness::{categorize, DefUse};
|
||||
use rustc::mir::visit::{PlaceContext, Visitor};
|
||||
use rustc::mir::{Local, Location, Mir};
|
||||
use rustc::mir::{Local, Location, Body};
|
||||
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
||||
use rustc_data_structures::vec_linked_list as vll;
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl LocalUseMap {
|
|||
crate fn build(
|
||||
live_locals: &Vec<Local>,
|
||||
elements: &RegionValueElements,
|
||||
mir: &Mir<'_>,
|
||||
mir: &Body<'_>,
|
||||
) -> Self {
|
||||
let nones = IndexVec::from_elem_n(None, mir.local_decls.len());
|
||||
let mut local_use_map = LocalUseMap {
|
||||
|
@ -81,7 +81,7 @@ impl LocalUseMap {
|
|||
elements,
|
||||
locals_with_use_data,
|
||||
}
|
||||
.visit_mir(mir);
|
||||
.visit_body(mir);
|
||||
|
||||
local_use_map
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::borrow_check::nll::ToRegionVid;
|
|||
use crate::dataflow::move_paths::MoveData;
|
||||
use crate::dataflow::FlowAtLocation;
|
||||
use crate::dataflow::MaybeInitializedPlaces;
|
||||
use rustc::mir::{Local, Mir};
|
||||
use rustc::mir::{Local, Body};
|
||||
use rustc::ty::{RegionVid, TyCtxt};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use std::rc::Rc;
|
||||
|
@ -27,7 +27,7 @@ mod trace;
|
|||
/// performed before
|
||||
pub(super) fn generate<'gcx, 'tcx>(
|
||||
typeck: &mut TypeChecker<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
elements: &Rc<RegionValueElements>,
|
||||
flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'_, 'gcx, 'tcx>>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
|
@ -77,7 +77,7 @@ pub(super) fn generate<'gcx, 'tcx>(
|
|||
fn compute_live_locals(
|
||||
tcx: TyCtxt<'_, '_, 'tcx>,
|
||||
free_regions: &FxHashSet<RegionVid>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
) -> Vec<Local> {
|
||||
let live_locals: Vec<Local> = mir
|
||||
.local_decls
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::dataflow::indexes::MovePathIndex;
|
|||
use crate::dataflow::move_paths::MoveData;
|
||||
use crate::dataflow::{FlowAtLocation, FlowsAtLocation, MaybeInitializedPlaces};
|
||||
use rustc::infer::canonical::QueryRegionConstraint;
|
||||
use rustc::mir::{BasicBlock, ConstraintCategory, Local, Location, Mir};
|
||||
use rustc::mir::{BasicBlock, ConstraintCategory, Local, Location, Body};
|
||||
use rustc::traits::query::dropck_outlives::DropckOutlivesResult;
|
||||
use rustc::traits::query::type_op::outlives::DropckOutlives;
|
||||
use rustc::traits::query::type_op::TypeOp;
|
||||
|
@ -32,7 +32,7 @@ use std::rc::Rc;
|
|||
/// this respects `#[may_dangle]` annotations).
|
||||
pub(super) fn trace(
|
||||
typeck: &mut TypeChecker<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
elements: &Rc<RegionValueElements>,
|
||||
flow_inits: &mut FlowAtLocation<'tcx, MaybeInitializedPlaces<'_, 'gcx, 'tcx>>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
|
@ -72,7 +72,7 @@ where
|
|||
elements: &'me RegionValueElements,
|
||||
|
||||
/// MIR we are analyzing.
|
||||
mir: &'me Mir<'tcx>,
|
||||
mir: &'me Body<'tcx>,
|
||||
|
||||
/// Mapping to/from the various indices used for initialization tracking.
|
||||
move_data: &'me MoveData<'tcx>,
|
||||
|
|
|
@ -112,7 +112,7 @@ mod relate_tys;
|
|||
pub(crate) fn type_check<'gcx, 'tcx>(
|
||||
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
||||
param_env: ty::ParamEnv<'gcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
universal_regions: &Rc<UniversalRegions<'tcx>>,
|
||||
location_table: &LocationTable,
|
||||
|
@ -179,7 +179,7 @@ fn type_check_internal<'a, 'gcx, 'tcx, R>(
|
|||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
mir_def_id: DefId,
|
||||
param_env: ty::ParamEnv<'gcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
|
||||
implicit_region_bound: ty::Region<'tcx>,
|
||||
borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>,
|
||||
|
@ -198,7 +198,7 @@ fn type_check_internal<'a, 'gcx, 'tcx, R>(
|
|||
);
|
||||
let errors_reported = {
|
||||
let mut verifier = TypeVerifier::new(&mut checker, mir);
|
||||
verifier.visit_mir(mir);
|
||||
verifier.visit_body(mir);
|
||||
verifier.errors_reported
|
||||
};
|
||||
|
||||
|
@ -253,7 +253,7 @@ enum FieldAccessError {
|
|||
/// is a problem.
|
||||
struct TypeVerifier<'a, 'b: 'a, 'gcx: 'tcx, 'tcx: 'b> {
|
||||
cx: &'a mut TypeChecker<'b, 'gcx, 'tcx>,
|
||||
mir: &'b Mir<'tcx>,
|
||||
mir: &'b Body<'tcx>,
|
||||
last_span: Span,
|
||||
mir_def_id: DefId,
|
||||
errors_reported: bool,
|
||||
|
@ -368,7 +368,7 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_mir(&mut self, mir: &Mir<'tcx>) {
|
||||
fn visit_body(&mut self, mir: &Body<'tcx>) {
|
||||
self.sanitize_type(&"return type", mir.return_ty());
|
||||
for local_decl in &mir.local_decls {
|
||||
self.sanitize_type(local_decl, local_decl.ty);
|
||||
|
@ -376,12 +376,12 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
if self.errors_reported {
|
||||
return;
|
||||
}
|
||||
self.super_mir(mir);
|
||||
self.super_body(mir);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
||||
fn new(cx: &'a mut TypeChecker<'b, 'gcx, 'tcx>, mir: &'b Mir<'tcx>) -> Self {
|
||||
fn new(cx: &'a mut TypeChecker<'b, 'gcx, 'tcx>, mir: &'b Body<'tcx>) -> Self {
|
||||
TypeVerifier {
|
||||
mir,
|
||||
mir_def_id: cx.mir_def_id,
|
||||
|
@ -538,7 +538,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
fn sanitize_promoted(&mut self, promoted_mir: &'b Mir<'tcx>, location: Location) {
|
||||
fn sanitize_promoted(&mut self, promoted_mir: &'b Body<'tcx>, location: Location) {
|
||||
// Determine the constraints from the promoted MIR by running the type
|
||||
// checker on the promoted MIR, then transfer the constraints back to
|
||||
// the main MIR, changing the locations to the provided location.
|
||||
|
@ -562,7 +562,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
&mut closure_bounds
|
||||
);
|
||||
|
||||
self.visit_mir(promoted_mir);
|
||||
self.visit_body(promoted_mir);
|
||||
|
||||
if !self.errors_reported {
|
||||
// if verifier failed, don't do further checks to avoid ICEs
|
||||
|
@ -969,7 +969,7 @@ impl Locations {
|
|||
}
|
||||
|
||||
/// Gets a span representing the location.
|
||||
pub fn span(&self, mir: &Mir<'_>) -> Span {
|
||||
pub fn span(&self, mir: &Body<'_>) -> Span {
|
||||
match self {
|
||||
Locations::All(span) => *span,
|
||||
Locations::Single(l) => mir.source_info(*l).span,
|
||||
|
@ -980,7 +980,7 @@ impl Locations {
|
|||
impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
fn new(
|
||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mir_def_id: DefId,
|
||||
param_env: ty::ParamEnv<'gcx>,
|
||||
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
|
||||
|
@ -1263,7 +1263,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
debug!(
|
||||
"eq_opaque_type_and_type: concrete_ty={:?}={:?} opaque_defn_ty={:?}",
|
||||
opaque_decl.concrete_ty,
|
||||
infcx.resolve_type_vars_if_possible(&opaque_decl.concrete_ty),
|
||||
infcx.resolve_vars_if_possible(&opaque_decl.concrete_ty),
|
||||
opaque_defn_ty
|
||||
);
|
||||
obligations.add(infcx
|
||||
|
@ -1317,7 +1317,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
self.infcx.tcx
|
||||
}
|
||||
|
||||
fn check_stmt(&mut self, mir: &Mir<'tcx>, stmt: &Statement<'tcx>, location: Location) {
|
||||
fn check_stmt(&mut self, mir: &Body<'tcx>, stmt: &Statement<'tcx>, location: Location) {
|
||||
debug!("check_stmt: {:?}", stmt);
|
||||
let tcx = self.tcx();
|
||||
match stmt.kind {
|
||||
|
@ -1456,7 +1456,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn check_terminator(
|
||||
&mut self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
term: &Terminator<'tcx>,
|
||||
term_location: Location,
|
||||
) {
|
||||
|
@ -1618,7 +1618,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn check_call_dest(
|
||||
&mut self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
term: &Terminator<'tcx>,
|
||||
sig: &ty::FnSig<'tcx>,
|
||||
destination: &Option<(Place<'tcx>, BasicBlock)>,
|
||||
|
@ -1687,7 +1687,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn check_call_inputs(
|
||||
&mut self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
term: &Terminator<'tcx>,
|
||||
sig: &ty::FnSig<'tcx>,
|
||||
args: &[Operand<'tcx>],
|
||||
|
@ -1728,7 +1728,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_iscleanup(&mut self, mir: &Mir<'tcx>, block_data: &BasicBlockData<'tcx>) {
|
||||
fn check_iscleanup(&mut self, mir: &Body<'tcx>, block_data: &BasicBlockData<'tcx>) {
|
||||
let is_cleanup = block_data.is_cleanup;
|
||||
self.last_span = block_data.terminator().source_info.span;
|
||||
match block_data.terminator().kind {
|
||||
|
@ -1820,7 +1820,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn assert_iscleanup(
|
||||
&mut self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
ctxt: &dyn fmt::Debug,
|
||||
bb: BasicBlock,
|
||||
iscleanuppad: bool,
|
||||
|
@ -1836,7 +1836,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_local(&mut self, mir: &Mir<'tcx>, local: Local, local_decl: &LocalDecl<'tcx>) {
|
||||
fn check_local(&mut self, mir: &Body<'tcx>, local: Local, local_decl: &LocalDecl<'tcx>) {
|
||||
match mir.local_kind(local) {
|
||||
LocalKind::ReturnPointer | LocalKind::Arg => {
|
||||
// return values of normal functions are required to be
|
||||
|
@ -1938,7 +1938,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_rvalue(&mut self, mir: &Mir<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) {
|
||||
fn check_rvalue(&mut self, mir: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) {
|
||||
let tcx = self.tcx();
|
||||
|
||||
match rvalue {
|
||||
|
@ -2274,7 +2274,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn check_aggregate_rvalue(
|
||||
&mut self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
rvalue: &Rvalue<'tcx>,
|
||||
aggregate_kind: &AggregateKind<'tcx>,
|
||||
operands: &[Operand<'tcx>],
|
||||
|
@ -2332,7 +2332,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
/// - `borrowed_place`: the place `P` being borrowed
|
||||
fn add_reborrow_constraint(
|
||||
&mut self,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
location: Location,
|
||||
borrow_region: ty::Region<'tcx>,
|
||||
borrowed_place: &Place<'tcx>,
|
||||
|
@ -2621,7 +2621,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
fn typeck_mir(&mut self, mir: &Mir<'tcx>) {
|
||||
fn typeck_mir(&mut self, mir: &Body<'tcx>) {
|
||||
self.last_span = mir.span;
|
||||
debug!("run_on_mir: {:?}", mir.span);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::borrow_check::borrow_set::{BorrowSet, BorrowData, TwoPhaseActivation}
|
|||
use crate::borrow_check::places_conflict;
|
||||
use crate::borrow_check::AccessDepth;
|
||||
use crate::dataflow::indexes::BorrowIndex;
|
||||
use rustc::mir::{BasicBlock, Location, Mir, Place, PlaceBase};
|
||||
use rustc::mir::{BasicBlock, Location, Body, Place, PlaceBase};
|
||||
use rustc::mir::{ProjectionElem, BorrowKind};
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_data_structures::graph::dominators::Dominators;
|
||||
|
@ -25,7 +25,7 @@ pub(super) enum Control {
|
|||
pub(super) fn each_borrow_involving_path<'a, 'tcx, 'gcx: 'tcx, F, I, S> (
|
||||
s: &mut S,
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
_location: Location,
|
||||
access_place: (AccessDepth, &Place<'tcx>),
|
||||
borrow_set: &BorrowSet<'tcx>,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustc::hir;
|
||||
use rustc::mir::ProjectionElem;
|
||||
use rustc::mir::{Mir, Place, PlaceBase, Mutability, Static, StaticKind};
|
||||
use rustc::mir::{Body, Place, PlaceBase, Mutability, Static, StaticKind};
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use crate::borrow_check::borrow_set::LocalsStateAtExit;
|
||||
|
||||
|
@ -13,7 +13,7 @@ crate trait PlaceExt<'tcx> {
|
|||
fn ignore_borrow(
|
||||
&self,
|
||||
tcx: TyCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
locals_state_at_exit: &LocalsStateAtExit,
|
||||
) -> bool;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {
|
|||
fn ignore_borrow(
|
||||
&self,
|
||||
tcx: TyCtxt<'_, '_, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
locals_state_at_exit: &LocalsStateAtExit,
|
||||
) -> bool {
|
||||
self.iterate(|place_base, place_projection| {
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::borrow_check::Overlap;
|
|||
use crate::borrow_check::{Deep, Shallow, AccessDepth};
|
||||
use rustc::hir;
|
||||
use rustc::mir::{
|
||||
BorrowKind, Mir, Place, PlaceBase, Projection, ProjectionElem, ProjectionsIter,
|
||||
BorrowKind, Body, Place, PlaceBase, Projection, ProjectionElem, ProjectionsIter,
|
||||
StaticKind
|
||||
};
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
|
@ -26,7 +26,7 @@ crate enum PlaceConflictBias {
|
|||
/// dataflow).
|
||||
crate fn places_conflict<'gcx, 'tcx>(
|
||||
tcx: TyCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
borrow_place: &Place<'tcx>,
|
||||
access_place: &Place<'tcx>,
|
||||
bias: PlaceConflictBias,
|
||||
|
@ -48,7 +48,7 @@ crate fn places_conflict<'gcx, 'tcx>(
|
|||
/// order to make the conservative choice and preserve soundness.
|
||||
pub(super) fn borrow_conflicts_with_place<'gcx, 'tcx>(
|
||||
tcx: TyCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
borrow_place: &Place<'tcx>,
|
||||
borrow_kind: BorrowKind,
|
||||
access_place: &Place<'tcx>,
|
||||
|
@ -85,7 +85,7 @@ pub(super) fn borrow_conflicts_with_place<'gcx, 'tcx>(
|
|||
|
||||
fn place_components_conflict<'gcx, 'tcx>(
|
||||
tcx: TyCtxt<'_, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
borrow_projections: (&PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>),
|
||||
borrow_kind: BorrowKind,
|
||||
access_projections: (&PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>),
|
||||
|
@ -367,7 +367,7 @@ fn place_base_conflict<'a, 'gcx: 'tcx, 'tcx>(
|
|||
// between `elem1` and `elem2`.
|
||||
fn place_projection_conflict<'a, 'gcx: 'tcx, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
pi1: &Projection<'tcx>,
|
||||
pi2: &Projection<'tcx>,
|
||||
bias: PlaceConflictBias,
|
||||
|
|
|
@ -11,7 +11,7 @@ use super::MirBorrowckCtxt;
|
|||
|
||||
use rustc::hir;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::mir::{Mir, Place, PlaceBase, ProjectionElem};
|
||||
use rustc::mir::{Body, Place, PlaceBase, ProjectionElem};
|
||||
|
||||
pub trait IsPrefixOf<'tcx> {
|
||||
fn is_prefix_of(&self, other: &Place<'tcx>) -> bool;
|
||||
|
@ -38,7 +38,7 @@ impl<'tcx> IsPrefixOf<'tcx> for Place<'tcx> {
|
|||
|
||||
|
||||
pub(super) struct Prefixes<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
|
||||
mir: &'cx Mir<'tcx>,
|
||||
mir: &'cx Body<'tcx>,
|
||||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
kind: PrefixSet,
|
||||
next: Option<&'cx Place<'tcx>>,
|
||||
|
|
|
@ -34,7 +34,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
never_initialized_mut_locals: &mut never_initialized_mut_locals,
|
||||
mbcx: self,
|
||||
};
|
||||
visitor.visit_mir(visitor.mbcx.mir);
|
||||
visitor.visit_body(visitor.mbcx.mir);
|
||||
}
|
||||
|
||||
// Take the union of the existed `used_mut` set with those variables we've found were
|
||||
|
|
|
@ -26,7 +26,7 @@ use syntax_pos::Span;
|
|||
use super::lints;
|
||||
|
||||
/// Construct the MIR for a given `DefId`.
|
||||
pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'tcx> {
|
||||
pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Body<'tcx> {
|
||||
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
|
||||
// Figure out what primary body this item has.
|
||||
|
@ -164,14 +164,14 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
|
|||
build::construct_const(cx, body_id, return_ty, return_ty_span)
|
||||
};
|
||||
|
||||
// Convert the Mir to global types.
|
||||
// Convert the `mir::Body` to global types.
|
||||
let mut globalizer = GlobalizeMir {
|
||||
tcx,
|
||||
span: mir.span
|
||||
};
|
||||
globalizer.visit_mir(&mut mir);
|
||||
globalizer.visit_body(&mut mir);
|
||||
let mir = unsafe {
|
||||
mem::transmute::<Mir<'_>, Mir<'tcx>>(mir)
|
||||
mem::transmute::<Body<'_>, Body<'tcx>>(mir)
|
||||
};
|
||||
|
||||
mir_util::dump_mir(tcx, None, "mir_map", &0,
|
||||
|
@ -236,22 +236,22 @@ impl<'a, 'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'a, 'gcx> {
|
|||
fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ctor_id: hir::HirId,
|
||||
v: &'tcx hir::VariantData)
|
||||
-> Mir<'tcx>
|
||||
-> Body<'tcx>
|
||||
{
|
||||
let span = tcx.hir().span_by_hir_id(ctor_id);
|
||||
if let hir::VariantData::Tuple(ref fields, ctor_id) = *v {
|
||||
tcx.infer_ctxt().enter(|infcx| {
|
||||
let mut mir = shim::build_adt_ctor(&infcx, ctor_id, fields, span);
|
||||
|
||||
// Convert the Mir to global types.
|
||||
// Convert the `mir::Body` to global types.
|
||||
let tcx = infcx.tcx.global_tcx();
|
||||
let mut globalizer = GlobalizeMir {
|
||||
tcx,
|
||||
span: mir.span
|
||||
};
|
||||
globalizer.visit_mir(&mut mir);
|
||||
globalizer.visit_body(&mut mir);
|
||||
let mir = unsafe {
|
||||
mem::transmute::<Mir<'_>, Mir<'tcx>>(mir)
|
||||
mem::transmute::<Body<'_>, Body<'tcx>>(mir)
|
||||
};
|
||||
|
||||
mir_util::dump_mir(tcx, None, "mir_map", &0,
|
||||
|
@ -628,7 +628,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
|
|||
yield_ty: Option<Ty<'gcx>>,
|
||||
return_ty_span: Span,
|
||||
body: &'gcx hir::Body)
|
||||
-> Mir<'tcx>
|
||||
-> Body<'tcx>
|
||||
where A: Iterator<Item=ArgInfo<'gcx>>
|
||||
{
|
||||
let arguments: Vec<_> = arguments.collect();
|
||||
|
@ -748,7 +748,7 @@ fn construct_const<'a, 'gcx, 'tcx>(
|
|||
body_id: hir::BodyId,
|
||||
const_ty: Ty<'tcx>,
|
||||
const_ty_span: Span,
|
||||
) -> Mir<'tcx> {
|
||||
) -> Body<'tcx> {
|
||||
let tcx = hir.tcx();
|
||||
let owner_id = tcx.hir().body_owner(body_id);
|
||||
let span = tcx.hir().span(owner_id);
|
||||
|
@ -787,7 +787,7 @@ fn construct_const<'a, 'gcx, 'tcx>(
|
|||
|
||||
fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
body_id: hir::BodyId)
|
||||
-> Mir<'tcx> {
|
||||
-> Body<'tcx> {
|
||||
let owner_id = hir.tcx().hir().body_owner(body_id);
|
||||
let span = hir.tcx().hir().span(owner_id);
|
||||
let ty = hir.tcx().types.err;
|
||||
|
@ -849,14 +849,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn finish(self,
|
||||
yield_ty: Option<Ty<'tcx>>)
|
||||
-> Mir<'tcx> {
|
||||
-> Body<'tcx> {
|
||||
for (index, block) in self.cfg.basic_blocks.iter().enumerate() {
|
||||
if block.terminator.is_none() {
|
||||
span_bug!(self.fn_span, "no terminator on block {:?}", index);
|
||||
}
|
||||
}
|
||||
|
||||
Mir::new(
|
||||
Body::new(
|
||||
self.cfg.basic_blocks,
|
||||
self.source_scopes,
|
||||
ClearCrossCrate::Set(self.source_scope_local_data),
|
||||
|
|
|
@ -55,7 +55,7 @@ pub(crate) fn mk_eval_cx<'a, 'mir, 'tcx>(
|
|||
pub(crate) fn eval_promoted<'a, 'mir, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
cid: GlobalId<'tcx>,
|
||||
mir: &'mir mir::Mir<'tcx>,
|
||||
mir: &'mir mir::Body<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> EvalResult<'tcx, MPlaceTy<'tcx>> {
|
||||
let span = tcx.def_span(cid.instance.def_id());
|
||||
|
@ -137,7 +137,7 @@ fn op_to_const<'tcx>(
|
|||
fn eval_body_using_ecx<'mir, 'tcx>(
|
||||
ecx: &mut CompileTimeEvalContext<'_, 'mir, 'tcx>,
|
||||
cid: GlobalId<'tcx>,
|
||||
mir: &'mir mir::Mir<'tcx>,
|
||||
mir: &'mir mir::Body<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> EvalResult<'tcx, MPlaceTy<'tcx>> {
|
||||
debug!("eval_body_using_ecx: {:?}, {:?}", cid, param_env);
|
||||
|
@ -331,7 +331,7 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
|
|||
args: &[OpTy<'tcx>],
|
||||
dest: Option<PlaceTy<'tcx>>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
) -> EvalResult<'tcx, Option<&'mir mir::Mir<'tcx>>> {
|
||||
) -> EvalResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
|
||||
debug!("eval_fn_call: {:?}", instance);
|
||||
// Only check non-glue functions
|
||||
if let ty::InstanceDef::Item(def_id) = instance.def {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc::mir::{self, Mir, Location};
|
||||
use rustc::mir::{self, Body, Location};
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use crate::util::elaborate_drops::DropFlagState;
|
||||
|
||||
|
@ -47,7 +47,7 @@ pub fn move_path_children_matching<'tcx, F>(move_data: &MoveData<'tcx>,
|
|||
//
|
||||
// FIXME: we have to do something for moving slice patterns.
|
||||
fn place_contents_drop_state_cannot_differ<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
place: &mir::Place<'tcx>) -> bool {
|
||||
let ty = place.ty(mir, tcx).ty;
|
||||
match ty.sty {
|
||||
|
@ -74,7 +74,7 @@ fn place_contents_drop_state_cannot_differ<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx,
|
|||
|
||||
pub(crate) fn on_lookup_result_bits<'a, 'gcx, 'tcx, F>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
lookup_result: LookupResult,
|
||||
each_child: F)
|
||||
|
@ -92,7 +92,7 @@ pub(crate) fn on_lookup_result_bits<'a, 'gcx, 'tcx, F>(
|
|||
|
||||
pub(crate) fn on_all_children_bits<'a, 'gcx, 'tcx, F>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
move_path_index: MovePathIndex,
|
||||
mut each_child: F)
|
||||
|
@ -100,7 +100,7 @@ pub(crate) fn on_all_children_bits<'a, 'gcx, 'tcx, F>(
|
|||
{
|
||||
fn is_terminal_path<'a, 'gcx, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
path: MovePathIndex) -> bool
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ pub(crate) fn on_all_children_bits<'a, 'gcx, 'tcx, F>(
|
|||
|
||||
fn on_all_children_bits<'a, 'gcx, 'tcx, F>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
move_path_index: MovePathIndex,
|
||||
each_child: &mut F)
|
||||
|
@ -133,7 +133,7 @@ pub(crate) fn on_all_children_bits<'a, 'gcx, 'tcx, F>(
|
|||
|
||||
pub(crate) fn on_all_drop_children_bits<'a, 'gcx, 'tcx, F>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
||||
path: MovePathIndex,
|
||||
mut each_child: F)
|
||||
|
@ -156,7 +156,7 @@ pub(crate) fn on_all_drop_children_bits<'a, 'gcx, 'tcx, F>(
|
|||
|
||||
pub(crate) fn drop_flag_effects_for_function_entry<'a, 'gcx, 'tcx, F>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
||||
mut callback: F)
|
||||
where F: FnMut(MovePathIndex, DropFlagState)
|
||||
|
@ -173,7 +173,7 @@ pub(crate) fn drop_flag_effects_for_function_entry<'a, 'gcx, 'tcx, F>(
|
|||
|
||||
pub(crate) fn drop_flag_effects_for_location<'a, 'gcx, 'tcx, F>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
||||
loc: Location,
|
||||
mut callback: F)
|
||||
|
@ -205,7 +205,7 @@ pub(crate) fn drop_flag_effects_for_location<'a, 'gcx, 'tcx, F>(
|
|||
|
||||
pub(crate) fn for_location_inits<'a, 'gcx, 'tcx, F>(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
loc: Location,
|
||||
mut callback: F)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Hook into libgraphviz for rendering dataflow graphs for MIR.
|
||||
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::mir::{BasicBlock, Mir};
|
||||
use rustc::mir::{BasicBlock, Body};
|
||||
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
@ -17,7 +17,7 @@ use super::DebugFormatted;
|
|||
pub trait MirWithFlowState<'tcx> {
|
||||
type BD: BitDenotation<'tcx>;
|
||||
fn def_id(&self) -> DefId;
|
||||
fn mir(&self) -> &Mir<'tcx>;
|
||||
fn mir(&self) -> &Body<'tcx>;
|
||||
fn flow_state(&self) -> &DataflowState<'tcx, Self::BD>;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ impl<'a, 'tcx, BD> MirWithFlowState<'tcx> for DataflowBuilder<'a, 'tcx, BD>
|
|||
{
|
||||
type BD = BD;
|
||||
fn def_id(&self) -> DefId { self.def_id }
|
||||
fn mir(&self) -> &Mir<'tcx> { self.flow_state.mir() }
|
||||
fn mir(&self) -> &Body<'tcx> { self.flow_state.mir() }
|
||||
fn flow_state(&self) -> &DataflowState<'tcx, Self::BD> { &self.flow_state.flow_state }
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ pub type Node = BasicBlock;
|
|||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Edge { source: BasicBlock, index: usize }
|
||||
|
||||
fn outgoing(mir: &Mir<'_>, bb: BasicBlock) -> Vec<Edge> {
|
||||
fn outgoing(mir: &Body<'_>, bb: BasicBlock) -> Vec<Edge> {
|
||||
(0..mir[bb].terminator().successors().count())
|
||||
.map(|index| Edge { source: bb, index: index}).collect()
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ where MWF: MirWithFlowState<'tcx>,
|
|||
n: &Node,
|
||||
w: &mut W,
|
||||
block: BasicBlock,
|
||||
mir: &Mir<'_>) -> io::Result<()> {
|
||||
mir: &Body<'_>) -> io::Result<()> {
|
||||
// Header rows
|
||||
const HDRS: [&str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"];
|
||||
const HDR_FMT: &str = "bgcolor=\"grey\"";
|
||||
|
@ -149,7 +149,7 @@ where MWF: MirWithFlowState<'tcx>,
|
|||
n: &Node,
|
||||
w: &mut W,
|
||||
block: BasicBlock,
|
||||
mir: &Mir<'_>)
|
||||
mir: &Body<'_>)
|
||||
-> io::Result<()> {
|
||||
let i = n.index();
|
||||
|
||||
|
@ -199,7 +199,7 @@ where MWF: MirWithFlowState<'tcx>,
|
|||
n: &Node,
|
||||
w: &mut W,
|
||||
block: BasicBlock,
|
||||
mir: &Mir<'_>)
|
||||
mir: &Body<'_>)
|
||||
-> io::Result<()> {
|
||||
let i = n.index();
|
||||
|
||||
|
|
|
@ -12,16 +12,16 @@ use crate::dataflow::BitDenotation;
|
|||
/// immovable generators.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct HaveBeenBorrowedLocals<'a, 'tcx: 'a> {
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx: 'a> HaveBeenBorrowedLocals<'a, 'tcx> {
|
||||
pub fn new(mir: &'a Mir<'tcx>)
|
||||
pub fn new(mir: &'a Body<'tcx>)
|
||||
-> Self {
|
||||
HaveBeenBorrowedLocals { mir }
|
||||
}
|
||||
|
||||
pub fn mir(&self) -> &Mir<'tcx> {
|
||||
pub fn mir(&self) -> &Body<'tcx> {
|
||||
self.mir
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::borrow_check::borrow_set::{BorrowSet, BorrowData};
|
||||
use crate::borrow_check::place_ext::PlaceExt;
|
||||
|
||||
use rustc::mir::{self, Location, Place, PlaceBase, Mir};
|
||||
use rustc::mir::{self, Location, Place, PlaceBase, Body};
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::ty::RegionVid;
|
||||
|
||||
|
@ -31,7 +31,7 @@ newtype_index! {
|
|||
/// borrows in compact bitvectors.
|
||||
pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
|
||||
borrow_set: Rc<BorrowSet<'tcx>>,
|
||||
borrows_out_of_scope_at_location: FxHashMap<Location, Vec<BorrowIndex>>,
|
||||
|
@ -48,7 +48,7 @@ struct StackEntry {
|
|||
}
|
||||
|
||||
fn precompute_borrows_out_of_scope<'tcx>(
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
regioncx: &Rc<RegionInferenceContext<'tcx>>,
|
||||
borrows_out_of_scope_at_location: &mut FxHashMap<Location, Vec<BorrowIndex>>,
|
||||
borrow_index: BorrowIndex,
|
||||
|
@ -136,7 +136,7 @@ fn precompute_borrows_out_of_scope<'tcx>(
|
|||
impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
|
||||
crate fn new(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
nonlexical_regioncx: Rc<RegionInferenceContext<'tcx>>,
|
||||
borrow_set: &Rc<BorrowSet<'tcx>>,
|
||||
) -> Self {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//! zero-sized structure.
|
||||
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::mir::{self, Mir, Location};
|
||||
use rustc::mir::{self, Body, Location};
|
||||
use rustc_data_structures::bit_set::{BitSet, BitSetOperator};
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
|
||||
|
@ -65,13 +65,13 @@ pub(super) mod borrows;
|
|||
/// places that would require a dynamic drop-flag at that statement.
|
||||
pub struct MaybeInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx: 'tcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
||||
-> Self
|
||||
{
|
||||
|
@ -120,13 +120,13 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 'tcx
|
|||
/// places that would require a dynamic drop-flag at that statement.
|
||||
pub struct MaybeUninitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
||||
-> Self
|
||||
{
|
||||
|
@ -174,13 +174,13 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, 't
|
|||
/// that would require a dynamic drop-flag at that statement.
|
||||
pub struct DefinitelyInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
||||
-> Self
|
||||
{
|
||||
|
@ -223,13 +223,13 @@ impl<'a, 'gcx, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, '
|
|||
/// ```
|
||||
pub struct EverInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx: 'tcx, 'tcx: 'a> EverInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
||||
-> Self
|
||||
{
|
||||
|
|
|
@ -5,16 +5,16 @@ use crate::dataflow::BitDenotation;
|
|||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct MaybeStorageLive<'a, 'tcx: 'a> {
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx: 'a> MaybeStorageLive<'a, 'tcx> {
|
||||
pub fn new(mir: &'a Mir<'tcx>)
|
||||
pub fn new(mir: &'a Body<'tcx>)
|
||||
-> Self {
|
||||
MaybeStorageLive { mir }
|
||||
}
|
||||
|
||||
pub fn mir(&self) -> &Mir<'tcx> {
|
||||
pub fn mir(&self) -> &Body<'tcx> {
|
||||
self.mir
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use rustc_data_structures::work_queue::WorkQueue;
|
|||
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::mir::{self, Mir, BasicBlock, BasicBlockData, Location, Statement, Terminator};
|
||||
use rustc::mir::{self, Body, BasicBlock, BasicBlockData, Location, Statement, Terminator};
|
||||
use rustc::mir::traversal;
|
||||
use rustc::session::Session;
|
||||
|
||||
|
@ -122,7 +122,7 @@ pub struct MoveDataParamEnv<'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub(crate) fn do_dataflow<'a, 'gcx, 'tcx, BD, P>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
def_id: DefId,
|
||||
attributes: &[ast::Attribute],
|
||||
dead_unwinds: &BitSet<BasicBlock>,
|
||||
|
@ -343,13 +343,13 @@ pub(crate) trait DataflowResultsConsumer<'a, 'tcx: 'a> {
|
|||
|
||||
// Delegated Hooks: Provide access to the MIR and process the flow state.
|
||||
|
||||
fn mir(&self) -> &'a Mir<'tcx>;
|
||||
fn mir(&self) -> &'a Body<'tcx>;
|
||||
}
|
||||
|
||||
pub fn state_for_location<'tcx, T: BitDenotation<'tcx>>(loc: Location,
|
||||
analysis: &T,
|
||||
result: &DataflowResults<'tcx, T>,
|
||||
mir: &Mir<'tcx>)
|
||||
mir: &Body<'tcx>)
|
||||
-> BitSet<T::Idx> {
|
||||
let mut on_entry = result.sets().on_entry_set_for(loc.block.index()).to_owned();
|
||||
let mut kill_set = on_entry.to_hybrid();
|
||||
|
@ -384,7 +384,7 @@ pub struct DataflowAnalysis<'a, 'tcx: 'a, O> where O: BitDenotation<'tcx>
|
|||
{
|
||||
flow_state: DataflowState<'tcx, O>,
|
||||
dead_unwinds: &'a BitSet<mir::BasicBlock>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx: 'a, O> DataflowAnalysis<'a, 'tcx, O> where O: BitDenotation<'tcx>
|
||||
|
@ -393,7 +393,7 @@ impl<'a, 'tcx: 'a, O> DataflowAnalysis<'a, 'tcx, O> where O: BitDenotation<'tcx>
|
|||
DataflowResults(self.flow_state)
|
||||
}
|
||||
|
||||
pub fn mir(&self) -> &'a Mir<'tcx> { self.mir }
|
||||
pub fn mir(&self) -> &'a Body<'tcx> { self.mir }
|
||||
}
|
||||
|
||||
pub struct DataflowResults<'tcx, O>(pub(crate) DataflowState<'tcx, O>) where O: BitDenotation<'tcx>;
|
||||
|
@ -697,7 +697,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator {
|
|||
|
||||
impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation<'tcx>
|
||||
{
|
||||
pub fn new(mir: &'a Mir<'tcx>,
|
||||
pub fn new(mir: &'a Body<'tcx>,
|
||||
dead_unwinds: &'a BitSet<mir::BasicBlock>,
|
||||
denotation: D) -> Self where D: InitialFlow {
|
||||
let bits_per_block = denotation.bits_per_block();
|
||||
|
|
|
@ -13,14 +13,14 @@ use super::{MoveError, InitIndex, Init, InitLocation, LookupResult, InitKind};
|
|||
use super::IllegalMoveOriginKind::*;
|
||||
|
||||
struct MoveDataBuilder<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
data: MoveData<'tcx>,
|
||||
errors: Vec<(Place<'tcx>, MoveError<'tcx>)>,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
|
||||
fn new(mir: &'a Mir<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self {
|
||||
fn new(mir: &'a Body<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self {
|
||||
let mut move_paths = IndexVec::new();
|
||||
let mut path_map = IndexVec::new();
|
||||
let mut init_path_map = IndexVec::new();
|
||||
|
@ -203,7 +203,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub(super) fn gather_moves<'a, 'gcx, 'tcx>(
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>
|
||||
) -> Result<MoveData<'tcx>, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)> {
|
||||
let mut builder = MoveDataBuilder::new(mir, tcx);
|
||||
|
|
|
@ -138,7 +138,7 @@ impl<T> IndexMut<Location> for LocationMap<T> {
|
|||
}
|
||||
|
||||
impl<T> LocationMap<T> where T: Default + Clone {
|
||||
fn new(mir: &Mir<'_>) -> Self {
|
||||
fn new(mir: &Body<'_>) -> Self {
|
||||
LocationMap {
|
||||
map: mir.basic_blocks().iter().map(|block| {
|
||||
vec![T::default(); block.statements.len()+1]
|
||||
|
@ -205,7 +205,7 @@ impl fmt::Debug for Init {
|
|||
}
|
||||
|
||||
impl Init {
|
||||
crate fn span<'gcx>(&self, mir: &Mir<'gcx>) -> Span {
|
||||
crate fn span<'gcx>(&self, mir: &Body<'gcx>) -> Span {
|
||||
match self.location {
|
||||
InitLocation::Argument(local) => mir.local_decls[local].source_info.span,
|
||||
InitLocation::Statement(location) => mir.source_info(location).span,
|
||||
|
@ -306,7 +306,7 @@ impl<'tcx> MoveError<'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> MoveData<'tcx> {
|
||||
pub fn gather_moves(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>)
|
||||
pub fn gather_moves(mir: &Body<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>)
|
||||
-> Result<Self, (Self, Vec<(Place<'tcx>, MoveError<'tcx>)>)> {
|
||||
builder::gather_moves(mir, tcx)
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
|
|||
/// Whether this constant/function needs overflow checks.
|
||||
check_overflow: bool,
|
||||
|
||||
/// See field with the same name on `Mir`.
|
||||
/// See field with the same name on `mir::Body`.
|
||||
control_flow_destroyed: Vec<(Span, String)>,
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ pub struct Frame<'mir, 'tcx: 'mir, Tag=(), Extra=()> {
|
|||
// Function and callsite information
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The MIR for the function called on this frame.
|
||||
pub mir: &'mir mir::Mir<'tcx>,
|
||||
pub mir: &'mir mir::Body<'tcx>,
|
||||
|
||||
/// The def_id and substs of the current function.
|
||||
pub instance: ty::Instance<'tcx>,
|
||||
|
@ -244,7 +244,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(super) fn mir(&self) -> &'mir mir::Mir<'tcx> {
|
||||
pub(super) fn mir(&self) -> &'mir mir::Body<'tcx> {
|
||||
self.frame().mir
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
|
|||
pub fn load_mir(
|
||||
&self,
|
||||
instance: ty::InstanceDef<'tcx>,
|
||||
) -> EvalResult<'tcx, &'tcx mir::Mir<'tcx>> {
|
||||
) -> EvalResult<'tcx, &'tcx mir::Body<'tcx>> {
|
||||
// do not continue if typeck errors occurred (can only occur in local crate)
|
||||
let did = instance.def_id();
|
||||
if did.is_local()
|
||||
|
@ -472,7 +472,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
|
|||
&mut self,
|
||||
instance: ty::Instance<'tcx>,
|
||||
span: source_map::Span,
|
||||
mir: &'mir mir::Mir<'tcx>,
|
||||
mir: &'mir mir::Body<'tcx>,
|
||||
return_place: Option<PlaceTy<'tcx, M::PointerTag>>,
|
||||
return_to_block: StackPopCleanup,
|
||||
) -> EvalResult<'tcx> {
|
||||
|
|
|
@ -117,7 +117,7 @@ pub trait Machine<'a, 'mir, 'tcx>: Sized {
|
|||
args: &[OpTy<'tcx, Self::PointerTag>],
|
||||
dest: Option<PlaceTy<'tcx, Self::PointerTag>>,
|
||||
ret: Option<mir::BasicBlock>,
|
||||
) -> EvalResult<'tcx, Option<&'mir mir::Mir<'tcx>>>;
|
||||
) -> EvalResult<'tcx, Option<&'mir mir::Body<'tcx>>>;
|
||||
|
||||
/// Directly process an intrinsic without pushing a stack frame.
|
||||
/// If this returns successfully, the engine will take care of jumping to the next block.
|
||||
|
|
|
@ -3,12 +3,12 @@ use rustc::hir::def_id::DefId;
|
|||
use rustc::hir::intravisit::FnKind;
|
||||
use rustc::hir::map::blocks::FnLikeNode;
|
||||
use rustc::lint::builtin::UNCONDITIONAL_RECURSION;
|
||||
use rustc::mir::{self, Mir, TerminatorKind};
|
||||
use rustc::mir::{self, Body, TerminatorKind};
|
||||
use rustc::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt};
|
||||
use rustc::ty::subst::InternalSubsts;
|
||||
|
||||
pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
def_id: DefId) {
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
|
||||
|
@ -19,7 +19,7 @@ pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
fn_kind: FnKind<'_>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
def_id: DefId) {
|
||||
if let FnKind::Closure(_) = fn_kind {
|
||||
// closures can't recur, so they don't matter.
|
||||
|
|
|
@ -517,7 +517,7 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
struct MirNeighborCollector<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &'a mir::Mir<'tcx>,
|
||||
mir: &'a mir::Body<'tcx>,
|
||||
output: &'a mut Vec<MonoItem<'tcx>>,
|
||||
param_substs: SubstsRef<'tcx>,
|
||||
}
|
||||
|
@ -1218,7 +1218,7 @@ fn collect_neighbours<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
mir: &mir,
|
||||
output,
|
||||
param_substs: instance.substs,
|
||||
}.visit_mir(&mir);
|
||||
}.visit_body(&mir);
|
||||
let param_env = ty::ParamEnv::reveal_all();
|
||||
for i in 0..mir.promoted.len() {
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
|
|
|
@ -28,7 +28,7 @@ pub fn provide(providers: &mut Providers<'_>) {
|
|||
|
||||
fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
instance: ty::InstanceDef<'tcx>)
|
||||
-> &'tcx Mir<'tcx>
|
||||
-> &'tcx Body<'tcx>
|
||||
{
|
||||
debug!("make_shim({:?})", instance);
|
||||
|
||||
|
@ -169,7 +169,7 @@ fn local_decls_for_sig<'tcx>(sig: &ty::FnSig<'tcx>, span: Span)
|
|||
fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId,
|
||||
ty: Option<Ty<'tcx>>)
|
||||
-> Mir<'tcx>
|
||||
-> Body<'tcx>
|
||||
{
|
||||
debug!("build_drop_shim(def_id={:?}, ty={:?})", def_id, ty);
|
||||
|
||||
|
@ -202,7 +202,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
block(&mut blocks, TerminatorKind::Goto { target: return_block });
|
||||
block(&mut blocks, TerminatorKind::Return);
|
||||
|
||||
let mut mir = Mir::new(
|
||||
let mut mir = Body::new(
|
||||
blocks,
|
||||
IndexVec::from_elem_n(
|
||||
SourceScopeData { span: span, parent_scope: None }, 1
|
||||
|
@ -256,7 +256,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
|
||||
pub struct DropShimElaborator<'a, 'tcx: 'a> {
|
||||
pub mir: &'a Mir<'tcx>,
|
||||
pub mir: &'a Body<'tcx>,
|
||||
pub patch: MirPatch<'tcx>,
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pub param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -272,7 +272,7 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {
|
|||
type Path = ();
|
||||
|
||||
fn patch(&mut self) -> &mut MirPatch<'tcx> { &mut self.patch }
|
||||
fn mir(&self) -> &'a Mir<'tcx> { self.mir }
|
||||
fn mir(&self) -> &'a Body<'tcx> { self.mir }
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.tcx }
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx> { self.param_env }
|
||||
|
||||
|
@ -309,7 +309,7 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {
|
|||
fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId,
|
||||
self_ty: Ty<'tcx>)
|
||||
-> Mir<'tcx>
|
||||
-> Body<'tcx>
|
||||
{
|
||||
debug!("build_clone_shim(def_id={:?})", def_id);
|
||||
|
||||
|
@ -371,8 +371,8 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn into_mir(self) -> Mir<'tcx> {
|
||||
Mir::new(
|
||||
fn into_mir(self) -> Body<'tcx> {
|
||||
Body::new(
|
||||
self.blocks,
|
||||
IndexVec::from_elem_n(
|
||||
SourceScopeData { span: self.span, parent_scope: None }, 1
|
||||
|
@ -696,7 +696,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
rcvr_adjustment: Adjustment,
|
||||
call_kind: CallKind,
|
||||
untuple_args: Option<&[Ty<'tcx>]>)
|
||||
-> Mir<'tcx>
|
||||
-> Body<'tcx>
|
||||
{
|
||||
debug!("build_call_shim(def_id={:?}, rcvr_adjustment={:?}, \
|
||||
call_kind={:?}, untuple_args={:?})",
|
||||
|
@ -821,7 +821,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
block(&mut blocks, vec![], TerminatorKind::Resume, true);
|
||||
}
|
||||
|
||||
let mut mir = Mir::new(
|
||||
let mut mir = Body::new(
|
||||
blocks,
|
||||
IndexVec::from_elem_n(
|
||||
SourceScopeData { span: span, parent_scope: None }, 1
|
||||
|
@ -846,7 +846,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
|
|||
ctor_id: hir::HirId,
|
||||
fields: &[hir::StructField],
|
||||
span: Span)
|
||||
-> Mir<'tcx>
|
||||
-> Body<'tcx>
|
||||
{
|
||||
let tcx = infcx.tcx;
|
||||
let gcx = tcx.global_tcx();
|
||||
|
@ -900,7 +900,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
|
|||
is_cleanup: false
|
||||
};
|
||||
|
||||
Mir::new(
|
||||
Body::new(
|
||||
IndexVec::from_elem_n(start_block, 1),
|
||||
IndexVec::from_elem_n(
|
||||
SourceScopeData { span: span, parent_scope: None }, 1
|
||||
|
|
|
@ -34,13 +34,13 @@ impl MirPass for AddCallGuards {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
_tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_src: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
self.add_call_guards(mir);
|
||||
}
|
||||
}
|
||||
|
||||
impl AddCallGuards {
|
||||
pub fn add_call_guards(&self, mir: &mut Mir<'_>) {
|
||||
pub fn add_call_guards(&self, mir: &mut Body<'_>) {
|
||||
let pred_count: IndexVec<_, _> =
|
||||
mir.predecessors().iter().map(|ps| ps.len()).collect();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ impl MirPass for AddMovesForPackedDrops {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
src: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>)
|
||||
mir: &mut Body<'tcx>)
|
||||
{
|
||||
debug!("add_moves_for_packed_drops({:?} @ {:?})", src, mir.span);
|
||||
add_moves_for_packed_drops(tcx, mir, src.def_id());
|
||||
|
@ -52,7 +52,7 @@ impl MirPass for AddMovesForPackedDrops {
|
|||
|
||||
pub fn add_moves_for_packed_drops<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &mut Mir<'tcx>,
|
||||
mir: &mut Body<'tcx>,
|
||||
def_id: DefId)
|
||||
{
|
||||
let patch = add_moves_for_packed_drops_patch(tcx, mir, def_id);
|
||||
|
@ -61,7 +61,7 @@ pub fn add_moves_for_packed_drops<'a, 'tcx>(
|
|||
|
||||
fn add_moves_for_packed_drops_patch<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
def_id: DefId)
|
||||
-> MirPatch<'tcx>
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ fn add_moves_for_packed_drops_patch<'a, 'tcx>(
|
|||
|
||||
fn add_move_for_packed_drop<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
patch: &mut MirPatch<'tcx>,
|
||||
terminator: &Terminator<'tcx>,
|
||||
loc: Location,
|
||||
|
|
|
@ -77,7 +77,7 @@ impl MirPass for AddRetag {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_src: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>)
|
||||
mir: &mut Body<'tcx>)
|
||||
{
|
||||
if !tcx.sess.opts.debugging_opts.mir_emit_retag {
|
||||
return;
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::ops::Bound;
|
|||
use crate::util;
|
||||
|
||||
pub struct UnsafetyChecker<'a, 'tcx: 'a> {
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
const_context: bool,
|
||||
min_const_fn: bool,
|
||||
source_scope_local_data: &'a IndexVec<SourceScope, SourceScopeLocalData>,
|
||||
|
@ -36,7 +36,7 @@ impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> {
|
|||
fn new(
|
||||
const_context: bool,
|
||||
min_const_fn: bool,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
source_scope_local_data: &'a IndexVec<SourceScope, SourceScopeLocalData>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -538,7 +538,7 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
|||
let mut checker = UnsafetyChecker::new(
|
||||
const_context, min_const_fn,
|
||||
mir, source_scope_local_data, tcx, param_env);
|
||||
checker.visit_mir(mir);
|
||||
checker.visit_body(mir);
|
||||
|
||||
check_unused_unsafe(tcx, def_id, &checker.used_unsafe, &mut checker.inherited_blocks);
|
||||
UnsafetyCheckResult {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
//! [`FakeRead`]: rustc::mir::StatementKind::FakeRead
|
||||
//! [`Nop`]: rustc::mir::StatementKind::Nop
|
||||
|
||||
use rustc::mir::{BorrowKind, Rvalue, Location, Mir};
|
||||
use rustc::mir::{BorrowKind, Rvalue, Location, Body};
|
||||
use rustc::mir::{Statement, StatementKind};
|
||||
use rustc::mir::visit::MutVisitor;
|
||||
use rustc::ty::TyCtxt;
|
||||
|
@ -30,9 +30,9 @@ impl MirPass for CleanupNonCodegenStatements {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
_tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_source: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
let mut delete = DeleteNonCodegenStatements;
|
||||
delete.visit_mir(mir);
|
||||
delete.visit_body(mir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use rustc::hir::def::DefKind;
|
||||
use rustc::mir::{
|
||||
AggregateKind, Constant, Location, Place, PlaceBase, Mir, Operand, Rvalue, Local,
|
||||
AggregateKind, Constant, Location, Place, PlaceBase, Body, Operand, Rvalue, Local,
|
||||
NullOp, UnOp, StatementKind, Statement, LocalKind, Static, StaticKind,
|
||||
TerminatorKind, Terminator, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem,
|
||||
SourceScope, SourceScopeLocalData, LocalDecl, Promoted,
|
||||
|
@ -33,7 +33,7 @@ impl MirPass for ConstProp {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
source: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
// will be evaluated by miri and produce its errors there
|
||||
if source.promoted.is_some() {
|
||||
return;
|
||||
|
@ -63,7 +63,7 @@ impl MirPass for ConstProp {
|
|||
// That would require an uniform one-def no-mutation analysis
|
||||
// and RPO (or recursing when needing the value of a local).
|
||||
let mut optimization_finder = ConstPropagator::new(mir, tcx, source);
|
||||
optimization_finder.visit_mir(mir);
|
||||
optimization_finder.visit_body(mir);
|
||||
|
||||
// put back the data we stole from `mir`
|
||||
std::mem::replace(
|
||||
|
@ -91,7 +91,7 @@ struct ConstPropagator<'a, 'mir, 'tcx:'a+'mir> {
|
|||
param_env: ParamEnv<'tcx>,
|
||||
source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
|
||||
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
|
||||
promoted: IndexVec<Promoted, Mir<'tcx>>,
|
||||
promoted: IndexVec<Promoted, Body<'tcx>>,
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'tcx> LayoutOf for ConstPropagator<'a, 'b, 'tcx> {
|
||||
|
@ -119,7 +119,7 @@ impl<'a, 'b, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'a, 'b, 'tcx> {
|
|||
|
||||
impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
|
||||
fn new(
|
||||
mir: &mut Mir<'tcx>,
|
||||
mir: &mut Body<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
source: MirSource<'tcx>,
|
||||
) -> ConstPropagator<'a, 'mir, 'tcx> {
|
||||
|
@ -143,7 +143,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
|
|||
can_const_prop,
|
||||
places: IndexVec::from_elem(None, &mir.local_decls),
|
||||
source_scope_local_data,
|
||||
//FIXME(wesleywiser) we can't steal this because `Visitor::super_visit_mir()` needs it
|
||||
//FIXME(wesleywiser) we can't steal this because `Visitor::super_visit_body()` needs it
|
||||
local_decls: mir.local_decls.clone(),
|
||||
promoted,
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ struct CanConstProp {
|
|||
|
||||
impl CanConstProp {
|
||||
/// returns true if `local` can be propagated
|
||||
fn check(mir: &Mir<'_>) -> IndexVec<Local, bool> {
|
||||
fn check(mir: &Body<'_>) -> IndexVec<Local, bool> {
|
||||
let mut cpv = CanConstProp {
|
||||
can_const_prop: IndexVec::from_elem(true, &mir.local_decls),
|
||||
found_assignment: IndexVec::from_elem(false, &mir.local_decls),
|
||||
|
@ -586,7 +586,7 @@ impl CanConstProp {
|
|||
trace!("local {:?} can't be propagated because it's not a temporary", local);
|
||||
}
|
||||
}
|
||||
cpv.visit_mir(mir);
|
||||
cpv.visit_body(mir);
|
||||
cpv.can_const_prop
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
//! future.
|
||||
|
||||
use rustc::mir::{
|
||||
Constant, Local, LocalKind, Location, Place, PlaceBase, Mir, Operand, Rvalue, StatementKind
|
||||
Constant, Local, LocalKind, Location, Place, PlaceBase, Body, Operand, Rvalue, StatementKind
|
||||
};
|
||||
use rustc::mir::visit::MutVisitor;
|
||||
use rustc::ty::TyCtxt;
|
||||
|
@ -33,7 +33,7 @@ impl MirPass for CopyPropagation {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_source: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
// We only run when the MIR optimization level is > 1.
|
||||
// This avoids a slow pass, and messing up debug info.
|
||||
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {
|
||||
|
@ -135,7 +135,7 @@ impl MirPass for CopyPropagation {
|
|||
}
|
||||
|
||||
fn eliminate_self_assignments(
|
||||
mir: &mut Mir<'_>,
|
||||
mir: &mut Body<'_>,
|
||||
def_use_analysis: &DefUseAnalysis,
|
||||
) -> bool {
|
||||
let mut changed = false;
|
||||
|
@ -177,7 +177,7 @@ enum Action<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> Action<'tcx> {
|
||||
fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis, src_place: &Place<'tcx>)
|
||||
fn local_copy(mir: &Body<'tcx>, def_use_analysis: &DefUseAnalysis, src_place: &Place<'tcx>)
|
||||
-> Option<Action<'tcx>> {
|
||||
// The source must be a local.
|
||||
let src_local = if let Place::Base(PlaceBase::Local(local)) = *src_place {
|
||||
|
@ -232,7 +232,7 @@ impl<'tcx> Action<'tcx> {
|
|||
}
|
||||
|
||||
fn perform(self,
|
||||
mir: &mut Mir<'tcx>,
|
||||
mir: &mut Body<'tcx>,
|
||||
def_use_analysis: &DefUseAnalysis,
|
||||
dest_local: Local,
|
||||
location: Location)
|
||||
|
|
|
@ -10,7 +10,7 @@ impl MirPass for Deaggregator {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_source: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
let (basic_blocks, local_decls) = mir.basic_blocks_and_local_decls_mut();
|
||||
let local_decls = &*local_decls;
|
||||
for bb in basic_blocks {
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::fmt;
|
|||
use std::fs::File;
|
||||
use std::io;
|
||||
|
||||
use rustc::mir::Mir;
|
||||
use rustc::mir::Body;
|
||||
use rustc::session::config::{OutputFilenames, OutputType};
|
||||
use rustc::ty::TyCtxt;
|
||||
use crate::transform::{MirPass, MirSource};
|
||||
|
@ -21,7 +21,7 @@ impl MirPass for Marker {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
_tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_source: MirSource<'tcx>,
|
||||
_mir: &mut Mir<'tcx>)
|
||||
_mir: &mut Body<'tcx>)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ pub fn on_mir_pass<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
pass_num: &dyn fmt::Display,
|
||||
pass_name: &str,
|
||||
source: MirSource<'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
is_after: bool) {
|
||||
if mir_util::dump_enabled(tcx, pass_name, source) {
|
||||
mir_util::dump_mir(tcx,
|
||||
|
|
|
@ -24,7 +24,7 @@ impl MirPass for ElaborateDrops {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
src: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>)
|
||||
mir: &mut Body<'tcx>)
|
||||
{
|
||||
debug!("elaborate_drops({:?} @ {:?})", src, mir.span);
|
||||
|
||||
|
@ -79,7 +79,7 @@ impl MirPass for ElaborateDrops {
|
|||
/// that can't drop anything.
|
||||
fn find_dead_unwinds<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
def_id: hir::def_id::DefId,
|
||||
env: &MoveDataParamEnv<'tcx, 'tcx>)
|
||||
-> BitSet<BasicBlock>
|
||||
|
@ -143,7 +143,7 @@ struct InitializationData {
|
|||
impl InitializationData {
|
||||
fn apply_location<'a,'tcx>(&mut self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
env: &MoveDataParamEnv<'tcx, 'tcx>,
|
||||
loc: Location)
|
||||
{
|
||||
|
@ -186,7 +186,7 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
|
|||
&mut self.ctxt.patch
|
||||
}
|
||||
|
||||
fn mir(&self) -> &'a Mir<'tcx> {
|
||||
fn mir(&self) -> &'a Body<'tcx> {
|
||||
self.ctxt.mir
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
|
|||
|
||||
struct ElaborateDropsCtxt<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
mir: &'a Body<'tcx>,
|
||||
env: &'a MoveDataParamEnv<'tcx, 'tcx>,
|
||||
flow_inits: DataflowResults<'tcx, MaybeInitializedPlaces<'a, 'tcx, 'tcx>>,
|
||||
flow_uninits: DataflowResults<'tcx, MaybeUninitializedPlaces<'a, 'tcx, 'tcx>>,
|
||||
|
|
|
@ -53,7 +53,7 @@ impl MirPass for EraseRegions {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
EraseRegionsVisitor::new(tcx).visit_mir(mir);
|
||||
mir: &mut Body<'tcx>) {
|
||||
EraseRegionsVisitor::new(tcx).visit_body(mir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ impl<'a, 'tcx> TransformVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
// Create a statement which reads the discriminant into a temporary
|
||||
fn get_discr(&self, mir: &mut Mir<'tcx>) -> (Statement<'tcx>, Place<'tcx>) {
|
||||
fn get_discr(&self, mir: &mut Body<'tcx>) -> (Statement<'tcx>, Place<'tcx>) {
|
||||
let temp_decl = LocalDecl::new_internal(self.tcx.types.isize, mir.span);
|
||||
let local_decls_len = mir.local_decls.push(temp_decl);
|
||||
let temp = Place::Base(PlaceBase::Local(local_decls_len));
|
||||
|
@ -304,7 +304,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for TransformVisitor<'a, 'tcx> {
|
|||
fn make_generator_state_argument_indirect<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
let gen_ty = mir.local_decls.raw[1].ty;
|
||||
|
||||
let region = ty::ReFree(ty::FreeRegion {
|
||||
|
@ -323,12 +323,12 @@ fn make_generator_state_argument_indirect<'a, 'tcx>(
|
|||
mir.local_decls.raw[1].ty = ref_gen_ty;
|
||||
|
||||
// Add a deref to accesses of the generator state
|
||||
DerefArgVisitor.visit_mir(mir);
|
||||
DerefArgVisitor.visit_body(mir);
|
||||
}
|
||||
|
||||
fn make_generator_state_argument_pinned<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
let ref_gen_ty = mir.local_decls.raw[1].ty;
|
||||
|
||||
let pin_did = tcx.lang_items().pin_type().unwrap();
|
||||
|
@ -340,12 +340,12 @@ fn make_generator_state_argument_pinned<'a, 'tcx>(
|
|||
mir.local_decls.raw[1].ty = pin_ref_gen_ty;
|
||||
|
||||
// Add the Pin field access to accesses of the generator state
|
||||
PinArgVisitor { ref_gen_ty }.visit_mir(mir);
|
||||
PinArgVisitor { ref_gen_ty }.visit_body(mir);
|
||||
}
|
||||
|
||||
fn replace_result_variable<'tcx>(
|
||||
ret_ty: Ty<'tcx>,
|
||||
mir: &mut Mir<'tcx>,
|
||||
mir: &mut Body<'tcx>,
|
||||
) -> Local {
|
||||
let source_info = source_info(mir);
|
||||
let new_ret = LocalDecl {
|
||||
|
@ -366,7 +366,7 @@ fn replace_result_variable<'tcx>(
|
|||
RenameLocalVisitor {
|
||||
from: RETURN_PLACE,
|
||||
to: new_ret_local,
|
||||
}.visit_mir(mir);
|
||||
}.visit_body(mir);
|
||||
|
||||
new_ret_local
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ impl<'tcx> Visitor<'tcx> for StorageIgnored {
|
|||
|
||||
fn locals_live_across_suspend_points(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
mir: &Body<'tcx>,
|
||||
source: MirSource<'tcx>,
|
||||
movable: bool,
|
||||
) -> (
|
||||
|
@ -408,7 +408,7 @@ fn locals_live_across_suspend_points(
|
|||
// Find the MIR locals which do not use StorageLive/StorageDead statements.
|
||||
// The storage of these locals are always live.
|
||||
let mut ignored = StorageIgnored(BitSet::new_filled(mir.local_decls.len()));
|
||||
ignored.visit_mir(mir);
|
||||
ignored.visit_body(mir);
|
||||
|
||||
// Calculate the MIR locals which have been previously
|
||||
// borrowed (even if they are still active).
|
||||
|
@ -503,7 +503,7 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
upvars: &Vec<Ty<'tcx>>,
|
||||
interior: Ty<'tcx>,
|
||||
movable: bool,
|
||||
mir: &mut Mir<'tcx>)
|
||||
mir: &mut Body<'tcx>)
|
||||
-> (FxHashMap<Local, (Ty<'tcx>, VariantIdx, usize)>,
|
||||
GeneratorLayout<'tcx>,
|
||||
FxHashMap<BasicBlock, liveness::LiveVarSet>)
|
||||
|
@ -576,7 +576,7 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
(remap, layout, storage_liveness)
|
||||
}
|
||||
|
||||
fn insert_switch<'a, 'tcx>(mir: &mut Mir<'tcx>,
|
||||
fn insert_switch<'a, 'tcx>(mir: &mut Body<'tcx>,
|
||||
cases: Vec<(usize, BasicBlock)>,
|
||||
transform: &TransformVisitor<'a, 'tcx>,
|
||||
default: TerminatorKind<'tcx>) {
|
||||
|
@ -608,7 +608,7 @@ fn insert_switch<'a, 'tcx>(mir: &mut Mir<'tcx>,
|
|||
|
||||
fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
use crate::util::elaborate_drops::{elaborate_drop, Unwind};
|
||||
use crate::util::patch::MirPatch;
|
||||
use crate::shim::DropShimElaborator;
|
||||
|
@ -663,8 +663,8 @@ fn create_generator_drop_shim<'a, 'tcx>(
|
|||
def_id: DefId,
|
||||
source: MirSource<'tcx>,
|
||||
gen_ty: Ty<'tcx>,
|
||||
mir: &Mir<'tcx>,
|
||||
drop_clean: BasicBlock) -> Mir<'tcx> {
|
||||
mir: &Body<'tcx>,
|
||||
drop_clean: BasicBlock) -> Body<'tcx> {
|
||||
let mut mir = mir.clone();
|
||||
|
||||
let source_info = source_info(&mir);
|
||||
|
@ -734,7 +734,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
|
|||
mir
|
||||
}
|
||||
|
||||
fn insert_term_block<'tcx>(mir: &mut Mir<'tcx>, kind: TerminatorKind<'tcx>) -> BasicBlock {
|
||||
fn insert_term_block<'tcx>(mir: &mut Body<'tcx>, kind: TerminatorKind<'tcx>) -> BasicBlock {
|
||||
let term_block = BasicBlock::new(mir.basic_blocks().len());
|
||||
let source_info = source_info(mir);
|
||||
mir.basic_blocks_mut().push(BasicBlockData {
|
||||
|
@ -749,7 +749,7 @@ fn insert_term_block<'tcx>(mir: &mut Mir<'tcx>, kind: TerminatorKind<'tcx>) -> B
|
|||
}
|
||||
|
||||
fn insert_panic_block<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
mir: &mut Mir<'tcx>,
|
||||
mir: &mut Body<'tcx>,
|
||||
message: AssertMessage<'tcx>) -> BasicBlock {
|
||||
let assert_block = BasicBlock::new(mir.basic_blocks().len());
|
||||
let term = TerminatorKind::Assert {
|
||||
|
@ -783,7 +783,7 @@ fn create_generator_resume_function<'a, 'tcx>(
|
|||
transform: TransformVisitor<'a, 'tcx>,
|
||||
def_id: DefId,
|
||||
source: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
// Poison the generator when it unwinds
|
||||
for block in mir.basic_blocks_mut() {
|
||||
let source_info = block.terminator().source_info;
|
||||
|
@ -821,14 +821,14 @@ fn create_generator_resume_function<'a, 'tcx>(
|
|||
dump_mir(tcx, None, "generator_resume", &0, source, mir, |_, _| Ok(()) );
|
||||
}
|
||||
|
||||
fn source_info<'a, 'tcx>(mir: &Mir<'tcx>) -> SourceInfo {
|
||||
fn source_info<'a, 'tcx>(mir: &Body<'tcx>) -> SourceInfo {
|
||||
SourceInfo {
|
||||
span: mir.span,
|
||||
scope: OUTERMOST_SOURCE_SCOPE,
|
||||
}
|
||||
}
|
||||
|
||||
fn insert_clean_drop<'a, 'tcx>(mir: &mut Mir<'tcx>) -> BasicBlock {
|
||||
fn insert_clean_drop<'a, 'tcx>(mir: &mut Body<'tcx>) -> BasicBlock {
|
||||
let return_block = insert_term_block(mir, TerminatorKind::Return);
|
||||
|
||||
// Create a block to destroy an unresumed generators. This can only destroy upvars.
|
||||
|
@ -851,7 +851,7 @@ fn insert_clean_drop<'a, 'tcx>(mir: &mut Mir<'tcx>) -> BasicBlock {
|
|||
drop_clean
|
||||
}
|
||||
|
||||
fn create_cases<'a, 'tcx, F>(mir: &mut Mir<'tcx>,
|
||||
fn create_cases<'a, 'tcx, F>(mir: &mut Body<'tcx>,
|
||||
transform: &TransformVisitor<'a, 'tcx>,
|
||||
target: F) -> Vec<(usize, BasicBlock)>
|
||||
where F: Fn(&SuspensionPoint) -> Option<BasicBlock> {
|
||||
|
@ -895,7 +895,7 @@ impl MirPass for StateTransform {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
source: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
let yield_ty = if let Some(yield_ty) = mir.yield_ty {
|
||||
yield_ty
|
||||
} else {
|
||||
|
@ -959,7 +959,7 @@ impl MirPass for StateTransform {
|
|||
new_ret_local,
|
||||
discr_ty,
|
||||
};
|
||||
transform.visit_mir(mir);
|
||||
transform.visit_body(mir);
|
||||
|
||||
// Update our MIR struct to reflect the changed we've made
|
||||
mir.yield_ty = None;
|
||||
|
|
|
@ -41,7 +41,7 @@ impl MirPass for Inline {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
source: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
|
||||
Inliner { tcx, source }.run_pass(mir);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ struct Inliner<'a, 'tcx: 'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
||||
fn run_pass(&self, caller_mir: &mut Mir<'tcx>) {
|
||||
fn run_pass(&self, caller_mir: &mut Body<'tcx>) {
|
||||
// Keep a queue of callsites to try inlining on. We take
|
||||
// advantage of the fact that queries detect cycles here to
|
||||
// allow us to try and fetch the fully optimized MIR of a
|
||||
|
@ -171,7 +171,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
|||
fn get_valid_function_call(&self,
|
||||
bb: BasicBlock,
|
||||
bb_data: &BasicBlockData<'tcx>,
|
||||
caller_mir: &Mir<'tcx>,
|
||||
caller_mir: &Body<'tcx>,
|
||||
param_env: ParamEnv<'tcx>,
|
||||
) -> Option<CallSite<'tcx>> {
|
||||
// Don't inline calls that are in cleanup blocks.
|
||||
|
@ -204,7 +204,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
|||
|
||||
fn consider_optimizing(&self,
|
||||
callsite: CallSite<'tcx>,
|
||||
callee_mir: &Mir<'tcx>)
|
||||
callee_mir: &Body<'tcx>)
|
||||
-> bool
|
||||
{
|
||||
debug!("consider_optimizing({:?})", callsite);
|
||||
|
@ -216,7 +216,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
|||
|
||||
fn should_inline(&self,
|
||||
callsite: CallSite<'tcx>,
|
||||
callee_mir: &Mir<'tcx>)
|
||||
callee_mir: &Body<'tcx>)
|
||||
-> bool
|
||||
{
|
||||
debug!("should_inline({:?})", callsite);
|
||||
|
@ -394,8 +394,8 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
|||
|
||||
fn inline_call(&self,
|
||||
callsite: CallSite<'tcx>,
|
||||
caller_mir: &mut Mir<'tcx>,
|
||||
mut callee_mir: Mir<'tcx>) -> bool {
|
||||
caller_mir: &mut Body<'tcx>,
|
||||
mut callee_mir: Body<'tcx>) -> bool {
|
||||
let terminator = caller_mir[callsite.bb].terminator.take().unwrap();
|
||||
match terminator.kind {
|
||||
// FIXME: Handle inlining of diverging calls
|
||||
|
@ -531,7 +531,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
|||
&self,
|
||||
args: Vec<Operand<'tcx>>,
|
||||
callsite: &CallSite<'tcx>,
|
||||
caller_mir: &mut Mir<'tcx>,
|
||||
caller_mir: &mut Body<'tcx>,
|
||||
) -> Vec<Local> {
|
||||
let tcx = self.tcx;
|
||||
|
||||
|
@ -601,7 +601,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
|||
&self,
|
||||
arg: Operand<'tcx>,
|
||||
callsite: &CallSite<'tcx>,
|
||||
caller_mir: &mut Mir<'tcx>,
|
||||
caller_mir: &mut Body<'tcx>,
|
||||
) -> Local {
|
||||
// FIXME: Analysis of the usage of the arguments to avoid
|
||||
// unnecessary temporaries.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! Performs various peephole optimizations.
|
||||
|
||||
use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, ProjectionElem, Rvalue, Local};
|
||||
use rustc::mir::{Constant, Location, Place, PlaceBase, Body, Operand, ProjectionElem, Rvalue,
|
||||
Local};
|
||||
use rustc::mir::visit::{MutVisitor, Visitor};
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
|
@ -14,7 +15,7 @@ impl MirPass for InstCombine {
|
|||
fn run_pass<'a, 'tcx>(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
_: MirSource<'tcx>,
|
||||
mir: &mut Mir<'tcx>) {
|
||||
mir: &mut Body<'tcx>) {
|
||||
// We only run when optimizing MIR (at any level).
|
||||
if tcx.sess.opts.debugging_opts.mir_opt_level == 0 {
|
||||
return
|
||||
|
@ -25,12 +26,12 @@ impl MirPass for InstCombine {
|
|||
// `Place::ty()`).
|
||||
let optimizations = {
|
||||
let mut optimization_finder = OptimizationFinder::new(mir, tcx);
|
||||
optimization_finder.visit_mir(mir);
|
||||
optimization_finder.visit_body(mir);
|
||||
optimization_finder.optimizations
|
||||
};
|
||||
|
||||
// Then carry out those optimizations.
|
||||
MutVisitor::visit_mir(&mut InstCombineVisitor { optimizations }, mir);
|
||||
MutVisitor::visit_body(&mut InstCombineVisitor { optimizations }, mir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,13 +64,13 @@ impl<'tcx> MutVisitor<'tcx> for InstCombineVisitor<'tcx> {
|
|||
|
||||
/// Finds optimization opportunities on the MIR.
|
||||
struct OptimizationFinder<'b, 'a, 'tcx:'a+'b> {
|
||||
mir: &'b Mir<'tcx>,
|
||||
mir: &'b Body<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
optimizations: OptimizationList<'tcx>,
|
||||
}
|
||||
|
||||
impl<'b, 'a, 'tcx:'b> OptimizationFinder<'b, 'a, 'tcx> {
|
||||
fn new(mir: &'b Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> OptimizationFinder<'b, 'a, 'tcx> {
|
||||
fn new(mir: &'b Body<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> OptimizationFinder<'b, 'a, 'tcx> {
|
||||
OptimizationFinder {
|
||||
mir,
|
||||
tcx,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue