Skip to content

Commit

Permalink
Run rustfmt --file-lines ... for changes from previous commits.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jun 18, 2019
1 parent 4c4fc75 commit ea78c3a
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 77 deletions.
11 changes: 5 additions & 6 deletions src/librustc/ty/query/on_disk_cache.rs
Expand Up @@ -505,12 +505,11 @@ impl<'a, 'tcx> DecoderWithPosition for CacheDecoder<'a, 'tcx> {

// Decode something that was encoded with encode_tagged() and verify that the
// tag matches and the correct amount of bytes was read.
fn decode_tagged<D, T, V>(decoder: &mut D,
expected_tag: T)
-> Result<V, D::Error>
where T: Decodable + Eq + ::std::fmt::Debug,
V: Decodable,
D: DecoderWithPosition,
fn decode_tagged<D, T, V>(decoder: &mut D, expected_tag: T) -> Result<V, D::Error>
where
T: Decodable + Eq + ::std::fmt::Debug,
V: Decodable,
D: DecoderWithPosition,
{
let start_pos = decoder.position();

Expand Down
24 changes: 14 additions & 10 deletions src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs
Expand Up @@ -20,7 +20,7 @@ struct GatherMoveInfo<'c, 'tcx> {
id: hir::ItemLocalId,
kind: MoveKind,
cmt: &'c mc::cmt_<'tcx>,
span_path_opt: Option<MovePlace<'tcx>>
span_path_opt: Option<MovePlace<'tcx>>,
}

/// Represents the kind of pattern
Expand Down Expand Up @@ -91,11 +91,13 @@ pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
gather_move(bccx, move_data, move_error_collector, move_info);
}

pub fn gather_move_from_pat<'a, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
move_data: &MoveData<'tcx>,
move_error_collector: &mut MoveErrorCollector<'tcx>,
move_pat: &hir::Pat,
cmt: &'c mc::cmt_<'tcx>) {
pub fn gather_move_from_pat<'a, 'c, 'tcx>(
bccx: &BorrowckCtxt<'a, 'tcx>,
move_data: &MoveData<'tcx>,
move_error_collector: &mut MoveErrorCollector<'tcx>,
move_pat: &hir::Pat,
cmt: &'c mc::cmt_<'tcx>,
) {
let source = get_pattern_source(bccx.tcx,move_pat);
let pat_span_path_opt = match move_pat.node {
PatKind::Binding(_, _, ident, _) => {
Expand All @@ -121,10 +123,12 @@ pub fn gather_move_from_pat<'a, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
gather_move(bccx, move_data, move_error_collector, move_info);
}

fn gather_move<'a, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
move_data: &MoveData<'tcx>,
move_error_collector: &mut MoveErrorCollector<'tcx>,
move_info: GatherMoveInfo<'c, 'tcx>) {
fn gather_move<'a, 'c, 'tcx>(
bccx: &BorrowckCtxt<'a, 'tcx>,
move_data: &MoveData<'tcx>,
move_error_collector: &mut MoveErrorCollector<'tcx>,
move_info: GatherMoveInfo<'c, 'tcx>,
) {
debug!("gather_move(move_id={:?}, cmt={:?})",
move_info.id, move_info.cmt);

Expand Down
16 changes: 7 additions & 9 deletions src/librustc_codegen_ssa/base.rs
Expand Up @@ -94,7 +94,7 @@ pub fn compare_simd_types<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
rhs: Bx::Value,
t: Ty<'tcx>,
ret_ty: Bx::Type,
op: hir::BinOpKind
op: hir::BinOpKind,
) -> Bx::Value {
let signed = match t.sty {
ty::Float(_) => {
Expand Down Expand Up @@ -156,7 +156,7 @@ pub fn unsize_thin_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
src: Bx::Value,
src_ty: Ty<'tcx>,
dst_ty: Ty<'tcx>
dst_ty: Ty<'tcx>,
) -> (Bx::Value, Bx::Value) {
debug!("unsize_thin_ptr: {:?} => {:?}", src_ty, dst_ty);
match (&src_ty.sty, &dst_ty.sty) {
Expand Down Expand Up @@ -210,8 +210,8 @@ pub fn unsize_thin_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
src: PlaceRef<'tcx, Bx::Value>,
dst: PlaceRef<'tcx, Bx::Value>
) {
dst: PlaceRef<'tcx, Bx::Value>,
) {
let src_ty = src.layout.ty;
let dst_ty = dst.layout.ty;
let mut coerce_ptr = || {
Expand Down Expand Up @@ -270,7 +270,7 @@ pub fn cast_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
op: hir::BinOpKind,
lhs: Bx::Value,
rhs: Bx::Value
rhs: Bx::Value,
) -> Bx::Value {
cast_shift_rhs(bx, op, lhs, rhs)
}
Expand Down Expand Up @@ -318,7 +318,7 @@ pub fn wants_msvc_seh(sess: &Session) -> bool {

pub fn from_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
val: Bx::Value
val: Bx::Value,
) -> Bx::Value {
if bx.cx().val_ty(val) == bx.cx().type_i1() {
bx.zext(val, bx.cx().type_i8())
Expand Down Expand Up @@ -387,9 +387,7 @@ pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(

/// Creates the `main` function which will initialize the rust runtime and call
/// users main function.
pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
cx: &'a Bx::CodegenCx
) {
pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'a Bx::CodegenCx) {
let (main_def_id, span) = match cx.tcx().entry_fn(LOCAL_CRATE) {
Some((def_id, _)) => { (def_id, cx.tcx().def_span(def_id)) },
None => return,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_codegen_ssa/common.rs
Expand Up @@ -140,7 +140,7 @@ pub fn langcall(tcx: TyCtxt<'_>, span: Option<Span>, msg: &str, li: LangItem) ->
pub fn build_unchecked_lshift<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
lhs: Bx::Value,
rhs: Bx::Value
rhs: Bx::Value,
) -> Bx::Value {
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shl, lhs, rhs);
// #1877, #10183: Ensure that input is always valid
Expand All @@ -152,7 +152,7 @@ pub fn build_unchecked_rshift<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
lhs_t: Ty<'tcx>,
lhs: Bx::Value,
rhs: Bx::Value
rhs: Bx::Value,
) -> Bx::Value {
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shr, lhs, rhs);
// #1877, #10183: Ensure that input is always valid
Expand All @@ -167,7 +167,7 @@ pub fn build_unchecked_rshift<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(

fn shift_mask_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
rhs: Bx::Value
rhs: Bx::Value,
) -> Bx::Value {
let rhs_llty = bx.val_ty(rhs);
let shift_val = shift_mask_val(bx, rhs_llty, rhs_llty, false);
Expand All @@ -178,7 +178,7 @@ pub fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
llty: Bx::Type,
mask_llty: Bx::Type,
invert: bool
invert: bool,
) -> Bx::Value {
let kind = bx.type_kind(llty);
match kind {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/glue.rs
Expand Up @@ -10,7 +10,7 @@ use crate::traits::*;
pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
t: Ty<'tcx>,
info: Option<Bx::Value>
info: Option<Bx::Value>,
) -> (Bx::Value, Bx::Value) {
let layout = bx.layout_of(t);
debug!("size_and_align_of_dst(ty={}, info={:?}): layout: {:?}",
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_codegen_ssa/mir/analyze.rs
Expand Up @@ -13,7 +13,7 @@ use super::FunctionCx;
use crate::traits::*;

pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
fx: &FunctionCx<'a, 'tcx, Bx>
fx: &FunctionCx<'a, 'tcx, Bx>,
) -> BitSet<mir::Local> {
let mir = fx.mir;
let mut analyzer = LocalAnalyzer::new(fx);
Expand Down Expand Up @@ -49,7 +49,7 @@ struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
non_ssa_locals: BitSet<mir::Local>,
// The location of the first visited direct assignment to each
// local, or an invalid location (out of bounds `block` index).
first_assignment: IndexVec<mir::Local, Location>
first_assignment: IndexVec<mir::Local, Location>,
}

impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
Expand Down Expand Up @@ -95,7 +95,8 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
}

impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
for LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
for LocalAnalyzer<'mir, 'a, 'tcx, Bx>
{
fn visit_assign(&mut self,
place: &mir::Place<'tcx>,
rvalue: &mir::Rvalue<'tcx>,
Expand Down
11 changes: 6 additions & 5 deletions src/librustc_codegen_ssa/mir/mod.rs
Expand Up @@ -43,7 +43,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
/// don't really care about it very much. Anyway, this value
/// contains an alloca into which the personality is stored and
/// then later loaded when generating the DIVERGE_BLOCK.
personality_slot: Option<PlaceRef<'tcx, Bx::Value,>>,
personality_slot: Option<PlaceRef<'tcx, Bx::Value>>,

/// A `Block` for each MIR `BasicBlock`
blocks: IndexVec<mir::BasicBlock, Bx::BasicBlock>,
Expand Down Expand Up @@ -355,10 +355,11 @@ fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
mir: &'a Body<'tcx>,
bx: &mut Bx,
cleanup_kinds: &IndexVec<mir::BasicBlock, CleanupKind>,
block_bxs: &IndexVec<mir::BasicBlock, Bx::BasicBlock>)
-> (IndexVec<mir::BasicBlock, Option<Bx::BasicBlock>>,
IndexVec<mir::BasicBlock, Option<Bx::Funclet>>)
{
block_bxs: &IndexVec<mir::BasicBlock, Bx::BasicBlock>,
) -> (
IndexVec<mir::BasicBlock, Option<Bx::BasicBlock>>,
IndexVec<mir::BasicBlock, Option<Bx::Funclet>>,
) {
block_bxs.iter_enumerated().zip(cleanup_kinds).map(|((bb, &llbb), cleanup_kind)| {
match *cleanup_kind {
CleanupKind::Funclet if base::wants_msvc_seh(bx.sess()) => {}
Expand Down
33 changes: 24 additions & 9 deletions src/librustc_mir/dataflow/mod.rs
Expand Up @@ -43,7 +43,7 @@ pub(crate) mod indexes {

pub(crate) struct DataflowBuilder<'a, 'tcx, BD>
where
BD: BitDenotation<'tcx>
BD: BitDenotation<'tcx>,
{
def_id: DefId,
flow_state: DataflowAnalysis<'a, 'tcx, BD>,
Expand Down Expand Up @@ -88,7 +88,7 @@ pub(crate) trait Dataflow<'tcx, BD: BitDenotation<'tcx>> {

impl<'a, 'tcx, BD> Dataflow<'tcx, BD> for DataflowBuilder<'a, 'tcx, BD>
where
BD: BitDenotation<'tcx>
BD: BitDenotation<'tcx>,
{
fn dataflow<P>(&mut self, p: P) where P: Fn(&BD, BD::Idx) -> DebugFormatted {
self.flow_state.build_sets();
Expand Down Expand Up @@ -179,12 +179,16 @@ where
}
}

struct PropagationContext<'b, 'a, 'tcx, O> where O: 'b + BitDenotation<'tcx>
struct PropagationContext<'b, 'a, 'tcx, O>
where
O: 'b + BitDenotation<'tcx>,
{
builder: &'b mut DataflowAnalysis<'a, 'tcx, O>,
}

impl<'a, 'tcx, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx>
impl<'a, 'tcx, BD> DataflowAnalysis<'a, 'tcx, BD>
where
BD: BitDenotation<'tcx>,
{
fn propagate(&mut self) {
let mut temp = BitSet::new_empty(self.flow_state.sets.bits_per_block);
Expand Down Expand Up @@ -234,7 +238,9 @@ impl<'a, 'tcx, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx>
}
}

impl<'b, 'a, 'tcx, BD> PropagationContext<'b, 'a, 'tcx, BD> where BD: BitDenotation<'tcx>
impl<'b, 'a, 'tcx, BD> PropagationContext<'b, 'a, 'tcx, BD>
where
BD: BitDenotation<'tcx>,
{
fn walk_cfg(&mut self, in_out: &mut BitSet<BD::Idx>) {
let mut dirty_queue: WorkQueue<mir::BasicBlock> =
Expand Down Expand Up @@ -265,7 +271,9 @@ fn dataflow_path(context: &str, path: &str) -> PathBuf {
path
}

impl<'a, 'tcx, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation<'tcx>
impl<'a, 'tcx, BD> DataflowBuilder<'a, 'tcx, BD>
where
BD: BitDenotation<'tcx>,
{
fn pre_dataflow_instrumentation<P>(&self, p: P) -> io::Result<()>
where P: Fn(&BD, BD::Idx) -> DebugFormatted
Expand Down Expand Up @@ -387,14 +395,18 @@ pub fn state_for_location<'tcx, T: BitDenotation<'tcx>>(loc: Location,
gen_set.to_dense()
}

pub struct DataflowAnalysis<'a, 'tcx, O> where O: BitDenotation<'tcx>
pub struct DataflowAnalysis<'a, 'tcx, O>
where
O: BitDenotation<'tcx>,
{
flow_state: DataflowState<'tcx, O>,
dead_unwinds: &'a BitSet<mir::BasicBlock>,
body: &'a Body<'tcx>,
}

impl<'a, 'tcx, O> DataflowAnalysis<'a, 'tcx, O> where O: BitDenotation<'tcx>
impl<'a, 'tcx, O> DataflowAnalysis<'a, 'tcx, O>
where
O: BitDenotation<'tcx>,
{
pub fn results(self) -> DataflowResults<'tcx, O> {
DataflowResults(self.flow_state)
Expand Down Expand Up @@ -734,7 +746,10 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation<'tcx>
}
}

impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation<'tcx> {
impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D>
where
D: BitDenotation<'tcx>,
{
/// Propagates the bits of `in_out` into all the successors of `bb`,
/// using bitwise operator denoted by `self.operator`.
///
Expand Down
9 changes: 6 additions & 3 deletions src/librustc_mir/hair/cx/to_ref.rs
Expand Up @@ -33,7 +33,8 @@ impl<'tcx> ToRef for Expr<'tcx> {
}

impl<'tcx, T, U> ToRef for &'tcx Option<T>
where &'tcx T: ToRef<Output = U>
where
&'tcx T: ToRef<Output = U>,
{
type Output = Option<U>;

Expand All @@ -43,7 +44,8 @@ impl<'tcx, T, U> ToRef for &'tcx Option<T>
}

impl<'tcx, T, U> ToRef for &'tcx Vec<T>
where &'tcx T: ToRef<Output = U>
where
&'tcx T: ToRef<Output = U>,
{
type Output = Vec<U>;

Expand All @@ -53,7 +55,8 @@ impl<'tcx, T, U> ToRef for &'tcx Vec<T>
}

impl<'tcx, T, U> ToRef for &'tcx P<[T]>
where &'tcx T: ToRef<Output = U>
where
&'tcx T: ToRef<Output = U>,
{
type Output = Vec<U>;

Expand Down

0 comments on commit ea78c3a

Please sign in to comment.