Fix tidy warnings
This commit is contained in:
parent
d861982ca6
commit
17c749f3ee
29 changed files with 122 additions and 75 deletions
|
@ -146,7 +146,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if local_visitor.found_impl_arg {
|
if local_visitor.found_impl_arg {
|
||||||
labels.push((DUMMY_SP, format!("consider giving a type to the implicit generator argument")));
|
labels.push((DUMMY_SP, format!("consider giving a type to the \
|
||||||
|
implicit generator argument")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut err = struct_span_err!(self.tcx.sess,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
|
|
|
@ -1166,7 +1166,8 @@ impl<'tcx> Visitor<'tcx> for YieldFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extent_has_yield<'a, 'gcx: 'a+'tcx, 'tcx: 'a>(tcx: TyCtxt<'a, 'gcx, 'tcx>, extent: CodeExtent) -> bool {
|
pub fn extent_has_yield<'a, 'gcx: 'a+'tcx, 'tcx: 'a>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
|
extent: CodeExtent) -> bool {
|
||||||
let mut finder = YieldFinder(false);
|
let mut finder = YieldFinder(false);
|
||||||
|
|
||||||
match extent {
|
match extent {
|
||||||
|
|
|
@ -1355,7 +1355,8 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||||
}
|
}
|
||||||
struct_fmt.field("$state", &lvs[freevars.len()]);
|
struct_fmt.field("$state", &lvs[freevars.len()]);
|
||||||
for i in (freevars.len() + 1)..lvs.len() {
|
for i in (freevars.len() + 1)..lvs.len() {
|
||||||
struct_fmt.field(&format!("${}", i - freevars.len() - 1), &lvs[i]);
|
struct_fmt.field(&format!("${}", i - freevars.len() - 1),
|
||||||
|
&lvs[i]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,10 @@ impl<'tcx> Rvalue<'tcx> {
|
||||||
}
|
}
|
||||||
AggregateKind::Generator(did, substs) => {
|
AggregateKind::Generator(did, substs) => {
|
||||||
let node_id = tcx.hir.as_local_node_id(did).unwrap();
|
let node_id = tcx.hir.as_local_node_id(did).unwrap();
|
||||||
let interior = *tcx.typeck_tables_of(did).generator_interiors.get(&node_id).unwrap();
|
let interior = *tcx.typeck_tables_of(did)
|
||||||
|
.generator_interiors
|
||||||
|
.get(&node_id)
|
||||||
|
.unwrap();
|
||||||
tcx.mk_generator(did, substs, interior.subst(tcx, substs.substs))
|
tcx.mk_generator(did, substs, interior.subst(tcx, substs.substs))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -541,7 +541,9 @@ macro_rules! define_maps {
|
||||||
impl<$tcx> Query<$tcx> {
|
impl<$tcx> Query<$tcx> {
|
||||||
pub fn describe(&self, tcx: TyCtxt) -> String {
|
pub fn describe(&self, tcx: TyCtxt) -> String {
|
||||||
let (r, name) = match *self {
|
let (r, name) = match *self {
|
||||||
$(Query::$name(key) => (queries::$name::describe(tcx, key), stringify!($name))),*
|
$(Query::$name(key) => {
|
||||||
|
(queries::$name::describe(tcx, key), stringify!($name))
|
||||||
|
})*
|
||||||
};
|
};
|
||||||
if tcx.sess.verbose() {
|
if tcx.sess.verbose() {
|
||||||
format!("{} [{}]", r, name)
|
format!("{} [{}]", r, name)
|
||||||
|
|
|
@ -304,7 +304,8 @@ impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::AutoBorrow<'a> {
|
||||||
impl<'a, 'tcx> Lift<'tcx> for ty::GenSig<'a> {
|
impl<'a, 'tcx> Lift<'tcx> for ty::GenSig<'a> {
|
||||||
type Lifted = ty::GenSig<'tcx>;
|
type Lifted = ty::GenSig<'tcx>;
|
||||||
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
|
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
|
||||||
tcx.lift(&(self.impl_arg_ty, self.suspend_ty, self.return_ty)).map(|(impl_arg_ty, suspend_ty, return_ty)| {
|
tcx.lift(&(self.impl_arg_ty, self.suspend_ty, self.return_ty))
|
||||||
|
.map(|(impl_arg_ty, suspend_ty, return_ty)| {
|
||||||
ty::GenSig {
|
ty::GenSig {
|
||||||
impl_arg_ty,
|
impl_arg_ty,
|
||||||
suspend_ty,
|
suspend_ty,
|
||||||
|
@ -572,7 +573,9 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||||
ty::TyRef(ref r, tm) => {
|
ty::TyRef(ref r, tm) => {
|
||||||
ty::TyRef(r.fold_with(folder), tm.fold_with(folder))
|
ty::TyRef(r.fold_with(folder), tm.fold_with(folder))
|
||||||
}
|
}
|
||||||
ty::TyGenerator(did, substs, interior) => ty::TyGenerator(did, substs.fold_with(folder), interior.fold_with(folder)),
|
ty::TyGenerator(did, substs, interior) => {
|
||||||
|
ty::TyGenerator(did, substs.fold_with(folder), interior.fold_with(folder))
|
||||||
|
}
|
||||||
ty::TyClosure(did, substs) => ty::TyClosure(did, substs.fold_with(folder)),
|
ty::TyClosure(did, substs) => ty::TyClosure(did, substs.fold_with(folder)),
|
||||||
ty::TyProjection(ref data) => ty::TyProjection(data.fold_with(folder)),
|
ty::TyProjection(ref data) => ty::TyProjection(data.fold_with(folder)),
|
||||||
ty::TyAnon(did, substs) => ty::TyAnon(did, substs.fold_with(folder)),
|
ty::TyAnon(did, substs) => ty::TyAnon(did, substs.fold_with(folder)),
|
||||||
|
@ -604,7 +607,9 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||||
ty::TyFnDef(_, substs) => substs.visit_with(visitor),
|
ty::TyFnDef(_, substs) => substs.visit_with(visitor),
|
||||||
ty::TyFnPtr(ref f) => f.visit_with(visitor),
|
ty::TyFnPtr(ref f) => f.visit_with(visitor),
|
||||||
ty::TyRef(r, ref tm) => r.visit_with(visitor) || tm.visit_with(visitor),
|
ty::TyRef(r, ref tm) => r.visit_with(visitor) || tm.visit_with(visitor),
|
||||||
ty::TyGenerator(_did, ref substs, ref interior) => substs.visit_with(visitor) || interior.visit_with(visitor),
|
ty::TyGenerator(_did, ref substs, ref interior) => {
|
||||||
|
substs.visit_with(visitor) || interior.visit_with(visitor)
|
||||||
|
}
|
||||||
ty::TyClosure(_did, ref substs) => substs.visit_with(visitor),
|
ty::TyClosure(_did, ref substs) => substs.visit_with(visitor),
|
||||||
ty::TyProjection(ref data) => data.visit_with(visitor),
|
ty::TyProjection(ref data) => data.visit_with(visitor),
|
||||||
ty::TyAnon(_, ref substs) => substs.visit_with(visitor),
|
ty::TyAnon(_, ref substs) => substs.visit_with(visitor),
|
||||||
|
|
|
@ -778,7 +778,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
for scope in scopes.iter_mut() {
|
for scope in scopes.iter_mut() {
|
||||||
target = build_diverge_scope(hir.tcx(), cfg, &unit_temp, span, scope, target, generator_drop);
|
target = build_diverge_scope(hir.tcx(),
|
||||||
|
cfg,
|
||||||
|
&unit_temp,
|
||||||
|
span,
|
||||||
|
scope,
|
||||||
|
target,
|
||||||
|
generator_drop);
|
||||||
}
|
}
|
||||||
Some(target)
|
Some(target)
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,7 +327,8 @@ fn locals_live_across_suspend_points<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The implicit argument is defined after each suspend point so it can never be live in a suspend point.
|
// The implicit argument is defined after each suspend point so it can never
|
||||||
|
// be live in a suspend point.
|
||||||
set.remove(&Local::new(2));
|
set.remove(&Local::new(2));
|
||||||
|
|
||||||
// The generator argument is ignored
|
// The generator argument is ignored
|
||||||
|
@ -340,7 +341,9 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
source: MirSource,
|
source: MirSource,
|
||||||
interior: GeneratorInterior<'tcx>,
|
interior: GeneratorInterior<'tcx>,
|
||||||
mir: &mut Mir<'tcx>) -> (HashMap<Local, (Ty<'tcx>, usize)>, GeneratorLayout<'tcx>) {
|
mir: &mut Mir<'tcx>)
|
||||||
|
-> (HashMap<Local, (Ty<'tcx>, usize)>, GeneratorLayout<'tcx>)
|
||||||
|
{
|
||||||
let source_info = SourceInfo {
|
let source_info = SourceInfo {
|
||||||
span: mir.span,
|
span: mir.span,
|
||||||
scope: ARGUMENT_VISIBILITY_SCOPE,
|
scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||||
|
@ -363,7 +366,10 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let upvar_len = mir.upvar_decls.len();
|
let upvar_len = mir.upvar_decls.len();
|
||||||
let live_decls : Vec<_> = mir.local_decls.iter_enumerated_mut().filter(|&(local, _)| live_locals.contains(&local)).collect();
|
let live_decls : Vec<_> = mir.local_decls
|
||||||
|
.iter_enumerated_mut()
|
||||||
|
.filter(|&(local, _)| live_locals.contains(&local))
|
||||||
|
.collect();
|
||||||
|
|
||||||
let mut remap = HashMap::new();
|
let mut remap = HashMap::new();
|
||||||
let unit = tcx.mk_nil();
|
let unit = tcx.mk_nil();
|
||||||
|
@ -650,7 +656,10 @@ fn generate_resume<'a, 'tcx>(
|
||||||
values: Cow::from(transform.bb_targets.values().map(|&i| {
|
values: Cow::from(transform.bb_targets.values().map(|&i| {
|
||||||
ConstInt::U32(i)
|
ConstInt::U32(i)
|
||||||
}).collect::<Vec<_>>()),
|
}).collect::<Vec<_>>()),
|
||||||
targets: transform.bb_targets.keys().map(|&(k, _)| k).chain(once(transform.return_block)).collect(),
|
targets: transform.bb_targets.keys()
|
||||||
|
.map(|&(k, _)| k)
|
||||||
|
.chain(once(transform.return_block))
|
||||||
|
.collect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
insert_entry_point(mir, BasicBlockData {
|
insert_entry_point(mir, BasicBlockData {
|
||||||
|
|
|
@ -34,7 +34,10 @@ fn mirbug(tcx: TyCtxt, span: Span, msg: &str) {
|
||||||
macro_rules! span_mirbug {
|
macro_rules! span_mirbug {
|
||||||
($context:expr, $elem:expr, $($message:tt)*) => ({
|
($context:expr, $elem:expr, $($message:tt)*) => ({
|
||||||
mirbug($context.tcx(), $context.last_span,
|
mirbug($context.tcx(), $context.last_span,
|
||||||
&format!("broken MIR in {:?} ({:?}): {}", $context.body_id, $elem, format!($($message)*)))
|
&format!("broken MIR in {:?} ({:?}): {}",
|
||||||
|
$context.body_id,
|
||||||
|
$elem,
|
||||||
|
format_args!($($message)*)))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
//! Liveness analysis.
|
//! Liveness analysis.
|
||||||
|
|
||||||
// FIXME: Make sure this analysis uses proper MIR semantics. Also find out what the MIR semantics are.
|
// FIXME: Make sure this analysis uses proper MIR semantics. Also find out what
|
||||||
|
// the MIR semantics are.
|
||||||
|
|
||||||
use rustc::mir::*;
|
use rustc::mir::*;
|
||||||
use rustc::mir::visit::{LvalueContext, Visitor};
|
use rustc::mir::visit::{LvalueContext, Visitor};
|
||||||
|
@ -188,7 +189,10 @@ pub fn write_mir_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
write_mir_intro(tcx, src, mir, w)?;
|
write_mir_intro(tcx, src, mir, w)?;
|
||||||
for block in mir.basic_blocks().indices() {
|
for block in mir.basic_blocks().indices() {
|
||||||
let print = |w: &mut Write, prefix, result: &IndexVec<BasicBlock, LocalSet>| {
|
let print = |w: &mut Write, prefix, result: &IndexVec<BasicBlock, LocalSet>| {
|
||||||
let live: Vec<String> = mir.local_decls.indices().filter(|i| result[block].contains(i)).map(|i| format!("{:?}", i)).collect();
|
let live: Vec<String> = mir.local_decls.indices()
|
||||||
|
.filter(|i| result[block].contains(i))
|
||||||
|
.map(|i| format!("{:?}", i))
|
||||||
|
.collect();
|
||||||
writeln!(w, "{} {{{}}}", prefix, live.join(", "))
|
writeln!(w, "{} {{{}}}", prefix, live.join(", "))
|
||||||
};
|
};
|
||||||
print(w, " ", &result.ins)?;
|
print(w, " ", &result.ins)?;
|
||||||
|
|
|
@ -171,8 +171,12 @@ impl<'a, 'tcx> mir_visit::Visitor<'tcx> for StatCollector<'a, 'tcx> {
|
||||||
self.record(match *msg {
|
self.record(match *msg {
|
||||||
AssertMessage::BoundsCheck { .. } => "AssertMessage::BoundsCheck",
|
AssertMessage::BoundsCheck { .. } => "AssertMessage::BoundsCheck",
|
||||||
AssertMessage::Math(..) => "AssertMessage::Math",
|
AssertMessage::Math(..) => "AssertMessage::Math",
|
||||||
AssertMessage::GeneratorResumedAfterReturn => "AssertMessage::GeneratorResumedAfterReturn",
|
AssertMessage::GeneratorResumedAfterReturn => {
|
||||||
AssertMessage::GeneratorResumedAfterPanic => "AssertMessage::GeneratorResumedAfterPanic",
|
"AssertMessage::GeneratorResumedAfterReturn"
|
||||||
|
}
|
||||||
|
AssertMessage::GeneratorResumedAfterPanic => {
|
||||||
|
"AssertMessage::GeneratorResumedAfterPanic"
|
||||||
|
}
|
||||||
}, msg);
|
}, msg);
|
||||||
self.super_assert_message(msg, location);
|
self.super_assert_message(msg, location);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,13 @@ impl<'a, 'gcx, 'tcx> InteriorVisitor<'a, 'gcx, 'tcx> {
|
||||||
if self.fcx.tcx.sess.verbose() {
|
if self.fcx.tcx.sess.verbose() {
|
||||||
if let Some(s) = scope {
|
if let Some(s) = scope {
|
||||||
self.fcx.tcx.sess.span_warn(s.span(&self.fcx.tcx.hir).unwrap_or(DUMMY_SP),
|
self.fcx.tcx.sess.span_warn(s.span(&self.fcx.tcx.hir).unwrap_or(DUMMY_SP),
|
||||||
&format!("type in generator with scope = {:?}, type = {:?}", scope, self.fcx.resolve_type_vars_if_possible(&ty)));
|
&format!("type in generator with scope = {:?}, type = {:?}",
|
||||||
|
scope,
|
||||||
|
self.fcx.resolve_type_vars_if_possible(&ty)));
|
||||||
} else {
|
} else {
|
||||||
self.fcx.tcx.sess.span_warn(DUMMY_SP,
|
self.fcx.tcx.sess.span_warn(DUMMY_SP,
|
||||||
&format!("type in generator WITHOUT scope, type = {:?}", self.fcx.resolve_type_vars_if_possible(&ty)));
|
&format!("type in generator WITHOUT scope, type = {:?}",
|
||||||
|
self.fcx.resolve_type_vars_if_possible(&ty)));
|
||||||
}
|
}
|
||||||
if let Some(e) = expr {
|
if let Some(e) = expr {
|
||||||
self.fcx.tcx.sess.span_warn(e.span,
|
self.fcx.tcx.sess.span_warn(e.span,
|
||||||
|
@ -51,7 +54,10 @@ impl<'a, 'gcx, 'tcx> InteriorVisitor<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, def_id: DefId, body_id: hir::BodyId, witness: Ty<'tcx>) {
|
pub fn find_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
|
||||||
|
def_id: DefId,
|
||||||
|
body_id: hir::BodyId,
|
||||||
|
witness: Ty<'tcx>) {
|
||||||
let body = fcx.tcx.hir.body(body_id);
|
let body = fcx.tcx.hir.body(body_id);
|
||||||
let mut visitor = InteriorVisitor {
|
let mut visitor = InteriorVisitor {
|
||||||
fcx,
|
fcx,
|
||||||
|
@ -64,7 +70,9 @@ pub fn find_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, def_id: De
|
||||||
visitor.types.insert(fcx.tcx.types.bool);
|
visitor.types.insert(fcx.tcx.types.bool);
|
||||||
|
|
||||||
// Deduplicate types
|
// Deduplicate types
|
||||||
let set: FxHashSet<_> = visitor.types.into_iter().map(|t| fcx.resolve_type_vars_if_possible(&t)).collect();
|
let set: FxHashSet<_> = visitor.types.into_iter()
|
||||||
|
.map(|t| fcx.resolve_type_vars_if_possible(&t))
|
||||||
|
.collect();
|
||||||
let types: Vec<_> = set.into_iter().collect();
|
let types: Vec<_> = set.into_iter().collect();
|
||||||
|
|
||||||
let tuple = fcx.tcx.intern_tup(&types, false);
|
let tuple = fcx.tcx.intern_tup(&types, false);
|
||||||
|
|
|
@ -2567,7 +2567,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_closure = match arg.node {
|
let is_closure = match arg.node {
|
||||||
// TODO: Should this be applied for generators?
|
// FIXME: Should this be applied for generators?
|
||||||
hir::ExprClosure(.., None) => true,
|
hir::ExprClosure(.., None) => true,
|
||||||
_ => false
|
_ => false
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue