mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
librustc_lint: use bug!(), span_bug!()
This commit is contained in:
@@ -30,7 +30,7 @@ pub enum MethodLateContext {
|
||||
pub fn method_context(cx: &LateContext, id: ast::NodeId, span: Span) -> MethodLateContext {
|
||||
let def_id = cx.tcx.map.local_def_id(id);
|
||||
match cx.tcx.impl_or_trait_items.borrow().get(&def_id) {
|
||||
None => cx.sess().span_bug(span, "missing method descriptor?!"),
|
||||
None => span_bug!(span, "missing method descriptor?!"),
|
||||
Some(item) => match item.container() {
|
||||
ty::TraitContainer(..) => MethodLateContext::TraitDefaultImpl,
|
||||
ty::ImplContainer(cid) => {
|
||||
|
||||
@@ -181,7 +181,7 @@ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
};
|
||||
},
|
||||
ty::TyUint(t) => {
|
||||
@@ -195,7 +195,7 @@ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
|
||||
// _v is u8, within range by definition
|
||||
ast::LitKind::Byte(_v) => return,
|
||||
ast::LitKind::Int(v, _) => v,
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
};
|
||||
if lit_val < min || lit_val > max {
|
||||
cx.span_lint(OVERFLOWING_LITERALS, e.span,
|
||||
@@ -212,7 +212,7 @@ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
|
||||
Err(_) => return
|
||||
}
|
||||
}
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
};
|
||||
if lit_val < min || lit_val > max {
|
||||
cx.span_lint(OVERFLOWING_LITERALS, e.span,
|
||||
@@ -233,7 +233,7 @@ fn is_valid<T:cmp::PartialOrd>(binop: hir::BinOp, v: T,
|
||||
hir::BiGt => v >= min && v < max,
|
||||
hir::BiGe => v > min && v <= max,
|
||||
hir::BiEq | hir::BiNe => v >= min && v <= max,
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ fn check_limits(tcx: &TyCtxt, binop: hir::BinOp,
|
||||
ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => v as i64,
|
||||
_ => return true
|
||||
},
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
};
|
||||
is_valid(norm_binop, lit_val, min, max)
|
||||
}
|
||||
@@ -330,7 +330,7 @@ fn check_limits(tcx: &TyCtxt, binop: hir::BinOp,
|
||||
ast::LitKind::Int(v, _) => v,
|
||||
_ => return true
|
||||
},
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
};
|
||||
is_valid(norm_binop, lit_val, min, max)
|
||||
}
|
||||
@@ -589,7 +589,7 @@ fn check_type_for_ffi(&self,
|
||||
ty::TyParam(..) | ty::TyInfer(..) | ty::TyError |
|
||||
ty::TyClosure(..) | ty::TyProjection(..) |
|
||||
ty::TyFnDef(..) => {
|
||||
panic!("Unexpected type in foreign function")
|
||||
bug!("Unexpected type in foreign function")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user