mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-13 07:24:00 +00:00
fix typos & docs
This commit is contained in:
parent
954fbe35e1
commit
e0b0fb0af7
@ -1,5 +1,6 @@
|
|||||||
//! This pass transforms derefs of Box into a deref of the pointer inside Box
|
//! This pass transforms derefs of Box into a deref of the pointer inside Box.
|
||||||
//! Codegen does not allow box to be directly dereferenced
|
//!
|
||||||
|
//! Box is not actually a pointer so it is incorrect to dereference it directly.
|
||||||
|
|
||||||
use crate::MirPass;
|
use crate::MirPass;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
@ -10,7 +11,7 @@ use rustc_middle::mir::*;
|
|||||||
use rustc_middle::ty::subst::Subst;
|
use rustc_middle::ty::subst::Subst;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
|
||||||
struct ElaborateBoxDerefVistor<'tcx, 'a> {
|
struct ElaborateBoxDerefVisitor<'tcx, 'a> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
unique_did: DefId,
|
unique_did: DefId,
|
||||||
nonnull_did: DefId,
|
nonnull_did: DefId,
|
||||||
@ -18,7 +19,7 @@ struct ElaborateBoxDerefVistor<'tcx, 'a> {
|
|||||||
patch: MirPatch<'tcx>,
|
patch: MirPatch<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, 'a> MutVisitor<'tcx> for ElaborateBoxDerefVistor<'tcx, 'a> {
|
impl<'tcx, 'a> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'tcx, 'a> {
|
||||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
|
|||||||
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
|
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
|
||||||
|
|
||||||
let mut visitor =
|
let mut visitor =
|
||||||
ElaborateBoxDerefVistor { tcx, unique_did, nonnull_did, local_decls, patch };
|
ElaborateBoxDerefVisitor { tcx, unique_did, nonnull_did, local_decls, patch };
|
||||||
|
|
||||||
for (block, BasicBlockData { statements, terminator, .. }) in
|
for (block, BasicBlockData { statements, terminator, .. }) in
|
||||||
basic_blocks.iter_enumerated_mut()
|
basic_blocks.iter_enumerated_mut()
|
||||||
@ -111,7 +112,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
|
|||||||
|
|
||||||
let location = Location { block, statement_index: index };
|
let location = Location { block, statement_index: index };
|
||||||
match terminator {
|
match terminator {
|
||||||
// yielding into a box is handed when lowering generators
|
// yielding into a box is handled when lowering generators
|
||||||
Some(Terminator { kind: TerminatorKind::Yield { value, .. }, .. }) => {
|
Some(Terminator { kind: TerminatorKind::Yield { value, .. }, .. }) => {
|
||||||
visitor.visit_operand(value, location);
|
visitor.visit_operand(value, location);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user