Auto merge of #32562 - ben0x539:bug-macro, r=nikomatsakis
librustc: Add bug!(), bug_span!() macros as unified entry points for internal compiler errors The macros pass `file!()`, `line!()` and `format_args!(...)` on to a cold, never-inlined function, ultimately calling `session::{span_,}bug_fmt` via the tcx in tls or, failing that, panicking directly. cc @eddyb r? @nikomatsakis
This commit is contained in:
commit
1af79cf34e
|
@ -583,13 +583,11 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||
return *l;
|
||||
}
|
||||
}
|
||||
self.tcx.sess.span_bug(expr.span,
|
||||
&format!("no loop scope for id {}", loop_id));
|
||||
span_bug!(expr.span, "no loop scope for id {}", loop_id);
|
||||
}
|
||||
|
||||
r => {
|
||||
self.tcx.sess.span_bug(expr.span,
|
||||
&format!("bad entry `{:?}` in def_map for label", r));
|
||||
span_bug!(expr.span, "bad entry `{:?}` in def_map for label", r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ impl DepGraphEdges {
|
|||
{
|
||||
match self.current_node() {
|
||||
Some(open_node) => self.add_edge_from_open_node(open_node, op),
|
||||
None => panic!("no current node, cannot add edge into dependency graph")
|
||||
None => bug!("no current node, cannot add edge into dependency graph")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ impl DepGraphThreadData {
|
|||
|
||||
// Outline this too.
|
||||
fn invalid_message(&self, string: &str) {
|
||||
panic!("{}; see src/librustc/dep_graph/README.md for more information", string)
|
||||
bug!("{}; see src/librustc/dep_graph/README.md for more information", string)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,13 +231,13 @@ impl<'a> FnLikeNode<'a> {
|
|||
span: i.span,
|
||||
attrs: &i.attrs,
|
||||
}),
|
||||
_ => panic!("item FnLikeNode that is not fn-like"),
|
||||
_ => bug!("item FnLikeNode that is not fn-like"),
|
||||
},
|
||||
map::NodeTraitItem(ti) => match ti.node {
|
||||
ast::MethodTraitItem(ref sig, Some(ref body)) => {
|
||||
method(ti.id, ti.name, sig, None, body, ti.span, &ti.attrs)
|
||||
}
|
||||
_ => panic!("trait method FnLikeNode that is not fn-like"),
|
||||
_ => bug!("trait method FnLikeNode that is not fn-like"),
|
||||
},
|
||||
map::NodeImplItem(ii) => {
|
||||
match ii.node {
|
||||
|
@ -245,7 +245,7 @@ impl<'a> FnLikeNode<'a> {
|
|||
method(ii.id, ii.name, sig, Some(ii.vis), body, ii.span, &ii.attrs)
|
||||
}
|
||||
_ => {
|
||||
panic!("impl method FnLikeNode that is not fn-like")
|
||||
bug!("impl method FnLikeNode that is not fn-like")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,9 +256,9 @@ impl<'a> FnLikeNode<'a> {
|
|||
e.id,
|
||||
e.span,
|
||||
e.attrs.as_attr_slice())),
|
||||
_ => panic!("expr FnLikeNode that is not fn-like"),
|
||||
_ => bug!("expr FnLikeNode that is not fn-like"),
|
||||
},
|
||||
_ => panic!("other FnLikeNode that is not fn-like"),
|
||||
_ => bug!("other FnLikeNode that is not fn-like"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -335,9 +335,9 @@ impl<'ast> Map<'ast> {
|
|||
return self.opt_local_def_id(id)
|
||||
.map(|def_id| DepNode::Hir(def_id))
|
||||
.unwrap_or_else(|| {
|
||||
panic!("Walking parents from `{}` \
|
||||
led to `NotPresent` at `{}`",
|
||||
id0, id)
|
||||
bug!("Walking parents from `{}` \
|
||||
led to `NotPresent` at `{}`",
|
||||
id0, id)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
@ -363,8 +363,8 @@ impl<'ast> Map<'ast> {
|
|||
|
||||
pub fn local_def_id(&self, node: NodeId) -> DefId {
|
||||
self.opt_local_def_id(node).unwrap_or_else(|| {
|
||||
panic!("local_def_id: no entry for `{}`, which has a map of `{:?}`",
|
||||
node, self.find_entry(node))
|
||||
bug!("local_def_id: no entry for `{}`, which has a map of `{:?}`",
|
||||
node, self.find_entry(node))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ impl<'ast> Map<'ast> {
|
|||
pub fn get(&self, id: NodeId) -> Node<'ast> {
|
||||
match self.find(id) {
|
||||
Some(node) => node, // read recorded by `find`
|
||||
None => panic!("couldn't find node id {} in the AST map", id)
|
||||
None => bug!("couldn't find node id {} in the AST map", id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -576,7 +576,7 @@ impl<'ast> Map<'ast> {
|
|||
self.read(id); // reveals some of the content of a node
|
||||
abi
|
||||
}
|
||||
None => panic!("expected foreign mod or inlined parent, found {}",
|
||||
None => bug!("expected foreign mod or inlined parent, found {}",
|
||||
self.node_to_string(parent))
|
||||
}
|
||||
}
|
||||
|
@ -584,14 +584,14 @@ impl<'ast> Map<'ast> {
|
|||
pub fn expect_item(&self, id: NodeId) -> &'ast Item {
|
||||
match self.find(id) { // read recorded by `find`
|
||||
Some(NodeItem(item)) => item,
|
||||
_ => panic!("expected item, found {}", self.node_to_string(id))
|
||||
_ => bug!("expected item, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_trait_item(&self, id: NodeId) -> &'ast TraitItem {
|
||||
match self.find(id) {
|
||||
Some(NodeTraitItem(item)) => item,
|
||||
_ => panic!("expected trait item, found {}", self.node_to_string(id))
|
||||
_ => bug!("expected trait item, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -600,38 +600,38 @@ impl<'ast> Map<'ast> {
|
|||
Some(NodeItem(i)) => {
|
||||
match i.node {
|
||||
ItemStruct(ref struct_def, _) => struct_def,
|
||||
_ => panic!("struct ID bound to non-struct")
|
||||
_ => bug!("struct ID bound to non-struct")
|
||||
}
|
||||
}
|
||||
Some(NodeVariant(variant)) => {
|
||||
if variant.node.data.is_struct() {
|
||||
&variant.node.data
|
||||
} else {
|
||||
panic!("struct ID bound to enum variant that isn't struct-like")
|
||||
bug!("struct ID bound to enum variant that isn't struct-like")
|
||||
}
|
||||
}
|
||||
_ => panic!(format!("expected struct, found {}", self.node_to_string(id))),
|
||||
_ => bug!("expected struct, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_variant(&self, id: NodeId) -> &'ast Variant {
|
||||
match self.find(id) {
|
||||
Some(NodeVariant(variant)) => variant,
|
||||
_ => panic!(format!("expected variant, found {}", self.node_to_string(id))),
|
||||
_ => bug!("expected variant, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_foreign_item(&self, id: NodeId) -> &'ast ForeignItem {
|
||||
match self.find(id) {
|
||||
Some(NodeForeignItem(item)) => item,
|
||||
_ => panic!("expected foreign item, found {}", self.node_to_string(id))
|
||||
_ => bug!("expected foreign item, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_expr(&self, id: NodeId) -> &'ast Expr {
|
||||
match self.find(id) { // read recorded by find
|
||||
Some(NodeExpr(expr)) => expr,
|
||||
_ => panic!("expected expr, found {}", self.node_to_string(id))
|
||||
_ => bug!("expected expr, found {}", self.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,7 @@ impl<'ast> Map<'ast> {
|
|||
NodeLocal(&Pat { node: PatKind::Ident(_,l,_), .. }) => {
|
||||
PathName(l.node.name)
|
||||
},
|
||||
_ => panic!("no path elem for {:?}", node)
|
||||
_ => bug!("no path elem for {:?}", node)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -773,7 +773,7 @@ impl<'ast> Map<'ast> {
|
|||
pub fn span(&self, id: NodeId) -> Span {
|
||||
self.read(id); // reveals span from node
|
||||
self.opt_span(id)
|
||||
.unwrap_or_else(|| panic!("AstMap.span: could not find span for id {:?}", id))
|
||||
.unwrap_or_else(|| bug!("AstMap.span: could not find span for id {:?}", id))
|
||||
}
|
||||
|
||||
pub fn span_if_local(&self, id: DefId) -> Option<Span> {
|
||||
|
@ -1019,12 +1019,12 @@ impl<'a> NodePrinter for pprust::State<'a> {
|
|||
NodePat(a) => self.print_pat(&a),
|
||||
NodeBlock(a) => self.print_block(&a),
|
||||
NodeLifetime(a) => self.print_lifetime(&a),
|
||||
NodeTyParam(_) => panic!("cannot print TyParam"),
|
||||
NodeTyParam(_) => bug!("cannot print TyParam"),
|
||||
// these cases do not carry enough information in the
|
||||
// ast_map to reconstruct their full structure for pretty
|
||||
// printing.
|
||||
NodeLocal(_) => panic!("cannot print isolated Local"),
|
||||
NodeStructCtor(_) => panic!("cannot print isolated StructCtor"),
|
||||
NodeLocal(_) => bug!("cannot print isolated Local"),
|
||||
NodeStructCtor(_) => bug!("cannot print isolated StructCtor"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -339,10 +339,10 @@ impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
|
|||
// Early-bound regions should really have been substituted away before
|
||||
// we get to this point.
|
||||
ty::ReEarlyBound(..) => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
self.span,
|
||||
&format!("Encountered early bound region when generalizing: {:?}",
|
||||
r));
|
||||
"Encountered early bound region when generalizing: {:?}",
|
||||
r);
|
||||
}
|
||||
|
||||
// Always make a fresh region variable for skolemized regions;
|
||||
|
|
|
@ -404,7 +404,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
bound_failures.push((origin.clone(), kind.clone(), region));
|
||||
}
|
||||
ProcessedErrors(..) => {
|
||||
panic!("should not encounter a `ProcessedErrors` yet: {:?}", error)
|
||||
bug!("should not encounter a `ProcessedErrors` yet: {:?}", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,11 +140,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
|
|||
ty::TyInfer(ty::FreshIntTy(c)) |
|
||||
ty::TyInfer(ty::FreshFloatTy(c)) => {
|
||||
if c >= self.freshen_count {
|
||||
tcx.sess.bug(
|
||||
&format!("Encountered a freshend type with id {} \
|
||||
but our counter is only at {}",
|
||||
c,
|
||||
self.freshen_count));
|
||||
bug!("Encountered a freshend type with id {} \
|
||||
but our counter is only at {}",
|
||||
c,
|
||||
self.freshen_count);
|
||||
}
|
||||
t
|
||||
}
|
||||
|
|
|
@ -183,11 +183,10 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
infcx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("region {:?} is not associated with \
|
||||
any bound region from A!",
|
||||
r0))
|
||||
"region {:?} is not associated with any bound region from A!",
|
||||
r0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +296,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
|
||||
if a_r.is_some() && b_r.is_some() && only_new_vars {
|
||||
// Related to exactly one bound variable from each fn:
|
||||
return rev_lookup(infcx, span, a_map, a_r.unwrap());
|
||||
return rev_lookup(span, a_map, a_r.unwrap());
|
||||
} else if a_r.is_none() && b_r.is_none() {
|
||||
// Not related to bound variables from either fn:
|
||||
assert!(!r0.is_bound());
|
||||
|
@ -308,8 +307,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn rev_lookup(infcx: &InferCtxt,
|
||||
span: Span,
|
||||
fn rev_lookup(span: Span,
|
||||
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
|
||||
r: ty::Region) -> ty::Region
|
||||
{
|
||||
|
@ -318,9 +316,10 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
|||
return ty::ReLateBound(ty::DebruijnIndex::new(1), *a_br);
|
||||
}
|
||||
}
|
||||
infcx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("could not find original bound region for {:?}", r));
|
||||
"could not find original bound region for {:?}",
|
||||
r);
|
||||
}
|
||||
|
||||
fn fresh_bound_variable(infcx: &InferCtxt, debruijn: ty::DebruijnIndex) -> ty::Region {
|
||||
|
@ -336,9 +335,10 @@ fn var_ids<'a, 'tcx>(fields: &CombineFields<'a, 'tcx>,
|
|||
.map(|(_, r)| match *r {
|
||||
ty::ReVar(r) => { r }
|
||||
r => {
|
||||
fields.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
fields.trace.origin.span(),
|
||||
&format!("found non-region-vid: {:?}", r));
|
||||
"found non-region-vid: {:?}",
|
||||
r);
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
|
|
@ -471,7 +471,7 @@ pub fn mk_eq_impl_headers<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
|||
match (a.trait_ref, b.trait_ref) {
|
||||
(Some(a_ref), Some(b_ref)) => mk_eq_trait_refs(cx, a_is_expected, origin, a_ref, b_ref),
|
||||
(None, None) => mk_eqty(cx, a_is_expected, origin, a.self_ty, b.self_ty),
|
||||
_ => cx.tcx.sess.bug("mk_eq_impl_headers given mismatched impl kinds"),
|
||||
_ => bug!("mk_eq_impl_headers given mismatched impl kinds"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -536,10 +536,10 @@ pub fn drain_fulfillment_cx_or_panic<'a,'tcx,T>(span: Span,
|
|||
match drain_fulfillment_cx(infcx, fulfill_cx, result) {
|
||||
Ok(v) => v,
|
||||
Err(errors) => {
|
||||
infcx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("Encountered errors `{:?}` fulfilling during trans",
|
||||
errors));
|
||||
"Encountered errors `{:?}` fulfilling during trans",
|
||||
errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1114,9 +1114,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
None if self.errors_since_creation() =>
|
||||
self.tcx.types.err,
|
||||
None => {
|
||||
self.tcx.sess.bug(
|
||||
&format!("no type for node {}: {} in fcx",
|
||||
id, self.tcx.map.node_to_string(id)));
|
||||
bug!("no type for node {}: {} in fcx",
|
||||
id, self.tcx.map.node_to_string(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1125,7 +1124,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
match self.tables.borrow().node_types.get(&ex.id) {
|
||||
Some(&t) => t,
|
||||
None => {
|
||||
self.tcx.sess.bug("no type for expr in fcx");
|
||||
bug!("no type for expr in fcx");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
|
|||
};
|
||||
|
||||
if output_template.is_empty() {
|
||||
tcx.sess.bug("empty string provided as RUST_REGION_GRAPH");
|
||||
bug!("empty string provided as RUST_REGION_GRAPH");
|
||||
}
|
||||
|
||||
if output_template.contains('%') {
|
||||
|
@ -182,13 +182,13 @@ impl<'a, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'tcx> {
|
|||
fn node_id(&self, n: &Node) -> dot::Id {
|
||||
let node_id = match self.node_ids.get(n) {
|
||||
Some(node_id) => node_id,
|
||||
None => panic!("no node_id found for node: {:?}", n),
|
||||
None => bug!("no node_id found for node: {:?}", n),
|
||||
};
|
||||
let name = || format!("node_{}", node_id);
|
||||
match dot::Id::new(name()) {
|
||||
Ok(id) => id,
|
||||
Err(_) => {
|
||||
panic!("failed to create graphviz node identified by {}", name());
|
||||
bug!("failed to create graphviz node identified by {}", name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
while undo_log.len() > snapshot.length + 1 {
|
||||
match undo_log.pop().unwrap() {
|
||||
OpenSnapshot => {
|
||||
panic!("Failure to observe stack discipline");
|
||||
bug!("Failure to observe stack discipline");
|
||||
}
|
||||
CommitedSnapshot => {}
|
||||
AddVar(vid) => {
|
||||
|
@ -413,7 +413,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
self.bound_count.set(sc + 1);
|
||||
|
||||
if sc >= self.bound_count.get() {
|
||||
self.tcx.sess.bug("rollover in RegionInference new_bound()");
|
||||
bug!("rollover in RegionInference new_bound()");
|
||||
}
|
||||
|
||||
ReLateBound(debruijn, BrFresh(sc))
|
||||
|
@ -497,10 +497,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
(ReLateBound(..), _) |
|
||||
(_, ReEarlyBound(..)) |
|
||||
(_, ReLateBound(..)) => {
|
||||
self.tcx.sess.span_bug(origin.span(),
|
||||
&format!("cannot relate bound region: {:?} <= {:?}",
|
||||
sub,
|
||||
sup));
|
||||
span_bug!(origin.span(),
|
||||
"cannot relate bound region: {:?} <= {:?}",
|
||||
sub,
|
||||
sup);
|
||||
}
|
||||
(_, ReStatic) => {
|
||||
// all regions are subregions of static, so we can ignore this
|
||||
|
@ -570,9 +570,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
pub fn resolve_var(&self, rid: RegionVid) -> ty::Region {
|
||||
match *self.values.borrow() {
|
||||
None => {
|
||||
self.tcx.sess.span_bug((*self.var_origins.borrow())[rid.index as usize].span(),
|
||||
"attempt to resolve region variable before values have \
|
||||
been computed!")
|
||||
span_bug!((*self.var_origins.borrow())[rid.index as usize].span(),
|
||||
"attempt to resolve region variable before values have \
|
||||
been computed!")
|
||||
}
|
||||
Some(ref values) => {
|
||||
let r = lookup(values, rid);
|
||||
|
@ -733,7 +733,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
(_, ReLateBound(..)) |
|
||||
(ReEarlyBound(..), _) |
|
||||
(_, ReEarlyBound(..)) => {
|
||||
self.tcx.sess.bug(&format!("cannot relate bound region: LUB({:?}, {:?})", a, b));
|
||||
bug!("cannot relate bound region: LUB({:?}, {:?})", a, b);
|
||||
}
|
||||
|
||||
(ReStatic, _) | (_, ReStatic) => {
|
||||
|
@ -745,11 +745,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
}
|
||||
|
||||
(ReVar(v_id), _) | (_, ReVar(v_id)) => {
|
||||
self.tcx.sess.span_bug((*self.var_origins.borrow())[v_id.index as usize].span(),
|
||||
&format!("lub_concrete_regions invoked with non-concrete \
|
||||
regions: {:?}, {:?}",
|
||||
a,
|
||||
b));
|
||||
span_bug!((*self.var_origins.borrow())[v_id.index as usize].span(),
|
||||
"lub_concrete_regions invoked with non-concrete \
|
||||
regions: {:?}, {:?}",
|
||||
a,
|
||||
b);
|
||||
}
|
||||
|
||||
(ReFree(ref fr), ReScope(s_id)) |
|
||||
|
@ -1193,13 +1193,13 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
self.tcx.sess.span_bug((*self.var_origins.borrow())[node_idx.index as usize].span(),
|
||||
&format!("collect_error_for_expanding_node() could not find \
|
||||
error for var {:?}, lower_bounds={:?}, \
|
||||
upper_bounds={:?}",
|
||||
node_idx,
|
||||
lower_bounds,
|
||||
upper_bounds));
|
||||
span_bug!((*self.var_origins.borrow())[node_idx.index as usize].span(),
|
||||
"collect_error_for_expanding_node() could not find \
|
||||
error for var {:?}, lower_bounds={:?}, \
|
||||
upper_bounds={:?}",
|
||||
node_idx,
|
||||
lower_bounds,
|
||||
upper_bounds);
|
||||
}
|
||||
|
||||
fn collect_concrete_regions(&self,
|
||||
|
|
|
@ -127,9 +127,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
|||
self.tcx().types.err
|
||||
}
|
||||
ty::TyInfer(_) => {
|
||||
self.infcx.tcx.sess.bug(
|
||||
&format!("Unexpected type in full type resolver: {:?}",
|
||||
t));
|
||||
bug!("Unexpected type in full type resolver: {:?}", t);
|
||||
}
|
||||
_ => {
|
||||
t.super_fold_with(self)
|
||||
|
|
|
@ -159,8 +159,8 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
|
||||
let (relations, default) = match old_value {
|
||||
Bounded { relations, default } => (relations, default),
|
||||
Known(_) => panic!("Asked to instantiate variable that is \
|
||||
already instantiated")
|
||||
Known(_) => bug!("Asked to instantiate variable that is \
|
||||
already instantiated")
|
||||
};
|
||||
|
||||
for &(dir, vid) in &relations {
|
||||
|
@ -259,7 +259,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
// quick check to see if this variable was
|
||||
// created since the snapshot started or not.
|
||||
let escaping_type = match self.values.get(vid.index as usize).value {
|
||||
Bounded { .. } => unreachable!(),
|
||||
Bounded { .. } => bug!(),
|
||||
Known(ty) => ty,
|
||||
};
|
||||
escaping_types.push(escaping_type);
|
||||
|
@ -318,7 +318,7 @@ impl<'tcx> sv::SnapshotVecDelegate for Delegate<'tcx> {
|
|||
|
||||
fn relations<'a>(v: &'a mut TypeVariableData) -> &'a mut Vec<Relation> {
|
||||
match v.value {
|
||||
Known(_) => panic!("var_sub_var: variable is known"),
|
||||
Known(_) => bug!("var_sub_var: variable is known"),
|
||||
Bounded { ref mut relations, .. } => relations
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ impl LintStore {
|
|||
// We load builtin lints first, so a duplicate is a compiler bug.
|
||||
// Use early_error when handling -W help with no crate.
|
||||
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
|
||||
(Some(sess), false) => sess.bug(&msg[..]),
|
||||
(Some(_), false) => bug!("{}", msg),
|
||||
|
||||
// A duplicate name from a plugin is a user error.
|
||||
(Some(sess), true) => sess.err(&msg[..]),
|
||||
|
@ -221,7 +221,7 @@ impl LintStore {
|
|||
// We load builtin lints first, so a duplicate is a compiler bug.
|
||||
// Use early_error when handling -W help with no crate.
|
||||
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
|
||||
(Some(sess), false) => sess.bug(&msg[..]),
|
||||
(Some(_), false) => bug!("{}", msg),
|
||||
|
||||
// A duplicate name from a plugin is a user error.
|
||||
(Some(sess), true) => sess.err(&msg[..]),
|
||||
|
@ -232,7 +232,7 @@ impl LintStore {
|
|||
pub fn register_renamed(&mut self, old_name: &str, new_name: &str) {
|
||||
let target = match self.by_name.get(new_name) {
|
||||
Some(&Id(lint_id)) => lint_id.clone(),
|
||||
_ => panic!("invalid lint renaming of {} to {}", old_name, new_name)
|
||||
_ => bug!("invalid lint renaming of {} to {}", old_name, new_name)
|
||||
};
|
||||
self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target));
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
|
|||
format!("{} [-{} {}]", msg,
|
||||
match level {
|
||||
Warn => 'W', Deny => 'D', Forbid => 'F',
|
||||
Allow => panic!()
|
||||
Allow => bug!()
|
||||
}, name.replace("_", "-"))
|
||||
},
|
||||
Node(src) => {
|
||||
|
@ -447,7 +447,7 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
|
|||
(Warn, None) => sess.struct_warn(&msg[..]),
|
||||
(Deny, Some(sp)) => sess.struct_span_err(sp, &msg[..]),
|
||||
(Deny, None) => sess.struct_err(&msg[..]),
|
||||
_ => sess.bug("impossible level in raw_emit_lint"),
|
||||
_ => bug!("impossible level in raw_emit_lint"),
|
||||
};
|
||||
|
||||
// Check for future incompatibility lints and issue a stronger warning.
|
||||
|
@ -1275,9 +1275,9 @@ pub fn check_crate(tcx: &TyCtxt, access_levels: &AccessLevels) {
|
|||
// in the iteration code.
|
||||
for (id, v) in tcx.sess.lints.borrow().iter() {
|
||||
for &(lint, span, ref msg) in v {
|
||||
tcx.sess.span_bug(span,
|
||||
&format!("unprocessed lint {} at {}: {}",
|
||||
lint.as_str(), tcx.map.node_to_string(*id), *msg))
|
||||
span_bug!(span,
|
||||
"unprocessed lint {} at {}: {}",
|
||||
lint.as_str(), tcx.map.node_to_string(*id), *msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1314,9 +1314,7 @@ pub fn check_ast_crate(sess: &Session, krate: &ast::Crate) {
|
|||
// in the iteration code.
|
||||
for (_, v) in sess.lints.borrow().iter() {
|
||||
for &(lint, span, ref msg) in v {
|
||||
sess.span_bug(span,
|
||||
&format!("unprocessed lint {}: {}",
|
||||
lint.as_str(), *msg))
|
||||
span_bug!(span, "unprocessed lint {}: {}", lint.as_str(), *msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,3 +44,18 @@ macro_rules! enum_from_u32 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! bug {
|
||||
() => ( bug!("impossible case reached") );
|
||||
($($message:tt)*) => ({
|
||||
$crate::session::bug_fmt(file!(), line!(), format_args!($($message)*))
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! span_bug {
|
||||
($span:expr, $($message:tt)*) => ({
|
||||
$crate::session::span_bug_fmt(file!(), line!(), $span, format_args!($($message)*))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -67,8 +67,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &TyCtxt<'tcx>, ast_ty: &ast::Ty)
|
|||
if let ast::TyPath(None, ref path) = ast_ty.node {
|
||||
let def = match tcx.def_map.borrow().get(&ast_ty.id) {
|
||||
None => {
|
||||
tcx.sess.span_bug(ast_ty.span,
|
||||
&format!("unbound path {:?}", path))
|
||||
span_bug!(ast_ty.span, "unbound path {:?}", path)
|
||||
}
|
||||
Some(d) => d.full_def()
|
||||
};
|
||||
|
|
|
@ -309,7 +309,7 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
|
|||
{
|
||||
let mut say = |s: &str| {
|
||||
match (sp, sess) {
|
||||
(_, None) => panic!("{}", s),
|
||||
(_, None) => bug!("{}", s),
|
||||
(Some(sp), Some(sess)) => sess.span_err(sp, s),
|
||||
(None, Some(sess)) => sess.err(s),
|
||||
}
|
||||
|
@ -336,121 +336,123 @@ pub struct DummyCrateStore;
|
|||
#[allow(unused_variables)]
|
||||
impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
||||
// item info
|
||||
fn stability(&self, def: DefId) -> Option<attr::Stability> { unimplemented!() }
|
||||
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { unimplemented!() }
|
||||
fn visibility(&self, def: DefId) -> hir::Visibility { unimplemented!() }
|
||||
fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
|
||||
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
|
||||
fn visibility(&self, def: DefId) -> hir::Visibility { bug!("visibility") }
|
||||
fn closure_kind(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
|
||||
-> ty::ClosureKind { unimplemented!() }
|
||||
-> ty::ClosureKind { bug!("closure_kind") }
|
||||
fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
|
||||
-> ty::ClosureTy<'tcx> { unimplemented!() }
|
||||
fn item_variances(&self, def: DefId) -> ty::ItemVariances { unimplemented!() }
|
||||
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { unimplemented!() }
|
||||
-> ty::ClosureTy<'tcx> { bug!("closure_ty") }
|
||||
fn item_variances(&self, def: DefId) -> ty::ItemVariances { bug!("item_variances") }
|
||||
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { bug!("repr_attrs") }
|
||||
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> ty::TypeScheme<'tcx> { unimplemented!() }
|
||||
fn relative_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() }
|
||||
-> ty::TypeScheme<'tcx> { bug!("item_type") }
|
||||
fn relative_item_path(&self, def: DefId)
|
||||
-> Vec<hir_map::PathElem> { bug!("relative_item_path") }
|
||||
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
|
||||
unimplemented!()
|
||||
bug!("visible_parent_map")
|
||||
}
|
||||
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() }
|
||||
fn item_name(&self, def: DefId) -> ast::Name { unimplemented!() }
|
||||
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { bug!("extern_item_path") }
|
||||
fn item_name(&self, def: DefId) -> ast::Name { bug!("item_name") }
|
||||
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> ty::GenericPredicates<'tcx> { unimplemented!() }
|
||||
-> ty::GenericPredicates<'tcx> { bug!("item_predicates") }
|
||||
fn item_super_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> ty::GenericPredicates<'tcx> { unimplemented!() }
|
||||
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { unimplemented!() }
|
||||
fn item_symbol(&self, def: DefId) -> String { unimplemented!() }
|
||||
-> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
|
||||
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
|
||||
fn item_symbol(&self, def: DefId) -> String { bug!("item_symbol") }
|
||||
fn trait_def(&self, tcx: &TyCtxt<'tcx>, def: DefId)-> ty::TraitDef<'tcx>
|
||||
{ unimplemented!() }
|
||||
{ bug!("trait_def") }
|
||||
fn adt_def(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
|
||||
{ unimplemented!() }
|
||||
fn method_arg_names(&self, did: DefId) -> Vec<String> { unimplemented!() }
|
||||
{ bug!("adt_def") }
|
||||
fn method_arg_names(&self, did: DefId) -> Vec<String> { bug!("method_arg_names") }
|
||||
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] }
|
||||
|
||||
// trait info
|
||||
fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId> { vec![] }
|
||||
fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> Vec<Rc<ty::Method<'tcx>>> { unimplemented!() }
|
||||
-> Vec<Rc<ty::Method<'tcx>>> { bug!("provided_trait_methods") }
|
||||
fn trait_item_def_ids(&self, def: DefId)
|
||||
-> Vec<ty::ImplOrTraitItemId> { unimplemented!() }
|
||||
-> Vec<ty::ImplOrTraitItemId> { bug!("trait_item_def_ids") }
|
||||
|
||||
// impl info
|
||||
fn impl_items(&self, impl_def_id: DefId) -> Vec<ty::ImplOrTraitItemId>
|
||||
{ unimplemented!() }
|
||||
{ bug!("impl_items") }
|
||||
fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> Option<ty::TraitRef<'tcx>> { unimplemented!() }
|
||||
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity> { unimplemented!() }
|
||||
-> Option<ty::TraitRef<'tcx>> { bug!("impl_trait_ref") }
|
||||
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity> { bug!("impl_polarity") }
|
||||
fn custom_coerce_unsized_kind(&self, def: DefId)
|
||||
-> Option<ty::adjustment::CustomCoerceUnsized>
|
||||
{ unimplemented!() }
|
||||
{ bug!("custom_coerce_unsized_kind") }
|
||||
fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> Vec<Rc<ty::AssociatedConst<'tcx>>> { unimplemented!() }
|
||||
fn impl_parent(&self, def: DefId) -> Option<DefId> { unimplemented!() }
|
||||
-> Vec<Rc<ty::AssociatedConst<'tcx>>> { bug!("associated_consts") }
|
||||
fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }
|
||||
|
||||
// trait/impl-item info
|
||||
fn trait_of_item(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
|
||||
-> Option<DefId> { unimplemented!() }
|
||||
-> Option<DefId> { bug!("trait_of_item") }
|
||||
fn impl_or_trait_item(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> Option<ty::ImplOrTraitItem<'tcx>> { unimplemented!() }
|
||||
-> Option<ty::ImplOrTraitItem<'tcx>> { bug!("impl_or_trait_item") }
|
||||
|
||||
// flags
|
||||
fn is_const_fn(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_defaulted_trait(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_impl(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool { unimplemented!() }
|
||||
fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_static_method(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
|
||||
fn is_defaulted_trait(&self, did: DefId) -> bool { bug!("is_defaulted_trait") }
|
||||
fn is_impl(&self, did: DefId) -> bool { bug!("is_impl") }
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
|
||||
fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool { bug!("is_extern_item") }
|
||||
fn is_static_method(&self, did: DefId) -> bool { bug!("is_static_method") }
|
||||
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool { false }
|
||||
fn is_typedef(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_typedef(&self, did: DefId) -> bool { bug!("is_typedef") }
|
||||
|
||||
// crate metadata
|
||||
fn dylib_dependency_formats(&self, cnum: ast::CrateNum)
|
||||
-> Vec<(ast::CrateNum, LinkagePreference)>
|
||||
{ unimplemented!() }
|
||||
{ bug!("dylib_dependency_formats") }
|
||||
fn lang_items(&self, cnum: ast::CrateNum) -> Vec<(DefIndex, usize)>
|
||||
{ unimplemented!() }
|
||||
{ bug!("lang_items") }
|
||||
fn missing_lang_items(&self, cnum: ast::CrateNum) -> Vec<lang_items::LangItem>
|
||||
{ unimplemented!() }
|
||||
fn is_staged_api(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
|
||||
fn is_explicitly_linked(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
|
||||
fn is_allocator(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
|
||||
fn extern_crate(&self, cnum: ast::CrateNum) -> Option<ExternCrate> { unimplemented!() }
|
||||
{ bug!("missing_lang_items") }
|
||||
fn is_staged_api(&self, cnum: ast::CrateNum) -> bool { bug!("is_staged_api") }
|
||||
fn is_explicitly_linked(&self, cnum: ast::CrateNum) -> bool { bug!("is_explicitly_linked") }
|
||||
fn is_allocator(&self, cnum: ast::CrateNum) -> bool { bug!("is_allocator") }
|
||||
fn extern_crate(&self, cnum: ast::CrateNum) -> Option<ExternCrate> { bug!("extern_crate") }
|
||||
fn crate_attrs(&self, cnum: ast::CrateNum) -> Vec<ast::Attribute>
|
||||
{ unimplemented!() }
|
||||
fn crate_name(&self, cnum: ast::CrateNum) -> InternedString { unimplemented!() }
|
||||
{ bug!("crate_attrs") }
|
||||
fn crate_name(&self, cnum: ast::CrateNum) -> InternedString { bug!("crate_name") }
|
||||
fn original_crate_name(&self, cnum: ast::CrateNum) -> InternedString {
|
||||
unimplemented!()
|
||||
bug!("original_crate_name")
|
||||
}
|
||||
fn crate_hash(&self, cnum: ast::CrateNum) -> Svh { unimplemented!() }
|
||||
fn crate_disambiguator(&self, cnum: ast::CrateNum) -> InternedString { unimplemented!() }
|
||||
fn crate_hash(&self, cnum: ast::CrateNum) -> Svh { bug!("crate_hash") }
|
||||
fn crate_disambiguator(&self, cnum: ast::CrateNum)
|
||||
-> InternedString { bug!("crate_disambiguator") }
|
||||
fn crate_struct_field_attrs(&self, cnum: ast::CrateNum)
|
||||
-> FnvHashMap<DefId, Vec<ast::Attribute>>
|
||||
{ unimplemented!() }
|
||||
{ bug!("crate_struct_field_attrs") }
|
||||
fn plugin_registrar_fn(&self, cnum: ast::CrateNum) -> Option<DefId>
|
||||
{ unimplemented!() }
|
||||
{ bug!("plugin_registrar_fn") }
|
||||
fn native_libraries(&self, cnum: ast::CrateNum) -> Vec<(NativeLibraryKind, String)>
|
||||
{ unimplemented!() }
|
||||
fn reachable_ids(&self, cnum: ast::CrateNum) -> Vec<DefId> { unimplemented!() }
|
||||
{ bug!("native_libraries") }
|
||||
fn reachable_ids(&self, cnum: ast::CrateNum) -> Vec<DefId> { bug!("reachable_ids") }
|
||||
|
||||
// resolve
|
||||
fn def_key(&self, def: DefId) -> hir_map::DefKey { unimplemented!() }
|
||||
fn relative_def_path(&self, def: DefId) -> hir_map::DefPath { unimplemented!() }
|
||||
fn variant_kind(&self, def_id: DefId) -> Option<VariantKind> { unimplemented!() }
|
||||
fn def_key(&self, def: DefId) -> hir_map::DefKey { bug!("def_key") }
|
||||
fn relative_def_path(&self, def: DefId) -> hir_map::DefPath { bug!("relative_def_path") }
|
||||
fn variant_kind(&self, def_id: DefId) -> Option<VariantKind> { bug!("variant_kind") }
|
||||
fn struct_ctor_def_id(&self, struct_def_id: DefId) -> Option<DefId>
|
||||
{ unimplemented!() }
|
||||
{ bug!("struct_ctor_def_id") }
|
||||
fn tuple_struct_definition_if_ctor(&self, did: DefId) -> Option<DefId>
|
||||
{ unimplemented!() }
|
||||
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { unimplemented!() }
|
||||
fn item_children(&self, did: DefId) -> Vec<ChildItem> { unimplemented!() }
|
||||
{ bug!("tuple_struct_definition_if_ctor") }
|
||||
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { bug!("struct_field_names") }
|
||||
fn item_children(&self, did: DefId) -> Vec<ChildItem> { bug!("item_children") }
|
||||
fn crate_top_level_items(&self, cnum: ast::CrateNum) -> Vec<ChildItem>
|
||||
{ unimplemented!() }
|
||||
{ bug!("crate_top_level_items") }
|
||||
|
||||
// misc. metadata
|
||||
fn maybe_get_item_ast(&'tcx self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> FoundAst<'tcx> { unimplemented!() }
|
||||
-> FoundAst<'tcx> { bug!("maybe_get_item_ast") }
|
||||
fn maybe_get_item_mir(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||
-> Option<Mir<'tcx>> { unimplemented!() }
|
||||
-> Option<Mir<'tcx>> { bug!("maybe_get_item_mir") }
|
||||
fn is_item_mir_available(&self, def: DefId) -> bool {
|
||||
unimplemented!()
|
||||
bug!("is_item_mir_available")
|
||||
}
|
||||
|
||||
// This is basically a 1-based range of ints, which is a little
|
||||
|
@ -460,18 +462,18 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
fn used_link_args(&self) -> Vec<String> { vec![] }
|
||||
|
||||
// utility functions
|
||||
fn metadata_filename(&self) -> &str { unimplemented!() }
|
||||
fn metadata_section_name(&self, target: &Target) -> &str { unimplemented!() }
|
||||
fn metadata_filename(&self) -> &str { bug!("metadata_filename") }
|
||||
fn metadata_section_name(&self, target: &Target) -> &str { bug!("metadata_section_name") }
|
||||
fn encode_type(&self,
|
||||
tcx: &TyCtxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
def_id_to_string: fn(&TyCtxt<'tcx>, DefId) -> String)
|
||||
-> Vec<u8> {
|
||||
unimplemented!()
|
||||
bug!("encode_type")
|
||||
}
|
||||
fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<PathBuf>)>
|
||||
{ vec![] }
|
||||
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource { unimplemented!() }
|
||||
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource { bug!("used_crate_source") }
|
||||
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None }
|
||||
fn encode_metadata(&self,
|
||||
tcx: &TyCtxt<'tcx>,
|
||||
|
@ -481,7 +483,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
reachable: &NodeSet,
|
||||
mir_map: &MirMap<'tcx>,
|
||||
krate: &hir::Crate) -> Vec<u8> { vec![] }
|
||||
fn metadata_encoding_version(&self) -> &[u8] { unimplemented!() }
|
||||
fn metadata_encoding_version(&self) -> &[u8] { bug!("metadata_encoding_version") }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
if let ty::TyStruct(def, _) = self.tcx.expr_ty_adjusted(lhs).sty {
|
||||
self.insert_def_id(def.struct_variant().field_named(name).did);
|
||||
} else {
|
||||
self.tcx.sess.span_bug(lhs.span, "named field access on non-struct")
|
||||
span_bug!(lhs.span, "named field access on non-struct")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
let pat_ty = self.tcx.node_id_to_type(lhs.id);
|
||||
let variant = match pat_ty.sty {
|
||||
ty::TyStruct(adt, _) | ty::TyEnum(adt, _) => adt.variant_of_def(def),
|
||||
_ => self.tcx.sess.span_bug(lhs.span, "non-ADT in struct pattern")
|
||||
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
|
||||
};
|
||||
for pat in pats {
|
||||
if let PatKind::Wild = pat.node.pat.node {
|
||||
|
|
|
@ -71,7 +71,7 @@ impl PathResolution {
|
|||
/// Get the definition, if fully resolved, otherwise panic.
|
||||
pub fn full_def(&self) -> Def {
|
||||
if self.depth != 0 {
|
||||
panic!("path not fully resolved: {:?}", self);
|
||||
bug!("path not fully resolved: {:?}", self);
|
||||
}
|
||||
self.base_def
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ impl Def {
|
|||
Def::TyParam(..) | Def::Struct(..) | Def::Trait(..) |
|
||||
Def::Method(..) | Def::Const(..) | Def::AssociatedConst(..) |
|
||||
Def::PrimTy(..) | Def::Label(..) | Def::SelfTy(..) | Def::Err => {
|
||||
panic!("attempted .var_id() on invalid {:?}", self)
|
||||
bug!("attempted .var_id() on invalid {:?}", self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ impl Def {
|
|||
Def::PrimTy(..) |
|
||||
Def::SelfTy(..) |
|
||||
Def::Err => {
|
||||
panic!("attempted .def_id() on invalid def: {:?}", self)
|
||||
bug!("attempted .def_id() on invalid def: {:?}", self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ impl OverloadedCallType {
|
|||
}
|
||||
}
|
||||
|
||||
tcx.sess.bug("overloaded call didn't map to known function trait")
|
||||
bug!("overloaded call didn't map to known function trait")
|
||||
}
|
||||
|
||||
fn from_method_id(tcx: &TyCtxt, method_id: DefId)
|
||||
|
@ -564,9 +564,10 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
OverloadedCallType::from_method_id(self.tcx(), method_id)
|
||||
}
|
||||
None => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
callee.span,
|
||||
&format!("unexpected callee type {}", callee_ty))
|
||||
"unexpected callee type {}",
|
||||
callee_ty)
|
||||
}
|
||||
};
|
||||
match overloaded_call_type {
|
||||
|
@ -683,7 +684,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
// may not. This will generate an error earlier in typeck,
|
||||
// so we can just ignore it.
|
||||
if !self.tcx().sess.has_errors() {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
with_expr.span,
|
||||
"with expression doesn't evaluate to a struct");
|
||||
}
|
||||
|
@ -750,9 +751,9 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
|
||||
let (m, r) = match self_ty.sty {
|
||||
ty::TyRef(r, ref m) => (m.mutbl, r),
|
||||
_ => self.tcx().sess.span_bug(expr.span,
|
||||
&format!("bad overloaded deref type {:?}",
|
||||
method_ty))
|
||||
_ => span_bug!(expr.span,
|
||||
"bad overloaded deref type {:?}",
|
||||
method_ty)
|
||||
};
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
self.delegate.borrow(expr.id, expr.span, cmt,
|
||||
|
@ -934,7 +935,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr,
|
||||
pat);
|
||||
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| {
|
||||
let tcx = self.tcx();
|
||||
let def_map = &self.tcx().def_map;
|
||||
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
|
||||
match pat.node {
|
||||
|
@ -947,7 +947,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span,
|
||||
"binding pattern not an identifier");
|
||||
}
|
||||
|
@ -972,8 +972,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
let delegate = &mut self.delegate;
|
||||
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
|
||||
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
|
||||
let tcx = typer.tcx;
|
||||
|
||||
debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}",
|
||||
cmt_pat,
|
||||
pat,
|
||||
|
@ -1007,7 +1005,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
delegate.consume_pat(pat, cmt_pat, mode);
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span,
|
||||
"binding pattern not an identifier");
|
||||
}
|
||||
|
@ -1117,10 +1115,10 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
|||
// reported.
|
||||
|
||||
if !tcx.sess.has_errors() {
|
||||
let msg = format!("Pattern has unexpected def: {:?} and type {:?}",
|
||||
def,
|
||||
cmt_pat.ty);
|
||||
tcx.sess.span_bug(pat.span, &msg[..])
|
||||
span_bug!(pat.span,
|
||||
"Pattern has unexpected def: {:?} and type {:?}",
|
||||
def,
|
||||
cmt_pat.ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ impl FreeRegionMap {
|
|||
}
|
||||
|
||||
pub fn relate_free_regions_from_predicates<'tcx>(&mut self,
|
||||
tcx: &TyCtxt<'tcx>,
|
||||
_tcx: &TyCtxt<'tcx>,
|
||||
predicates: &[ty::Predicate<'tcx>]) {
|
||||
debug!("relate_free_regions_from_predicates(predicates={:?})", predicates);
|
||||
for predicate in predicates {
|
||||
|
@ -72,10 +72,9 @@ impl FreeRegionMap {
|
|||
}
|
||||
_ => {
|
||||
// All named regions are instantiated with free regions.
|
||||
tcx.sess.bug(
|
||||
&format!("record_region_bounds: non free region: {:?} / {:?}",
|
||||
r_a,
|
||||
r_b));
|
||||
bug!("record_region_bounds: non free region: {:?} / {:?}",
|
||||
r_a,
|
||||
r_b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
|||
let param_env = match self.param_envs.last() {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
self.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
"transmute encountered outside of any fn");
|
||||
}
|
||||
|
@ -245,9 +245,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
self.tcx
|
||||
.sess
|
||||
.span_bug(expr.span, "transmute wasn't a bare fn?!");
|
||||
span_bug!(expr.span, "transmute wasn't a bare fn?!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,13 +325,10 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
|
|||
|
||||
fn variable(&self, node_id: NodeId, span: Span) -> Variable {
|
||||
match self.variable_map.get(&node_id) {
|
||||
Some(&var) => var,
|
||||
None => {
|
||||
self.tcx
|
||||
.sess
|
||||
.span_bug(span, &format!("no variable registered for id {}",
|
||||
node_id));
|
||||
}
|
||||
Some(&var) => var,
|
||||
None => {
|
||||
span_bug!(span, "no variable registered for id {}", node_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -578,10 +575,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
// above and the propagation code below; the two sets of
|
||||
// code have to agree about which AST nodes are worth
|
||||
// creating liveness nodes for.
|
||||
self.ir.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("no live node registered for node {}",
|
||||
node_id));
|
||||
"no live node registered for node {}",
|
||||
node_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -703,15 +700,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
// to find with one
|
||||
match self.ir.tcx.def_map.borrow().get(&id).map(|d| d.full_def()) {
|
||||
Some(Def::Label(loop_id)) => loop_id,
|
||||
_ => self.ir.tcx.sess.span_bug(sp, "label on break/loop \
|
||||
doesn't refer to a loop")
|
||||
_ => span_bug!(sp, "label on break/loop \
|
||||
doesn't refer to a loop")
|
||||
}
|
||||
}
|
||||
None => {
|
||||
// Vanilla 'break' or 'loop', so use the enclosing
|
||||
// loop scope
|
||||
if self.loop_scope.is_empty() {
|
||||
self.ir.tcx.sess.span_bug(sp, "break outside loop");
|
||||
span_bug!(sp, "break outside loop");
|
||||
} else {
|
||||
*self.loop_scope.last().unwrap()
|
||||
}
|
||||
|
@ -967,7 +964,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
let caps = match this.ir.capture_info_map.get(&expr.id) {
|
||||
Some(caps) => caps.clone(),
|
||||
None => {
|
||||
this.ir.tcx.sess.span_bug(expr.span, "no registered caps");
|
||||
span_bug!(expr.span, "no registered caps");
|
||||
}
|
||||
};
|
||||
caps.iter().rev().fold(succ, |succ, cap| {
|
||||
|
@ -1061,8 +1058,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
match self.break_ln.get(&sc) {
|
||||
Some(&b) => b,
|
||||
None => self.ir.tcx.sess.span_bug(expr.span,
|
||||
"break to unknown label")
|
||||
None => span_bug!(expr.span, "break to unknown label")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1075,8 +1071,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
match self.cont_ln.get(&sc) {
|
||||
Some(&b) => b,
|
||||
None => self.ir.tcx.sess.span_bug(expr.span,
|
||||
"loop to unknown label")
|
||||
None => span_bug!(expr.span, "loop to unknown label")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -312,9 +312,9 @@ impl MutabilityCategory {
|
|||
McImmutable
|
||||
}
|
||||
}
|
||||
_ => tcx.sess.span_bug(p.span, "expected identifier pattern")
|
||||
_ => span_bug!(p.span, "expected identifier pattern")
|
||||
},
|
||||
_ => tcx.sess.span_bug(tcx.map.span(id), "expected identifier pattern")
|
||||
_ => span_bug!(tcx.map.span(id), "expected identifier pattern")
|
||||
};
|
||||
debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}",
|
||||
"from_local", id, ret);
|
||||
|
@ -559,8 +559,8 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
Def::TyParam(..) |
|
||||
Def::Label(_) | Def::SelfTy(..) |
|
||||
Def::AssociatedTy(..) => {
|
||||
self.tcx().sess.span_bug(span, &format!("Unexpected definition in \
|
||||
memory categorization: {:?}", def));
|
||||
span_bug!(span, "Unexpected definition in \
|
||||
memory categorization: {:?}", def);
|
||||
}
|
||||
|
||||
Def::Static(_, mutbl) => {
|
||||
|
@ -583,18 +583,19 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
self.cat_upvar(id, span, var_id, fn_node_id, kind)
|
||||
}
|
||||
None => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("No closure kind for {:?}", closure_id));
|
||||
"No closure kind for {:?}",
|
||||
closure_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("Upvar of non-closure {} - {:?}",
|
||||
fn_node_id,
|
||||
ty));
|
||||
"Upvar of non-closure {} - {:?}",
|
||||
fn_node_id,
|
||||
ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -610,7 +611,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
}))
|
||||
}
|
||||
|
||||
Def::Err => panic!("Def::Err in memory categorization")
|
||||
Def::Err => bug!("Def::Err in memory categorization")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,12 +724,12 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
let fn_body_id = {
|
||||
let fn_expr = match self.tcx().map.find(upvar_id.closure_expr_id) {
|
||||
Some(ast_map::NodeExpr(e)) => e,
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
|
||||
match fn_expr.node {
|
||||
hir::ExprClosure(_, _, ref body) => body.id,
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -926,7 +927,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
let ptr = if implicit {
|
||||
match ptr {
|
||||
BorrowedPtr(bk, r) => Implicit(bk, r),
|
||||
_ => self.tcx().sess.span_bug(node.span(),
|
||||
_ => span_bug!(node.span(),
|
||||
"Implicit deref of non-borrowed pointer")
|
||||
}
|
||||
} else {
|
||||
|
@ -1044,7 +1045,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
mutbl:m,
|
||||
ty: match base_cmt.ty.builtin_deref(false, ty::NoPreference) {
|
||||
Some(mt) => mt.ty,
|
||||
None => self.tcx().sess.bug("Found non-derefable type")
|
||||
None => bug!("Found non-derefable type")
|
||||
},
|
||||
note: NoteNone
|
||||
})
|
||||
|
@ -1092,8 +1093,8 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
},
|
||||
|
||||
_ => {
|
||||
tcx.sess.span_bug(pat.span,
|
||||
"type of slice pattern is not a slice");
|
||||
span_bug!(pat.span,
|
||||
"type of slice pattern is not a slice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1261,9 +1262,10 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span,
|
||||
&format!("enum pattern didn't resolve to enum or struct {:?}", opt_def));
|
||||
"enum pattern didn't resolve to enum or struct {:?}",
|
||||
opt_def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1451,10 +1453,10 @@ impl<'tcx> cmt_<'tcx> {
|
|||
match inner.cat {
|
||||
Categorization::Deref(ref inner, _, _) => inner.clone(),
|
||||
Categorization::Upvar(..) => inner.clone(),
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
})
|
||||
}
|
||||
NoteNone => None
|
||||
|
@ -1483,7 +1485,7 @@ impl<'tcx> cmt_<'tcx> {
|
|||
Some(&Categorization::Upvar(ref var)) => {
|
||||
var.to_string()
|
||||
}
|
||||
Some(_) => unreachable!(),
|
||||
Some(_) => bug!(),
|
||||
None => {
|
||||
match pk {
|
||||
Implicit(..) => {
|
||||
|
|
|
@ -67,10 +67,10 @@ fn method_might_be_inlined(tcx: &TyCtxt, sig: &hir::MethodSig,
|
|||
Some(ast_map::NodeItem(item)) =>
|
||||
item_might_be_inlined(&item),
|
||||
Some(..) | None =>
|
||||
tcx.sess.span_bug(impl_item.span, "impl did is not an item")
|
||||
span_bug!(impl_item.span, "impl did is not an item")
|
||||
}
|
||||
} else {
|
||||
tcx.sess.span_bug(impl_item.span, "found a foreign impl as a parent of a local method")
|
||||
span_bug!(impl_item.span, "found a foreign impl as a parent of a local method")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
|
|||
let def = match self.tcx.def_map.borrow().get(&expr.id) {
|
||||
Some(d) => d.full_def(),
|
||||
None => {
|
||||
self.tcx.sess.span_bug(expr.span,
|
||||
"def ID not in def map?!")
|
||||
span_bug!(expr.span, "def ID not in def map?!")
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -312,12 +311,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
ast_map::NodeVariant(_) |
|
||||
ast_map::NodeStructCtor(_) => {}
|
||||
_ => {
|
||||
self.tcx
|
||||
.sess
|
||||
.bug(&format!("found unexpected thingy in worklist: {}",
|
||||
self.tcx
|
||||
.map
|
||||
.node_to_string(search_item)))
|
||||
bug!("found unexpected thingy in worklist: {}",
|
||||
self.tcx.map.node_to_string(search_item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ impl RegionMaps {
|
|||
pub fn lookup_code_extent(&self, e: CodeExtentData) -> CodeExtent {
|
||||
match self.code_extent_interner.borrow().get(&e) {
|
||||
Some(&d) => d,
|
||||
None => panic!("unknown code extent {:?}", e)
|
||||
None => bug!("unknown code extent {:?}", e)
|
||||
}
|
||||
}
|
||||
pub fn node_extent(&self, n: ast::NodeId) -> CodeExtent {
|
||||
|
@ -385,8 +385,8 @@ impl RegionMaps {
|
|||
}
|
||||
Entry::Vacant(v) => {
|
||||
if self.code_extents.borrow().len() > 0xffffffffusize {
|
||||
unreachable!() // should pass a sess,
|
||||
// but this isn't the only place
|
||||
bug!() // should pass a sess,
|
||||
// but this isn't the only place
|
||||
}
|
||||
let idx = CodeExtent(self.code_extents.borrow().len() as u32);
|
||||
info!("CodeExtent({}) = {:?} [parent={}]", idx.0, e, parent.0);
|
||||
|
@ -470,7 +470,7 @@ impl RegionMaps {
|
|||
pub fn var_scope(&self, var_id: ast::NodeId) -> CodeExtent {
|
||||
match self.var_map.borrow().get(&var_id) {
|
||||
Some(&r) => r,
|
||||
None => { panic!("no enclosing scope for id {:?}", var_id); }
|
||||
None => { bug!("no enclosing scope for id {:?}", var_id); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,12 +601,12 @@ impl RegionMaps {
|
|||
scope_a
|
||||
} else {
|
||||
// neither fn encloses the other
|
||||
unreachable!()
|
||||
bug!()
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// root ids are always Misc right now
|
||||
unreachable!()
|
||||
bug!()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -747,9 +747,9 @@ impl<'a> LifetimeContext<'a> {
|
|||
lifetime_ref: &hir::Lifetime,
|
||||
def: DefRegion) {
|
||||
if lifetime_ref.id == ast::DUMMY_NODE_ID {
|
||||
self.sess.span_bug(lifetime_ref.span,
|
||||
"lifetime reference not renumbered, \
|
||||
probably a bug in syntax::fold");
|
||||
span_bug!(lifetime_ref.span,
|
||||
"lifetime reference not renumbered, \
|
||||
probably a bug in syntax::fold");
|
||||
}
|
||||
|
||||
debug!("lifetime_ref={:?} id={:?} resolved to {:?}",
|
||||
|
@ -822,7 +822,7 @@ fn early_bound_lifetime_names(generics: &hir::Generics) -> Vec<ast::Name> {
|
|||
collector.visit_lifetime(bound);
|
||||
}
|
||||
}
|
||||
&hir::WherePredicate::EqPredicate(_) => unimplemented!()
|
||||
&hir::WherePredicate::EqPredicate(_) => bug!("unimplemented")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -516,8 +516,8 @@ pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr,
|
|||
span = field.span;
|
||||
match tcx.expr_ty_adjusted(base_e).sty {
|
||||
ty::TyStruct(def, _) => def.struct_variant().field_named(field.node).did,
|
||||
_ => tcx.sess.span_bug(e.span,
|
||||
"stability::check_expr: named field access on non-struct")
|
||||
_ => span_bug!(e.span,
|
||||
"stability::check_expr: named field access on non-struct")
|
||||
}
|
||||
}
|
||||
hir::ExprTupField(ref base_e, ref field) => {
|
||||
|
@ -525,9 +525,9 @@ pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr,
|
|||
match tcx.expr_ty_adjusted(base_e).sty {
|
||||
ty::TyStruct(def, _) => def.struct_variant().fields[field.node].did,
|
||||
ty::TyTuple(..) => return,
|
||||
_ => tcx.sess.span_bug(e.span,
|
||||
"stability::check_expr: unnamed field access on \
|
||||
something other than a tuple or struct")
|
||||
_ => span_bug!(e.span,
|
||||
"stability::check_expr: unnamed field access on \
|
||||
something other than a tuple or struct")
|
||||
}
|
||||
}
|
||||
hir::ExprStruct(_, ref expr_fields, _) => {
|
||||
|
@ -551,10 +551,10 @@ pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr,
|
|||
// a bug to have construct one.
|
||||
ty::TyEnum(..) => return,
|
||||
_ => {
|
||||
tcx.sess.span_bug(e.span,
|
||||
&format!("stability::check_expr: struct construction \
|
||||
of non-struct, type {:?}",
|
||||
type_));
|
||||
span_bug!(e.span,
|
||||
"stability::check_expr: struct construction \
|
||||
of non-struct, type {:?}",
|
||||
type_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1016,7 +1016,7 @@ fn fmt_const_val<W: Write>(fmt: &mut W, const_val: &ConstVal) -> fmt::Result {
|
|||
Struct(node_id) | Tuple(node_id) | Array(node_id, _) | Repeat(node_id, _) =>
|
||||
write!(fmt, "{}", node_to_string(node_id)),
|
||||
Char(c) => write!(fmt, "{:?}", c),
|
||||
Dummy => unreachable!(),
|
||||
Dummy => bug!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ impl<'tcx> LvalueTy<'tcx> {
|
|||
variant_index: index }
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.bug(&format!("cannot downcast non-enum type: `{:?}`", self))
|
||||
bug!("cannot downcast non-enum type: `{:?}`", self)
|
||||
}
|
||||
},
|
||||
ProjectionElem::Field(_, fty) => LvalueTy::Ty { ty: fty }
|
||||
|
|
|
@ -362,7 +362,7 @@ macro_rules! options {
|
|||
value, $outputname,
|
||||
key, type_desc))
|
||||
}
|
||||
(None, None) => unreachable!()
|
||||
(None, None) => bug!()
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
|
|
|
@ -155,14 +155,14 @@ pub fn get_or_default_sysroot() -> PathBuf {
|
|||
// gcc chokes on verbatim paths which fs::canonicalize generates
|
||||
// so we try to avoid those kinds of paths.
|
||||
Ok(canon) => Some(rustcfs::fix_windows_verbatim_for_gcc(&canon)),
|
||||
Err(e) => panic!("failed to get realpath: {}", e),
|
||||
Err(e) => bug!("failed to get realpath: {}", e),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
match canonicalize(env::current_exe().ok()) {
|
||||
Some(mut p) => { p.pop(); p.pop(); p }
|
||||
None => panic!("can't determine value for sysroot")
|
||||
None => bug!("can't determine value for sysroot")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ use lint;
|
|||
use middle::cstore::CrateStore;
|
||||
use middle::dependency_format;
|
||||
use session::search_paths::PathKind;
|
||||
use ty::tls;
|
||||
use util::nodemap::{NodeMap, FnvHashMap};
|
||||
use mir::transform as mir_pass;
|
||||
|
||||
|
@ -35,6 +36,7 @@ use std::cell::{Cell, RefCell};
|
|||
use std::collections::{HashMap, HashSet};
|
||||
use std::env;
|
||||
use std::rc::Rc;
|
||||
use std::fmt;
|
||||
|
||||
pub mod config;
|
||||
pub mod filesearch;
|
||||
|
@ -216,22 +218,10 @@ impl Session {
|
|||
None => self.warn(msg),
|
||||
}
|
||||
}
|
||||
pub fn opt_span_bug<S: Into<MultiSpan>>(&self, opt_sp: Option<S>, msg: &str) -> ! {
|
||||
match opt_sp {
|
||||
Some(sp) => self.span_bug(sp, msg),
|
||||
None => self.bug(msg),
|
||||
}
|
||||
}
|
||||
/// Delay a span_bug() call until abort_if_errors()
|
||||
pub fn delay_span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
|
||||
self.diagnostic().delay_span_bug(sp, msg)
|
||||
}
|
||||
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
|
||||
self.diagnostic().span_bug(sp, msg)
|
||||
}
|
||||
pub fn bug(&self, msg: &str) -> ! {
|
||||
self.diagnostic().bug(msg)
|
||||
}
|
||||
pub fn note_without_error(&self, msg: &str) {
|
||||
self.diagnostic().note_without_error(msg)
|
||||
}
|
||||
|
@ -268,7 +258,7 @@ impl Session {
|
|||
|
||||
match id.checked_add(count) {
|
||||
Some(next) => self.next_node_id.set(next),
|
||||
None => self.bug("Input too large, ran out of node ids!")
|
||||
None => bug!("Input too large, ran out of node ids!")
|
||||
}
|
||||
|
||||
id
|
||||
|
@ -279,11 +269,6 @@ impl Session {
|
|||
pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
|
||||
self.parse_sess.codemap()
|
||||
}
|
||||
// This exists to help with refactoring to eliminate impossible
|
||||
// cases later on
|
||||
pub fn impossible_case<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
|
||||
self.span_bug(sp, &format!("impossible case reached: {}", msg));
|
||||
}
|
||||
pub fn verbose(&self) -> bool { self.opts.debugging_opts.verbose }
|
||||
pub fn time_passes(&self) -> bool { self.opts.debugging_opts.time_passes }
|
||||
pub fn count_llvm_insns(&self) -> bool {
|
||||
|
@ -541,3 +526,35 @@ pub fn compile_result_from_err_count(err_count: usize) -> CompileResult {
|
|||
Err(err_count)
|
||||
}
|
||||
}
|
||||
|
||||
#[cold]
|
||||
#[inline(never)]
|
||||
pub fn bug_fmt(file: &'static str, line: u32, args: fmt::Arguments) -> ! {
|
||||
// this wrapper mostly exists so I don't have to write a fully
|
||||
// qualified path of None::<Span> inside the bug!() macro defintion
|
||||
opt_span_bug_fmt(file, line, None::<Span>, args);
|
||||
}
|
||||
|
||||
#[cold]
|
||||
#[inline(never)]
|
||||
pub fn span_bug_fmt<S: Into<MultiSpan>>(file: &'static str,
|
||||
line: u32,
|
||||
span: S,
|
||||
args: fmt::Arguments) -> ! {
|
||||
opt_span_bug_fmt(file, line, Some(span), args);
|
||||
}
|
||||
|
||||
fn opt_span_bug_fmt<S: Into<MultiSpan>>(file: &'static str,
|
||||
line: u32,
|
||||
span: Option<S>,
|
||||
args: fmt::Arguments) -> ! {
|
||||
tls::with_opt(move |tcx| {
|
||||
let msg = format!("{}:{}: {}", file, line, args);
|
||||
match (tcx, span) {
|
||||
(Some(tcx), Some(span)) => tcx.sess.diagnostic().span_bug(span, &msg),
|
||||
(Some(tcx), None) => tcx.sess.diagnostic().bug(&msg),
|
||||
(None, _) => panic!(msg)
|
||||
}
|
||||
});
|
||||
unreachable!();
|
||||
}
|
||||
|
|
|
@ -291,9 +291,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
}
|
||||
|
||||
ty::TyClosure(..) => {
|
||||
tcx.sess.bug(
|
||||
&format!("ty_is_local invoked on unexpected type: {:?}",
|
||||
ty))
|
||||
bug!("ty_is_local invoked on unexpected type: {:?}", ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ pub fn report_overflow_error<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
|
||||
err.emit();
|
||||
infcx.tcx.sess.abort_if_errors();
|
||||
unreachable!();
|
||||
bug!();
|
||||
}
|
||||
|
||||
/// Reports that a cycle was detected which led to overflow and halts
|
||||
|
@ -268,9 +268,9 @@ pub fn try_report_overflow_error_type_of_infinite_size<'a, 'tcx>(
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
infcx.tcx.sess.span_bug(obligation.cause.span,
|
||||
&format!("Sized cycle involving non-trait-ref: {:?}",
|
||||
obligation.predicate));
|
||||
span_bug!(obligation.cause.span,
|
||||
"Sized cycle involving non-trait-ref: {:?}",
|
||||
obligation.predicate);
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
@ -323,7 +323,7 @@ pub fn try_report_overflow_error_type_of_infinite_size<'a, 'tcx>(
|
|||
}
|
||||
err.emit();
|
||||
infcx.tcx.sess.abort_if_errors();
|
||||
unreachable!();
|
||||
bug!();
|
||||
}
|
||||
|
||||
pub fn recursive_type_with_infinite_size_error<'tcx>(tcx: &TyCtxt<'tcx>,
|
||||
|
@ -472,9 +472,10 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
// ambiguity; otherwise, they always
|
||||
// degenerate into other obligations
|
||||
// (which may fail).
|
||||
infcx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
&format!("WF predicate not satisfied for {:?}", ty));
|
||||
"WF predicate not satisfied for {:?}",
|
||||
ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -719,8 +719,8 @@ fn project_type<'cx,'tcx>(
|
|||
// The essential problem here is that the projection fails,
|
||||
// leaving two unnormalized types, which appear not to unify
|
||||
// -- so the overlap check succeeds, when it should fail.
|
||||
selcx.tcx().sess.bug("Tried to project an inherited associated type during \
|
||||
coherence checking, which is currently not supported.");
|
||||
bug!("Tried to project an inherited associated type during \
|
||||
coherence checking, which is currently not supported.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -858,10 +858,10 @@ fn assemble_candidates_from_object_type<'cx,'tcx>(
|
|||
let data = match object_ty.sty {
|
||||
ty::TyTrait(ref data) => data,
|
||||
_ => {
|
||||
selcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
&format!("assemble_candidates_from_object_type called with non-object: {:?}",
|
||||
object_ty));
|
||||
"assemble_candidates_from_object_type called with non-object: {:?}",
|
||||
object_ty);
|
||||
}
|
||||
};
|
||||
let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), object_ty);
|
||||
|
@ -951,10 +951,10 @@ fn assemble_candidates_from_impls<'cx,'tcx>(
|
|||
super::VtableDefaultImpl(..) |
|
||||
super::VtableBuiltin(..) => {
|
||||
// These traits have no associated types.
|
||||
selcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
&format!("Cannot project an associated type from `{:?}`",
|
||||
vtable));
|
||||
"Cannot project an associated type from `{:?}`",
|
||||
vtable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1084,12 +1084,12 @@ fn confirm_param_env_candidate<'cx,'tcx>(
|
|||
projection.projection_ty.trait_ref.clone()) {
|
||||
Ok(()) => { }
|
||||
Err(e) => {
|
||||
selcx.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
&format!("Failed to unify `{:?}` and `{:?}` in projection: {}",
|
||||
obligation,
|
||||
projection,
|
||||
e));
|
||||
"Failed to unify `{:?}` and `{:?}` in projection: {}",
|
||||
obligation,
|
||||
projection,
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1124,8 +1124,9 @@ fn confirm_impl_candidate<'cx,'tcx>(
|
|||
(ty.subst(tcx, substs), nested)
|
||||
}
|
||||
None => {
|
||||
tcx.sess.span_bug(obligation.cause.span,
|
||||
&format!("No associated type for {:?}", trait_ref));
|
||||
span_bug!(obligation.cause.span,
|
||||
"No associated type for {:?}",
|
||||
trait_ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1088,7 +1088,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let trait_def_id = match obligation.predicate.0.trait_ref.self_ty().sty {
|
||||
ty::TyProjection(ref data) => data.trait_ref.def_id,
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
self.tcx().sess.span_bug(obligation.cause.span,
|
||||
span_bug!(obligation.cause.span,
|
||||
"Self=_ should have been handled by assemble_candidates");
|
||||
}
|
||||
_ => { return; }
|
||||
|
@ -1125,11 +1125,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let projection_trait_ref = match skol_trait_predicate.trait_ref.self_ty().sty {
|
||||
ty::TyProjection(ref data) => &data.trait_ref,
|
||||
_ => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
&format!("match_projection_obligation_against_bounds_from_trait() called \
|
||||
but self-ty not a projection: {:?}",
|
||||
skol_trait_predicate.trait_ref.self_ty()));
|
||||
"match_projection_obligation_against_bounds_from_trait() called \
|
||||
but self-ty not a projection: {:?}",
|
||||
skol_trait_predicate.trait_ref.self_ty());
|
||||
}
|
||||
};
|
||||
debug!("match_projection_obligation_against_bounds_from_trait: \
|
||||
|
@ -1601,7 +1601,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ObjectCandidate |
|
||||
ParamCandidate(_) | ProjectionCandidate => match victim.candidate {
|
||||
DefaultImplCandidate(..) => {
|
||||
self.tcx().sess.bug(
|
||||
bug!(
|
||||
"default implementations shouldn't be recorded \
|
||||
when there are other valid candidates");
|
||||
}
|
||||
|
@ -1703,7 +1703,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::BoundSized => ok_if(Vec::new()),
|
||||
|
||||
ty::BoundSync | ty::BoundSend => {
|
||||
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
bug!("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1713,7 +1713,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::BoundCopy | ty::BoundSized => ok_if(Vec::new()),
|
||||
|
||||
ty::BoundSync | ty::BoundSend => {
|
||||
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
bug!("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1741,7 +1741,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
}
|
||||
ty::BoundSync | ty::BoundSend => {
|
||||
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
bug!("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1762,7 +1762,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::BoundSized => ok_if(Vec::new()),
|
||||
|
||||
ty::BoundSync | ty::BoundSend => {
|
||||
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
bug!("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1773,7 +1773,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::BoundCopy => ok_if(vec![element_ty]),
|
||||
ty::BoundSized => ok_if(Vec::new()),
|
||||
ty::BoundSync | ty::BoundSend => {
|
||||
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
bug!("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1781,7 +1781,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::TyStr | ty::TySlice(_) => {
|
||||
match bound {
|
||||
ty::BoundSync | ty::BoundSend => {
|
||||
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
bug!("Send/Sync shouldn't occur in builtin_bounds()");
|
||||
}
|
||||
|
||||
ty::BoundCopy | ty::BoundSized => Err(Unimplemented),
|
||||
|
@ -1847,10 +1847,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::TyInfer(ty::FreshTy(_))
|
||||
| ty::TyInfer(ty::FreshIntTy(_))
|
||||
| ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||
self.tcx().sess.bug(
|
||||
&format!(
|
||||
"asked to assemble builtin bounds of unexpected type: {:?}",
|
||||
self_ty));
|
||||
bug!("asked to assemble builtin bounds of unexpected type: {:?}",
|
||||
self_ty);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1872,7 +1870,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::BoundSized => ok_if(types),
|
||||
|
||||
// Shouldn't be coming through here.
|
||||
ty::BoundSend | ty::BoundSync => unreachable!(),
|
||||
ty::BoundSend | ty::BoundSync => bug!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1911,10 +1909,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
ty::TyInfer(ty::FreshTy(_)) |
|
||||
ty::TyInfer(ty::FreshIntTy(_)) |
|
||||
ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||
self.tcx().sess.bug(
|
||||
&format!(
|
||||
"asked to assemble constituent types of unexpected type: {:?}",
|
||||
t));
|
||||
bug!("asked to assemble constituent types of unexpected type: {:?}",
|
||||
t);
|
||||
}
|
||||
|
||||
ty::TyBox(referent_ty) => { // Box<T>
|
||||
|
@ -2135,10 +2131,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
match self.match_where_clause_trait_ref(obligation, param.clone()) {
|
||||
Ok(obligations) => obligations,
|
||||
Err(()) => {
|
||||
self.tcx().sess.bug(
|
||||
&format!("Where clause `{:?}` was applicable to `{:?}` but now is not",
|
||||
param,
|
||||
obligation));
|
||||
bug!("Where clause `{:?}` was applicable to `{:?}` but now is not",
|
||||
param,
|
||||
obligation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2155,10 +2150,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
match self.builtin_bound(bound, obligation)? {
|
||||
If(nested) => Ok(self.vtable_builtin_data(obligation, bound, nested)),
|
||||
AmbiguousBuiltin | ParameterBuiltin => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
&format!("builtin bound for {:?} was ambig",
|
||||
obligation));
|
||||
"builtin bound for {:?} was ambig",
|
||||
obligation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2175,7 +2170,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let trait_def = match self.tcx().lang_items.from_builtin_kind(bound) {
|
||||
Ok(def_id) => def_id,
|
||||
Err(_) => {
|
||||
self.tcx().sess.bug("builtin trait definition not found");
|
||||
bug!("builtin trait definition not found");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2238,10 +2233,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.vtable_default_impl(obligation, trait_def_id, all_types)
|
||||
}
|
||||
_ => {
|
||||
self.tcx().sess.bug(
|
||||
&format!(
|
||||
"asked to confirm default object implementation for non-object type: {:?}",
|
||||
self_ty));
|
||||
bug!("asked to confirm default object implementation for non-object type: {:?}",
|
||||
self_ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2360,8 +2353,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
data.principal_trait_ref_with_self_ty(self.tcx(), self_ty)
|
||||
}
|
||||
_ => {
|
||||
self.tcx().sess.span_bug(obligation.cause.span,
|
||||
"object candidate with non-object");
|
||||
span_bug!(obligation.cause.span,
|
||||
"object candidate with non-object");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2667,7 +2660,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
vec![inner_target]));
|
||||
}
|
||||
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
|
||||
Ok(VtableBuiltinData { nested: nested })
|
||||
|
@ -2692,10 +2685,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
match self.match_impl(impl_def_id, obligation, snapshot) {
|
||||
Ok((substs, skol_map)) => (substs, skol_map),
|
||||
Err(()) => {
|
||||
self.tcx().sess.bug(
|
||||
&format!("Impl {:?} was matchable against {:?} but now is not",
|
||||
impl_def_id,
|
||||
obligation));
|
||||
bug!("Impl {:?} was matchable against {:?} but now is not",
|
||||
impl_def_id,
|
||||
obligation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,10 +93,8 @@ pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
fulfill_implication(infcx, source_trait_ref, target_impl).unwrap_or_else(|_| {
|
||||
infcx.tcx
|
||||
.sess
|
||||
.bug("When translating substitutions for specialization, the expected \
|
||||
specializaiton failed to hold")
|
||||
bug!("When translating substitutions for specialization, the expected \
|
||||
specializaiton failed to hold")
|
||||
})
|
||||
}
|
||||
specialization_graph::Node::Trait(..) => source_trait_ref.substs.clone(),
|
||||
|
|
|
@ -145,8 +145,8 @@ impl Graph {
|
|||
/// Insert cached metadata mapping from a child impl back to its parent.
|
||||
pub fn record_impl_from_cstore(&mut self, parent: DefId, child: DefId) {
|
||||
if self.parent.insert(child, parent).is_some() {
|
||||
panic!("When recording an impl from the crate store, information about its parent \
|
||||
was already present.");
|
||||
bug!("When recording an impl from the crate store, information about its parent \
|
||||
was already present.");
|
||||
}
|
||||
|
||||
self.children.entry(parent).or_insert(vec![]).push(child);
|
||||
|
|
|
@ -481,8 +481,8 @@ pub fn get_vtable_index_of_object_method<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
tcx.sess.bug(&format!("get_vtable_index_of_object_method: {:?} was not found",
|
||||
method_def_id));
|
||||
bug!("get_vtable_index_of_object_method: {:?} was not found",
|
||||
method_def_id);
|
||||
}
|
||||
|
||||
pub enum TupleArgumentsFlag { Yes, No }
|
||||
|
|
|
@ -159,9 +159,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
cx.mk_ty(ty::TyFnPtr(b))
|
||||
}
|
||||
_ => {
|
||||
cx.sess.bug(
|
||||
&format!("AdjustReifyFnPointer adjustment on non-fn-item: \
|
||||
{:?}", self));
|
||||
bug!("AdjustReifyFnPointer adjustment on non-fn-item: {:?}",
|
||||
self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,10 +169,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
match self.sty {
|
||||
ty::TyFnPtr(b) => cx.safe_to_unsafe_fn_ty(b),
|
||||
ref b => {
|
||||
cx.sess.bug(
|
||||
&format!("AdjustUnsafeFnPointer adjustment on non-fn-ptr: \
|
||||
{:?}",
|
||||
b));
|
||||
bug!("AdjustUnsafeFnPointer adjustment on non-fn-ptr: {:?}",
|
||||
b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,10 +182,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
mutbl: hir::MutImmutable
|
||||
}),
|
||||
ref b => {
|
||||
cx.sess.bug(
|
||||
&format!("AdjustMutToConstPointer on non-raw-ptr: \
|
||||
{:?}",
|
||||
b));
|
||||
bug!("AdjustMutToConstPointer on non-raw-ptr: {:?}",
|
||||
b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,12 +234,11 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
match adjusted_ty.builtin_deref(true, NoPreference) {
|
||||
Some(mt) => mt.ty,
|
||||
None => {
|
||||
cx.sess.span_bug(
|
||||
span_bug!(
|
||||
expr_span,
|
||||
&format!("the {}th autoderef failed: {}",
|
||||
autoderef,
|
||||
adjusted_ty)
|
||||
);
|
||||
"the {}th autoderef failed: {}",
|
||||
autoderef,
|
||||
adjusted_ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
|
||||
ty::TyInfer(_) |
|
||||
ty::TyError => {
|
||||
cx.sess.bug("asked to compute contents of error type");
|
||||
bug!("asked to compute contents of error type");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -462,8 +462,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let did = def.trait_ref.def_id;
|
||||
let interned = self.arenas.trait_defs.alloc(def);
|
||||
if let Some(prev) = self.trait_defs.borrow_mut().insert(did, interned) {
|
||||
self.sess.bug(&format!("Tried to overwrite interned TraitDef: {:?}",
|
||||
prev))
|
||||
bug!("Tried to overwrite interned TraitDef: {:?}", prev)
|
||||
}
|
||||
interned
|
||||
}
|
||||
|
@ -482,8 +481,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let interned = self.arenas.adt_defs.alloc(def);
|
||||
// this will need a transmute when reverse-variance is removed
|
||||
if let Some(prev) = self.adt_defs.borrow_mut().insert(did, interned) {
|
||||
self.sess.bug(&format!("Tried to overwrite interned AdtDef: {:?}",
|
||||
prev))
|
||||
bug!("Tried to overwrite interned AdtDef: {:?}", prev)
|
||||
}
|
||||
interned
|
||||
}
|
||||
|
@ -497,16 +495,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
if let Some(prev) = self.stability_interner
|
||||
.borrow_mut()
|
||||
.insert(interned, interned) {
|
||||
self.sess.bug(&format!("Tried to overwrite interned Stability: {:?}",
|
||||
prev))
|
||||
bug!("Tried to overwrite interned Stability: {:?}", prev)
|
||||
}
|
||||
interned
|
||||
}
|
||||
|
||||
pub fn store_free_region_map(&self, id: NodeId, map: FreeRegionMap) {
|
||||
if self.free_region_maps.borrow_mut().insert(id, map).is_some() {
|
||||
self.sess.bug(&format!("Tried to overwrite interned FreeRegionMap for NodeId {:?}",
|
||||
id))
|
||||
bug!("Tried to overwrite interned FreeRegionMap for NodeId {:?}", id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1241,9 +1241,8 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
|||
cx.region_maps.call_site_extent(id, body.id))
|
||||
}
|
||||
_ => {
|
||||
cx.sess
|
||||
.bug("ParameterEnvironment::for_item(): \
|
||||
got non-method item from impl method?!")
|
||||
bug!("ParameterEnvironment::for_item(): \
|
||||
got non-method item from impl method?!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1295,10 +1294,9 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
|||
extent)
|
||||
}
|
||||
_ => {
|
||||
cx.sess
|
||||
.bug("ParameterEnvironment::for_item(): \
|
||||
got non-method item from provided \
|
||||
method?!")
|
||||
bug!("ParameterEnvironment::for_item(): \
|
||||
got non-method item from provided \
|
||||
method?!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1341,10 +1339,10 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
|||
cx.region_maps.item_extent(id))
|
||||
}
|
||||
_ => {
|
||||
cx.sess.span_bug(item.span,
|
||||
"ParameterEnvironment::for_item():
|
||||
can't create a parameter \
|
||||
environment for this kind of item")
|
||||
span_bug!(item.span,
|
||||
"ParameterEnvironment::for_item():
|
||||
can't create a parameter \
|
||||
environment for this kind of item")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1353,9 +1351,9 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
|||
ParameterEnvironment::for_item(cx, cx.map.get_parent(id))
|
||||
}
|
||||
_ => {
|
||||
cx.sess.bug(&format!("ParameterEnvironment::for_item(): \
|
||||
`{}` is not an item",
|
||||
cx.map.node_to_string(id)))
|
||||
bug!("ParameterEnvironment::from_item(): \
|
||||
`{}` is not an item",
|
||||
cx.map.node_to_string(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1649,7 +1647,7 @@ impl<'tcx, 'container> AdtDefData<'tcx, 'container> {
|
|||
match def {
|
||||
Def::Variant(_, vid) => self.variant_with_id(vid),
|
||||
Def::Struct(..) | Def::TyAlias(..) => self.struct_variant(),
|
||||
_ => panic!("unexpected def {:?} in variant_of_def", def)
|
||||
_ => bug!("unexpected def {:?} in variant_of_def", def)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1859,7 +1857,7 @@ fn lookup_locally_or_in_crate_store<M, F>(descr: &str,
|
|||
{
|
||||
map.memoize(def_id, || {
|
||||
if def_id.is_local() {
|
||||
panic!("No def'n found for {:?} in tcx.{}", def_id, descr);
|
||||
bug!("No def'n found for {:?} in tcx.{}", def_id, descr);
|
||||
}
|
||||
load_external()
|
||||
})
|
||||
|
@ -1902,9 +1900,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
pub fn node_id_to_type(&self, id: NodeId) -> Ty<'tcx> {
|
||||
match self.node_id_to_type_opt(id) {
|
||||
Some(ty) => ty,
|
||||
None => self.sess.bug(
|
||||
&format!("node_id_to_type: no type for node `{}`",
|
||||
self.map.node_to_string(id)))
|
||||
None => bug!("node_id_to_type: no type for node `{}`",
|
||||
self.map.node_to_string(id))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1980,12 +1977,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
e.span
|
||||
}
|
||||
Some(f) => {
|
||||
self.sess.bug(&format!("Node id {} is not an expr: {:?}",
|
||||
id, f));
|
||||
bug!("Node id {} is not an expr: {:?}", id, f);
|
||||
}
|
||||
None => {
|
||||
self.sess.bug(&format!("Node id {} is not present \
|
||||
in the node map", id));
|
||||
bug!("Node id {} is not present in the node map", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1996,11 +1991,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
match pat.node {
|
||||
PatKind::Ident(_, ref path1, _) => path1.node.name.as_str(),
|
||||
_ => {
|
||||
self.sess.bug(&format!("Variable id {} maps to {:?}, not local", id, pat));
|
||||
bug!("Variable id {} maps to {:?}, not local", id, pat);
|
||||
},
|
||||
}
|
||||
},
|
||||
r => self.sess.bug(&format!("Variable id {} maps to {:?}, not local", id, r)),
|
||||
r => bug!("Variable id {} maps to {:?}, not local", id, r),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2008,8 +2003,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
match self.def_map.borrow().get(&expr.id) {
|
||||
Some(def) => def.full_def(),
|
||||
None => {
|
||||
self.sess.span_bug(expr.span, &format!(
|
||||
"no def-map entry for expr {}", expr.id));
|
||||
span_bug!(expr.span, "no def-map entry for expr {}", expr.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2032,8 +2026,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
Some(&def::PathResolution { base_def: Def::Err, .. })=> true,
|
||||
Some(..) => false,
|
||||
None => self.sess.span_bug(expr.span, &format!(
|
||||
"no def for path {}", expr.id))
|
||||
None => span_bug!(expr.span, "no def for path {}", expr.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2085,9 +2078,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
match self.impl_or_trait_item(self.map.local_def_id(ti.id)) {
|
||||
MethodTraitItem(m) => Some(m),
|
||||
_ => {
|
||||
self.sess.bug("provided_trait_methods(): \
|
||||
non-method item found from \
|
||||
looking up provided method?!")
|
||||
bug!("provided_trait_methods(): \
|
||||
non-method item found from \
|
||||
looking up provided method?!")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2095,7 +2088,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
}).collect()
|
||||
} else {
|
||||
self.sess.bug(&format!("provided_trait_methods: `{:?}` is not a trait", id))
|
||||
bug!("provided_trait_methods: `{:?}` is not a trait", id)
|
||||
}
|
||||
} else {
|
||||
self.sess.cstore.provided_trait_methods(self, id)
|
||||
|
@ -2111,9 +2104,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
match self.impl_or_trait_item(self.map.local_def_id(ti.id)) {
|
||||
ConstTraitItem(ac) => Some(ac),
|
||||
_ => {
|
||||
self.sess.bug("associated_consts(): \
|
||||
non-const item found from \
|
||||
looking up a constant?!")
|
||||
bug!("associated_consts(): \
|
||||
non-const item found from \
|
||||
looking up a constant?!")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2127,9 +2120,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
match self.impl_or_trait_item(self.map.local_def_id(ii.id)) {
|
||||
ConstTraitItem(ac) => Some(ac),
|
||||
_ => {
|
||||
self.sess.bug("associated_consts(): \
|
||||
non-const item found from \
|
||||
looking up a constant?!")
|
||||
bug!("associated_consts(): \
|
||||
non-const item found from \
|
||||
looking up a constant?!")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2138,8 +2131,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}).collect()
|
||||
}
|
||||
_ => {
|
||||
self.sess.bug(&format!("associated_consts: `{:?}` is not a trait \
|
||||
or impl", id))
|
||||
bug!("associated_consts: `{:?}` is not a trait or impl", id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2174,9 +2166,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
match kind {
|
||||
Some(kind) => kind,
|
||||
None => {
|
||||
self.sess.bug(&format!("custom_coerce_unsized_kind: \
|
||||
{} impl `{}` is missing its kind",
|
||||
src, self.item_path_str(did)));
|
||||
bug!("custom_coerce_unsized_kind: \
|
||||
{} impl `{}` is missing its kind",
|
||||
src, self.item_path_str(did));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -453,7 +453,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
|||
(_, &ty::TyInfer(_)) =>
|
||||
{
|
||||
// The caller should handle these cases!
|
||||
tcx.sess.bug("var types encountered in super_relate_tys")
|
||||
bug!("var types encountered in super_relate_tys")
|
||||
}
|
||||
|
||||
(&ty::TyError, _) | (_, &ty::TyError) =>
|
||||
|
|
|
@ -259,7 +259,7 @@ impl<'tcx> Decodable for &'tcx ClosureSubsts<'tcx> {
|
|||
Box::new(closure_substs));
|
||||
match ty.sty {
|
||||
TyClosure(_, ref closure_substs) => Ok(&**closure_substs),
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ impl<'tcx> FnOutput<'tcx> {
|
|||
pub fn unwrap(self) -> Ty<'tcx> {
|
||||
match self {
|
||||
ty::FnConverging(t) => t,
|
||||
ty::FnDiverging => unreachable!()
|
||||
ty::FnDiverging => bug!()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -978,8 +978,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
match self.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => ty,
|
||||
TyStr => cx.mk_mach_uint(ast::UintTy::U8),
|
||||
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
|
||||
self)),
|
||||
_ => bug!("sequence_element_type called on non-sequence value: {}", self),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,14 +987,14 @@ impl<'tcx> TyS<'tcx> {
|
|||
TyStruct(def, substs) => {
|
||||
def.struct_variant().fields[0].ty(cx, substs)
|
||||
}
|
||||
_ => panic!("simd_type called on invalid type")
|
||||
_ => bug!("simd_type called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simd_size(&self, _cx: &TyCtxt) -> usize {
|
||||
match self.sty {
|
||||
TyStruct(def, _) => def.struct_variant().fields.len(),
|
||||
_ => panic!("simd_size called on invalid type")
|
||||
_ => bug!("simd_size called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1147,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
pub fn fn_sig(&self) -> &'tcx PolyFnSig<'tcx> {
|
||||
match self.sty {
|
||||
TyFnDef(_, _, ref f) | TyFnPtr(ref f) => &f.sig,
|
||||
_ => panic!("Ty::fn_sig() called on non-fn type: {:?}", self)
|
||||
_ => bug!("Ty::fn_sig() called on non-fn type: {:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1155,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
pub fn fn_abi(&self) -> abi::Abi {
|
||||
match self.sty {
|
||||
TyFnDef(_, _, ref f) | TyFnPtr(ref f) => f.abi,
|
||||
_ => panic!("Ty::fn_abi() called on non-fn type"),
|
||||
_ => bug!("Ty::fn_abi() called on non-fn type"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ impl ParamSpace {
|
|||
0 => TypeSpace,
|
||||
1 => SelfSpace,
|
||||
2 => FnSpace,
|
||||
_ => panic!("Invalid ParamSpace: {}", u)
|
||||
_ => bug!("Invalid ParamSpace: {}", u)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -604,15 +604,15 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
|||
}
|
||||
None => {
|
||||
let span = self.span.unwrap_or(DUMMY_SP);
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("Region parameter out of range \
|
||||
when substituting in region {} (root type={:?}) \
|
||||
(space={:?}, index={})",
|
||||
data.name,
|
||||
self.root_ty,
|
||||
data.space,
|
||||
data.index));
|
||||
"Region parameter out of range \
|
||||
when substituting in region {} (root type={:?}) \
|
||||
(space={:?}, index={})",
|
||||
data.name,
|
||||
self.root_ty,
|
||||
data.space,
|
||||
data.index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -659,16 +659,16 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> {
|
|||
Some(t) => *t,
|
||||
None => {
|
||||
let span = self.span.unwrap_or(DUMMY_SP);
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("Type parameter `{:?}` ({:?}/{:?}/{}) out of range \
|
||||
when substituting (root type={:?}) substs={:?}",
|
||||
p,
|
||||
source_ty,
|
||||
p.space,
|
||||
p.idx,
|
||||
self.root_ty,
|
||||
self.substs));
|
||||
"Type parameter `{:?}` ({:?}/{:?}/{}) out of range \
|
||||
when substituting (root type={:?}) substs={:?}",
|
||||
p,
|
||||
source_ty,
|
||||
p.space,
|
||||
p.idx,
|
||||
self.root_ty,
|
||||
self.substs);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ impl IntTypeExt for attr::IntType {
|
|||
SignedInt(ast::IntTy::Is) => match tcx.sess.target.int_type {
|
||||
ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32(0)),
|
||||
ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64(0)),
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
},
|
||||
UnsignedInt(ast::UintTy::U8) => ConstInt::U8(0),
|
||||
UnsignedInt(ast::UintTy::U16) => ConstInt::U16(0),
|
||||
|
@ -71,7 +71,7 @@ impl IntTypeExt for attr::IntType {
|
|||
UnsignedInt(ast::UintTy::Us) => match tcx.sess.target.uint_type {
|
||||
ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32(0)),
|
||||
ast::UintTy::U64 => ConstInt::Usize(ConstUsize::Us64(0)),
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ impl IntTypeExt for attr::IntType {
|
|||
(UnsignedInt(ast::UintTy::U32), ConstInt::U32(_)) => {},
|
||||
(UnsignedInt(ast::UintTy::U64), ConstInt::U64(_)) => {},
|
||||
(UnsignedInt(ast::UintTy::Us), ConstInt::Usize(_)) => {},
|
||||
_ => panic!("disr type mismatch: {:?} vs {:?}", self, val),
|
||||
_ => bug!("disr type mismatch: {:?} vs {:?}", self, val),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
ty::ReScope(..) |
|
||||
ty::ReVar(..) |
|
||||
ty::ReSkolemized(..) => {
|
||||
tcx.sess.bug("unexpected region found when hashing a type")
|
||||
bug!("unexpected region found when hashing a type")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -453,7 +453,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
hash!(p.idx);
|
||||
hash!(p.name.as_str());
|
||||
}
|
||||
TyInfer(_) => unreachable!(),
|
||||
TyInfer(_) => bug!(),
|
||||
TyError => byte!(21),
|
||||
TyClosure(d, _) => {
|
||||
byte!(22);
|
||||
|
@ -632,7 +632,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
TyClosure(..) => {
|
||||
// this check is run on type definitions, so we don't expect
|
||||
// to see closure types
|
||||
cx.sess.bug(&format!("requires check invoked on inapplicable type: {:?}", ty))
|
||||
bug!("requires check invoked on inapplicable type: {:?}", ty)
|
||||
}
|
||||
_ => Representability::Representable,
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ use rustc::middle::mem_categorization as mc;
|
|||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
|
@ -428,8 +428,8 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
|
|||
let tuple_idx = match *origin_field_name {
|
||||
mc::PositionalField(tuple_idx) => tuple_idx,
|
||||
mc::NamedField(_) =>
|
||||
panic!("tuple type {:?} should not have named fields.",
|
||||
parent_ty),
|
||||
bug!("tuple type {:?} should not have named fields.",
|
||||
parent_ty),
|
||||
};
|
||||
let tuple_len = v.len();
|
||||
for i in 0..tuple_len {
|
||||
|
@ -493,10 +493,11 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
|
|||
}
|
||||
|
||||
ref sty_and_variant_info => {
|
||||
let msg = format!("type {:?} ({:?}) is not fragmentable",
|
||||
parent_ty, sty_and_variant_info);
|
||||
let opt_span = origin_id.and_then(|id|tcx.map.opt_span(id));
|
||||
tcx.sess.opt_span_bug(opt_span, &msg[..])
|
||||
span_bug!(opt_span.unwrap_or(DUMMY_SP),
|
||||
"type {:?} ({:?}) is not fragmentable",
|
||||
parent_ty,
|
||||
sty_and_variant_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,8 +78,8 @@ pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
LpDowncast(ref base_lp, _) =>
|
||||
move_data.add_variant_match(
|
||||
tcx, lp.clone(), move_pat.id, base_lp.clone(), mode),
|
||||
_ => panic!("should only call gather_match_variant \
|
||||
for cat_downcast cmt"),
|
||||
_ => bug!("should only call gather_match_variant \
|
||||
for cat_downcast cmt"),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
|
|
|
@ -378,10 +378,10 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
|
|||
ty::ReEarlyBound(..) |
|
||||
ty::ReVar(..) |
|
||||
ty::ReSkolemized(..) => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
cmt.span,
|
||||
&format!("invalid borrow lifetime: {:?}",
|
||||
loan_region));
|
||||
"invalid borrow lifetime: {:?}",
|
||||
loan_region);
|
||||
}
|
||||
};
|
||||
debug!("loan_scope = {:?}", loan_scope);
|
||||
|
|
|
@ -134,8 +134,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
a non-copy fixed-size array",
|
||||
b.ty)
|
||||
} else {
|
||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
||||
unreachable!();
|
||||
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,14 +149,12 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
b.ty)
|
||||
},
|
||||
_ => {
|
||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
||||
unreachable!();
|
||||
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
||||
unreachable!();
|
||||
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -569,7 +569,7 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &TyCtxt<'tcx>) -> MoveData<'tcx> {
|
|||
Rvalue::InlineAsm { .. } => {}
|
||||
|
||||
Rvalue::Slice {..} => {
|
||||
bb_ctxt.tcx.sess.bug("cannot move out of slice");
|
||||
bug!("cannot move out of slice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -420,10 +420,10 @@ pub fn closure_to_block(closure_id: ast::NodeId,
|
|||
block.id
|
||||
}
|
||||
_ => {
|
||||
panic!("encountered non-closure id: {}", closure_id)
|
||||
bug!("encountered non-closure id: {}", closure_id)
|
||||
}
|
||||
},
|
||||
_ => panic!("encountered non-expr id: {}", closure_id)
|
||||
_ => bug!("encountered non-expr id: {}", closure_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -704,10 +704,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
(self.tcx.expr_ty_adjusted(&expr), expr.span)
|
||||
}
|
||||
r => {
|
||||
self.tcx.sess.bug(&format!("MoveExpr({}) maps to \
|
||||
{:?}, not Expr",
|
||||
the_move.id,
|
||||
r))
|
||||
bug!("MoveExpr({}) maps to {:?}, not Expr",
|
||||
the_move.id,
|
||||
r)
|
||||
}
|
||||
};
|
||||
let (suggestion, _) =
|
||||
|
@ -766,10 +765,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
(self.tcx.expr_ty_adjusted(&expr), expr.span)
|
||||
}
|
||||
r => {
|
||||
self.tcx.sess.bug(&format!("Captured({}) maps to \
|
||||
{:?}, not Expr",
|
||||
the_move.id,
|
||||
r))
|
||||
bug!("Captured({}) maps to {:?}, not Expr",
|
||||
the_move.id,
|
||||
r)
|
||||
}
|
||||
};
|
||||
let (suggestion, help) =
|
||||
|
@ -852,10 +850,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
self.tcx.sess.span_err_with_code(s, msg, code);
|
||||
}
|
||||
|
||||
pub fn span_bug(&self, s: Span, m: &str) {
|
||||
self.tcx.sess.span_bug(s, m);
|
||||
}
|
||||
|
||||
pub fn bckerr_to_string(&self, err: &BckError<'tcx>) -> String {
|
||||
match err.code {
|
||||
err_mutbl => {
|
||||
|
@ -895,7 +889,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
format!("cannot borrow {} as mutable", descr)
|
||||
}
|
||||
BorrowViolation(euv::ClosureInvocation) => {
|
||||
self.tcx.sess.span_bug(err.span,
|
||||
span_bug!(err.span,
|
||||
"err_mutbl with a closure invocation");
|
||||
}
|
||||
}
|
||||
|
@ -1035,7 +1029,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
// We need to determine which is the case here.
|
||||
let kind = match err.cmt.upvar().unwrap().cat {
|
||||
Categorization::Upvar(mc::Upvar { kind, .. }) => kind,
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
if kind == ty::ClosureKind::Fn {
|
||||
db.span_help(
|
||||
|
|
|
@ -515,7 +515,7 @@ impl<'tcx> MoveData<'tcx> {
|
|||
assignment_index);
|
||||
}
|
||||
LpExtend(..) => {
|
||||
tcx.sess.bug("var assignment for non var path");
|
||||
bug!("var assignment for non var path");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
|
||||
// refers to the borrowck-specific graphviz adapter traits.
|
||||
extern crate graphviz as dot;
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
extern crate rustc_front;
|
||||
extern crate rustc_mir;
|
||||
|
|
|
@ -339,7 +339,7 @@ fn check_arms(cx: &MatchCheckCtxt,
|
|||
// `Some(<head>)` and `None`. It's impossible to have an unreachable
|
||||
// pattern
|
||||
// (see libsyntax/ext/expand.rs for the full expansion of a for loop)
|
||||
cx.tcx.sess.span_bug(pat.span, "unreachable for-loop pattern")
|
||||
span_bug!(pat.span, "unreachable for-loop pattern")
|
||||
},
|
||||
|
||||
hir::MatchSource::Normal => {
|
||||
|
@ -347,12 +347,12 @@ fn check_arms(cx: &MatchCheckCtxt,
|
|||
},
|
||||
|
||||
hir::MatchSource::TryDesugar => {
|
||||
cx.tcx.sess.span_bug(pat.span, "unreachable try pattern")
|
||||
span_bug!(pat.span, "unreachable try pattern")
|
||||
},
|
||||
}
|
||||
}
|
||||
Useful => (),
|
||||
UsefulWithWitness(_) => unreachable!()
|
||||
UsefulWithWitness(_) => bug!()
|
||||
}
|
||||
if guard.is_none() {
|
||||
let Matrix(mut rows) = seen;
|
||||
|
@ -384,9 +384,9 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
|
|||
let witness = match witnesses[0].node {
|
||||
PatKind::TupleStruct(_, Some(ref pats)) => match &pats[..] {
|
||||
[ref pat] => &**pat,
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
};
|
||||
span_err!(cx.tcx.sess, sp, E0297,
|
||||
"refutable pattern in `for` loop binding: \
|
||||
|
@ -399,7 +399,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
|
|||
}).collect();
|
||||
const LIMIT: usize = 3;
|
||||
let joined_patterns = match pattern_strings.len() {
|
||||
0 => unreachable!(),
|
||||
0 => bug!(),
|
||||
1 => format!("`{}`", pattern_strings[0]),
|
||||
2...LIMIT => {
|
||||
let (tail, head) = pattern_strings.split_last().unwrap();
|
||||
|
@ -420,14 +420,14 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
|
|||
NotUseful => {
|
||||
// This is good, wildcard pattern isn't reachable
|
||||
},
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
|
||||
fn const_val_to_expr(value: &ConstVal) -> P<hir::Expr> {
|
||||
let node = match value {
|
||||
&ConstVal::Bool(b) => ast::LitKind::Bool(b),
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
P(hir::Expr {
|
||||
id: 0,
|
||||
|
@ -579,14 +579,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
|
|||
assert_eq!(pats_len, n);
|
||||
PatKind::Vec(pats.collect(), None, hir::HirVec::new())
|
||||
},
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
},
|
||||
ty::TySlice(_) => match ctor {
|
||||
&Slice(n) => {
|
||||
assert_eq!(pats_len, n);
|
||||
PatKind::Vec(pats.collect(), None, hir::HirVec::new())
|
||||
},
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
},
|
||||
ty::TyStr => PatKind::Wild,
|
||||
|
||||
|
@ -791,17 +791,16 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
|
|||
PatKind::Struct(..) | PatKind::TupleStruct(..) | PatKind::Path(..) | PatKind::Ident(..) =>
|
||||
match cx.tcx.def_map.borrow().get(&pat.id).unwrap().full_def() {
|
||||
Def::Const(..) | Def::AssociatedConst(..) =>
|
||||
cx.tcx.sess.span_bug(pat.span, "const pattern should've \
|
||||
been rewritten"),
|
||||
span_bug!(pat.span, "const pattern should've \
|
||||
been rewritten"),
|
||||
Def::Struct(..) | Def::TyAlias(..) => vec![Single],
|
||||
Def::Variant(_, id) => vec![Variant(id)],
|
||||
Def::Local(..) => vec![],
|
||||
def => cx.tcx.sess.span_bug(pat.span, &format!("pat_constructors: unexpected \
|
||||
definition {:?}", def)),
|
||||
def => span_bug!(pat.span, "pat_constructors: unexpected \
|
||||
definition {:?}", def),
|
||||
},
|
||||
PatKind::QPath(..) =>
|
||||
cx.tcx.sess.span_bug(pat.span, "const pattern should've \
|
||||
been rewritten"),
|
||||
span_bug!(pat.span, "const pattern should've been rewritten"),
|
||||
PatKind::Lit(ref expr) =>
|
||||
vec!(ConstantValue(eval_const_expr(cx.tcx, &expr))),
|
||||
PatKind::Range(ref lo, ref hi) =>
|
||||
|
@ -837,7 +836,7 @@ pub fn constructor_arity(_cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> us
|
|||
ty::TySlice(_) => match *ctor {
|
||||
Slice(length) => length,
|
||||
ConstantValue(_) => 0,
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
},
|
||||
ty::TyStr => 0,
|
||||
_ => 1
|
||||
|
@ -856,7 +855,7 @@ fn range_covered_by_constructor(ctor: &Constructor,
|
|||
ConstantValue(ref value) => (value, value),
|
||||
ConstantRange(ref from, ref to) => (from, to),
|
||||
Single => return Some(true),
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
let cmp_from = compare_const_vals(c_from, from);
|
||||
let cmp_to = compare_const_vals(c_to, to);
|
||||
|
@ -889,13 +888,13 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
|||
let def = cx.tcx.def_map.borrow().get(&pat_id).unwrap().full_def();
|
||||
match def {
|
||||
Def::Const(..) | Def::AssociatedConst(..) =>
|
||||
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
|
||||
been rewritten"),
|
||||
span_bug!(pat_span, "const pattern should've \
|
||||
been rewritten"),
|
||||
Def::Variant(_, id) if *constructor != Variant(id) => None,
|
||||
Def::Variant(..) | Def::Struct(..) => Some(Vec::new()),
|
||||
Def::Local(..) => Some(vec![DUMMY_WILD_PAT; arity]),
|
||||
_ => cx.tcx.sess.span_bug(pat_span, &format!("specialize: unexpected \
|
||||
definition {:?}", def)),
|
||||
_ => span_bug!(pat_span, "specialize: unexpected \
|
||||
definition {:?}", def),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -903,8 +902,8 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
|||
let def = cx.tcx.def_map.borrow().get(&pat_id).unwrap().full_def();
|
||||
match def {
|
||||
Def::Const(..) | Def::AssociatedConst(..) =>
|
||||
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
|
||||
been rewritten"),
|
||||
span_bug!(pat_span, "const pattern should've \
|
||||
been rewritten"),
|
||||
Def::Variant(_, id) if *constructor != Variant(id) => None,
|
||||
Def::Variant(..) | Def::Struct(..) => {
|
||||
Some(match args {
|
||||
|
@ -917,8 +916,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
|||
}
|
||||
|
||||
PatKind::QPath(_, _) => {
|
||||
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
|
||||
been rewritten")
|
||||
span_bug!(pat_span, "const pattern should've been rewritten")
|
||||
}
|
||||
|
||||
PatKind::Struct(_, ref pattern_fields, _) => {
|
||||
|
@ -1062,7 +1060,7 @@ fn is_refutable<A, F>(cx: &MatchCheckCtxt, pat: &Pat, refutable: F) -> Option<A>
|
|||
match is_useful(cx, &pats, &[DUMMY_WILD_PAT], ConstructWitness) {
|
||||
UsefulWithWitness(pats) => Some(refutable(&pats[0])),
|
||||
NotUseful => None,
|
||||
Useful => unreachable!()
|
||||
Useful => bug!()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1119,12 +1117,11 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
|
|||
PatKind::Ident(hir::BindByRef(_), _, _) => {
|
||||
}
|
||||
_ => {
|
||||
cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
p.span,
|
||||
&format!("binding pattern {} is not an \
|
||||
identifier: {:?}",
|
||||
p.id,
|
||||
p.node));
|
||||
"binding pattern {} is not an identifier: {:?}",
|
||||
p.id,
|
||||
p.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, pat_id: ast::NodeId, spa
|
|||
node: PatKind::Lit(P(expr.clone())),
|
||||
span: span,
|
||||
})),
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
let pats = try!(args.iter()
|
||||
.map(|expr| const_expr_to_pat(tcx, &**expr,
|
||||
|
@ -330,7 +330,7 @@ pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, pat_id: ast::NodeId, spa
|
|||
let (expr, _ty) = lookup_const_by_id(tcx, def_id, substs).unwrap();
|
||||
return const_expr_to_pat(tcx, expr, pat_id, span);
|
||||
},
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
IntTy::I64 => if n == I64_OVERFLOW {
|
||||
return Ok(Integral(Isize(Is64(::std::i64::MIN))));
|
||||
},
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
|
@ -697,7 +697,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
Some(IntType::UnsignedInt(ty)) => ty_hint.checked_or(tcx.mk_mach_uint(ty)),
|
||||
Some(IntType::SignedInt(ty)) => ty_hint.checked_or(tcx.mk_mach_int(ty)),
|
||||
// we had a type hint, so we can't have an unknown type
|
||||
None => unreachable!(),
|
||||
None => bug!(),
|
||||
};
|
||||
eval_const_expr_partial(tcx, &base, hint, fn_args)?
|
||||
},
|
||||
|
@ -798,7 +798,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
hir::ExprBlock(ref block) => {
|
||||
match block.expr {
|
||||
Some(ref expr) => eval_const_expr_partial(tcx, &expr, ty_hint, fn_args)?,
|
||||
None => unreachable!(),
|
||||
None => bug!(),
|
||||
}
|
||||
}
|
||||
hir::ExprType(ref e, _) => eval_const_expr_partial(tcx, &e, ty_hint, fn_args)?,
|
||||
|
@ -813,7 +813,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
let idx_hint = ty_hint.checked_or(tcx.types.usize);
|
||||
let idx = match eval_const_expr_partial(tcx, idx, idx_hint, fn_args)? {
|
||||
Integral(Usize(i)) => i.as_u64(tcx.sess.target.uint_type),
|
||||
Integral(_) => unreachable!(),
|
||||
Integral(_) => bug!(),
|
||||
_ => signal!(idx, IndexNotInt),
|
||||
};
|
||||
assert_eq!(idx as usize as u64, idx);
|
||||
|
@ -823,7 +823,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
assert_eq!(n as usize as u64, n);
|
||||
eval_const_expr_partial(tcx, &v[idx as usize], ty_hint, fn_args)?
|
||||
} else {
|
||||
unreachable!()
|
||||
bug!()
|
||||
},
|
||||
|
||||
Repeat(_, n) if idx >= n => signal!(e, IndexOutOfBounds),
|
||||
|
@ -840,7 +840,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
},
|
||||
|
||||
Str(ref s) if idx as usize >= s.len() => signal!(e, IndexOutOfBounds),
|
||||
Str(_) => unimplemented!(), // FIXME: return a const char
|
||||
Str(_) => bug!("unimplemented"), // FIXME: return a const char
|
||||
_ => signal!(e, IndexedNonVec),
|
||||
}
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
signal!(e, TupleIndexOutOfBounds);
|
||||
}
|
||||
} else {
|
||||
unreachable!()
|
||||
bug!()
|
||||
}
|
||||
} else {
|
||||
signal!(base, ExpectedConstTuple);
|
||||
|
@ -888,7 +888,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||
signal!(e, MissingStructField);
|
||||
}
|
||||
} else {
|
||||
unreachable!()
|
||||
bug!()
|
||||
}
|
||||
} else {
|
||||
signal!(base, ExpectedConstStruct);
|
||||
|
@ -1025,7 +1025,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a TyCtxt<'tcx>,
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
ti.span,
|
||||
"resolve_trait_associated_const: unexpected vtable type")
|
||||
}
|
||||
|
@ -1127,7 +1127,7 @@ fn lit_to_const<'tcx>(lit: &ast::LitKind,
|
|||
let int_ty = tcx.enum_repr_type(hints.iter().next());
|
||||
infer(Infer(n), tcx, &int_ty.to_ty(tcx).sty, span).map(Integral)
|
||||
},
|
||||
Some(ty_hint) => panic!("bad ty_hint: {:?}, {:?}", ty_hint, lit),
|
||||
Some(ty_hint) => bug!("bad ty_hint: {:?}, {:?}", ty_hint, lit),
|
||||
}
|
||||
},
|
||||
LitKind::Int(n, Unsigned(ity)) => {
|
||||
|
@ -1140,7 +1140,7 @@ fn lit_to_const<'tcx>(lit: &ast::LitKind,
|
|||
Ok(Float(x))
|
||||
} else {
|
||||
// FIXME(#31407) this is only necessary because float parsing is buggy
|
||||
tcx.sess.span_bug(span, "could not evaluate float literal (see issue #31407)");
|
||||
span_bug!(span, "could not evaluate float literal (see issue #31407)");
|
||||
}
|
||||
}
|
||||
LitKind::Bool(b) => Ok(Bool(b)),
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#[macro_use] extern crate syntax;
|
||||
#[macro_use] extern crate log;
|
||||
extern crate rustc;
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_front;
|
||||
extern crate rustc_back;
|
||||
extern crate rustc_const_math;
|
||||
|
|
|
@ -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 @@ impl LateLintPass for TypeLimits {
|
|||
return;
|
||||
}
|
||||
}
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
};
|
||||
},
|
||||
ty::TyUint(t) => {
|
||||
|
@ -195,7 +195,7 @@ impl LateLintPass for TypeLimits {
|
|||
// _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 @@ impl LateLintPass for TypeLimits {
|
|||
Err(_) => return
|
||||
}
|
||||
}
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
};
|
||||
if lit_val < min || lit_val > max {
|
||||
cx.span_lint(OVERFLOWING_LITERALS, e.span,
|
||||
|
@ -233,7 +233,7 @@ impl LateLintPass for TypeLimits {
|
|||
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 @@ impl LateLintPass for TypeLimits {
|
|||
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 @@ impl LateLintPass for TypeLimits {
|
|||
ast::LitKind::Int(v, _) => v,
|
||||
_ => return true
|
||||
},
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
};
|
||||
is_valid(norm_binop, lit_val, min, max)
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
ty::TyParam(..) | ty::TyInfer(..) | ty::TyError |
|
||||
ty::TyClosure(..) | ty::TyProjection(..) |
|
||||
ty::TyFnDef(..) => {
|
||||
panic!("Unexpected type in foreign function")
|
||||
bug!("Unexpected type in foreign function")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -991,7 +991,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
|||
region: this.read_enum_variant_arg(1,
|
||||
|this| Ok(this.read_region(dcx))).unwrap()
|
||||
}),
|
||||
_ => panic!("bad enum variant for ty::UpvarCapture")
|
||||
_ => bug!("bad enum variant for ty::UpvarCapture")
|
||||
})
|
||||
})
|
||||
}).unwrap()
|
||||
|
@ -1013,7 +1013,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
|||
|
||||
adjustment::AdjustDerefRef(auto_deref_ref)
|
||||
}
|
||||
_ => panic!("bad enum variant for adjustment::AutoAdjustment")
|
||||
_ => bug!("bad enum variant for adjustment::AutoAdjustment")
|
||||
})
|
||||
})
|
||||
}).unwrap()
|
||||
|
@ -1072,7 +1072,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
|||
|
||||
adjustment::AutoUnsafe(m)
|
||||
}
|
||||
_ => panic!("bad enum variant for adjustment::AutoRef")
|
||||
_ => bug!("bad enum variant for adjustment::AutoRef")
|
||||
})
|
||||
})
|
||||
}).unwrap()
|
||||
|
@ -1140,9 +1140,7 @@ fn decode_side_tables(dcx: &DecodeContext,
|
|||
let decoded_tag: Option<c::astencode_tag> = c::astencode_tag::from_u32(tag);
|
||||
match decoded_tag {
|
||||
None => {
|
||||
dcx.tcx.sess.bug(
|
||||
&format!("unknown tag found in side tables: {:x}",
|
||||
tag));
|
||||
bug!("unknown tag found in side tables: {:x}", tag);
|
||||
}
|
||||
Some(value) => {
|
||||
let val_dsr = &mut entry_dsr;
|
||||
|
@ -1206,9 +1204,7 @@ fn decode_side_tables(dcx: &DecodeContext,
|
|||
dcx.tcx.const_qualif_map.borrow_mut().insert(id, qualif);
|
||||
}
|
||||
_ => {
|
||||
dcx.tcx.sess.bug(
|
||||
&format!("unknown tag found in side tables: {:x}",
|
||||
tag));
|
||||
bug!("unknown tag found in side tables: {:x}", tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1404,6 +1400,6 @@ fn test_simplification() {
|
|||
assert!(pprust::item_to_string(&item_out) ==
|
||||
pprust::item_to_string(&item_exp));
|
||||
}
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ use syntax::codemap::{self, Span, mk_sp, Pos};
|
|||
use syntax::parse;
|
||||
use syntax::attr;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::errors::FatalError;
|
||||
use syntax::parse::token::InternedString;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use rustc_front::hir;
|
||||
|
@ -527,7 +526,7 @@ impl<'a> CrateReader<'a> {
|
|||
load_ctxt.filesearch = self.sess.target_filesearch(PathKind::Crate);
|
||||
load_ctxt.load_library_crate()
|
||||
}
|
||||
None => { load_ctxt.report_load_errs(); unreachable!() },
|
||||
None => { load_ctxt.report_load_errs(); },
|
||||
};
|
||||
|
||||
let dylib = library.dylib.clone();
|
||||
|
@ -573,7 +572,8 @@ impl<'a> CrateReader<'a> {
|
|||
Ok(body) => body,
|
||||
Err(mut err) => {
|
||||
err.emit();
|
||||
panic!(FatalError);
|
||||
self.sess.abort_if_errors();
|
||||
unreachable!();
|
||||
}
|
||||
};
|
||||
let local_span = mk_sp(lo, p.last_span.hi);
|
||||
|
|
|
@ -70,7 +70,7 @@ impl crate_metadata {
|
|||
|
||||
fn lookup_item(&self, item_id: DefIndex) -> rbml::Doc {
|
||||
match self.get_item(item_id) {
|
||||
None => panic!("lookup_item: id not found: {:?}", item_id),
|
||||
None => bug!("lookup_item: id not found: {:?}", item_id),
|
||||
Some(d) => d
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ fn item_family(item: rbml::Doc) -> Family {
|
|||
'u' => Struct(VariantKind::Unit),
|
||||
'g' => PublicField,
|
||||
'N' => InheritedField,
|
||||
c => panic!("unexpected family char: {}", c)
|
||||
c => bug!("unexpected family char: {}", c)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ fn item_visibility(item: rbml::Doc) -> hir::Visibility {
|
|||
match reader::doc_as_u8(visibility_doc) as char {
|
||||
'y' => hir::Public,
|
||||
'i' => hir::Inherited,
|
||||
_ => panic!("unknown visibility character")
|
||||
_ => bug!("unknown visibility character")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ fn fn_constness(item: rbml::Doc) -> hir::Constness {
|
|||
match reader::doc_as_u8(constness_doc) as char {
|
||||
'c' => hir::Constness::Const,
|
||||
'n' => hir::Constness::NotConst,
|
||||
_ => panic!("unknown constness character")
|
||||
_ => bug!("unknown constness character")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ fn item_defaultness(item: rbml::Doc) -> hir::Defaultness {
|
|||
match reader::doc_as_u8(defaultness_doc) as char {
|
||||
'd' => hir::Defaultness::Default,
|
||||
'f' => hir::Defaultness::Final,
|
||||
_ => panic!("unknown defaultness character")
|
||||
_ => bug!("unknown defaultness character")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -387,16 +387,15 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
|||
item_id: DefIndex,
|
||||
tcx: &TyCtxt<'tcx>) -> ty::AdtDefMaster<'tcx>
|
||||
{
|
||||
fn expect_variant_kind<'tcx>(family: Family, tcx: &TyCtxt<'tcx>) -> ty::VariantKind {
|
||||
fn expect_variant_kind(family: Family) -> ty::VariantKind {
|
||||
match family_to_variant_kind(family) {
|
||||
Some(kind) => kind,
|
||||
_ => tcx.sess.bug(&format!("unexpected family: {:?}", family)),
|
||||
_ => bug!("unexpected family: {:?}", family),
|
||||
}
|
||||
}
|
||||
fn get_enum_variants<'tcx>(intr: &IdentInterner,
|
||||
cdata: Cmd,
|
||||
doc: rbml::Doc,
|
||||
tcx: &TyCtxt<'tcx>) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
|
||||
doc: rbml::Doc) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
|
||||
let mut disr_val = 0;
|
||||
reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| {
|
||||
let did = translated_def_id(cdata, p);
|
||||
|
@ -411,22 +410,21 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
|||
ty::VariantDefData {
|
||||
did: did,
|
||||
name: item_name(intr, item),
|
||||
fields: get_variant_fields(intr, cdata, item, tcx),
|
||||
fields: get_variant_fields(intr, cdata, item),
|
||||
disr_val: ConstInt::Infer(disr),
|
||||
kind: expect_variant_kind(item_family(item), tcx),
|
||||
kind: expect_variant_kind(item_family(item)),
|
||||
}
|
||||
}).collect()
|
||||
}
|
||||
fn get_variant_fields<'tcx>(intr: &IdentInterner,
|
||||
cdata: Cmd,
|
||||
doc: rbml::Doc,
|
||||
tcx: &TyCtxt<'tcx>) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
|
||||
doc: rbml::Doc) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
|
||||
let mut index = 0;
|
||||
reader::tagged_docs(doc, tag_item_field).map(|f| {
|
||||
let ff = item_family(f);
|
||||
match ff {
|
||||
PublicField | InheritedField => {},
|
||||
_ => tcx.sess.bug(&format!("expected field, found {:?}", ff))
|
||||
_ => bug!("expected field, found {:?}", ff)
|
||||
};
|
||||
ty::FieldDefData::new(item_def_id(f, cdata),
|
||||
item_name(intr, f),
|
||||
|
@ -442,14 +440,13 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
|||
fn get_struct_variant<'tcx>(intr: &IdentInterner,
|
||||
cdata: Cmd,
|
||||
doc: rbml::Doc,
|
||||
did: DefId,
|
||||
tcx: &TyCtxt<'tcx>) -> ty::VariantDefData<'tcx, 'tcx> {
|
||||
did: DefId) -> ty::VariantDefData<'tcx, 'tcx> {
|
||||
ty::VariantDefData {
|
||||
did: did,
|
||||
name: item_name(intr, doc),
|
||||
fields: get_variant_fields(intr, cdata, doc, tcx),
|
||||
fields: get_variant_fields(intr, cdata, doc),
|
||||
disr_val: ConstInt::Infer(0),
|
||||
kind: expect_variant_kind(item_family(doc), tcx),
|
||||
kind: expect_variant_kind(item_family(doc)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -458,18 +455,17 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
|||
let (kind, variants) = match item_family(doc) {
|
||||
Enum => {
|
||||
(ty::AdtKind::Enum,
|
||||
get_enum_variants(intr, cdata, doc, tcx))
|
||||
get_enum_variants(intr, cdata, doc))
|
||||
}
|
||||
Struct(..) => {
|
||||
let ctor_did =
|
||||
reader::maybe_get_doc(doc, tag_items_data_item_struct_ctor).
|
||||
map_or(did, |ctor_doc| translated_def_id(cdata, ctor_doc));
|
||||
(ty::AdtKind::Struct,
|
||||
vec![get_struct_variant(intr, cdata, doc, ctor_did, tcx)])
|
||||
vec![get_struct_variant(intr, cdata, doc, ctor_did)])
|
||||
}
|
||||
_ => tcx.sess.bug(
|
||||
&format!("get_adt_def called on a non-ADT {:?} - {:?}",
|
||||
item_family(doc), did))
|
||||
_ => bug!("get_adt_def called on a non-ADT {:?} - {:?}",
|
||||
item_family(doc), did)
|
||||
};
|
||||
|
||||
let adt = tcx.intern_adt_def(did, kind, variants);
|
||||
|
@ -495,7 +491,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
|||
assert!(!inputs.has_escaping_regions());
|
||||
inputs
|
||||
},
|
||||
_ => tcx.sess.bug("tuple-variant ctor is not an ADT")
|
||||
_ => bug!("tuple-variant ctor is not an ADT")
|
||||
};
|
||||
for (field, &ty) in variant.fields.iter().zip(field_tys.iter()) {
|
||||
field.fulfill_ty(ty);
|
||||
|
@ -915,7 +911,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory {
|
|||
match ch as char {
|
||||
'i' => hir::MutImmutable,
|
||||
'm' => hir::MutMutable,
|
||||
_ => panic!("unknown mutability character: `{}`", ch as char),
|
||||
_ => bug!("unknown mutability character: `{}`", ch as char),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -933,7 +929,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory {
|
|||
ty::ReEmpty,
|
||||
get_mutability(string.as_bytes()[1]))
|
||||
}
|
||||
_ => panic!("unknown self type code: `{}`", explicit_self_kind as char)
|
||||
_ => bug!("unknown self type code: `{}`", explicit_self_kind as char)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -946,7 +942,7 @@ pub fn get_impl_items(cdata: Cmd, impl_id: DefIndex)
|
|||
Some('C') | Some('c') => ty::ConstTraitItemId(def_id),
|
||||
Some('r') | Some('p') => ty::MethodTraitItemId(def_id),
|
||||
Some('t') => ty::TypeTraitItemId(def_id),
|
||||
_ => panic!("unknown impl item sort"),
|
||||
_ => bug!("unknown impl item sort"),
|
||||
}
|
||||
}).collect()
|
||||
}
|
||||
|
@ -1012,9 +1008,9 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
|
|||
let ity = tcx.lookup_item_type(def_id).ty;
|
||||
let fty = match ity.sty {
|
||||
ty::TyFnDef(_, _, fty) => fty.clone(),
|
||||
_ => tcx.sess.bug(&format!(
|
||||
_ => bug!(
|
||||
"the type {:?} of the method {:?} is not a function?",
|
||||
ity, name))
|
||||
ity, name)
|
||||
};
|
||||
let explicit_self = get_explicit_self(item_doc);
|
||||
|
||||
|
@ -1052,7 +1048,7 @@ pub fn get_trait_item_def_ids(cdata: Cmd, id: DefIndex)
|
|||
Some('C') | Some('c') => ty::ConstTraitItemId(def_id),
|
||||
Some('r') | Some('p') => ty::MethodTraitItemId(def_id),
|
||||
Some('t') => ty::TypeTraitItemId(def_id),
|
||||
_ => panic!("unknown trait item sort"),
|
||||
_ => bug!("unknown trait item sort"),
|
||||
}
|
||||
}).collect()
|
||||
}
|
||||
|
@ -1172,7 +1168,7 @@ fn struct_field_family_to_visibility(family: Family) -> hir::Visibility {
|
|||
match family {
|
||||
PublicField => hir::Public,
|
||||
InheritedField => hir::Inherited,
|
||||
_ => panic!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1354,7 +1350,7 @@ pub fn translate_def_id(cdata: Cmd, did: DefId) -> DefId {
|
|||
index: did.index,
|
||||
}
|
||||
}
|
||||
None => panic!("didn't find a crate in the cnum_map")
|
||||
None => bug!("didn't find a crate in the cnum_map")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1544,7 +1540,7 @@ pub fn get_dylib_dependency_formats(cdata: Cmd)
|
|||
let cnum: ast::CrateNum = cnum.parse().unwrap();
|
||||
let cnum = match cdata.cnum_map.borrow().get(&cnum) {
|
||||
Some(&n) => n,
|
||||
None => panic!("didn't find a crate in the cnum_map")
|
||||
None => bug!("didn't find a crate in the cnum_map")
|
||||
};
|
||||
result.push((cnum, if link == "d" {
|
||||
LinkagePreference::RequireDynamic
|
||||
|
@ -1772,7 +1768,7 @@ pub fn def_key(cdata: Cmd, id: DefIndex) -> hir_map::DefKey {
|
|||
hir_map::DefKey::decode(&mut decoder).unwrap()
|
||||
}
|
||||
None => {
|
||||
panic!("failed to find block with tag {:?} for item with family {:?}",
|
||||
bug!("failed to find block with tag {:?} for item with family {:?}",
|
||||
tag_def_key,
|
||||
item_family(item_doc))
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ fn encode_symbol(ecx: &EncodeContext,
|
|||
rbml_w.wr_tagged_str(tag_items_data_item_symbol, x);
|
||||
}
|
||||
None => {
|
||||
ecx.diag.bug(&format!("encode_symbol: id not found {}", id));
|
||||
bug!("encode_symbol: id not found {}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ extern crate flate;
|
|||
extern crate rbml;
|
||||
extern crate serialize;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
extern crate rustc_back;
|
||||
extern crate rustc_front;
|
||||
|
|
|
@ -300,16 +300,10 @@ impl<'a> Context<'a> {
|
|||
}
|
||||
|
||||
pub fn load_library_crate(&mut self) -> Library {
|
||||
match self.find_library_crate() {
|
||||
Some(t) => t,
|
||||
None => {
|
||||
self.report_load_errs();
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
self.find_library_crate().unwrap_or_else(|| self.report_load_errs())
|
||||
}
|
||||
|
||||
pub fn report_load_errs(&mut self) {
|
||||
pub fn report_load_errs(&mut self) -> ! {
|
||||
let add = match self.root {
|
||||
&None => String::new(),
|
||||
&Some(ref r) => format!(" which `{}` depends on",
|
||||
|
@ -374,6 +368,7 @@ impl<'a> Context<'a> {
|
|||
|
||||
err.emit();
|
||||
self.sess.abort_if_errors();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
fn find_library_crate(&mut self) -> Option<Library> {
|
||||
|
|
|
@ -167,7 +167,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
ty::BrFresh(id)
|
||||
}
|
||||
'e' => ty::BrEnv,
|
||||
_ => panic!("parse_bound_region: bad input")
|
||||
_ => bug!("parse_bound_region: bad input")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
'e' => {
|
||||
ty::ReStatic
|
||||
}
|
||||
_ => panic!("parse_region: bad input")
|
||||
_ => bug!("parse_region: bad input")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
};
|
||||
region::CodeExtentData::Remainder(block_remainder)
|
||||
}
|
||||
_ => panic!("parse_scope: bad input")
|
||||
_ => bug!("parse_scope: bad input")
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
match self.next() {
|
||||
'n' => None,
|
||||
's' => Some(f(self)),
|
||||
_ => panic!("parse_opt: bad input")
|
||||
_ => bug!("parse_opt: bad input")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
'D' => return tcx.types.i64,
|
||||
'f' => return tcx.types.f32,
|
||||
'F' => return tcx.types.f64,
|
||||
_ => panic!("parse_ty: bad numeric type")
|
||||
_ => bug!("parse_ty: bad numeric type")
|
||||
}
|
||||
}
|
||||
'c' => return tcx.types.char,
|
||||
|
@ -441,7 +441,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
'e' => {
|
||||
return tcx.types.err;
|
||||
}
|
||||
c => { panic!("unexpected char in type string: {}", c);}
|
||||
c => { bug!("unexpected char in type string: {}", c);}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
let variadic = match self.next() {
|
||||
'V' => true,
|
||||
'N' => false,
|
||||
r => panic!(format!("bad variadic: {}", r)),
|
||||
r => bug!("bad variadic: {}", r),
|
||||
};
|
||||
let output = match self.peek() {
|
||||
'z' => {
|
||||
|
@ -553,7 +553,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
assert_eq!(self.next(), '|');
|
||||
ty::Predicate::ObjectSafe(def_id)
|
||||
}
|
||||
c => panic!("Encountered invalid character in metadata: {}", c)
|
||||
c => bug!("Encountered invalid character in metadata: {}", c)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
'R' => bounds.push(self.parse_region()),
|
||||
'.' => { break; }
|
||||
c => {
|
||||
panic!("parse_region_param_def: bad bounds ('{}')", c)
|
||||
bug!("parse_region_param_def: bad bounds ('{}')", c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,7 +624,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
let region = self.parse_region();
|
||||
ty::ObjectLifetimeDefault::Specific(region)
|
||||
}
|
||||
_ => panic!("parse_object_lifetime_default: bad input")
|
||||
_ => bug!("parse_object_lifetime_default: bad input")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
}
|
||||
'.' => { break; }
|
||||
c => {
|
||||
panic!("parse_bounds: bad bounds ('{}')", c)
|
||||
bug!("parse_bounds: bad bounds ('{}')", c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
|||
return builtin_bounds;
|
||||
}
|
||||
c => {
|
||||
panic!("parse_bounds: bad builtin bounds ('{}')", c)
|
||||
bug!("parse_bounds: bad builtin bounds ('{}')", c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ fn parse_defid(buf: &[u8]) -> DefId {
|
|||
while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1; }
|
||||
if colon_idx == len {
|
||||
error!("didn't find ':' when parsing def id");
|
||||
panic!();
|
||||
bug!();
|
||||
}
|
||||
|
||||
let crate_part = &buf[0..colon_idx];
|
||||
|
@ -693,14 +693,14 @@ fn parse_defid(buf: &[u8]) -> DefId {
|
|||
s.parse::<usize>().ok()
|
||||
}) {
|
||||
Some(cn) => cn as ast::CrateNum,
|
||||
None => panic!("internal error: parse_defid: crate number expected, found {:?}",
|
||||
None => bug!("internal error: parse_defid: crate number expected, found {:?}",
|
||||
crate_part)
|
||||
};
|
||||
let def_num = match str::from_utf8(def_part).ok().and_then(|s| {
|
||||
s.parse::<usize>().ok()
|
||||
}) {
|
||||
Some(dn) => dn,
|
||||
None => panic!("internal error: parse_defid: id expected, found {:?}",
|
||||
None => bug!("internal error: parse_defid: id expected, found {:?}",
|
||||
def_part)
|
||||
};
|
||||
let index = DefIndex::new(def_num);
|
||||
|
@ -711,6 +711,6 @@ fn parse_unsafety(c: char) -> hir::Unsafety {
|
|||
match c {
|
||||
'u' => hir::Unsafety::Unsafe,
|
||||
'n' => hir::Unsafety::Normal,
|
||||
_ => panic!("parse_unsafety: bad unsafety {}", c)
|
||||
_ => bug!("parse_unsafety: bad unsafety {}", c)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Cursor<Vec<u8>>, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx
|
|||
enc_bare_fn_ty(w, cx, f);
|
||||
}
|
||||
ty::TyInfer(_) => {
|
||||
cx.diag.bug("cannot encode inference variable types");
|
||||
bug!("cannot encode inference variable types");
|
||||
}
|
||||
ty::TyParam(ParamTy {space, idx, name}) => {
|
||||
write!(w, "p[{}|{}|{}]", idx, space.to_uint(), name);
|
||||
|
@ -285,7 +285,7 @@ pub fn enc_region(w: &mut Cursor<Vec<u8>>, cx: &ctxt, r: ty::Region) {
|
|||
}
|
||||
ty::ReVar(_) | ty::ReSkolemized(..) => {
|
||||
// these should not crop up after typeck
|
||||
cx.diag.bug("cannot encode region variables");
|
||||
bug!("cannot encode region variables");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,10 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
ExprKind::Literal { literal } =>
|
||||
Constant { span: span, ty: ty, literal: literal },
|
||||
_ =>
|
||||
this.hir.span_bug(
|
||||
span_bug!(
|
||||
span,
|
||||
&format!("expression is not a valid constant {:?}", kind)),
|
||||
"expression is not a valid constant {:?}",
|
||||
kind),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
let temp_lifetime = match expr.temp_lifetime {
|
||||
Some(t) => t,
|
||||
None => {
|
||||
this.hir.span_bug(expr.span, "no temp_lifetime for expr");
|
||||
span_bug!(expr.span, "no temp_lifetime for expr");
|
||||
}
|
||||
};
|
||||
this.schedule_drop(expr.span, temp_lifetime, &temp, expr_ty);
|
||||
|
|
|
@ -162,10 +162,10 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
unpack!(block = self.simplify_candidate(block, &mut candidate));
|
||||
|
||||
if !candidate.match_pairs.is_empty() {
|
||||
self.hir.span_bug(candidate.match_pairs[0].pattern.span,
|
||||
&format!("match pairs {:?} remaining after simplifying \
|
||||
irrefutable pattern",
|
||||
candidate.match_pairs));
|
||||
span_bug!(candidate.match_pairs[0].pattern.span,
|
||||
"match pairs {:?} remaining after simplifying \
|
||||
irrefutable pattern",
|
||||
candidate.match_pairs);
|
||||
}
|
||||
|
||||
// now apply the bindings, which will also declare the variables
|
||||
|
|
|
@ -521,8 +521,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
}
|
||||
|
||||
fn error_simplifyable<'pat>(&mut self, match_pair: &MatchPair<'pat, 'tcx>) -> ! {
|
||||
self.hir.span_bug(match_pair.pattern.span,
|
||||
&format!("simplifyable pattern found: {:?}", match_pair.pattern))
|
||||
span_bug!(match_pair.pattern.span,
|
||||
"simplifyable pattern found: {:?}",
|
||||
match_pair.pattern)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -218,8 +218,8 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
|
|||
.enumerate()
|
||||
.all(|(index, block)| {
|
||||
if block.terminator.is_none() {
|
||||
panic!("no terminator on block {:?} in fn {:?}",
|
||||
index, fn_id)
|
||||
bug!("no terminator on block {:?} in fn {:?}",
|
||||
index, fn_id)
|
||||
}
|
||||
true
|
||||
}));
|
||||
|
|
|
@ -306,7 +306,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
debug!("exit_scope(extent={:?}, block={:?}, target={:?})", extent, block, target);
|
||||
let scope_count = 1 + self.scopes.iter().rev().position(|scope| scope.extent == extent)
|
||||
.unwrap_or_else(||{
|
||||
self.hir.span_bug(span, &format!("extent {:?} does not enclose", extent))
|
||||
span_bug!(span, "extent {:?} does not enclose", extent)
|
||||
});
|
||||
|
||||
let tmp = self.get_unit_temp();
|
||||
|
@ -345,7 +345,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
span: Span,
|
||||
label: Option<CodeExtent>)
|
||||
-> &mut LoopScope {
|
||||
let Builder { ref mut loop_scopes, ref mut hir, .. } = *self;
|
||||
let loop_scopes = &mut self.loop_scopes;
|
||||
match label {
|
||||
None => {
|
||||
// no label? return the innermost loop scope
|
||||
|
@ -358,7 +358,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
.filter(|loop_scope| loop_scope.extent == label)
|
||||
.next()
|
||||
}
|
||||
}.unwrap_or_else(|| hir.span_bug(span, "no enclosing loop scope found?"))
|
||||
}.unwrap_or_else(|| span_bug!(span, "no enclosing loop scope found?"))
|
||||
}
|
||||
|
||||
pub fn innermost_scope_id(&self) -> ScopeId {
|
||||
|
@ -410,8 +410,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
scope.invalidate_cache()
|
||||
}
|
||||
}
|
||||
self.hir.span_bug(span,
|
||||
&format!("extent {:?} not in scope to drop {:?}", extent, lvalue));
|
||||
span_bug!(span, "extent {:?} not in scope to drop {:?}", extent, lvalue);
|
||||
}
|
||||
|
||||
/// Schedule dropping of a not-yet-fully-initialised box.
|
||||
|
@ -444,8 +443,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
scope.invalidate_cache();
|
||||
}
|
||||
}
|
||||
self.hir.span_bug(span,
|
||||
&format!("extent {:?} not in scope to free {:?}", extent, value));
|
||||
span_bug!(span, "extent {:?} not in scope to free {:?}", extent, value);
|
||||
}
|
||||
|
||||
// Other
|
||||
|
@ -531,7 +529,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
let tup_ty = if let ty::TyRef(_, tyandmut) = ref_ty.sty {
|
||||
tyandmut.ty
|
||||
} else {
|
||||
self.hir.span_bug(span, &format!("unexpected panic_bound_check type: {:?}", func.ty));
|
||||
span_bug!(span, "unexpected panic_bound_check type: {:?}", func.ty);
|
||||
};
|
||||
|
||||
let (tuple, tuple_ref) = (self.temp(tup_ty), self.temp(ref_ty));
|
||||
|
@ -566,7 +564,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||
let tup_ty = if let ty::TyRef(_, tyandmut) = ref_ty.sty {
|
||||
tyandmut.ty
|
||||
} else {
|
||||
self.hir.span_bug(span, &format!("unexpected panic type: {:?}", func.ty));
|
||||
span_bug!(span, "unexpected panic type: {:?}", func.ty);
|
||||
};
|
||||
|
||||
let (tuple, tuple_ref) = (self.temp(tup_ty), self.temp(ref_ty));
|
||||
|
|
|
@ -64,11 +64,11 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
|||
|
||||
let sig = match method.ty.sty {
|
||||
ty::TyFnDef(_, _, fn_ty) => &fn_ty.sig,
|
||||
_ => cx.tcx.sess.span_bug(self.span, "type of method is not an fn")
|
||||
_ => span_bug!(self.span, "type of method is not an fn")
|
||||
};
|
||||
|
||||
let sig = cx.tcx.no_late_bound_regions(sig).unwrap_or_else(|| {
|
||||
cx.tcx.sess.span_bug(self.span, "method call has late-bound regions")
|
||||
span_bug!(self.span, "method call has late-bound regions")
|
||||
});
|
||||
|
||||
assert_eq!(sig.inputs.len(), 2);
|
||||
|
@ -128,7 +128,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
|||
hir::ExprAddrOf(mutbl, ref expr) => {
|
||||
let region = match expr_ty.sty {
|
||||
ty::TyRef(r, _) => r,
|
||||
_ => cx.tcx.sess.span_bug(expr.span, "type of & not region"),
|
||||
_ => span_bug!(expr.span, "type of & not region"),
|
||||
};
|
||||
ExprKind::Borrow {
|
||||
region: *region,
|
||||
|
@ -297,16 +297,18 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
|||
}
|
||||
}
|
||||
ref def => {
|
||||
cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
self.span,
|
||||
&format!("unexpected def: {:?}", def));
|
||||
"unexpected def: {:?}",
|
||||
def);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
self.span,
|
||||
&format!("unexpected type for struct literal: {:?}", expr_ty));
|
||||
"unexpected type for struct literal: {:?}",
|
||||
expr_ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,9 +318,9 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
|||
let (def_id, substs) = match closure_ty.sty {
|
||||
ty::TyClosure(def_id, ref substs) => (def_id, substs),
|
||||
_ => {
|
||||
cx.tcx.sess.span_bug(self.span,
|
||||
&format!("closure expr w/o closure type: {:?}",
|
||||
closure_ty));
|
||||
span_bug!(self.span,
|
||||
"closure expr w/o closure type: {:?}",
|
||||
closure_ty);
|
||||
}
|
||||
};
|
||||
let upvars = cx.tcx.with_freevars(self.id, |freevars| {
|
||||
|
@ -355,7 +357,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
|||
span: c.span,
|
||||
value: match const_eval::eval_const_expr(cx.tcx, c) {
|
||||
ConstVal::Integral(ConstInt::Usize(u)) => u,
|
||||
other => panic!("constant evaluation of repeat count yielded {:?}", other),
|
||||
other => bug!("constant evaluation of repeat count yielded {:?}", other),
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -383,14 +385,16 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
|||
ty::TyStruct(adt_def, _) =>
|
||||
adt_def.variants[0].index_of_field_named(name.node),
|
||||
ref ty =>
|
||||
cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
self.span,
|
||||
&format!("field of non-struct: {:?}", ty)),
|
||||
"field of non-struct: {:?}",
|
||||
ty),
|
||||
};
|
||||
let index = index.unwrap_or_else(|| {
|
||||
cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
self.span,
|
||||
&format!("no index found for field `{}`", name.node));
|
||||
"no index found for field `{}`",
|
||||
name.node)
|
||||
});
|
||||
ExprKind::Field { lhs: source.to_ref(), name: Field::new(index) }
|
||||
}
|
||||
|
@ -474,8 +478,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
|||
Some(ty::FnConverging(&ty::TyS {
|
||||
sty: ty::TyRef(region, mt), ..
|
||||
})) => (region, mt.mutbl),
|
||||
_ => cx.tcx.sess.span_bug(
|
||||
expr.span, "autoderef returned bad type")
|
||||
_ => span_bug!(expr.span, "autoderef returned bad type")
|
||||
};
|
||||
|
||||
expr = Expr {
|
||||
|
@ -651,7 +654,7 @@ fn convert_path_expr<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr)
|
|||
fields: vec![],
|
||||
base: None
|
||||
},
|
||||
ref sty => panic!("unexpected sty: {:?}", sty)
|
||||
ref sty => bug!("unexpected sty: {:?}", sty)
|
||||
},
|
||||
Def::Variant(enum_id, variant_id) => match cx.tcx.node_id_to_type(expr.id).sty {
|
||||
// A variant constructor. Should only be reached if not called in the same
|
||||
|
@ -669,7 +672,7 @@ fn convert_path_expr<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr)
|
|||
base: None
|
||||
};
|
||||
},
|
||||
ref sty => panic!("unexpected sty: {:?}", sty)
|
||||
ref sty => bug!("unexpected sty: {:?}", sty)
|
||||
},
|
||||
Def::Const(def_id) |
|
||||
Def::AssociatedConst(def_id) => {
|
||||
|
@ -693,9 +696,10 @@ fn convert_path_expr<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr)
|
|||
def @ Def::Upvar(..) => return convert_var(cx, expr, def),
|
||||
|
||||
def =>
|
||||
cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("def `{:?}` not yet implemented", def)),
|
||||
"def `{:?}` not yet implemented",
|
||||
def),
|
||||
};
|
||||
ExprKind::Literal {
|
||||
literal: Literal::Item { def_id: def_id, substs: substs }
|
||||
|
@ -724,12 +728,12 @@ fn convert_var<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
|||
match expr.node {
|
||||
hir::ExprClosure(_, _, ref body) => body.id,
|
||||
_ => {
|
||||
cx.tcx.sess.span_bug(expr.span, "closure expr is not a closure expr");
|
||||
span_bug!(expr.span, "closure expr is not a closure expr");
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
cx.tcx.sess.span_bug(expr.span, "ast-map has garbage for closure expr");
|
||||
span_bug!(expr.span, "ast-map has garbage for closure expr");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -809,9 +813,10 @@ fn convert_var<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
|||
let upvar_capture = match cx.tcx.upvar_capture(upvar_id) {
|
||||
Some(c) => c,
|
||||
None => {
|
||||
cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
expr.span,
|
||||
&format!("no upvar_capture for {:?}", upvar_id));
|
||||
"no upvar_capture for {:?}",
|
||||
upvar_id);
|
||||
}
|
||||
};
|
||||
match upvar_capture {
|
||||
|
@ -834,7 +839,7 @@ fn convert_var<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
_ => cx.tcx.sess.span_bug(expr.span, "type of & not region"),
|
||||
_ => span_bug!(expr.span, "type of & not region"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -857,7 +862,7 @@ fn bin_op(op: hir::BinOp_) -> BinOp {
|
|||
hir::BinOp_::BiNe => BinOp::Ne,
|
||||
hir::BinOp_::BiGe => BinOp::Ge,
|
||||
hir::BinOp_::BiGt => BinOp::Gt,
|
||||
_ => panic!("no equivalent for ast binop {:?}", op),
|
||||
_ => bug!("no equivalent for ast binop {:?}", op),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -997,7 +1002,7 @@ fn loop_label<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr) -> Cod
|
|||
match cx.tcx.def_map.borrow().get(&expr.id).map(|d| d.full_def()) {
|
||||
Some(Def::Label(loop_id)) => cx.tcx.region_maps.node_extent(loop_id),
|
||||
d => {
|
||||
cx.tcx.sess.span_bug(expr.span, &format!("loop scope resolved to {:?}", d));
|
||||
span_bug!(expr.span, "loop scope resolved to {:?}", d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ use rustc::middle::def_id::DefId;
|
|||
use rustc::infer::InferCtxt;
|
||||
use rustc::ty::subst::{Subst, Substs};
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use rustc_front::hir;
|
||||
use rustc_const_math::{ConstInt, ConstUsize};
|
||||
|
@ -57,7 +56,7 @@ impl<'a,'tcx:'a> Cx<'a, 'tcx> {
|
|||
pub fn usize_literal(&mut self, value: u64) -> Literal<'tcx> {
|
||||
match ConstUsize::new(value, self.tcx.sess.target.uint_type) {
|
||||
Ok(val) => Literal::Value { value: ConstVal::Integral(ConstInt::Usize(val))},
|
||||
Err(_) => panic!("usize literal out of range for target"),
|
||||
Err(_) => bug!("usize literal out of range for target"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +123,7 @@ impl<'a,'tcx:'a> Cx<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
self.tcx.sess.bug(&format!("found no method `{}` in `{:?}`", method_name, trait_def_id));
|
||||
bug!("found no method `{}` in `{:?}`", method_name, trait_def_id);
|
||||
}
|
||||
|
||||
pub fn num_variants(&mut self, adt_def: ty::AdtDef<'tcx>) -> usize {
|
||||
|
@ -141,10 +140,6 @@ impl<'a,'tcx:'a> Cx<'a, 'tcx> {
|
|||
self.tcx.type_needs_drop_given_env(ty, &self.infcx.parameter_environment)
|
||||
}
|
||||
|
||||
pub fn span_bug(&mut self, span: Span, message: &str) -> ! {
|
||||
self.tcx.sess.span_bug(span, message)
|
||||
}
|
||||
|
||||
pub fn tcx(&self) -> &'a TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
|
|
@ -97,21 +97,23 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
|||
Ok(pat) =>
|
||||
return self.to_pattern(&pat),
|
||||
Err(_) =>
|
||||
self.cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span, "illegal constant"),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
self.cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span,
|
||||
&format!("cannot eval constant: {:?}", def_id))
|
||||
"cannot eval constant: {:?}",
|
||||
def_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
_ =>
|
||||
self.cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span,
|
||||
&format!("def not a constant: {:?}", def)),
|
||||
"def not a constant: {:?}",
|
||||
def),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,9 +140,10 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
|||
self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix),
|
||||
|
||||
ref sty =>
|
||||
self.cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span,
|
||||
&format!("unexpanded type for vector pattern: {:?}", sty)),
|
||||
"unexpanded type for vector pattern: {:?}",
|
||||
sty),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +189,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
|||
if let ty::TyRef(_, mt) = ty.sty {
|
||||
ty = mt.ty;
|
||||
} else {
|
||||
unreachable!("`ref {}` has wrong type {}", ident.node, ty);
|
||||
bug!("`ref {}` has wrong type {}", ident.node, ty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,7 +225,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
|||
let adt_def = match pat_ty.sty {
|
||||
ty::TyStruct(adt_def, _) | ty::TyEnum(adt_def, _) => adt_def,
|
||||
_ => {
|
||||
self.cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span,
|
||||
"struct pattern not applied to struct or enum");
|
||||
}
|
||||
|
@ -236,9 +239,10 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
|||
.map(|field| {
|
||||
let index = variant_def.index_of_field_named(field.node.name);
|
||||
let index = index.unwrap_or_else(|| {
|
||||
self.cx.tcx.sess.span_bug(
|
||||
span_bug!(
|
||||
pat.span,
|
||||
&format!("no field with name {:?}", field.node.name));
|
||||
"no field with name {:?}",
|
||||
field.node.name);
|
||||
});
|
||||
FieldPattern {
|
||||
field: Field::new(index),
|
||||
|
@ -251,7 +255,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
|||
}
|
||||
|
||||
PatKind::QPath(..) => {
|
||||
self.cx.tcx.sess.span_bug(pat.span, "unexpanded macro or bad constant etc");
|
||||
span_bug!(pat.span, "unexpanded macro or bad constant etc");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -298,7 +302,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
|||
}
|
||||
|
||||
_ => {
|
||||
self.cx.tcx.sess.span_bug(span, "unexpanded macro or bad constant etc");
|
||||
span_bug!(span, "unexpanded macro or bad constant etc");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -327,8 +331,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
|||
}
|
||||
|
||||
_ => {
|
||||
self.cx.tcx.sess.span_bug(pat.span,
|
||||
&format!("inappropriate def for pattern: {:?}", def));
|
||||
span_bug!(pat.span, "inappropriate def for pattern: {:?}", def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
|
|||
|
||||
#[macro_use] extern crate log;
|
||||
extern crate graphviz as dot;
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_front;
|
||||
|
|
|
@ -165,8 +165,7 @@ fn build_mir<'a,'tcx:'a>(cx: Cx<'a,'tcx>,
|
|||
let fn_sig = match cx.tcx().tables.borrow().liberated_fn_sigs.get(&fn_id) {
|
||||
Some(f) => f.clone(),
|
||||
None => {
|
||||
cx.tcx().sess.span_bug(span,
|
||||
&format!("no liberated fn sig for {:?}", fn_id));
|
||||
span_bug!(span, "no liberated fn sig for {:?}", fn_id);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@ impl<'a, 'v> Visitor<'v> for CheckBlock<'a> {
|
|||
visit::walk_expr(self, e);
|
||||
}
|
||||
}
|
||||
fn visit_item(&mut self, _i: &'v ast::Item) { panic!("should be handled in CheckConstFn") }
|
||||
fn visit_item(&mut self, _i: &'v ast::Item) { bug!("should be handled in CheckConstFn") }
|
||||
fn visit_fn(&mut self,
|
||||
_fk: FnKind<'v>,
|
||||
_fd: &'v ast::FnDecl,
|
||||
_b: &'v ast::Block,
|
||||
_s: Span,
|
||||
_fn_id: ast::NodeId) { panic!("should be handled in CheckConstFn") }
|
||||
_fn_id: ast::NodeId) { bug!("should be handled in CheckConstFn") }
|
||||
}
|
||||
|
||||
fn check_block(sess: &Session, b: &ast::Block, kind: &'static str) {
|
||||
|
@ -67,7 +67,7 @@ fn check_block(sess: &Session, b: &ast::Block, kind: &'static str) {
|
|||
}
|
||||
ast::StmtKind::Expr(ref expr, _) => expr.span,
|
||||
ast::StmtKind::Semi(ref semi, _) => semi.span,
|
||||
ast::StmtKind::Mac(..) => unreachable!(),
|
||||
ast::StmtKind::Mac(..) => bug!(),
|
||||
};
|
||||
span_err!(sess, span, E0016,
|
||||
"blocks in {}s are limited to items and tail expressions", kind);
|
||||
|
|
|
@ -229,7 +229,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
|||
Mode::Const => "constant",
|
||||
Mode::ConstFn => "constant function",
|
||||
Mode::StaticMut | Mode::Static => "static",
|
||||
Mode::Var => unreachable!(),
|
||||
Mode::Var => bug!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
|||
// The count is checked elsewhere (typeck).
|
||||
let count = match node_ty.sty {
|
||||
ty::TyArray(_, n) => n,
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
// [element; 0] is always zero-sized.
|
||||
if count == 0 {
|
||||
|
@ -570,7 +570,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
|
|||
hir::ExprCast(ref from, _) => {
|
||||
debug!("Checking const cast(id={})", from.id);
|
||||
match v.tcx.cast_kinds.borrow().get(&from.id) {
|
||||
None => v.tcx.sess.span_bug(e.span, "no kind for cast"),
|
||||
None => span_bug!(e.span, "no kind for cast"),
|
||||
Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
|
||||
v.add_qualif(ConstQualif::NOT_CONST);
|
||||
if v.mode != Mode::Var {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#![feature(rustc_private)]
|
||||
|
||||
extern crate core;
|
||||
extern crate rustc;
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_front;
|
||||
extern crate rustc_const_eval;
|
||||
|
||||
|
|
|
@ -218,9 +218,9 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
|
|||
// borrow fall out of scope, so that we can reborrow farther down.
|
||||
maybe_expr = (*get_expr).clone();
|
||||
} else {
|
||||
self.sess.span_bug(variant.span,
|
||||
"`check_static_recursion` attempted to visit \
|
||||
variant with unknown discriminant")
|
||||
span_bug!(variant.span,
|
||||
"`check_static_recursion` attempted to visit \
|
||||
variant with unknown discriminant")
|
||||
}
|
||||
// If `maybe_expr` is `None`, that's because no discriminant is
|
||||
// specified that affects this variant. Thus, no risk of recursion.
|
||||
|
@ -254,10 +254,10 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
|
|||
self.visit_impl_item(item),
|
||||
ast_map::NodeForeignItem(_) => {},
|
||||
_ => {
|
||||
self.sess.span_bug(
|
||||
span_bug!(
|
||||
e.span,
|
||||
&format!("expected item, found {}",
|
||||
self.ast_map.node_to_string(node_id)));
|
||||
"expected item, found {}",
|
||||
self.ast_map.node_to_string(node_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,9 +277,9 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
|
|||
let variant = self.ast_map.expect_variant(variant_id);
|
||||
self.visit_variant(variant, generics, enum_id);
|
||||
} else {
|
||||
self.sess.span_bug(e.span,
|
||||
"`check_static_recursion` found \
|
||||
non-enum in Def::Variant");
|
||||
span_bug!(e.span,
|
||||
"`check_static_recursion` found \
|
||||
non-enum in Def::Variant");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate syntax;
|
||||
|
||||
extern crate rustc;
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_front;
|
||||
|
||||
use std::cmp;
|
||||
|
|
|
@ -507,7 +507,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
|
|||
Def::Label(..) |
|
||||
Def::SelfTy(..) |
|
||||
Def::Err => {
|
||||
panic!("didn't expect `{:?}`", def);
|
||||
bug!("didn't expect `{:?}`", def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ extern crate arena;
|
|||
#[no_link]
|
||||
extern crate rustc_bitflags;
|
||||
extern crate rustc_front;
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
|
||||
use self::PatternBindingMode::*;
|
||||
|
@ -2375,11 +2376,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
// The below shouldn't happen because all
|
||||
// qualified paths should be in PatKind::QPath.
|
||||
TypecheckRequired =>
|
||||
self.session.span_bug(path.span,
|
||||
"resolve_possibly_assoc_item claimed that a path \
|
||||
in PatKind::Path or PatKind::TupleStruct \
|
||||
requires typecheck to resolve, but qualified \
|
||||
paths should be PatKind::QPath"),
|
||||
span_bug!(path.span,
|
||||
"resolve_possibly_assoc_item claimed that a path \
|
||||
in PatKind::Path or PatKind::TupleStruct \
|
||||
requires typecheck to resolve, but qualified \
|
||||
paths should be PatKind::QPath"),
|
||||
ResolveAttempt(resolution) => resolution,
|
||||
};
|
||||
if let Some(path_res) = resolution {
|
||||
|
@ -2668,7 +2669,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let mut def = local_def.def;
|
||||
match def {
|
||||
Def::Upvar(..) => {
|
||||
self.session.span_bug(span, &format!("unexpected {:?} in bindings", def))
|
||||
span_bug!(span, "unexpected {:?} in bindings", def)
|
||||
}
|
||||
Def::Local(_, node_id) => {
|
||||
for rib in ribs {
|
||||
|
@ -3189,7 +3190,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
})
|
||||
}
|
||||
Some(_) => {
|
||||
self.session.span_bug(expr.span, "label wasn't mapped to a label def!")
|
||||
span_bug!(expr.span, "label wasn't mapped to a label def!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3346,7 +3347,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
paths.push(segm);
|
||||
paths
|
||||
}
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
};
|
||||
|
||||
if !in_module_is_extern || name_binding.is_public() {
|
||||
|
@ -3368,10 +3369,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
debug!("(recording def) recording {:?} for {}", resolution, node_id);
|
||||
if let Some(prev_res) = self.def_map.borrow_mut().insert(node_id, resolution) {
|
||||
let span = self.ast_map.opt_span(node_id).unwrap_or(codemap::DUMMY_SP);
|
||||
self.session.span_bug(span,
|
||||
&format!("path resolved multiple times ({:?} before, {:?} now)",
|
||||
prev_res,
|
||||
resolution));
|
||||
span_bug!(span,
|
||||
"path resolved multiple times ({:?} before, {:?} now)",
|
||||
prev_res,
|
||||
resolution);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,17 +20,6 @@ use rustc::ty;
|
|||
use syntax::ast::{CrateNum, NodeId};
|
||||
use syntax::codemap::Span;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! down_cast_data {
|
||||
($id:ident, $kind:ident, $this:ident, $sp:expr) => {
|
||||
let $id = if let super::Data::$kind(data) = $id {
|
||||
data
|
||||
} else {
|
||||
$this.sess.span_bug($sp, &format!("unexpected data kind: {:?}", $id));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub struct CrateData {
|
||||
pub name: String,
|
||||
pub number: u32,
|
||||
|
|
|
@ -51,11 +51,11 @@ use super::span_utils::SpanUtils;
|
|||
use super::recorder;
|
||||
|
||||
macro_rules! down_cast_data {
|
||||
($id:ident, $kind:ident, $this:ident, $sp:expr) => {
|
||||
($id:ident, $kind:ident, $sp:expr) => {
|
||||
let $id = if let super::Data::$kind(data) = $id {
|
||||
data
|
||||
} else {
|
||||
$this.sess.span_bug($sp, &format!("unexpected data kind: {:?}", $id));
|
||||
span_bug!($sp, "unexpected data kind: {:?}", $id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -271,8 +271,7 @@ where D: Dump
|
|||
// looks up anything, not just a type
|
||||
fn lookup_type_ref(&self, ref_id: NodeId) -> Option<DefId> {
|
||||
if !self.tcx.def_map.borrow().contains_key(&ref_id) {
|
||||
self.sess.bug(&format!("def_map has no key for {} in lookup_type_ref",
|
||||
ref_id));
|
||||
bug!("def_map has no key for {} in lookup_type_ref", ref_id);
|
||||
}
|
||||
let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def();
|
||||
match def {
|
||||
|
@ -294,9 +293,9 @@ where D: Dump
|
|||
|
||||
let def_map = self.tcx.def_map.borrow();
|
||||
if !def_map.contains_key(&ref_id) {
|
||||
self.sess.span_bug(span,
|
||||
&format!("def_map has no key for {} in lookup_def_kind",
|
||||
ref_id));
|
||||
span_bug!(span,
|
||||
"def_map has no key for {} in lookup_def_kind",
|
||||
ref_id);
|
||||
}
|
||||
let def = def_map.get(&ref_id).unwrap().full_def();
|
||||
match def {
|
||||
|
@ -347,8 +346,9 @@ where D: Dump
|
|||
Def::Method(..) |
|
||||
Def::PrimTy(_) |
|
||||
Def::Err => {
|
||||
self.sess.span_bug(span,
|
||||
&format!("process_def_kind for unexpected item: {:?}", def));
|
||||
span_bug!(span,
|
||||
"process_def_kind for unexpected item: {:?}",
|
||||
def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ where D: Dump
|
|||
ty_params: &ast::Generics,
|
||||
body: &ast::Block) {
|
||||
if let Some(fn_data) = self.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(fn_data, FunctionData, self, item.span);
|
||||
down_cast_data!(fn_data, FunctionData, item.span);
|
||||
if !self.span.filter_generated(Some(fn_data.span), item.span) {
|
||||
self.dumper.function(item.span, fn_data.clone().normalize(&self.tcx));
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ where D: Dump
|
|||
|
||||
fn process_static_or_const_item(&mut self, item: &ast::Item, typ: &ast::Ty, expr: &ast::Expr) {
|
||||
if let Some(var_data) = self.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(var_data, VariableData, self, item.span);
|
||||
down_cast_data!(var_data, VariableData, item.span);
|
||||
if !self.span.filter_generated(Some(var_data.span), item.span) {
|
||||
let mut var_data = var_data;
|
||||
var_data.scope = normalize_node_id(&self.tcx, var_data.scope) as u32;
|
||||
|
@ -578,7 +578,7 @@ where D: Dump
|
|||
None => return,
|
||||
Some(data) => data,
|
||||
};
|
||||
down_cast_data!(enum_data, EnumData, self, item.span);
|
||||
down_cast_data!(enum_data, EnumData, item.span);
|
||||
let normalized = enum_data.clone().normalize(&self.tcx);
|
||||
if !self.span.filter_generated(Some(normalized.span), item.span) {
|
||||
self.dumper.enum_data(item.span, normalized);
|
||||
|
@ -638,7 +638,7 @@ where D: Dump
|
|||
impl_items: &[ast::ImplItem]) {
|
||||
let mut has_self_ref = false;
|
||||
if let Some(impl_data) = self.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(impl_data, ImplData, self, item.span);
|
||||
down_cast_data!(impl_data, ImplData, item.span);
|
||||
if let Some(ref self_ref) = impl_data.self_ref {
|
||||
has_self_ref = true;
|
||||
if !self.span.filter_generated(Some(self_ref.span), item.span) {
|
||||
|
@ -734,7 +734,7 @@ where D: Dump
|
|||
// `item` is the module in question, represented as an item.
|
||||
fn process_mod(&mut self, item: &ast::Item) {
|
||||
if let Some(mod_data) = self.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(mod_data, ModData, self, item.span);
|
||||
down_cast_data!(mod_data, ModData, item.span);
|
||||
if !self.span.filter_generated(Some(mod_data.span), item.span) {
|
||||
self.dumper.mod_data(mod_data.normalize(&self.tcx));
|
||||
}
|
||||
|
@ -750,10 +750,9 @@ where D: Dump
|
|||
let path_data = match path_data {
|
||||
Some(pd) => pd,
|
||||
None => {
|
||||
self.tcx.sess.span_bug(path.span,
|
||||
&format!("Unexpected def kind while looking up path in \
|
||||
`{}`",
|
||||
self.span.snippet(path.span)))
|
||||
span_bug!(path.span,
|
||||
"Unexpected def kind while looking up path in `{}`",
|
||||
self.span.snippet(path.span))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -807,8 +806,7 @@ where D: Dump
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
self.sess.span_bug(path.span,
|
||||
&format!("Unexpected data: {:?}", path_data));
|
||||
span_bug!(path.span, "Unexpected data: {:?}", path_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -844,7 +842,7 @@ where D: Dump
|
|||
self.write_sub_paths_truncated(path, false);
|
||||
|
||||
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
|
||||
down_cast_data!(struct_lit_data, TypeRefData, self, ex.span);
|
||||
down_cast_data!(struct_lit_data, TypeRefData, ex.span);
|
||||
if !self.span.filter_generated(Some(struct_lit_data.span), ex.span) {
|
||||
self.dumper.type_ref(ex.span, struct_lit_data.normalize(&self.tcx));
|
||||
}
|
||||
|
@ -869,7 +867,7 @@ where D: Dump
|
|||
|
||||
fn process_method_call(&mut self, ex: &ast::Expr, args: &Vec<P<ast::Expr>>) {
|
||||
if let Some(mcd) = self.save_ctxt.get_expr_data(ex) {
|
||||
down_cast_data!(mcd, MethodCallData, self, ex.span);
|
||||
down_cast_data!(mcd, MethodCallData, ex.span);
|
||||
if !self.span.filter_generated(Some(mcd.span), ex.span) {
|
||||
self.dumper.method_call(ex.span, mcd.normalize(&self.tcx));
|
||||
}
|
||||
|
@ -1234,7 +1232,7 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
|
|||
self.visit_expr(&sub_ex);
|
||||
|
||||
if let Some(field_data) = self.save_ctxt.get_expr_data(ex) {
|
||||
down_cast_data!(field_data, VariableRefData, self, ex.span);
|
||||
down_cast_data!(field_data, VariableRefData, ex.span);
|
||||
if !self.span.filter_generated(Some(field_data.span), ex.span) {
|
||||
self.dumper.variable_ref(ex.span, field_data.normalize(&self.tcx));
|
||||
}
|
||||
|
@ -1258,9 +1256,9 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
|
|||
}
|
||||
}
|
||||
ty::TyTuple(_) => {}
|
||||
_ => self.sess.span_bug(ex.span,
|
||||
&format!("Expected struct or tuple type, found {:?}",
|
||||
ty)),
|
||||
_ => span_bug!(ex.span,
|
||||
"Expected struct or tuple type, found {:?}",
|
||||
ty),
|
||||
}
|
||||
}
|
||||
ast::ExprKind::Closure(_, ref decl, ref body) => {
|
||||
|
@ -1302,7 +1300,7 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
|
|||
|
||||
fn visit_mac(&mut self, mac: &ast::Mac) {
|
||||
// These shouldn't exist in the AST at this point, log a span bug.
|
||||
self.sess.span_bug(mac.span, "macro invocation should have been expanded out of AST");
|
||||
span_bug!(mac.span, "macro invocation should have been expanded out of AST");
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, p: &ast::Pat) {
|
||||
|
@ -1325,8 +1323,7 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
|
|||
for &(id, ref p, immut, ref_kind) in &collector.collected_paths {
|
||||
let def_map = self.tcx.def_map.borrow();
|
||||
if !def_map.contains_key(&id) {
|
||||
self.sess.span_bug(p.span,
|
||||
&format!("def_map has no key for {} in visit_arm", id));
|
||||
span_bug!(p.span, "def_map has no key for {} in visit_arm", id);
|
||||
}
|
||||
let def = def_map.get(&id).unwrap().full_def();
|
||||
match def {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(staged_api)]
|
||||
|
||||
extern crate rustc;
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_front;
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
|
@ -47,7 +47,6 @@ use syntax::visit::{self, Visitor};
|
|||
use syntax::print::pprust::ty_to_string;
|
||||
|
||||
mod csv_dumper;
|
||||
#[macro_use]
|
||||
mod data;
|
||||
mod dump;
|
||||
mod dump_visitor;
|
||||
|
@ -240,7 +239,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
_ => {
|
||||
// FIXME
|
||||
unimplemented!();
|
||||
bug!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,21 +291,19 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
result
|
||||
}
|
||||
_ => {
|
||||
self.tcx.sess.span_bug(span,
|
||||
&format!("Container {:?} for method {} not \
|
||||
an impl?",
|
||||
impl_id,
|
||||
id));
|
||||
span_bug!(span,
|
||||
"Container {:?} for method {} not an impl?",
|
||||
impl_id,
|
||||
id);
|
||||
}
|
||||
}
|
||||
}
|
||||
r => {
|
||||
self.tcx.sess.span_bug(span,
|
||||
&format!("Container {:?} for method {} is not a node \
|
||||
item {:?}",
|
||||
impl_id,
|
||||
id,
|
||||
r));
|
||||
span_bug!(span,
|
||||
"Container {:?} for method {} is not a node item {:?}",
|
||||
impl_id,
|
||||
id,
|
||||
r);
|
||||
}
|
||||
},
|
||||
None => match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) {
|
||||
|
@ -316,18 +313,17 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
format!("::{}", self.tcx.item_path_str(def_id))
|
||||
}
|
||||
r => {
|
||||
self.tcx.sess.span_bug(span,
|
||||
&format!("Could not find container {:?} for \
|
||||
method {}, got {:?}",
|
||||
def_id,
|
||||
id,
|
||||
r));
|
||||
span_bug!(span,
|
||||
"Could not find container {:?} for \
|
||||
method {}, got {:?}",
|
||||
def_id,
|
||||
id,
|
||||
r);
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
self.tcx.sess.span_bug(span,
|
||||
&format!("Could not find container for method {}", id));
|
||||
span_bug!(span, "Could not find container for method {}", id);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -443,7 +439,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
_ => {
|
||||
// FIXME
|
||||
unimplemented!();
|
||||
bug!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -451,8 +447,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Data> {
|
||||
let def_map = self.tcx.def_map.borrow();
|
||||
if !def_map.contains_key(&id) {
|
||||
self.tcx.sess.span_bug(path.span,
|
||||
&format!("def_map has no key for {} in visit_expr", id));
|
||||
span_bug!(path.span, "def_map has no key for {} in visit_expr", id);
|
||||
}
|
||||
let def = def_map.get(&id).unwrap().full_def();
|
||||
let sub_span = self.span_utils.span_for_last_ident(path.span);
|
||||
|
@ -618,13 +613,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
|
||||
pub fn get_data_for_id(&self, _id: &NodeId) -> Data {
|
||||
// FIXME
|
||||
unimplemented!();
|
||||
bug!();
|
||||
}
|
||||
|
||||
fn lookup_ref_id(&self, ref_id: NodeId) -> Option<DefId> {
|
||||
if !self.tcx.def_map.borrow().contains_key(&ref_id) {
|
||||
self.tcx.sess.bug(&format!("def_map has no key for {} in lookup_type_ref",
|
||||
ref_id));
|
||||
bug!("def_map has no key for {} in lookup_type_ref", ref_id);
|
||||
}
|
||||
let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def();
|
||||
match def {
|
||||
|
|
|
@ -223,12 +223,12 @@ impl<'a> SpanUtils<'a> {
|
|||
}
|
||||
if bracket_count != 0 {
|
||||
let loc = self.sess.codemap().lookup_char_pos(span.lo);
|
||||
self.sess.span_bug(span,
|
||||
&format!("Mis-counted brackets when breaking path? Parsing '{}' \
|
||||
in {}, line {}",
|
||||
self.snippet(span),
|
||||
loc.file.name,
|
||||
loc.line));
|
||||
span_bug!(span,
|
||||
"Mis-counted brackets when breaking path? Parsing '{}' \
|
||||
in {}, line {}",
|
||||
self.snippet(span),
|
||||
loc.file.name,
|
||||
loc.line);
|
||||
}
|
||||
if result.is_none() && prev.tok.is_ident() && bracket_count == 0 {
|
||||
return self.make_sub_span(span, Some(prev.sp));
|
||||
|
@ -256,12 +256,12 @@ impl<'a> SpanUtils<'a> {
|
|||
return vec!();
|
||||
}
|
||||
let loc = self.sess.codemap().lookup_char_pos(span.lo);
|
||||
self.sess.span_bug(span,
|
||||
&format!("Mis-counted brackets when breaking path? \
|
||||
Parsing '{}' in {}, line {}",
|
||||
self.snippet(span),
|
||||
loc.file.name,
|
||||
loc.line));
|
||||
span_bug!(span,
|
||||
"Mis-counted brackets when breaking path? \
|
||||
Parsing '{}' in {}, line {}",
|
||||
self.snippet(span),
|
||||
loc.file.name,
|
||||
loc.line);
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ impl<'a> SpanUtils<'a> {
|
|||
loc.line);
|
||||
self.err_count.set(self.err_count.get() + 1);
|
||||
if self.err_count.get() > 1000 {
|
||||
self.sess.bug("span errors reached 1000, giving up");
|
||||
bug!("span errors reached 1000, giving up");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ impl<'a> ConstantExpr<'a> {
|
|||
fn eq(self, other: ConstantExpr<'a>, tcx: &TyCtxt) -> bool {
|
||||
match compare_lit_exprs(tcx, self.0, other.0) {
|
||||
Some(result) => result == Ordering::Equal,
|
||||
None => panic!("compare_list_exprs: type mismatch"),
|
||||
None => bug!("compare_list_exprs: type mismatch"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -828,7 +828,7 @@ impl FailureHandler {
|
|||
fn handle_fail(&self, bcx: Block) {
|
||||
match *self {
|
||||
Infallible =>
|
||||
panic!("attempted to panic in a non-panicking panic handler!"),
|
||||
bug!("attempted to panic in a non-panicking panic handler!"),
|
||||
JumpToBasicBlock(basic_block) =>
|
||||
Br(bcx, basic_block, DebugLoc::None),
|
||||
Unreachable =>
|
||||
|
@ -939,11 +939,11 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
|
||||
compare_str(cx, lhs_data, lhs_len, rhs_data, rhs_len, rhs_t, debug_loc)
|
||||
},
|
||||
_ => cx.sess().bug("only byte strings supported in compare_values"),
|
||||
_ => bug!("only byte strings supported in compare_values"),
|
||||
},
|
||||
_ => cx.sess().bug("only string and byte strings supported in compare_values"),
|
||||
_ => bug!("only string and byte strings supported in compare_values"),
|
||||
},
|
||||
_ => cx.sess().bug("only scalars, byte strings, and strings supported in compare_values"),
|
||||
_ => bug!("only scalars, byte strings, and strings supported in compare_values"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,7 +986,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
Lvalue::new_with_hint("_match::insert_lllocals (match_input)",
|
||||
bcx, binding_info.id, hint_kind)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
_ => bug!(),
|
||||
};
|
||||
let datum = Datum::new(llval, binding_info.ty, lvalue);
|
||||
call_lifetime_start(bcx, llbinding);
|
||||
|
@ -1317,7 +1317,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
bcx = r.bcx;
|
||||
}
|
||||
_ => {
|
||||
bcx.sess().bug(
|
||||
bug!(
|
||||
"in compile_submatch, expected \
|
||||
opt.trans() to return a SingleResult")
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ impl FnType {
|
|||
Rust | RustCall => llvm::CCallConv,
|
||||
|
||||
// It's the ABI's job to select this, not us.
|
||||
System => ccx.sess().bug("system abi should be selected elsewhere"),
|
||||
System => bug!("system abi should be selected elsewhere"),
|
||||
|
||||
Stdcall => llvm::X86StdcallCallConv,
|
||||
Fastcall => llvm::X86FastcallCallConv,
|
||||
|
@ -241,8 +241,8 @@ impl FnType {
|
|||
&tupled_arguments[..]
|
||||
}
|
||||
_ => {
|
||||
unreachable!("argument to function with \"rust-call\" ABI \
|
||||
is not a tuple");
|
||||
bug!("argument to function with \"rust-call\" ABI \
|
||||
is not a tuple");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -302,9 +302,8 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
// non-empty body, explicit discriminants should have
|
||||
// been rejected by a checker before this point.
|
||||
if !cases.iter().enumerate().all(|(i,c)| c.discr == Disr::from(i)) {
|
||||
cx.sess().bug(&format!("non-C-like enum {} with specified \
|
||||
discriminants",
|
||||
cx.tcx().item_path_str(def.did)));
|
||||
bug!("non-C-like enum {} with specified discriminants",
|
||||
cx.tcx().item_path_str(def.did));
|
||||
}
|
||||
|
||||
if cases.len() == 1 {
|
||||
|
@ -430,7 +429,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
General(ity, fields, dtor_to_init_u8(dtor))
|
||||
}
|
||||
_ => cx.sess().bug(&format!("adt::represent_type called on non-ADT type: {}", t))
|
||||
_ => bug!("adt::represent_type called on non-ADT type: {}", t)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -615,7 +614,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
|
|||
match hint {
|
||||
attr::ReprInt(span, ity) => {
|
||||
if !bounds_usable(cx, ity, bounds) {
|
||||
cx.sess().span_bug(span, "representation hint insufficient for discriminant range")
|
||||
span_bug!(span, "representation hint insufficient for discriminant range")
|
||||
}
|
||||
return ity;
|
||||
}
|
||||
|
@ -632,10 +631,10 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
|
|||
attempts = choose_shortest;
|
||||
},
|
||||
attr::ReprPacked => {
|
||||
cx.tcx().sess.bug("range_to_inttype: found ReprPacked on an enum");
|
||||
bug!("range_to_inttype: found ReprPacked on an enum");
|
||||
}
|
||||
attr::ReprSimd => {
|
||||
cx.tcx().sess.bug("range_to_inttype: found ReprSimd on an enum");
|
||||
bug!("range_to_inttype: found ReprSimd on an enum");
|
||||
}
|
||||
}
|
||||
for &ity in attempts {
|
||||
|
@ -835,7 +834,7 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
Type::array(&Type::i64(cx), align_units),
|
||||
a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4),
|
||||
align_units),
|
||||
_ => panic!("unsupported enum alignment: {}", align)
|
||||
_ => bug!("unsupported enum alignment: {}", align)
|
||||
};
|
||||
assert_eq!(machine::llalign_of_min(cx, fill_ty), align);
|
||||
assert_eq!(padded_discr_size % discr_size, 0); // Ensure discr_ty can fill pad evenly
|
||||
|
@ -984,7 +983,7 @@ pub fn trans_case<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr, discr: Disr)
|
|||
C_integral(ll_inttype(bcx.ccx(), ity), discr.0, true)
|
||||
}
|
||||
Univariant(..) => {
|
||||
bcx.ccx().sess().bug("no cases for univariants or structs")
|
||||
bug!("no cases for univariants or structs")
|
||||
}
|
||||
RawNullablePointer { .. } |
|
||||
StructWrappedNullablePointer { .. } => {
|
||||
|
@ -1088,7 +1087,7 @@ pub fn trans_field_ptr_builder<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
|
|||
// someday), it will need to return a possibly-new bcx as well.
|
||||
match *r {
|
||||
CEnum(..) => {
|
||||
bcx.ccx().sess().bug("element access in C-like enum")
|
||||
bug!("element access in C-like enum")
|
||||
}
|
||||
Univariant(ref st, _dtor) => {
|
||||
assert_eq!(discr, Disr(0));
|
||||
|
@ -1279,7 +1278,7 @@ pub fn fold_variants<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
bcx_next
|
||||
}
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1319,7 +1318,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
|
||||
datum::DatumBlock::new(bcx, expr_datum)
|
||||
}
|
||||
_ => bcx.ccx().sess().bug("tried to get drop flag of non-droppable type")
|
||||
_ => bug!("tried to get drop flag of non-droppable type")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1478,7 +1477,7 @@ pub fn const_get_discrim(r: &Repr, val: ValueRef) -> Disr {
|
|||
}
|
||||
Univariant(..) => Disr(0),
|
||||
RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
|
||||
unreachable!("const discrim access of non c-like enum")
|
||||
bug!("const discrim access of non c-like enum")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1488,10 +1487,10 @@ pub fn const_get_discrim(r: &Repr, val: ValueRef) -> Disr {
|
|||
///
|
||||
/// (Not to be confused with `common::const_get_elt`, which operates on
|
||||
/// raw LLVM-level structs and arrays.)
|
||||
pub fn const_get_field(ccx: &CrateContext, r: &Repr, val: ValueRef,
|
||||
_discr: Disr, ix: usize) -> ValueRef {
|
||||
pub fn const_get_field(r: &Repr, val: ValueRef, _discr: Disr,
|
||||
ix: usize) -> ValueRef {
|
||||
match *r {
|
||||
CEnum(..) => ccx.sess().bug("element access in C-like enum const"),
|
||||
CEnum(..) => bug!("element access in C-like enum const"),
|
||||
Univariant(..) => const_struct_field(val, ix),
|
||||
General(..) => const_struct_field(val, ix + 1),
|
||||
RawNullablePointer { .. } => {
|
||||
|
|
|
@ -221,7 +221,7 @@ fn dump_graph(tcx: &TyCtxt) {
|
|||
// Expect one of: "-> target", "source -> target", or "source ->".
|
||||
let parts: Vec<_> = string.split("->").collect();
|
||||
if parts.len() > 2 {
|
||||
panic!("Invalid RUST_DEP_GRAPH_FILTER: expected '[source] -> [target]'");
|
||||
bug!("Invalid RUST_DEP_GRAPH_FILTER: expected '[source] -> [target]'");
|
||||
}
|
||||
let sources = node_set(&query, &parts[0]);
|
||||
let targets = node_set(&query, &parts[1]);
|
||||
|
|
|
@ -187,8 +187,8 @@ pub fn link_binary(sess: &Session,
|
|||
let mut out_filenames = Vec::new();
|
||||
for &crate_type in sess.crate_types.borrow().iter() {
|
||||
if invalid_output_for_target(sess, crate_type) {
|
||||
sess.bug(&format!("invalid output type `{:?}` for target os `{}`",
|
||||
crate_type, sess.opts.target_triple));
|
||||
bug!("invalid output type `{:?}` for target os `{}`",
|
||||
crate_type, sess.opts.target_triple);
|
||||
}
|
||||
let out_file = link_binary_output(sess, trans, crate_type, outputs,
|
||||
crate_name);
|
||||
|
@ -282,7 +282,7 @@ pub fn each_linked_rlib(sess: &Session,
|
|||
let fmts = fmts.get(&config::CrateTypeExecutable).or_else(|| {
|
||||
fmts.get(&config::CrateTypeStaticlib)
|
||||
}).unwrap_or_else(|| {
|
||||
sess.bug("could not find formats for rlibs")
|
||||
bug!("could not find formats for rlibs")
|
||||
});
|
||||
for (cnum, path) in crates {
|
||||
match fmts[cnum as usize - 1] {
|
||||
|
@ -895,7 +895,7 @@ fn add_local_native_libraries(cmd: &mut Linker, sess: &Session) {
|
|||
match kind {
|
||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(l),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(l),
|
||||
NativeLibraryKind::NativeStatic => unreachable!(),
|
||||
NativeLibraryKind::NativeStatic => bug!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1081,7 +1081,7 @@ fn add_upstream_native_libraries(cmd: &mut Linker, sess: &Session) {
|
|||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(lib),
|
||||
NativeLibraryKind::NativeFramework => cmd.link_framework(lib),
|
||||
NativeLibraryKind::NativeStatic => {
|
||||
sess.bug("statics shouldn't be propagated");
|
||||
bug!("statics shouldn't be propagated");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,10 +271,10 @@ impl<'a> Linker for MsvcLinker<'a> {
|
|||
}
|
||||
|
||||
fn framework_path(&mut self, _path: &Path) {
|
||||
panic!("frameworks are not supported on windows")
|
||||
bug!("frameworks are not supported on windows")
|
||||
}
|
||||
fn link_framework(&mut self, _framework: &str) {
|
||||
panic!("frameworks are not supported on windows")
|
||||
bug!("frameworks are not supported on windows")
|
||||
}
|
||||
|
||||
fn link_whole_staticlib(&mut self, lib: &str, _search_path: &[PathBuf]) {
|
||||
|
|
|
@ -224,8 +224,8 @@ fn exported_name_with_opt_suffix<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
// to be a value or type-def or something in there
|
||||
// *somewhere*
|
||||
ty_def_id.index = key.parent.unwrap_or_else(|| {
|
||||
panic!("finding type for {:?}, encountered def-id {:?} with no \
|
||||
parent", def_id, ty_def_id);
|
||||
bug!("finding type for {:?}, encountered def-id {:?} with no \
|
||||
parent", def_id, ty_def_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ impl Emitter for SharedEmitter {
|
|||
}
|
||||
|
||||
fn custom_emit(&mut self, _sp: &errors::RenderSpan, _msg: &str, _lvl: Level) {
|
||||
panic!("SharedEmitter doesn't support custom_emit");
|
||||
bug!("SharedEmitter doesn't support custom_emit");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
|||
.cg
|
||||
.relocation_model));
|
||||
sess.abort_if_errors();
|
||||
unreachable!();
|
||||
bug!();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -190,7 +190,7 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
|||
.cg
|
||||
.code_model));
|
||||
sess.abort_if_errors();
|
||||
unreachable!();
|
||||
bug!();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue