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;
|
return *l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.tcx.sess.span_bug(expr.span,
|
span_bug!(expr.span, "no loop scope for id {}", loop_id);
|
||||||
&format!("no loop scope for id {}", loop_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r => {
|
r => {
|
||||||
self.tcx.sess.span_bug(expr.span,
|
span_bug!(expr.span, "bad entry `{:?}` in def_map for label", r);
|
||||||
&format!("bad entry `{:?}` in def_map for label", r));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ impl DepGraphEdges {
|
||||||
{
|
{
|
||||||
match self.current_node() {
|
match self.current_node() {
|
||||||
Some(open_node) => self.add_edge_from_open_node(open_node, op),
|
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.
|
// Outline this too.
|
||||||
fn invalid_message(&self, string: &str) {
|
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,
|
span: i.span,
|
||||||
attrs: &i.attrs,
|
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 {
|
map::NodeTraitItem(ti) => match ti.node {
|
||||||
ast::MethodTraitItem(ref sig, Some(ref body)) => {
|
ast::MethodTraitItem(ref sig, Some(ref body)) => {
|
||||||
method(ti.id, ti.name, sig, None, body, ti.span, &ti.attrs)
|
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) => {
|
map::NodeImplItem(ii) => {
|
||||||
match ii.node {
|
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)
|
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.id,
|
||||||
e.span,
|
e.span,
|
||||||
e.attrs.as_attr_slice())),
|
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)
|
return self.opt_local_def_id(id)
|
||||||
.map(|def_id| DepNode::Hir(def_id))
|
.map(|def_id| DepNode::Hir(def_id))
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
panic!("Walking parents from `{}` \
|
bug!("Walking parents from `{}` \
|
||||||
led to `NotPresent` at `{}`",
|
led to `NotPresent` at `{}`",
|
||||||
id0, id)
|
id0, id)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,8 +363,8 @@ impl<'ast> Map<'ast> {
|
||||||
|
|
||||||
pub fn local_def_id(&self, node: NodeId) -> DefId {
|
pub fn local_def_id(&self, node: NodeId) -> DefId {
|
||||||
self.opt_local_def_id(node).unwrap_or_else(|| {
|
self.opt_local_def_id(node).unwrap_or_else(|| {
|
||||||
panic!("local_def_id: no entry for `{}`, which has a map of `{:?}`",
|
bug!("local_def_id: no entry for `{}`, which has a map of `{:?}`",
|
||||||
node, self.find_entry(node))
|
node, self.find_entry(node))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ impl<'ast> Map<'ast> {
|
||||||
pub fn get(&self, id: NodeId) -> Node<'ast> {
|
pub fn get(&self, id: NodeId) -> Node<'ast> {
|
||||||
match self.find(id) {
|
match self.find(id) {
|
||||||
Some(node) => node, // read recorded by `find`
|
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
|
self.read(id); // reveals some of the content of a node
|
||||||
abi
|
abi
|
||||||
}
|
}
|
||||||
None => panic!("expected foreign mod or inlined parent, found {}",
|
None => bug!("expected foreign mod or inlined parent, found {}",
|
||||||
self.node_to_string(parent))
|
self.node_to_string(parent))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -584,14 +584,14 @@ impl<'ast> Map<'ast> {
|
||||||
pub fn expect_item(&self, id: NodeId) -> &'ast Item {
|
pub fn expect_item(&self, id: NodeId) -> &'ast Item {
|
||||||
match self.find(id) { // read recorded by `find`
|
match self.find(id) { // read recorded by `find`
|
||||||
Some(NodeItem(item)) => item,
|
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 {
|
pub fn expect_trait_item(&self, id: NodeId) -> &'ast TraitItem {
|
||||||
match self.find(id) {
|
match self.find(id) {
|
||||||
Some(NodeTraitItem(item)) => item,
|
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)) => {
|
Some(NodeItem(i)) => {
|
||||||
match i.node {
|
match i.node {
|
||||||
ItemStruct(ref struct_def, _) => struct_def,
|
ItemStruct(ref struct_def, _) => struct_def,
|
||||||
_ => panic!("struct ID bound to non-struct")
|
_ => bug!("struct ID bound to non-struct")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(NodeVariant(variant)) => {
|
Some(NodeVariant(variant)) => {
|
||||||
if variant.node.data.is_struct() {
|
if variant.node.data.is_struct() {
|
||||||
&variant.node.data
|
&variant.node.data
|
||||||
} else {
|
} 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 {
|
pub fn expect_variant(&self, id: NodeId) -> &'ast Variant {
|
||||||
match self.find(id) {
|
match self.find(id) {
|
||||||
Some(NodeVariant(variant)) => variant,
|
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 {
|
pub fn expect_foreign_item(&self, id: NodeId) -> &'ast ForeignItem {
|
||||||
match self.find(id) {
|
match self.find(id) {
|
||||||
Some(NodeForeignItem(item)) => item,
|
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 {
|
pub fn expect_expr(&self, id: NodeId) -> &'ast Expr {
|
||||||
match self.find(id) { // read recorded by find
|
match self.find(id) { // read recorded by find
|
||||||
Some(NodeExpr(expr)) => expr,
|
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,_), .. }) => {
|
NodeLocal(&Pat { node: PatKind::Ident(_,l,_), .. }) => {
|
||||||
PathName(l.node.name)
|
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 {
|
pub fn span(&self, id: NodeId) -> Span {
|
||||||
self.read(id); // reveals span from node
|
self.read(id); // reveals span from node
|
||||||
self.opt_span(id)
|
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> {
|
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),
|
NodePat(a) => self.print_pat(&a),
|
||||||
NodeBlock(a) => self.print_block(&a),
|
NodeBlock(a) => self.print_block(&a),
|
||||||
NodeLifetime(a) => self.print_lifetime(&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
|
// these cases do not carry enough information in the
|
||||||
// ast_map to reconstruct their full structure for pretty
|
// ast_map to reconstruct their full structure for pretty
|
||||||
// printing.
|
// printing.
|
||||||
NodeLocal(_) => panic!("cannot print isolated Local"),
|
NodeLocal(_) => bug!("cannot print isolated Local"),
|
||||||
NodeStructCtor(_) => panic!("cannot print isolated StructCtor"),
|
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
|
// Early-bound regions should really have been substituted away before
|
||||||
// we get to this point.
|
// we get to this point.
|
||||||
ty::ReEarlyBound(..) => {
|
ty::ReEarlyBound(..) => {
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
self.span,
|
self.span,
|
||||||
&format!("Encountered early bound region when generalizing: {:?}",
|
"Encountered early bound region when generalizing: {:?}",
|
||||||
r));
|
r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always make a fresh region variable for skolemized regions;
|
// 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));
|
bound_failures.push((origin.clone(), kind.clone(), region));
|
||||||
}
|
}
|
||||||
ProcessedErrors(..) => {
|
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::FreshIntTy(c)) |
|
||||||
ty::TyInfer(ty::FreshFloatTy(c)) => {
|
ty::TyInfer(ty::FreshFloatTy(c)) => {
|
||||||
if c >= self.freshen_count {
|
if c >= self.freshen_count {
|
||||||
tcx.sess.bug(
|
bug!("Encountered a freshend type with id {} \
|
||||||
&format!("Encountered a freshend type with id {} \
|
but our counter is only at {}",
|
||||||
but our counter is only at {}",
|
c,
|
||||||
c,
|
self.freshen_count);
|
||||||
self.freshen_count));
|
|
||||||
}
|
}
|
||||||
t
|
t
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,11 +183,10 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
infcx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
&format!("region {:?} is not associated with \
|
"region {:?} is not associated with any bound region from A!",
|
||||||
any bound region from A!",
|
r0)
|
||||||
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 {
|
if a_r.is_some() && b_r.is_some() && only_new_vars {
|
||||||
// Related to exactly one bound variable from each fn:
|
// 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() {
|
} else if a_r.is_none() && b_r.is_none() {
|
||||||
// Not related to bound variables from either fn:
|
// Not related to bound variables from either fn:
|
||||||
assert!(!r0.is_bound());
|
assert!(!r0.is_bound());
|
||||||
|
@ -308,8 +307,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rev_lookup(infcx: &InferCtxt,
|
fn rev_lookup(span: Span,
|
||||||
span: Span,
|
|
||||||
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
|
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
|
||||||
r: ty::Region) -> 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);
|
return ty::ReLateBound(ty::DebruijnIndex::new(1), *a_br);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infcx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
span,
|
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 {
|
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 {
|
.map(|(_, r)| match *r {
|
||||||
ty::ReVar(r) => { r }
|
ty::ReVar(r) => { r }
|
||||||
r => {
|
r => {
|
||||||
fields.tcx().sess.span_bug(
|
span_bug!(
|
||||||
fields.trace.origin.span(),
|
fields.trace.origin.span(),
|
||||||
&format!("found non-region-vid: {:?}", r));
|
"found non-region-vid: {:?}",
|
||||||
|
r);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|
|
@ -471,7 +471,7 @@ pub fn mk_eq_impl_headers<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
|
||||||
match (a.trait_ref, b.trait_ref) {
|
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),
|
(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),
|
(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) {
|
match drain_fulfillment_cx(infcx, fulfill_cx, result) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(errors) => {
|
Err(errors) => {
|
||||||
infcx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
&format!("Encountered errors `{:?}` fulfilling during trans",
|
"Encountered errors `{:?}` fulfilling during trans",
|
||||||
errors));
|
errors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1114,9 +1114,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
None if self.errors_since_creation() =>
|
None if self.errors_since_creation() =>
|
||||||
self.tcx.types.err,
|
self.tcx.types.err,
|
||||||
None => {
|
None => {
|
||||||
self.tcx.sess.bug(
|
bug!("no type for node {}: {} in fcx",
|
||||||
&format!("no type for node {}: {} in fcx",
|
id, self.tcx.map.node_to_string(id));
|
||||||
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) {
|
match self.tables.borrow().node_types.get(&ex.id) {
|
||||||
Some(&t) => t,
|
Some(&t) => t,
|
||||||
None => {
|
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() {
|
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('%') {
|
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 {
|
fn node_id(&self, n: &Node) -> dot::Id {
|
||||||
let node_id = match self.node_ids.get(n) {
|
let node_id = match self.node_ids.get(n) {
|
||||||
Some(node_id) => node_id,
|
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);
|
let name = || format!("node_{}", node_id);
|
||||||
match dot::Id::new(name()) {
|
match dot::Id::new(name()) {
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(_) => {
|
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 {
|
while undo_log.len() > snapshot.length + 1 {
|
||||||
match undo_log.pop().unwrap() {
|
match undo_log.pop().unwrap() {
|
||||||
OpenSnapshot => {
|
OpenSnapshot => {
|
||||||
panic!("Failure to observe stack discipline");
|
bug!("Failure to observe stack discipline");
|
||||||
}
|
}
|
||||||
CommitedSnapshot => {}
|
CommitedSnapshot => {}
|
||||||
AddVar(vid) => {
|
AddVar(vid) => {
|
||||||
|
@ -413,7 +413,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||||
self.bound_count.set(sc + 1);
|
self.bound_count.set(sc + 1);
|
||||||
|
|
||||||
if sc >= self.bound_count.get() {
|
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))
|
ReLateBound(debruijn, BrFresh(sc))
|
||||||
|
@ -497,10 +497,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||||
(ReLateBound(..), _) |
|
(ReLateBound(..), _) |
|
||||||
(_, ReEarlyBound(..)) |
|
(_, ReEarlyBound(..)) |
|
||||||
(_, ReLateBound(..)) => {
|
(_, ReLateBound(..)) => {
|
||||||
self.tcx.sess.span_bug(origin.span(),
|
span_bug!(origin.span(),
|
||||||
&format!("cannot relate bound region: {:?} <= {:?}",
|
"cannot relate bound region: {:?} <= {:?}",
|
||||||
sub,
|
sub,
|
||||||
sup));
|
sup);
|
||||||
}
|
}
|
||||||
(_, ReStatic) => {
|
(_, ReStatic) => {
|
||||||
// all regions are subregions of static, so we can ignore this
|
// 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 {
|
pub fn resolve_var(&self, rid: RegionVid) -> ty::Region {
|
||||||
match *self.values.borrow() {
|
match *self.values.borrow() {
|
||||||
None => {
|
None => {
|
||||||
self.tcx.sess.span_bug((*self.var_origins.borrow())[rid.index as usize].span(),
|
span_bug!((*self.var_origins.borrow())[rid.index as usize].span(),
|
||||||
"attempt to resolve region variable before values have \
|
"attempt to resolve region variable before values have \
|
||||||
been computed!")
|
been computed!")
|
||||||
}
|
}
|
||||||
Some(ref values) => {
|
Some(ref values) => {
|
||||||
let r = lookup(values, rid);
|
let r = lookup(values, rid);
|
||||||
|
@ -733,7 +733,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||||
(_, ReLateBound(..)) |
|
(_, ReLateBound(..)) |
|
||||||
(ReEarlyBound(..), _) |
|
(ReEarlyBound(..), _) |
|
||||||
(_, ReEarlyBound(..)) => {
|
(_, ReEarlyBound(..)) => {
|
||||||
self.tcx.sess.bug(&format!("cannot relate bound region: LUB({:?}, {:?})", a, b));
|
bug!("cannot relate bound region: LUB({:?}, {:?})", a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
(ReStatic, _) | (_, ReStatic) => {
|
(ReStatic, _) | (_, ReStatic) => {
|
||||||
|
@ -745,11 +745,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
(ReVar(v_id), _) | (_, ReVar(v_id)) => {
|
(ReVar(v_id), _) | (_, ReVar(v_id)) => {
|
||||||
self.tcx.sess.span_bug((*self.var_origins.borrow())[v_id.index as usize].span(),
|
span_bug!((*self.var_origins.borrow())[v_id.index as usize].span(),
|
||||||
&format!("lub_concrete_regions invoked with non-concrete \
|
"lub_concrete_regions invoked with non-concrete \
|
||||||
regions: {:?}, {:?}",
|
regions: {:?}, {:?}",
|
||||||
a,
|
a,
|
||||||
b));
|
b);
|
||||||
}
|
}
|
||||||
|
|
||||||
(ReFree(ref fr), ReScope(s_id)) |
|
(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(),
|
span_bug!((*self.var_origins.borrow())[node_idx.index as usize].span(),
|
||||||
&format!("collect_error_for_expanding_node() could not find \
|
"collect_error_for_expanding_node() could not find \
|
||||||
error for var {:?}, lower_bounds={:?}, \
|
error for var {:?}, lower_bounds={:?}, \
|
||||||
upper_bounds={:?}",
|
upper_bounds={:?}",
|
||||||
node_idx,
|
node_idx,
|
||||||
lower_bounds,
|
lower_bounds,
|
||||||
upper_bounds));
|
upper_bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_concrete_regions(&self,
|
fn collect_concrete_regions(&self,
|
||||||
|
|
|
@ -127,9 +127,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
|
||||||
self.tcx().types.err
|
self.tcx().types.err
|
||||||
}
|
}
|
||||||
ty::TyInfer(_) => {
|
ty::TyInfer(_) => {
|
||||||
self.infcx.tcx.sess.bug(
|
bug!("Unexpected type in full type resolver: {:?}", t);
|
||||||
&format!("Unexpected type in full type resolver: {:?}",
|
|
||||||
t));
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
t.super_fold_with(self)
|
t.super_fold_with(self)
|
||||||
|
|
|
@ -159,8 +159,8 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
||||||
|
|
||||||
let (relations, default) = match old_value {
|
let (relations, default) = match old_value {
|
||||||
Bounded { relations, default } => (relations, default),
|
Bounded { relations, default } => (relations, default),
|
||||||
Known(_) => panic!("Asked to instantiate variable that is \
|
Known(_) => bug!("Asked to instantiate variable that is \
|
||||||
already instantiated")
|
already instantiated")
|
||||||
};
|
};
|
||||||
|
|
||||||
for &(dir, vid) in &relations {
|
for &(dir, vid) in &relations {
|
||||||
|
@ -259,7 +259,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
||||||
// quick check to see if this variable was
|
// quick check to see if this variable was
|
||||||
// created since the snapshot started or not.
|
// created since the snapshot started or not.
|
||||||
let escaping_type = match self.values.get(vid.index as usize).value {
|
let escaping_type = match self.values.get(vid.index as usize).value {
|
||||||
Bounded { .. } => unreachable!(),
|
Bounded { .. } => bug!(),
|
||||||
Known(ty) => ty,
|
Known(ty) => ty,
|
||||||
};
|
};
|
||||||
escaping_types.push(escaping_type);
|
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> {
|
fn relations<'a>(v: &'a mut TypeVariableData) -> &'a mut Vec<Relation> {
|
||||||
match v.value {
|
match v.value {
|
||||||
Known(_) => panic!("var_sub_var: variable is known"),
|
Known(_) => bug!("var_sub_var: variable is known"),
|
||||||
Bounded { ref mut relations, .. } => relations
|
Bounded { ref mut relations, .. } => relations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ impl LintStore {
|
||||||
// We load builtin lints first, so a duplicate is a compiler bug.
|
// We load builtin lints first, so a duplicate is a compiler bug.
|
||||||
// Use early_error when handling -W help with no crate.
|
// Use early_error when handling -W help with no crate.
|
||||||
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
|
(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.
|
// A duplicate name from a plugin is a user error.
|
||||||
(Some(sess), true) => sess.err(&msg[..]),
|
(Some(sess), true) => sess.err(&msg[..]),
|
||||||
|
@ -221,7 +221,7 @@ impl LintStore {
|
||||||
// We load builtin lints first, so a duplicate is a compiler bug.
|
// We load builtin lints first, so a duplicate is a compiler bug.
|
||||||
// Use early_error when handling -W help with no crate.
|
// Use early_error when handling -W help with no crate.
|
||||||
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
|
(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.
|
// A duplicate name from a plugin is a user error.
|
||||||
(Some(sess), true) => sess.err(&msg[..]),
|
(Some(sess), true) => sess.err(&msg[..]),
|
||||||
|
@ -232,7 +232,7 @@ impl LintStore {
|
||||||
pub fn register_renamed(&mut self, old_name: &str, new_name: &str) {
|
pub fn register_renamed(&mut self, old_name: &str, new_name: &str) {
|
||||||
let target = match self.by_name.get(new_name) {
|
let target = match self.by_name.get(new_name) {
|
||||||
Some(&Id(lint_id)) => lint_id.clone(),
|
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));
|
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,
|
format!("{} [-{} {}]", msg,
|
||||||
match level {
|
match level {
|
||||||
Warn => 'W', Deny => 'D', Forbid => 'F',
|
Warn => 'W', Deny => 'D', Forbid => 'F',
|
||||||
Allow => panic!()
|
Allow => bug!()
|
||||||
}, name.replace("_", "-"))
|
}, name.replace("_", "-"))
|
||||||
},
|
},
|
||||||
Node(src) => {
|
Node(src) => {
|
||||||
|
@ -447,7 +447,7 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
|
||||||
(Warn, None) => sess.struct_warn(&msg[..]),
|
(Warn, None) => sess.struct_warn(&msg[..]),
|
||||||
(Deny, Some(sp)) => sess.struct_span_err(sp, &msg[..]),
|
(Deny, Some(sp)) => sess.struct_span_err(sp, &msg[..]),
|
||||||
(Deny, None) => sess.struct_err(&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.
|
// 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.
|
// in the iteration code.
|
||||||
for (id, v) in tcx.sess.lints.borrow().iter() {
|
for (id, v) in tcx.sess.lints.borrow().iter() {
|
||||||
for &(lint, span, ref msg) in v {
|
for &(lint, span, ref msg) in v {
|
||||||
tcx.sess.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("unprocessed lint {} at {}: {}",
|
"unprocessed lint {} at {}: {}",
|
||||||
lint.as_str(), tcx.map.node_to_string(*id), *msg))
|
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.
|
// in the iteration code.
|
||||||
for (_, v) in sess.lints.borrow().iter() {
|
for (_, v) in sess.lints.borrow().iter() {
|
||||||
for &(lint, span, ref msg) in v {
|
for &(lint, span, ref msg) in v {
|
||||||
sess.span_bug(span,
|
span_bug!(span, "unprocessed lint {}: {}", lint.as_str(), *msg)
|
||||||
&format!("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 {
|
if let ast::TyPath(None, ref path) = ast_ty.node {
|
||||||
let def = match tcx.def_map.borrow().get(&ast_ty.id) {
|
let def = match tcx.def_map.borrow().get(&ast_ty.id) {
|
||||||
None => {
|
None => {
|
||||||
tcx.sess.span_bug(ast_ty.span,
|
span_bug!(ast_ty.span, "unbound path {:?}", path)
|
||||||
&format!("unbound path {:?}", path))
|
|
||||||
}
|
}
|
||||||
Some(d) => d.full_def()
|
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| {
|
let mut say = |s: &str| {
|
||||||
match (sp, sess) {
|
match (sp, sess) {
|
||||||
(_, None) => panic!("{}", s),
|
(_, None) => bug!("{}", s),
|
||||||
(Some(sp), Some(sess)) => sess.span_err(sp, s),
|
(Some(sp), Some(sess)) => sess.span_err(sp, s),
|
||||||
(None, Some(sess)) => sess.err(s),
|
(None, Some(sess)) => sess.err(s),
|
||||||
}
|
}
|
||||||
|
@ -336,121 +336,123 @@ pub struct DummyCrateStore;
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
||||||
// item info
|
// item info
|
||||||
fn stability(&self, def: DefId) -> Option<attr::Stability> { unimplemented!() }
|
fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
|
||||||
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { unimplemented!() }
|
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
|
||||||
fn visibility(&self, def: DefId) -> hir::Visibility { unimplemented!() }
|
fn visibility(&self, def: DefId) -> hir::Visibility { bug!("visibility") }
|
||||||
fn closure_kind(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
|
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)
|
fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
|
||||||
-> ty::ClosureTy<'tcx> { unimplemented!() }
|
-> ty::ClosureTy<'tcx> { bug!("closure_ty") }
|
||||||
fn item_variances(&self, def: DefId) -> ty::ItemVariances { unimplemented!() }
|
fn item_variances(&self, def: DefId) -> ty::ItemVariances { bug!("item_variances") }
|
||||||
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { unimplemented!() }
|
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { bug!("repr_attrs") }
|
||||||
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||||
-> ty::TypeScheme<'tcx> { unimplemented!() }
|
-> ty::TypeScheme<'tcx> { bug!("item_type") }
|
||||||
fn relative_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() }
|
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>> {
|
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 extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { bug!("extern_item_path") }
|
||||||
fn item_name(&self, def: DefId) -> ast::Name { unimplemented!() }
|
fn item_name(&self, def: DefId) -> ast::Name { bug!("item_name") }
|
||||||
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
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)
|
fn item_super_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||||
-> ty::GenericPredicates<'tcx> { unimplemented!() }
|
-> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
|
||||||
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { unimplemented!() }
|
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
|
||||||
fn item_symbol(&self, def: DefId) -> String { unimplemented!() }
|
fn item_symbol(&self, def: DefId) -> String { bug!("item_symbol") }
|
||||||
fn trait_def(&self, tcx: &TyCtxt<'tcx>, def: DefId)-> ty::TraitDef<'tcx>
|
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>
|
fn adt_def(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
|
||||||
{ unimplemented!() }
|
{ bug!("adt_def") }
|
||||||
fn method_arg_names(&self, did: DefId) -> Vec<String> { unimplemented!() }
|
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![] }
|
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] }
|
||||||
|
|
||||||
// trait info
|
// trait info
|
||||||
fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId> { vec![] }
|
fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId> { vec![] }
|
||||||
fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
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)
|
fn trait_item_def_ids(&self, def: DefId)
|
||||||
-> Vec<ty::ImplOrTraitItemId> { unimplemented!() }
|
-> Vec<ty::ImplOrTraitItemId> { bug!("trait_item_def_ids") }
|
||||||
|
|
||||||
// impl info
|
// impl info
|
||||||
fn impl_items(&self, impl_def_id: DefId) -> Vec<ty::ImplOrTraitItemId>
|
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)
|
fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||||
-> Option<ty::TraitRef<'tcx>> { unimplemented!() }
|
-> Option<ty::TraitRef<'tcx>> { bug!("impl_trait_ref") }
|
||||||
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity> { unimplemented!() }
|
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity> { bug!("impl_polarity") }
|
||||||
fn custom_coerce_unsized_kind(&self, def: DefId)
|
fn custom_coerce_unsized_kind(&self, def: DefId)
|
||||||
-> Option<ty::adjustment::CustomCoerceUnsized>
|
-> Option<ty::adjustment::CustomCoerceUnsized>
|
||||||
{ unimplemented!() }
|
{ bug!("custom_coerce_unsized_kind") }
|
||||||
fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId)
|
||||||
-> Vec<Rc<ty::AssociatedConst<'tcx>>> { unimplemented!() }
|
-> Vec<Rc<ty::AssociatedConst<'tcx>>> { bug!("associated_consts") }
|
||||||
fn impl_parent(&self, def: DefId) -> Option<DefId> { unimplemented!() }
|
fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }
|
||||||
|
|
||||||
// trait/impl-item info
|
// trait/impl-item info
|
||||||
fn trait_of_item(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
|
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)
|
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
|
// flags
|
||||||
fn is_const_fn(&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 { unimplemented!() }
|
fn is_defaulted_trait(&self, did: DefId) -> bool { bug!("is_defaulted_trait") }
|
||||||
fn is_impl(&self, did: DefId) -> bool { unimplemented!() }
|
fn is_impl(&self, did: DefId) -> bool { bug!("is_impl") }
|
||||||
fn is_default_impl(&self, impl_did: DefId) -> bool { unimplemented!() }
|
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
|
||||||
fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool { unimplemented!() }
|
fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool { bug!("is_extern_item") }
|
||||||
fn is_static_method(&self, did: DefId) -> bool { unimplemented!() }
|
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_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
|
// crate metadata
|
||||||
fn dylib_dependency_formats(&self, cnum: ast::CrateNum)
|
fn dylib_dependency_formats(&self, cnum: ast::CrateNum)
|
||||||
-> Vec<(ast::CrateNum, LinkagePreference)>
|
-> Vec<(ast::CrateNum, LinkagePreference)>
|
||||||
{ unimplemented!() }
|
{ bug!("dylib_dependency_formats") }
|
||||||
fn lang_items(&self, cnum: ast::CrateNum) -> Vec<(DefIndex, usize)>
|
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>
|
fn missing_lang_items(&self, cnum: ast::CrateNum) -> Vec<lang_items::LangItem>
|
||||||
{ unimplemented!() }
|
{ bug!("missing_lang_items") }
|
||||||
fn is_staged_api(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
|
fn is_staged_api(&self, cnum: ast::CrateNum) -> bool { bug!("is_staged_api") }
|
||||||
fn is_explicitly_linked(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
|
fn is_explicitly_linked(&self, cnum: ast::CrateNum) -> bool { bug!("is_explicitly_linked") }
|
||||||
fn is_allocator(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
|
fn is_allocator(&self, cnum: ast::CrateNum) -> bool { bug!("is_allocator") }
|
||||||
fn extern_crate(&self, cnum: ast::CrateNum) -> Option<ExternCrate> { unimplemented!() }
|
fn extern_crate(&self, cnum: ast::CrateNum) -> Option<ExternCrate> { bug!("extern_crate") }
|
||||||
fn crate_attrs(&self, cnum: ast::CrateNum) -> Vec<ast::Attribute>
|
fn crate_attrs(&self, cnum: ast::CrateNum) -> Vec<ast::Attribute>
|
||||||
{ unimplemented!() }
|
{ bug!("crate_attrs") }
|
||||||
fn crate_name(&self, cnum: ast::CrateNum) -> InternedString { unimplemented!() }
|
fn crate_name(&self, cnum: ast::CrateNum) -> InternedString { bug!("crate_name") }
|
||||||
fn original_crate_name(&self, cnum: ast::CrateNum) -> InternedString {
|
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_hash(&self, cnum: ast::CrateNum) -> Svh { bug!("crate_hash") }
|
||||||
fn crate_disambiguator(&self, cnum: ast::CrateNum) -> InternedString { unimplemented!() }
|
fn crate_disambiguator(&self, cnum: ast::CrateNum)
|
||||||
|
-> InternedString { bug!("crate_disambiguator") }
|
||||||
fn crate_struct_field_attrs(&self, cnum: ast::CrateNum)
|
fn crate_struct_field_attrs(&self, cnum: ast::CrateNum)
|
||||||
-> FnvHashMap<DefId, Vec<ast::Attribute>>
|
-> FnvHashMap<DefId, Vec<ast::Attribute>>
|
||||||
{ unimplemented!() }
|
{ bug!("crate_struct_field_attrs") }
|
||||||
fn plugin_registrar_fn(&self, cnum: ast::CrateNum) -> Option<DefId>
|
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)>
|
fn native_libraries(&self, cnum: ast::CrateNum) -> Vec<(NativeLibraryKind, String)>
|
||||||
{ unimplemented!() }
|
{ bug!("native_libraries") }
|
||||||
fn reachable_ids(&self, cnum: ast::CrateNum) -> Vec<DefId> { unimplemented!() }
|
fn reachable_ids(&self, cnum: ast::CrateNum) -> Vec<DefId> { bug!("reachable_ids") }
|
||||||
|
|
||||||
// resolve
|
// resolve
|
||||||
fn def_key(&self, def: DefId) -> hir_map::DefKey { unimplemented!() }
|
fn def_key(&self, def: DefId) -> hir_map::DefKey { bug!("def_key") }
|
||||||
fn relative_def_path(&self, def: DefId) -> hir_map::DefPath { unimplemented!() }
|
fn relative_def_path(&self, def: DefId) -> hir_map::DefPath { bug!("relative_def_path") }
|
||||||
fn variant_kind(&self, def_id: DefId) -> Option<VariantKind> { unimplemented!() }
|
fn variant_kind(&self, def_id: DefId) -> Option<VariantKind> { bug!("variant_kind") }
|
||||||
fn struct_ctor_def_id(&self, struct_def_id: DefId) -> Option<DefId>
|
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>
|
fn tuple_struct_definition_if_ctor(&self, did: DefId) -> Option<DefId>
|
||||||
{ unimplemented!() }
|
{ bug!("tuple_struct_definition_if_ctor") }
|
||||||
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { unimplemented!() }
|
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { bug!("struct_field_names") }
|
||||||
fn item_children(&self, did: DefId) -> Vec<ChildItem> { unimplemented!() }
|
fn item_children(&self, did: DefId) -> Vec<ChildItem> { bug!("item_children") }
|
||||||
fn crate_top_level_items(&self, cnum: ast::CrateNum) -> Vec<ChildItem>
|
fn crate_top_level_items(&self, cnum: ast::CrateNum) -> Vec<ChildItem>
|
||||||
{ unimplemented!() }
|
{ bug!("crate_top_level_items") }
|
||||||
|
|
||||||
// misc. metadata
|
// misc. metadata
|
||||||
fn maybe_get_item_ast(&'tcx self, tcx: &TyCtxt<'tcx>, def: DefId)
|
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)
|
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 {
|
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
|
// 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![] }
|
fn used_link_args(&self) -> Vec<String> { vec![] }
|
||||||
|
|
||||||
// utility functions
|
// utility functions
|
||||||
fn metadata_filename(&self) -> &str { unimplemented!() }
|
fn metadata_filename(&self) -> &str { bug!("metadata_filename") }
|
||||||
fn metadata_section_name(&self, target: &Target) -> &str { unimplemented!() }
|
fn metadata_section_name(&self, target: &Target) -> &str { bug!("metadata_section_name") }
|
||||||
fn encode_type(&self,
|
fn encode_type(&self,
|
||||||
tcx: &TyCtxt<'tcx>,
|
tcx: &TyCtxt<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
def_id_to_string: fn(&TyCtxt<'tcx>, DefId) -> String)
|
def_id_to_string: fn(&TyCtxt<'tcx>, DefId) -> String)
|
||||||
-> Vec<u8> {
|
-> Vec<u8> {
|
||||||
unimplemented!()
|
bug!("encode_type")
|
||||||
}
|
}
|
||||||
fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<PathBuf>)>
|
fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<PathBuf>)>
|
||||||
{ vec![] }
|
{ 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 extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None }
|
||||||
fn encode_metadata(&self,
|
fn encode_metadata(&self,
|
||||||
tcx: &TyCtxt<'tcx>,
|
tcx: &TyCtxt<'tcx>,
|
||||||
|
@ -481,7 +483,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
||||||
reachable: &NodeSet,
|
reachable: &NodeSet,
|
||||||
mir_map: &MirMap<'tcx>,
|
mir_map: &MirMap<'tcx>,
|
||||||
krate: &hir::Crate) -> Vec<u8> { vec![] }
|
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 {
|
if let ty::TyStruct(def, _) = self.tcx.expr_ty_adjusted(lhs).sty {
|
||||||
self.insert_def_id(def.struct_variant().field_named(name).did);
|
self.insert_def_id(def.struct_variant().field_named(name).did);
|
||||||
} else {
|
} 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 pat_ty = self.tcx.node_id_to_type(lhs.id);
|
||||||
let variant = match pat_ty.sty {
|
let variant = match pat_ty.sty {
|
||||||
ty::TyStruct(adt, _) | ty::TyEnum(adt, _) => adt.variant_of_def(def),
|
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 {
|
for pat in pats {
|
||||||
if let PatKind::Wild = pat.node.pat.node {
|
if let PatKind::Wild = pat.node.pat.node {
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl PathResolution {
|
||||||
/// Get the definition, if fully resolved, otherwise panic.
|
/// Get the definition, if fully resolved, otherwise panic.
|
||||||
pub fn full_def(&self) -> Def {
|
pub fn full_def(&self) -> Def {
|
||||||
if self.depth != 0 {
|
if self.depth != 0 {
|
||||||
panic!("path not fully resolved: {:?}", self);
|
bug!("path not fully resolved: {:?}", self);
|
||||||
}
|
}
|
||||||
self.base_def
|
self.base_def
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ impl Def {
|
||||||
Def::TyParam(..) | Def::Struct(..) | Def::Trait(..) |
|
Def::TyParam(..) | Def::Struct(..) | Def::Trait(..) |
|
||||||
Def::Method(..) | Def::Const(..) | Def::AssociatedConst(..) |
|
Def::Method(..) | Def::Const(..) | Def::AssociatedConst(..) |
|
||||||
Def::PrimTy(..) | Def::Label(..) | Def::SelfTy(..) | Def::Err => {
|
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::PrimTy(..) |
|
||||||
Def::SelfTy(..) |
|
Def::SelfTy(..) |
|
||||||
Def::Err => {
|
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)
|
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)
|
OverloadedCallType::from_method_id(self.tcx(), method_id)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
callee.span,
|
callee.span,
|
||||||
&format!("unexpected callee type {}", callee_ty))
|
"unexpected callee type {}",
|
||||||
|
callee_ty)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match overloaded_call_type {
|
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,
|
// may not. This will generate an error earlier in typeck,
|
||||||
// so we can just ignore it.
|
// so we can just ignore it.
|
||||||
if !self.tcx().sess.has_errors() {
|
if !self.tcx().sess.has_errors() {
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
with_expr.span,
|
with_expr.span,
|
||||||
"with expression doesn't evaluate to a struct");
|
"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 {
|
let (m, r) = match self_ty.sty {
|
||||||
ty::TyRef(r, ref m) => (m.mutbl, r),
|
ty::TyRef(r, ref m) => (m.mutbl, r),
|
||||||
_ => self.tcx().sess.span_bug(expr.span,
|
_ => span_bug!(expr.span,
|
||||||
&format!("bad overloaded deref type {:?}",
|
"bad overloaded deref type {:?}",
|
||||||
method_ty))
|
method_ty)
|
||||||
};
|
};
|
||||||
let bk = ty::BorrowKind::from_mutbl(m);
|
let bk = ty::BorrowKind::from_mutbl(m);
|
||||||
self.delegate.borrow(expr.id, expr.span, cmt,
|
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,
|
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr,
|
||||||
pat);
|
pat);
|
||||||
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, 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;
|
let def_map = &self.tcx().def_map;
|
||||||
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
|
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
|
||||||
match pat.node {
|
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,
|
pat.span,
|
||||||
"binding pattern not an identifier");
|
"binding pattern not an identifier");
|
||||||
}
|
}
|
||||||
|
@ -972,8 +972,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
let delegate = &mut self.delegate;
|
let delegate = &mut self.delegate;
|
||||||
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
|
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
|
||||||
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
|
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
|
||||||
let tcx = typer.tcx;
|
|
||||||
|
|
||||||
debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}",
|
debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}",
|
||||||
cmt_pat,
|
cmt_pat,
|
||||||
pat,
|
pat,
|
||||||
|
@ -1007,7 +1005,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
delegate.consume_pat(pat, cmt_pat, mode);
|
delegate.consume_pat(pat, cmt_pat, mode);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.span_bug(
|
span_bug!(
|
||||||
pat.span,
|
pat.span,
|
||||||
"binding pattern not an identifier");
|
"binding pattern not an identifier");
|
||||||
}
|
}
|
||||||
|
@ -1117,10 +1115,10 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
// reported.
|
// reported.
|
||||||
|
|
||||||
if !tcx.sess.has_errors() {
|
if !tcx.sess.has_errors() {
|
||||||
let msg = format!("Pattern has unexpected def: {:?} and type {:?}",
|
span_bug!(pat.span,
|
||||||
def,
|
"Pattern has unexpected def: {:?} and type {:?}",
|
||||||
cmt_pat.ty);
|
def,
|
||||||
tcx.sess.span_bug(pat.span, &msg[..])
|
cmt_pat.ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl FreeRegionMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn relate_free_regions_from_predicates<'tcx>(&mut self,
|
pub fn relate_free_regions_from_predicates<'tcx>(&mut self,
|
||||||
tcx: &TyCtxt<'tcx>,
|
_tcx: &TyCtxt<'tcx>,
|
||||||
predicates: &[ty::Predicate<'tcx>]) {
|
predicates: &[ty::Predicate<'tcx>]) {
|
||||||
debug!("relate_free_regions_from_predicates(predicates={:?})", predicates);
|
debug!("relate_free_regions_from_predicates(predicates={:?})", predicates);
|
||||||
for predicate in predicates {
|
for predicate in predicates {
|
||||||
|
@ -72,10 +72,9 @@ impl FreeRegionMap {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// All named regions are instantiated with free regions.
|
// All named regions are instantiated with free regions.
|
||||||
tcx.sess.bug(
|
bug!("record_region_bounds: non free region: {:?} / {:?}",
|
||||||
&format!("record_region_bounds: non free region: {:?} / {:?}",
|
r_a,
|
||||||
r_a,
|
r_b);
|
||||||
r_b));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||||
let param_env = match self.param_envs.last() {
|
let param_env = match self.param_envs.last() {
|
||||||
Some(p) => p,
|
Some(p) => p,
|
||||||
None => {
|
None => {
|
||||||
self.tcx.sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
"transmute encountered outside of any fn");
|
"transmute encountered outside of any fn");
|
||||||
}
|
}
|
||||||
|
@ -245,9 +245,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx
|
span_bug!(expr.span, "transmute wasn't a bare fn?!");
|
||||||
.sess
|
|
||||||
.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 {
|
fn variable(&self, node_id: NodeId, span: Span) -> Variable {
|
||||||
match self.variable_map.get(&node_id) {
|
match self.variable_map.get(&node_id) {
|
||||||
Some(&var) => var,
|
Some(&var) => var,
|
||||||
None => {
|
None => {
|
||||||
self.tcx
|
span_bug!(span, "no variable registered for id {}", node_id);
|
||||||
.sess
|
}
|
||||||
.span_bug(span, &format!("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
|
// above and the propagation code below; the two sets of
|
||||||
// code have to agree about which AST nodes are worth
|
// code have to agree about which AST nodes are worth
|
||||||
// creating liveness nodes for.
|
// creating liveness nodes for.
|
||||||
self.ir.tcx.sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
&format!("no live node registered for node {}",
|
"no live node registered for node {}",
|
||||||
node_id));
|
node_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -703,15 +700,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
// to find with one
|
// to find with one
|
||||||
match self.ir.tcx.def_map.borrow().get(&id).map(|d| d.full_def()) {
|
match self.ir.tcx.def_map.borrow().get(&id).map(|d| d.full_def()) {
|
||||||
Some(Def::Label(loop_id)) => loop_id,
|
Some(Def::Label(loop_id)) => loop_id,
|
||||||
_ => self.ir.tcx.sess.span_bug(sp, "label on break/loop \
|
_ => span_bug!(sp, "label on break/loop \
|
||||||
doesn't refer to a loop")
|
doesn't refer to a loop")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Vanilla 'break' or 'loop', so use the enclosing
|
// Vanilla 'break' or 'loop', so use the enclosing
|
||||||
// loop scope
|
// loop scope
|
||||||
if self.loop_scope.is_empty() {
|
if self.loop_scope.is_empty() {
|
||||||
self.ir.tcx.sess.span_bug(sp, "break outside loop");
|
span_bug!(sp, "break outside loop");
|
||||||
} else {
|
} else {
|
||||||
*self.loop_scope.last().unwrap()
|
*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) {
|
let caps = match this.ir.capture_info_map.get(&expr.id) {
|
||||||
Some(caps) => caps.clone(),
|
Some(caps) => caps.clone(),
|
||||||
None => {
|
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| {
|
caps.iter().rev().fold(succ, |succ, cap| {
|
||||||
|
@ -1061,8 +1058,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
|
|
||||||
match self.break_ln.get(&sc) {
|
match self.break_ln.get(&sc) {
|
||||||
Some(&b) => b,
|
Some(&b) => b,
|
||||||
None => self.ir.tcx.sess.span_bug(expr.span,
|
None => span_bug!(expr.span, "break to unknown label")
|
||||||
"break to unknown label")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,8 +1071,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
|
|
||||||
match self.cont_ln.get(&sc) {
|
match self.cont_ln.get(&sc) {
|
||||||
Some(&b) => b,
|
Some(&b) => b,
|
||||||
None => self.ir.tcx.sess.span_bug(expr.span,
|
None => span_bug!(expr.span, "loop to unknown label")
|
||||||
"loop to unknown label")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,9 +312,9 @@ impl MutabilityCategory {
|
||||||
McImmutable
|
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={:?}) => {:?}",
|
debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}",
|
||||||
"from_local", id, ret);
|
"from_local", id, ret);
|
||||||
|
@ -559,8 +559,8 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||||
Def::TyParam(..) |
|
Def::TyParam(..) |
|
||||||
Def::Label(_) | Def::SelfTy(..) |
|
Def::Label(_) | Def::SelfTy(..) |
|
||||||
Def::AssociatedTy(..) => {
|
Def::AssociatedTy(..) => {
|
||||||
self.tcx().sess.span_bug(span, &format!("Unexpected definition in \
|
span_bug!(span, "Unexpected definition in \
|
||||||
memory categorization: {:?}", def));
|
memory categorization: {:?}", def);
|
||||||
}
|
}
|
||||||
|
|
||||||
Def::Static(_, mutbl) => {
|
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)
|
self.cat_upvar(id, span, var_id, fn_node_id, kind)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
&format!("No closure kind for {:?}", closure_id));
|
"No closure kind for {:?}",
|
||||||
|
closure_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
&format!("Upvar of non-closure {} - {:?}",
|
"Upvar of non-closure {} - {:?}",
|
||||||
fn_node_id,
|
fn_node_id,
|
||||||
ty));
|
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_body_id = {
|
||||||
let fn_expr = match self.tcx().map.find(upvar_id.closure_expr_id) {
|
let fn_expr = match self.tcx().map.find(upvar_id.closure_expr_id) {
|
||||||
Some(ast_map::NodeExpr(e)) => e,
|
Some(ast_map::NodeExpr(e)) => e,
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
|
|
||||||
match fn_expr.node {
|
match fn_expr.node {
|
||||||
hir::ExprClosure(_, _, ref body) => body.id,
|
hir::ExprClosure(_, _, ref body) => body.id,
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -926,7 +927,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||||
let ptr = if implicit {
|
let ptr = if implicit {
|
||||||
match ptr {
|
match ptr {
|
||||||
BorrowedPtr(bk, r) => Implicit(bk, r),
|
BorrowedPtr(bk, r) => Implicit(bk, r),
|
||||||
_ => self.tcx().sess.span_bug(node.span(),
|
_ => span_bug!(node.span(),
|
||||||
"Implicit deref of non-borrowed pointer")
|
"Implicit deref of non-borrowed pointer")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1044,7 +1045,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||||
mutbl:m,
|
mutbl:m,
|
||||||
ty: match base_cmt.ty.builtin_deref(false, ty::NoPreference) {
|
ty: match base_cmt.ty.builtin_deref(false, ty::NoPreference) {
|
||||||
Some(mt) => mt.ty,
|
Some(mt) => mt.ty,
|
||||||
None => self.tcx().sess.bug("Found non-derefable type")
|
None => bug!("Found non-derefable type")
|
||||||
},
|
},
|
||||||
note: NoteNone
|
note: NoteNone
|
||||||
})
|
})
|
||||||
|
@ -1092,8 +1093,8 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.span_bug(pat.span,
|
span_bug!(pat.span,
|
||||||
"type of slice pattern is not a slice");
|
"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,
|
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 {
|
match inner.cat {
|
||||||
Categorization::Deref(ref inner, _, _) => inner.clone(),
|
Categorization::Deref(ref inner, _, _) => inner.clone(),
|
||||||
Categorization::Upvar(..) => inner.clone(),
|
Categorization::Upvar(..) => inner.clone(),
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
NoteNone => None
|
NoteNone => None
|
||||||
|
@ -1483,7 +1485,7 @@ impl<'tcx> cmt_<'tcx> {
|
||||||
Some(&Categorization::Upvar(ref var)) => {
|
Some(&Categorization::Upvar(ref var)) => {
|
||||||
var.to_string()
|
var.to_string()
|
||||||
}
|
}
|
||||||
Some(_) => unreachable!(),
|
Some(_) => bug!(),
|
||||||
None => {
|
None => {
|
||||||
match pk {
|
match pk {
|
||||||
Implicit(..) => {
|
Implicit(..) => {
|
||||||
|
|
|
@ -67,10 +67,10 @@ fn method_might_be_inlined(tcx: &TyCtxt, sig: &hir::MethodSig,
|
||||||
Some(ast_map::NodeItem(item)) =>
|
Some(ast_map::NodeItem(item)) =>
|
||||||
item_might_be_inlined(&item),
|
item_might_be_inlined(&item),
|
||||||
Some(..) | None =>
|
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 {
|
} 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) {
|
let def = match self.tcx.def_map.borrow().get(&expr.id) {
|
||||||
Some(d) => d.full_def(),
|
Some(d) => d.full_def(),
|
||||||
None => {
|
None => {
|
||||||
self.tcx.sess.span_bug(expr.span,
|
span_bug!(expr.span, "def ID not in def map?!")
|
||||||
"def ID not in def map?!")
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -312,12 +311,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||||
ast_map::NodeVariant(_) |
|
ast_map::NodeVariant(_) |
|
||||||
ast_map::NodeStructCtor(_) => {}
|
ast_map::NodeStructCtor(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx
|
bug!("found unexpected thingy in worklist: {}",
|
||||||
.sess
|
self.tcx.map.node_to_string(search_item))
|
||||||
.bug(&format!("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 {
|
pub fn lookup_code_extent(&self, e: CodeExtentData) -> CodeExtent {
|
||||||
match self.code_extent_interner.borrow().get(&e) {
|
match self.code_extent_interner.borrow().get(&e) {
|
||||||
Some(&d) => d,
|
Some(&d) => d,
|
||||||
None => panic!("unknown code extent {:?}", e)
|
None => bug!("unknown code extent {:?}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn node_extent(&self, n: ast::NodeId) -> CodeExtent {
|
pub fn node_extent(&self, n: ast::NodeId) -> CodeExtent {
|
||||||
|
@ -385,8 +385,8 @@ impl RegionMaps {
|
||||||
}
|
}
|
||||||
Entry::Vacant(v) => {
|
Entry::Vacant(v) => {
|
||||||
if self.code_extents.borrow().len() > 0xffffffffusize {
|
if self.code_extents.borrow().len() > 0xffffffffusize {
|
||||||
unreachable!() // should pass a sess,
|
bug!() // should pass a sess,
|
||||||
// but this isn't the only place
|
// but this isn't the only place
|
||||||
}
|
}
|
||||||
let idx = CodeExtent(self.code_extents.borrow().len() as u32);
|
let idx = CodeExtent(self.code_extents.borrow().len() as u32);
|
||||||
info!("CodeExtent({}) = {:?} [parent={}]", idx.0, e, parent.0);
|
info!("CodeExtent({}) = {:?} [parent={}]", idx.0, e, parent.0);
|
||||||
|
@ -470,7 +470,7 @@ impl RegionMaps {
|
||||||
pub fn var_scope(&self, var_id: ast::NodeId) -> CodeExtent {
|
pub fn var_scope(&self, var_id: ast::NodeId) -> CodeExtent {
|
||||||
match self.var_map.borrow().get(&var_id) {
|
match self.var_map.borrow().get(&var_id) {
|
||||||
Some(&r) => r,
|
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
|
scope_a
|
||||||
} else {
|
} else {
|
||||||
// neither fn encloses the other
|
// neither fn encloses the other
|
||||||
unreachable!()
|
bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// root ids are always Misc right now
|
// root ids are always Misc right now
|
||||||
unreachable!()
|
bug!()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -747,9 +747,9 @@ impl<'a> LifetimeContext<'a> {
|
||||||
lifetime_ref: &hir::Lifetime,
|
lifetime_ref: &hir::Lifetime,
|
||||||
def: DefRegion) {
|
def: DefRegion) {
|
||||||
if lifetime_ref.id == ast::DUMMY_NODE_ID {
|
if lifetime_ref.id == ast::DUMMY_NODE_ID {
|
||||||
self.sess.span_bug(lifetime_ref.span,
|
span_bug!(lifetime_ref.span,
|
||||||
"lifetime reference not renumbered, \
|
"lifetime reference not renumbered, \
|
||||||
probably a bug in syntax::fold");
|
probably a bug in syntax::fold");
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("lifetime_ref={:?} id={:?} resolved to {:?}",
|
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);
|
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;
|
span = field.span;
|
||||||
match tcx.expr_ty_adjusted(base_e).sty {
|
match tcx.expr_ty_adjusted(base_e).sty {
|
||||||
ty::TyStruct(def, _) => def.struct_variant().field_named(field.node).did,
|
ty::TyStruct(def, _) => def.struct_variant().field_named(field.node).did,
|
||||||
_ => tcx.sess.span_bug(e.span,
|
_ => span_bug!(e.span,
|
||||||
"stability::check_expr: named field access on non-struct")
|
"stability::check_expr: named field access on non-struct")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprTupField(ref base_e, ref field) => {
|
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 {
|
match tcx.expr_ty_adjusted(base_e).sty {
|
||||||
ty::TyStruct(def, _) => def.struct_variant().fields[field.node].did,
|
ty::TyStruct(def, _) => def.struct_variant().fields[field.node].did,
|
||||||
ty::TyTuple(..) => return,
|
ty::TyTuple(..) => return,
|
||||||
_ => tcx.sess.span_bug(e.span,
|
_ => span_bug!(e.span,
|
||||||
"stability::check_expr: unnamed field access on \
|
"stability::check_expr: unnamed field access on \
|
||||||
something other than a tuple or struct")
|
something other than a tuple or struct")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprStruct(_, ref expr_fields, _) => {
|
hir::ExprStruct(_, ref expr_fields, _) => {
|
||||||
|
@ -551,10 +551,10 @@ pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr,
|
||||||
// a bug to have construct one.
|
// a bug to have construct one.
|
||||||
ty::TyEnum(..) => return,
|
ty::TyEnum(..) => return,
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess.span_bug(e.span,
|
span_bug!(e.span,
|
||||||
&format!("stability::check_expr: struct construction \
|
"stability::check_expr: struct construction \
|
||||||
of non-struct, type {:?}",
|
of non-struct, type {:?}",
|
||||||
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, _) =>
|
Struct(node_id) | Tuple(node_id) | Array(node_id, _) | Repeat(node_id, _) =>
|
||||||
write!(fmt, "{}", node_to_string(node_id)),
|
write!(fmt, "{}", node_to_string(node_id)),
|
||||||
Char(c) => write!(fmt, "{:?}", c),
|
Char(c) => write!(fmt, "{:?}", c),
|
||||||
Dummy => unreachable!(),
|
Dummy => bug!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl<'tcx> LvalueTy<'tcx> {
|
||||||
variant_index: index }
|
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 }
|
ProjectionElem::Field(_, fty) => LvalueTy::Ty { ty: fty }
|
||||||
|
|
|
@ -362,7 +362,7 @@ macro_rules! options {
|
||||||
value, $outputname,
|
value, $outputname,
|
||||||
key, type_desc))
|
key, type_desc))
|
||||||
}
|
}
|
||||||
(None, None) => unreachable!()
|
(None, None) => bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
|
|
|
@ -155,14 +155,14 @@ pub fn get_or_default_sysroot() -> PathBuf {
|
||||||
// gcc chokes on verbatim paths which fs::canonicalize generates
|
// gcc chokes on verbatim paths which fs::canonicalize generates
|
||||||
// so we try to avoid those kinds of paths.
|
// so we try to avoid those kinds of paths.
|
||||||
Ok(canon) => Some(rustcfs::fix_windows_verbatim_for_gcc(&canon)),
|
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()) {
|
match canonicalize(env::current_exe().ok()) {
|
||||||
Some(mut p) => { p.pop(); p.pop(); p }
|
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::cstore::CrateStore;
|
||||||
use middle::dependency_format;
|
use middle::dependency_format;
|
||||||
use session::search_paths::PathKind;
|
use session::search_paths::PathKind;
|
||||||
|
use ty::tls;
|
||||||
use util::nodemap::{NodeMap, FnvHashMap};
|
use util::nodemap::{NodeMap, FnvHashMap};
|
||||||
use mir::transform as mir_pass;
|
use mir::transform as mir_pass;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ use std::cell::{Cell, RefCell};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod filesearch;
|
pub mod filesearch;
|
||||||
|
@ -216,22 +218,10 @@ impl Session {
|
||||||
None => self.warn(msg),
|
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()
|
/// Delay a span_bug() call until abort_if_errors()
|
||||||
pub fn delay_span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
|
pub fn delay_span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
|
||||||
self.diagnostic().delay_span_bug(sp, msg)
|
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) {
|
pub fn note_without_error(&self, msg: &str) {
|
||||||
self.diagnostic().note_without_error(msg)
|
self.diagnostic().note_without_error(msg)
|
||||||
}
|
}
|
||||||
|
@ -268,7 +258,7 @@ impl Session {
|
||||||
|
|
||||||
match id.checked_add(count) {
|
match id.checked_add(count) {
|
||||||
Some(next) => self.next_node_id.set(next),
|
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
|
id
|
||||||
|
@ -279,11 +269,6 @@ impl Session {
|
||||||
pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
|
pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
|
||||||
self.parse_sess.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 verbose(&self) -> bool { self.opts.debugging_opts.verbose }
|
||||||
pub fn time_passes(&self) -> bool { self.opts.debugging_opts.time_passes }
|
pub fn time_passes(&self) -> bool { self.opts.debugging_opts.time_passes }
|
||||||
pub fn count_llvm_insns(&self) -> bool {
|
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)
|
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(..) => {
|
ty::TyClosure(..) => {
|
||||||
tcx.sess.bug(
|
bug!("ty_is_local invoked on unexpected type: {:?}", ty)
|
||||||
&format!("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();
|
err.emit();
|
||||||
infcx.tcx.sess.abort_if_errors();
|
infcx.tcx.sess.abort_if_errors();
|
||||||
unreachable!();
|
bug!();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reports that a cycle was detected which led to overflow and halts
|
/// 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,
|
span_bug!(obligation.cause.span,
|
||||||
&format!("Sized cycle involving non-trait-ref: {:?}",
|
"Sized cycle involving non-trait-ref: {:?}",
|
||||||
obligation.predicate));
|
obligation.predicate);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -323,7 +323,7 @@ pub fn try_report_overflow_error_type_of_infinite_size<'a, 'tcx>(
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
infcx.tcx.sess.abort_if_errors();
|
infcx.tcx.sess.abort_if_errors();
|
||||||
unreachable!();
|
bug!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recursive_type_with_infinite_size_error<'tcx>(tcx: &TyCtxt<'tcx>,
|
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
|
// ambiguity; otherwise, they always
|
||||||
// degenerate into other obligations
|
// degenerate into other obligations
|
||||||
// (which may fail).
|
// (which may fail).
|
||||||
infcx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
obligation.cause.span,
|
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,
|
// The essential problem here is that the projection fails,
|
||||||
// leaving two unnormalized types, which appear not to unify
|
// leaving two unnormalized types, which appear not to unify
|
||||||
// -- so the overlap check succeeds, when it should fail.
|
// -- so the overlap check succeeds, when it should fail.
|
||||||
selcx.tcx().sess.bug("Tried to project an inherited associated type during \
|
bug!("Tried to project an inherited associated type during \
|
||||||
coherence checking, which is currently not supported.");
|
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 {
|
let data = match object_ty.sty {
|
||||||
ty::TyTrait(ref data) => data,
|
ty::TyTrait(ref data) => data,
|
||||||
_ => {
|
_ => {
|
||||||
selcx.tcx().sess.span_bug(
|
span_bug!(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
&format!("assemble_candidates_from_object_type called with non-object: {:?}",
|
"assemble_candidates_from_object_type called with non-object: {:?}",
|
||||||
object_ty));
|
object_ty);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), 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::VtableDefaultImpl(..) |
|
||||||
super::VtableBuiltin(..) => {
|
super::VtableBuiltin(..) => {
|
||||||
// These traits have no associated types.
|
// These traits have no associated types.
|
||||||
selcx.tcx().sess.span_bug(
|
span_bug!(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
&format!("Cannot project an associated type from `{:?}`",
|
"Cannot project an associated type from `{:?}`",
|
||||||
vtable));
|
vtable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1084,12 +1084,12 @@ fn confirm_param_env_candidate<'cx,'tcx>(
|
||||||
projection.projection_ty.trait_ref.clone()) {
|
projection.projection_ty.trait_ref.clone()) {
|
||||||
Ok(()) => { }
|
Ok(()) => { }
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
selcx.tcx().sess.span_bug(
|
span_bug!(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
&format!("Failed to unify `{:?}` and `{:?}` in projection: {}",
|
"Failed to unify `{:?}` and `{:?}` in projection: {}",
|
||||||
obligation,
|
obligation,
|
||||||
projection,
|
projection,
|
||||||
e));
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,8 +1124,9 @@ fn confirm_impl_candidate<'cx,'tcx>(
|
||||||
(ty.subst(tcx, substs), nested)
|
(ty.subst(tcx, substs), nested)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
tcx.sess.span_bug(obligation.cause.span,
|
span_bug!(obligation.cause.span,
|
||||||
&format!("No associated type for {:?}", trait_ref));
|
"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 {
|
let trait_def_id = match obligation.predicate.0.trait_ref.self_ty().sty {
|
||||||
ty::TyProjection(ref data) => data.trait_ref.def_id,
|
ty::TyProjection(ref data) => data.trait_ref.def_id,
|
||||||
ty::TyInfer(ty::TyVar(_)) => {
|
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");
|
"Self=_ should have been handled by assemble_candidates");
|
||||||
}
|
}
|
||||||
_ => { return; }
|
_ => { return; }
|
||||||
|
@ -1125,11 +1125,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
let projection_trait_ref = match skol_trait_predicate.trait_ref.self_ty().sty {
|
let projection_trait_ref = match skol_trait_predicate.trait_ref.self_ty().sty {
|
||||||
ty::TyProjection(ref data) => &data.trait_ref,
|
ty::TyProjection(ref data) => &data.trait_ref,
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
&format!("match_projection_obligation_against_bounds_from_trait() called \
|
"match_projection_obligation_against_bounds_from_trait() called \
|
||||||
but self-ty not a projection: {:?}",
|
but self-ty not a projection: {:?}",
|
||||||
skol_trait_predicate.trait_ref.self_ty()));
|
skol_trait_predicate.trait_ref.self_ty());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
debug!("match_projection_obligation_against_bounds_from_trait: \
|
debug!("match_projection_obligation_against_bounds_from_trait: \
|
||||||
|
@ -1601,7 +1601,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
ObjectCandidate |
|
ObjectCandidate |
|
||||||
ParamCandidate(_) | ProjectionCandidate => match victim.candidate {
|
ParamCandidate(_) | ProjectionCandidate => match victim.candidate {
|
||||||
DefaultImplCandidate(..) => {
|
DefaultImplCandidate(..) => {
|
||||||
self.tcx().sess.bug(
|
bug!(
|
||||||
"default implementations shouldn't be recorded \
|
"default implementations shouldn't be recorded \
|
||||||
when there are other valid candidates");
|
when there are other valid candidates");
|
||||||
}
|
}
|
||||||
|
@ -1703,7 +1703,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
ty::BoundSized => ok_if(Vec::new()),
|
ty::BoundSized => ok_if(Vec::new()),
|
||||||
|
|
||||||
ty::BoundSync | ty::BoundSend => {
|
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::BoundCopy | ty::BoundSized => ok_if(Vec::new()),
|
||||||
|
|
||||||
ty::BoundSync | ty::BoundSend => {
|
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 => {
|
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::BoundSized => ok_if(Vec::new()),
|
||||||
|
|
||||||
ty::BoundSync | ty::BoundSend => {
|
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::BoundCopy => ok_if(vec![element_ty]),
|
||||||
ty::BoundSized => ok_if(Vec::new()),
|
ty::BoundSized => ok_if(Vec::new()),
|
||||||
ty::BoundSync | ty::BoundSend => {
|
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(_) => {
|
ty::TyStr | ty::TySlice(_) => {
|
||||||
match bound {
|
match bound {
|
||||||
ty::BoundSync | ty::BoundSend => {
|
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),
|
ty::BoundCopy | ty::BoundSized => Err(Unimplemented),
|
||||||
|
@ -1847,10 +1847,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
ty::TyInfer(ty::FreshTy(_))
|
ty::TyInfer(ty::FreshTy(_))
|
||||||
| ty::TyInfer(ty::FreshIntTy(_))
|
| ty::TyInfer(ty::FreshIntTy(_))
|
||||||
| ty::TyInfer(ty::FreshFloatTy(_)) => {
|
| ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||||
self.tcx().sess.bug(
|
bug!("asked to assemble builtin bounds of unexpected type: {:?}",
|
||||||
&format!(
|
self_ty);
|
||||||
"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),
|
ty::BoundSized => ok_if(types),
|
||||||
|
|
||||||
// Shouldn't be coming through here.
|
// 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::FreshTy(_)) |
|
||||||
ty::TyInfer(ty::FreshIntTy(_)) |
|
ty::TyInfer(ty::FreshIntTy(_)) |
|
||||||
ty::TyInfer(ty::FreshFloatTy(_)) => {
|
ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||||
self.tcx().sess.bug(
|
bug!("asked to assemble constituent types of unexpected type: {:?}",
|
||||||
&format!(
|
t);
|
||||||
"asked to assemble constituent types of unexpected type: {:?}",
|
|
||||||
t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyBox(referent_ty) => { // Box<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()) {
|
match self.match_where_clause_trait_ref(obligation, param.clone()) {
|
||||||
Ok(obligations) => obligations,
|
Ok(obligations) => obligations,
|
||||||
Err(()) => {
|
Err(()) => {
|
||||||
self.tcx().sess.bug(
|
bug!("Where clause `{:?}` was applicable to `{:?}` but now is not",
|
||||||
&format!("Where clause `{:?}` was applicable to `{:?}` but now is not",
|
param,
|
||||||
param,
|
obligation);
|
||||||
obligation));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2155,10 +2150,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
match self.builtin_bound(bound, obligation)? {
|
match self.builtin_bound(bound, obligation)? {
|
||||||
If(nested) => Ok(self.vtable_builtin_data(obligation, bound, nested)),
|
If(nested) => Ok(self.vtable_builtin_data(obligation, bound, nested)),
|
||||||
AmbiguousBuiltin | ParameterBuiltin => {
|
AmbiguousBuiltin | ParameterBuiltin => {
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
&format!("builtin bound for {:?} was ambig",
|
"builtin bound for {:?} was ambig",
|
||||||
obligation));
|
obligation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2175,7 +2170,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
let trait_def = match self.tcx().lang_items.from_builtin_kind(bound) {
|
let trait_def = match self.tcx().lang_items.from_builtin_kind(bound) {
|
||||||
Ok(def_id) => def_id,
|
Ok(def_id) => def_id,
|
||||||
Err(_) => {
|
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.vtable_default_impl(obligation, trait_def_id, all_types)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx().sess.bug(
|
bug!("asked to confirm default object implementation for non-object type: {:?}",
|
||||||
&format!(
|
self_ty);
|
||||||
"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)
|
data.principal_trait_ref_with_self_ty(self.tcx(), self_ty)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx().sess.span_bug(obligation.cause.span,
|
span_bug!(obligation.cause.span,
|
||||||
"object candidate with non-object");
|
"object candidate with non-object");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2667,7 +2660,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
vec![inner_target]));
|
vec![inner_target]));
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(VtableBuiltinData { nested: nested })
|
Ok(VtableBuiltinData { nested: nested })
|
||||||
|
@ -2692,10 +2685,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
match self.match_impl(impl_def_id, obligation, snapshot) {
|
match self.match_impl(impl_def_id, obligation, snapshot) {
|
||||||
Ok((substs, skol_map)) => (substs, skol_map),
|
Ok((substs, skol_map)) => (substs, skol_map),
|
||||||
Err(()) => {
|
Err(()) => {
|
||||||
self.tcx().sess.bug(
|
bug!("Impl {:?} was matchable against {:?} but now is not",
|
||||||
&format!("Impl {:?} was matchable against {:?} but now is not",
|
impl_def_id,
|
||||||
impl_def_id,
|
obligation);
|
||||||
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(|_| {
|
fulfill_implication(infcx, source_trait_ref, target_impl).unwrap_or_else(|_| {
|
||||||
infcx.tcx
|
bug!("When translating substitutions for specialization, the expected \
|
||||||
.sess
|
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(),
|
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.
|
/// Insert cached metadata mapping from a child impl back to its parent.
|
||||||
pub fn record_impl_from_cstore(&mut self, parent: DefId, child: DefId) {
|
pub fn record_impl_from_cstore(&mut self, parent: DefId, child: DefId) {
|
||||||
if self.parent.insert(child, parent).is_some() {
|
if self.parent.insert(child, parent).is_some() {
|
||||||
panic!("When recording an impl from the crate store, information about its parent \
|
bug!("When recording an impl from the crate store, information about its parent \
|
||||||
was already present.");
|
was already present.");
|
||||||
}
|
}
|
||||||
|
|
||||||
self.children.entry(parent).or_insert(vec![]).push(child);
|
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",
|
bug!("get_vtable_index_of_object_method: {:?} was not found",
|
||||||
method_def_id));
|
method_def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum TupleArgumentsFlag { Yes, No }
|
pub enum TupleArgumentsFlag { Yes, No }
|
||||||
|
|
|
@ -159,9 +159,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
cx.mk_ty(ty::TyFnPtr(b))
|
cx.mk_ty(ty::TyFnPtr(b))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess.bug(
|
bug!("AdjustReifyFnPointer adjustment on non-fn-item: {:?}",
|
||||||
&format!("AdjustReifyFnPointer adjustment on non-fn-item: \
|
self);
|
||||||
{:?}", self));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,10 +169,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
ty::TyFnPtr(b) => cx.safe_to_unsafe_fn_ty(b),
|
ty::TyFnPtr(b) => cx.safe_to_unsafe_fn_ty(b),
|
||||||
ref b => {
|
ref b => {
|
||||||
cx.sess.bug(
|
bug!("AdjustUnsafeFnPointer adjustment on non-fn-ptr: {:?}",
|
||||||
&format!("AdjustUnsafeFnPointer adjustment on non-fn-ptr: \
|
b);
|
||||||
{:?}",
|
|
||||||
b));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,10 +182,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
mutbl: hir::MutImmutable
|
mutbl: hir::MutImmutable
|
||||||
}),
|
}),
|
||||||
ref b => {
|
ref b => {
|
||||||
cx.sess.bug(
|
bug!("AdjustMutToConstPointer on non-raw-ptr: {:?}",
|
||||||
&format!("AdjustMutToConstPointer on non-raw-ptr: \
|
b);
|
||||||
{:?}",
|
|
||||||
b));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,12 +234,11 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
match adjusted_ty.builtin_deref(true, NoPreference) {
|
match adjusted_ty.builtin_deref(true, NoPreference) {
|
||||||
Some(mt) => mt.ty,
|
Some(mt) => mt.ty,
|
||||||
None => {
|
None => {
|
||||||
cx.sess.span_bug(
|
span_bug!(
|
||||||
expr_span,
|
expr_span,
|
||||||
&format!("the {}th autoderef failed: {}",
|
"the {}th autoderef failed: {}",
|
||||||
autoderef,
|
autoderef,
|
||||||
adjusted_ty)
|
adjusted_ty);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
|
|
||||||
ty::TyInfer(_) |
|
ty::TyInfer(_) |
|
||||||
ty::TyError => {
|
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 did = def.trait_ref.def_id;
|
||||||
let interned = self.arenas.trait_defs.alloc(def);
|
let interned = self.arenas.trait_defs.alloc(def);
|
||||||
if let Some(prev) = self.trait_defs.borrow_mut().insert(did, interned) {
|
if let Some(prev) = self.trait_defs.borrow_mut().insert(did, interned) {
|
||||||
self.sess.bug(&format!("Tried to overwrite interned TraitDef: {:?}",
|
bug!("Tried to overwrite interned TraitDef: {:?}", prev)
|
||||||
prev))
|
|
||||||
}
|
}
|
||||||
interned
|
interned
|
||||||
}
|
}
|
||||||
|
@ -482,8 +481,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
let interned = self.arenas.adt_defs.alloc(def);
|
let interned = self.arenas.adt_defs.alloc(def);
|
||||||
// this will need a transmute when reverse-variance is removed
|
// this will need a transmute when reverse-variance is removed
|
||||||
if let Some(prev) = self.adt_defs.borrow_mut().insert(did, interned) {
|
if let Some(prev) = self.adt_defs.borrow_mut().insert(did, interned) {
|
||||||
self.sess.bug(&format!("Tried to overwrite interned AdtDef: {:?}",
|
bug!("Tried to overwrite interned AdtDef: {:?}", prev)
|
||||||
prev))
|
|
||||||
}
|
}
|
||||||
interned
|
interned
|
||||||
}
|
}
|
||||||
|
@ -497,16 +495,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if let Some(prev) = self.stability_interner
|
if let Some(prev) = self.stability_interner
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.insert(interned, interned) {
|
.insert(interned, interned) {
|
||||||
self.sess.bug(&format!("Tried to overwrite interned Stability: {:?}",
|
bug!("Tried to overwrite interned Stability: {:?}", prev)
|
||||||
prev))
|
|
||||||
}
|
}
|
||||||
interned
|
interned
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn store_free_region_map(&self, id: NodeId, map: FreeRegionMap) {
|
pub fn store_free_region_map(&self, id: NodeId, map: FreeRegionMap) {
|
||||||
if self.free_region_maps.borrow_mut().insert(id, map).is_some() {
|
if self.free_region_maps.borrow_mut().insert(id, map).is_some() {
|
||||||
self.sess.bug(&format!("Tried to overwrite interned FreeRegionMap for NodeId {:?}",
|
bug!("Tried to overwrite interned FreeRegionMap for NodeId {:?}", id)
|
||||||
id))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1241,9 +1241,8 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
||||||
cx.region_maps.call_site_extent(id, body.id))
|
cx.region_maps.call_site_extent(id, body.id))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess
|
bug!("ParameterEnvironment::for_item(): \
|
||||||
.bug("ParameterEnvironment::for_item(): \
|
got non-method item from impl method?!")
|
||||||
got non-method item from impl method?!")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1295,10 +1294,9 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
||||||
extent)
|
extent)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess
|
bug!("ParameterEnvironment::for_item(): \
|
||||||
.bug("ParameterEnvironment::for_item(): \
|
got non-method item from provided \
|
||||||
got non-method item from provided \
|
method?!")
|
||||||
method?!")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1341,10 +1339,10 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
||||||
cx.region_maps.item_extent(id))
|
cx.region_maps.item_extent(id))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess.span_bug(item.span,
|
span_bug!(item.span,
|
||||||
"ParameterEnvironment::for_item():
|
"ParameterEnvironment::for_item():
|
||||||
can't create a parameter \
|
can't create a parameter \
|
||||||
environment for this kind of item")
|
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))
|
ParameterEnvironment::for_item(cx, cx.map.get_parent(id))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess.bug(&format!("ParameterEnvironment::for_item(): \
|
bug!("ParameterEnvironment::from_item(): \
|
||||||
`{}` is not an item",
|
`{}` is not an item",
|
||||||
cx.map.node_to_string(id)))
|
cx.map.node_to_string(id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1649,7 +1647,7 @@ impl<'tcx, 'container> AdtDefData<'tcx, 'container> {
|
||||||
match def {
|
match def {
|
||||||
Def::Variant(_, vid) => self.variant_with_id(vid),
|
Def::Variant(_, vid) => self.variant_with_id(vid),
|
||||||
Def::Struct(..) | Def::TyAlias(..) => self.struct_variant(),
|
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, || {
|
map.memoize(def_id, || {
|
||||||
if def_id.is_local() {
|
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()
|
load_external()
|
||||||
})
|
})
|
||||||
|
@ -1902,9 +1900,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
pub fn node_id_to_type(&self, id: NodeId) -> Ty<'tcx> {
|
pub fn node_id_to_type(&self, id: NodeId) -> Ty<'tcx> {
|
||||||
match self.node_id_to_type_opt(id) {
|
match self.node_id_to_type_opt(id) {
|
||||||
Some(ty) => ty,
|
Some(ty) => ty,
|
||||||
None => self.sess.bug(
|
None => bug!("node_id_to_type: no type for node `{}`",
|
||||||
&format!("node_id_to_type: no type for node `{}`",
|
self.map.node_to_string(id))
|
||||||
self.map.node_to_string(id)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1980,12 +1977,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
e.span
|
e.span
|
||||||
}
|
}
|
||||||
Some(f) => {
|
Some(f) => {
|
||||||
self.sess.bug(&format!("Node id {} is not an expr: {:?}",
|
bug!("Node id {} is not an expr: {:?}", id, f);
|
||||||
id, f));
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.sess.bug(&format!("Node id {} is not present \
|
bug!("Node id {} is not present in the node map", id);
|
||||||
in the node map", id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1996,11 +1991,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
match pat.node {
|
match pat.node {
|
||||||
PatKind::Ident(_, ref path1, _) => path1.node.name.as_str(),
|
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) {
|
match self.def_map.borrow().get(&expr.id) {
|
||||||
Some(def) => def.full_def(),
|
Some(def) => def.full_def(),
|
||||||
None => {
|
None => {
|
||||||
self.sess.span_bug(expr.span, &format!(
|
span_bug!(expr.span, "no def-map entry for expr {}", expr.id);
|
||||||
"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(&def::PathResolution { base_def: Def::Err, .. })=> true,
|
||||||
Some(..) => false,
|
Some(..) => false,
|
||||||
None => self.sess.span_bug(expr.span, &format!(
|
None => span_bug!(expr.span, "no def for path {}", expr.id)
|
||||||
"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)) {
|
match self.impl_or_trait_item(self.map.local_def_id(ti.id)) {
|
||||||
MethodTraitItem(m) => Some(m),
|
MethodTraitItem(m) => Some(m),
|
||||||
_ => {
|
_ => {
|
||||||
self.sess.bug("provided_trait_methods(): \
|
bug!("provided_trait_methods(): \
|
||||||
non-method item found from \
|
non-method item found from \
|
||||||
looking up provided method?!")
|
looking up provided method?!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2095,7 +2088,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
}).collect()
|
}).collect()
|
||||||
} else {
|
} else {
|
||||||
self.sess.bug(&format!("provided_trait_methods: `{:?}` is not a trait", id))
|
bug!("provided_trait_methods: `{:?}` is not a trait", id)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.sess.cstore.provided_trait_methods(self, id)
|
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)) {
|
match self.impl_or_trait_item(self.map.local_def_id(ti.id)) {
|
||||||
ConstTraitItem(ac) => Some(ac),
|
ConstTraitItem(ac) => Some(ac),
|
||||||
_ => {
|
_ => {
|
||||||
self.sess.bug("associated_consts(): \
|
bug!("associated_consts(): \
|
||||||
non-const item found from \
|
non-const item found from \
|
||||||
looking up a constant?!")
|
looking up a constant?!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2127,9 +2120,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
match self.impl_or_trait_item(self.map.local_def_id(ii.id)) {
|
match self.impl_or_trait_item(self.map.local_def_id(ii.id)) {
|
||||||
ConstTraitItem(ac) => Some(ac),
|
ConstTraitItem(ac) => Some(ac),
|
||||||
_ => {
|
_ => {
|
||||||
self.sess.bug("associated_consts(): \
|
bug!("associated_consts(): \
|
||||||
non-const item found from \
|
non-const item found from \
|
||||||
looking up a constant?!")
|
looking up a constant?!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2138,8 +2131,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.sess.bug(&format!("associated_consts: `{:?}` is not a trait \
|
bug!("associated_consts: `{:?}` is not a trait or impl", id)
|
||||||
or impl", id))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2174,9 +2166,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
match kind {
|
match kind {
|
||||||
Some(kind) => kind,
|
Some(kind) => kind,
|
||||||
None => {
|
None => {
|
||||||
self.sess.bug(&format!("custom_coerce_unsized_kind: \
|
bug!("custom_coerce_unsized_kind: \
|
||||||
{} impl `{}` is missing its kind",
|
{} impl `{}` is missing its kind",
|
||||||
src, self.item_path_str(did)));
|
src, self.item_path_str(did));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -453,7 +453,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
||||||
(_, &ty::TyInfer(_)) =>
|
(_, &ty::TyInfer(_)) =>
|
||||||
{
|
{
|
||||||
// The caller should handle these cases!
|
// 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) =>
|
(&ty::TyError, _) | (_, &ty::TyError) =>
|
||||||
|
|
|
@ -259,7 +259,7 @@ impl<'tcx> Decodable for &'tcx ClosureSubsts<'tcx> {
|
||||||
Box::new(closure_substs));
|
Box::new(closure_substs));
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
TyClosure(_, ref closure_substs) => Ok(&**closure_substs),
|
TyClosure(_, ref closure_substs) => Ok(&**closure_substs),
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ impl<'tcx> FnOutput<'tcx> {
|
||||||
pub fn unwrap(self) -> Ty<'tcx> {
|
pub fn unwrap(self) -> Ty<'tcx> {
|
||||||
match self {
|
match self {
|
||||||
ty::FnConverging(t) => t,
|
ty::FnConverging(t) => t,
|
||||||
ty::FnDiverging => unreachable!()
|
ty::FnDiverging => bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,8 +978,7 @@ impl<'tcx> TyS<'tcx> {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyArray(ty, _) | TySlice(ty) => ty,
|
TyArray(ty, _) | TySlice(ty) => ty,
|
||||||
TyStr => cx.mk_mach_uint(ast::UintTy::U8),
|
TyStr => cx.mk_mach_uint(ast::UintTy::U8),
|
||||||
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
|
_ => bug!("sequence_element_type called on non-sequence value: {}", self),
|
||||||
self)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,14 +987,14 @@ impl<'tcx> TyS<'tcx> {
|
||||||
TyStruct(def, substs) => {
|
TyStruct(def, substs) => {
|
||||||
def.struct_variant().fields[0].ty(cx, 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 {
|
pub fn simd_size(&self, _cx: &TyCtxt) -> usize {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyStruct(def, _) => def.struct_variant().fields.len(),
|
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> {
|
pub fn fn_sig(&self) -> &'tcx PolyFnSig<'tcx> {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyFnDef(_, _, ref f) | TyFnPtr(ref f) => &f.sig,
|
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 {
|
pub fn fn_abi(&self) -> abi::Abi {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyFnDef(_, _, ref f) | TyFnPtr(ref f) => f.abi,
|
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,
|
0 => TypeSpace,
|
||||||
1 => SelfSpace,
|
1 => SelfSpace,
|
||||||
2 => FnSpace,
|
2 => FnSpace,
|
||||||
_ => panic!("Invalid ParamSpace: {}", u)
|
_ => bug!("Invalid ParamSpace: {}", u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -604,15 +604,15 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let span = self.span.unwrap_or(DUMMY_SP);
|
let span = self.span.unwrap_or(DUMMY_SP);
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
&format!("Region parameter out of range \
|
"Region parameter out of range \
|
||||||
when substituting in region {} (root type={:?}) \
|
when substituting in region {} (root type={:?}) \
|
||||||
(space={:?}, index={})",
|
(space={:?}, index={})",
|
||||||
data.name,
|
data.name,
|
||||||
self.root_ty,
|
self.root_ty,
|
||||||
data.space,
|
data.space,
|
||||||
data.index));
|
data.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,16 +659,16 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> {
|
||||||
Some(t) => *t,
|
Some(t) => *t,
|
||||||
None => {
|
None => {
|
||||||
let span = self.span.unwrap_or(DUMMY_SP);
|
let span = self.span.unwrap_or(DUMMY_SP);
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
&format!("Type parameter `{:?}` ({:?}/{:?}/{}) out of range \
|
"Type parameter `{:?}` ({:?}/{:?}/{}) out of range \
|
||||||
when substituting (root type={:?}) substs={:?}",
|
when substituting (root type={:?}) substs={:?}",
|
||||||
p,
|
p,
|
||||||
source_ty,
|
source_ty,
|
||||||
p.space,
|
p.space,
|
||||||
p.idx,
|
p.idx,
|
||||||
self.root_ty,
|
self.root_ty,
|
||||||
self.substs));
|
self.substs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl IntTypeExt for attr::IntType {
|
||||||
SignedInt(ast::IntTy::Is) => match tcx.sess.target.int_type {
|
SignedInt(ast::IntTy::Is) => match tcx.sess.target.int_type {
|
||||||
ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32(0)),
|
ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32(0)),
|
||||||
ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64(0)),
|
ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64(0)),
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
},
|
},
|
||||||
UnsignedInt(ast::UintTy::U8) => ConstInt::U8(0),
|
UnsignedInt(ast::UintTy::U8) => ConstInt::U8(0),
|
||||||
UnsignedInt(ast::UintTy::U16) => ConstInt::U16(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 {
|
UnsignedInt(ast::UintTy::Us) => match tcx.sess.target.uint_type {
|
||||||
ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32(0)),
|
ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32(0)),
|
||||||
ast::UintTy::U64 => ConstInt::Usize(ConstUsize::Us64(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::U32), ConstInt::U32(_)) => {},
|
||||||
(UnsignedInt(ast::UintTy::U64), ConstInt::U64(_)) => {},
|
(UnsignedInt(ast::UintTy::U64), ConstInt::U64(_)) => {},
|
||||||
(UnsignedInt(ast::UintTy::Us), ConstInt::Usize(_)) => {},
|
(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::ReScope(..) |
|
||||||
ty::ReVar(..) |
|
ty::ReVar(..) |
|
||||||
ty::ReSkolemized(..) => {
|
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.idx);
|
||||||
hash!(p.name.as_str());
|
hash!(p.name.as_str());
|
||||||
}
|
}
|
||||||
TyInfer(_) => unreachable!(),
|
TyInfer(_) => bug!(),
|
||||||
TyError => byte!(21),
|
TyError => byte!(21),
|
||||||
TyClosure(d, _) => {
|
TyClosure(d, _) => {
|
||||||
byte!(22);
|
byte!(22);
|
||||||
|
@ -632,7 +632,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
TyClosure(..) => {
|
TyClosure(..) => {
|
||||||
// this check is run on type definitions, so we don't expect
|
// this check is run on type definitions, so we don't expect
|
||||||
// to see closure types
|
// 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,
|
_ => Representability::Representable,
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ use rustc::middle::mem_categorization as mc;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::{Span, DUMMY_SP};
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
#[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 {
|
let tuple_idx = match *origin_field_name {
|
||||||
mc::PositionalField(tuple_idx) => tuple_idx,
|
mc::PositionalField(tuple_idx) => tuple_idx,
|
||||||
mc::NamedField(_) =>
|
mc::NamedField(_) =>
|
||||||
panic!("tuple type {:?} should not have named fields.",
|
bug!("tuple type {:?} should not have named fields.",
|
||||||
parent_ty),
|
parent_ty),
|
||||||
};
|
};
|
||||||
let tuple_len = v.len();
|
let tuple_len = v.len();
|
||||||
for i in 0..tuple_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 => {
|
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));
|
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, _) =>
|
LpDowncast(ref base_lp, _) =>
|
||||||
move_data.add_variant_match(
|
move_data.add_variant_match(
|
||||||
tcx, lp.clone(), move_pat.id, base_lp.clone(), mode),
|
tcx, lp.clone(), move_pat.id, base_lp.clone(), mode),
|
||||||
_ => panic!("should only call gather_match_variant \
|
_ => bug!("should only call gather_match_variant \
|
||||||
for cat_downcast cmt"),
|
for cat_downcast cmt"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -378,10 +378,10 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
|
||||||
ty::ReEarlyBound(..) |
|
ty::ReEarlyBound(..) |
|
||||||
ty::ReVar(..) |
|
ty::ReVar(..) |
|
||||||
ty::ReSkolemized(..) => {
|
ty::ReSkolemized(..) => {
|
||||||
self.tcx().sess.span_bug(
|
span_bug!(
|
||||||
cmt.span,
|
cmt.span,
|
||||||
&format!("invalid borrow lifetime: {:?}",
|
"invalid borrow lifetime: {:?}",
|
||||||
loan_region));
|
loan_region);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
debug!("loan_scope = {:?}", loan_scope);
|
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",
|
a non-copy fixed-size array",
|
||||||
b.ty)
|
b.ty)
|
||||||
} else {
|
} else {
|
||||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||||
unreachable!();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,14 +149,12 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||||
b.ty)
|
b.ty)
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||||
unreachable!();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||||
unreachable!();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -569,7 +569,7 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &TyCtxt<'tcx>) -> MoveData<'tcx> {
|
||||||
Rvalue::InlineAsm { .. } => {}
|
Rvalue::InlineAsm { .. } => {}
|
||||||
|
|
||||||
Rvalue::Slice {..} => {
|
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
|
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)
|
(self.tcx.expr_ty_adjusted(&expr), expr.span)
|
||||||
}
|
}
|
||||||
r => {
|
r => {
|
||||||
self.tcx.sess.bug(&format!("MoveExpr({}) maps to \
|
bug!("MoveExpr({}) maps to {:?}, not Expr",
|
||||||
{:?}, not Expr",
|
the_move.id,
|
||||||
the_move.id,
|
r)
|
||||||
r))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let (suggestion, _) =
|
let (suggestion, _) =
|
||||||
|
@ -766,10 +765,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
(self.tcx.expr_ty_adjusted(&expr), expr.span)
|
(self.tcx.expr_ty_adjusted(&expr), expr.span)
|
||||||
}
|
}
|
||||||
r => {
|
r => {
|
||||||
self.tcx.sess.bug(&format!("Captured({}) maps to \
|
bug!("Captured({}) maps to {:?}, not Expr",
|
||||||
{:?}, not Expr",
|
the_move.id,
|
||||||
the_move.id,
|
r)
|
||||||
r))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let (suggestion, help) =
|
let (suggestion, help) =
|
||||||
|
@ -852,10 +850,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
self.tcx.sess.span_err_with_code(s, msg, code);
|
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 {
|
pub fn bckerr_to_string(&self, err: &BckError<'tcx>) -> String {
|
||||||
match err.code {
|
match err.code {
|
||||||
err_mutbl => {
|
err_mutbl => {
|
||||||
|
@ -895,7 +889,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
format!("cannot borrow {} as mutable", descr)
|
format!("cannot borrow {} as mutable", descr)
|
||||||
}
|
}
|
||||||
BorrowViolation(euv::ClosureInvocation) => {
|
BorrowViolation(euv::ClosureInvocation) => {
|
||||||
self.tcx.sess.span_bug(err.span,
|
span_bug!(err.span,
|
||||||
"err_mutbl with a closure invocation");
|
"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.
|
// We need to determine which is the case here.
|
||||||
let kind = match err.cmt.upvar().unwrap().cat {
|
let kind = match err.cmt.upvar().unwrap().cat {
|
||||||
Categorization::Upvar(mc::Upvar { kind, .. }) => kind,
|
Categorization::Upvar(mc::Upvar { kind, .. }) => kind,
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
if kind == ty::ClosureKind::Fn {
|
if kind == ty::ClosureKind::Fn {
|
||||||
db.span_help(
|
db.span_help(
|
||||||
|
|
|
@ -515,7 +515,7 @@ impl<'tcx> MoveData<'tcx> {
|
||||||
assignment_index);
|
assignment_index);
|
||||||
}
|
}
|
||||||
LpExtend(..) => {
|
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`
|
// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
|
||||||
// refers to the borrowck-specific graphviz adapter traits.
|
// refers to the borrowck-specific graphviz adapter traits.
|
||||||
extern crate graphviz as dot;
|
extern crate graphviz as dot;
|
||||||
|
#[macro_use]
|
||||||
extern crate rustc;
|
extern crate rustc;
|
||||||
extern crate rustc_front;
|
extern crate rustc_front;
|
||||||
extern crate rustc_mir;
|
extern crate rustc_mir;
|
||||||
|
|
|
@ -339,7 +339,7 @@ fn check_arms(cx: &MatchCheckCtxt,
|
||||||
// `Some(<head>)` and `None`. It's impossible to have an unreachable
|
// `Some(<head>)` and `None`. It's impossible to have an unreachable
|
||||||
// pattern
|
// pattern
|
||||||
// (see libsyntax/ext/expand.rs for the full expansion of a for loop)
|
// (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 => {
|
hir::MatchSource::Normal => {
|
||||||
|
@ -347,12 +347,12 @@ fn check_arms(cx: &MatchCheckCtxt,
|
||||||
},
|
},
|
||||||
|
|
||||||
hir::MatchSource::TryDesugar => {
|
hir::MatchSource::TryDesugar => {
|
||||||
cx.tcx.sess.span_bug(pat.span, "unreachable try pattern")
|
span_bug!(pat.span, "unreachable try pattern")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Useful => (),
|
Useful => (),
|
||||||
UsefulWithWitness(_) => unreachable!()
|
UsefulWithWitness(_) => bug!()
|
||||||
}
|
}
|
||||||
if guard.is_none() {
|
if guard.is_none() {
|
||||||
let Matrix(mut rows) = seen;
|
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 {
|
let witness = match witnesses[0].node {
|
||||||
PatKind::TupleStruct(_, Some(ref pats)) => match &pats[..] {
|
PatKind::TupleStruct(_, Some(ref pats)) => match &pats[..] {
|
||||||
[ref pat] => &**pat,
|
[ref pat] => &**pat,
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
span_err!(cx.tcx.sess, sp, E0297,
|
span_err!(cx.tcx.sess, sp, E0297,
|
||||||
"refutable pattern in `for` loop binding: \
|
"refutable pattern in `for` loop binding: \
|
||||||
|
@ -399,7 +399,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
|
||||||
}).collect();
|
}).collect();
|
||||||
const LIMIT: usize = 3;
|
const LIMIT: usize = 3;
|
||||||
let joined_patterns = match pattern_strings.len() {
|
let joined_patterns = match pattern_strings.len() {
|
||||||
0 => unreachable!(),
|
0 => bug!(),
|
||||||
1 => format!("`{}`", pattern_strings[0]),
|
1 => format!("`{}`", pattern_strings[0]),
|
||||||
2...LIMIT => {
|
2...LIMIT => {
|
||||||
let (tail, head) = pattern_strings.split_last().unwrap();
|
let (tail, head) = pattern_strings.split_last().unwrap();
|
||||||
|
@ -420,14 +420,14 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
|
||||||
NotUseful => {
|
NotUseful => {
|
||||||
// This is good, wildcard pattern isn't reachable
|
// This is good, wildcard pattern isn't reachable
|
||||||
},
|
},
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_val_to_expr(value: &ConstVal) -> P<hir::Expr> {
|
fn const_val_to_expr(value: &ConstVal) -> P<hir::Expr> {
|
||||||
let node = match value {
|
let node = match value {
|
||||||
&ConstVal::Bool(b) => ast::LitKind::Bool(b),
|
&ConstVal::Bool(b) => ast::LitKind::Bool(b),
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
P(hir::Expr {
|
P(hir::Expr {
|
||||||
id: 0,
|
id: 0,
|
||||||
|
@ -579,14 +579,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
|
||||||
assert_eq!(pats_len, n);
|
assert_eq!(pats_len, n);
|
||||||
PatKind::Vec(pats.collect(), None, hir::HirVec::new())
|
PatKind::Vec(pats.collect(), None, hir::HirVec::new())
|
||||||
},
|
},
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
},
|
},
|
||||||
ty::TySlice(_) => match ctor {
|
ty::TySlice(_) => match ctor {
|
||||||
&Slice(n) => {
|
&Slice(n) => {
|
||||||
assert_eq!(pats_len, n);
|
assert_eq!(pats_len, n);
|
||||||
PatKind::Vec(pats.collect(), None, hir::HirVec::new())
|
PatKind::Vec(pats.collect(), None, hir::HirVec::new())
|
||||||
},
|
},
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
},
|
},
|
||||||
ty::TyStr => PatKind::Wild,
|
ty::TyStr => PatKind::Wild,
|
||||||
|
|
||||||
|
@ -791,17 +791,16 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
|
||||||
PatKind::Struct(..) | PatKind::TupleStruct(..) | PatKind::Path(..) | PatKind::Ident(..) =>
|
PatKind::Struct(..) | PatKind::TupleStruct(..) | PatKind::Path(..) | PatKind::Ident(..) =>
|
||||||
match cx.tcx.def_map.borrow().get(&pat.id).unwrap().full_def() {
|
match cx.tcx.def_map.borrow().get(&pat.id).unwrap().full_def() {
|
||||||
Def::Const(..) | Def::AssociatedConst(..) =>
|
Def::Const(..) | Def::AssociatedConst(..) =>
|
||||||
cx.tcx.sess.span_bug(pat.span, "const pattern should've \
|
span_bug!(pat.span, "const pattern should've \
|
||||||
been rewritten"),
|
been rewritten"),
|
||||||
Def::Struct(..) | Def::TyAlias(..) => vec![Single],
|
Def::Struct(..) | Def::TyAlias(..) => vec![Single],
|
||||||
Def::Variant(_, id) => vec![Variant(id)],
|
Def::Variant(_, id) => vec![Variant(id)],
|
||||||
Def::Local(..) => vec![],
|
Def::Local(..) => vec![],
|
||||||
def => cx.tcx.sess.span_bug(pat.span, &format!("pat_constructors: unexpected \
|
def => span_bug!(pat.span, "pat_constructors: unexpected \
|
||||||
definition {:?}", def)),
|
definition {:?}", def),
|
||||||
},
|
},
|
||||||
PatKind::QPath(..) =>
|
PatKind::QPath(..) =>
|
||||||
cx.tcx.sess.span_bug(pat.span, "const pattern should've \
|
span_bug!(pat.span, "const pattern should've been rewritten"),
|
||||||
been rewritten"),
|
|
||||||
PatKind::Lit(ref expr) =>
|
PatKind::Lit(ref expr) =>
|
||||||
vec!(ConstantValue(eval_const_expr(cx.tcx, &expr))),
|
vec!(ConstantValue(eval_const_expr(cx.tcx, &expr))),
|
||||||
PatKind::Range(ref lo, ref hi) =>
|
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 {
|
ty::TySlice(_) => match *ctor {
|
||||||
Slice(length) => length,
|
Slice(length) => length,
|
||||||
ConstantValue(_) => 0,
|
ConstantValue(_) => 0,
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
},
|
},
|
||||||
ty::TyStr => 0,
|
ty::TyStr => 0,
|
||||||
_ => 1
|
_ => 1
|
||||||
|
@ -856,7 +855,7 @@ fn range_covered_by_constructor(ctor: &Constructor,
|
||||||
ConstantValue(ref value) => (value, value),
|
ConstantValue(ref value) => (value, value),
|
||||||
ConstantRange(ref from, ref to) => (from, to),
|
ConstantRange(ref from, ref to) => (from, to),
|
||||||
Single => return Some(true),
|
Single => return Some(true),
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
let cmp_from = compare_const_vals(c_from, from);
|
let cmp_from = compare_const_vals(c_from, from);
|
||||||
let cmp_to = compare_const_vals(c_to, to);
|
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();
|
let def = cx.tcx.def_map.borrow().get(&pat_id).unwrap().full_def();
|
||||||
match def {
|
match def {
|
||||||
Def::Const(..) | Def::AssociatedConst(..) =>
|
Def::Const(..) | Def::AssociatedConst(..) =>
|
||||||
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
|
span_bug!(pat_span, "const pattern should've \
|
||||||
been rewritten"),
|
been rewritten"),
|
||||||
Def::Variant(_, id) if *constructor != Variant(id) => None,
|
Def::Variant(_, id) if *constructor != Variant(id) => None,
|
||||||
Def::Variant(..) | Def::Struct(..) => Some(Vec::new()),
|
Def::Variant(..) | Def::Struct(..) => Some(Vec::new()),
|
||||||
Def::Local(..) => Some(vec![DUMMY_WILD_PAT; arity]),
|
Def::Local(..) => Some(vec![DUMMY_WILD_PAT; arity]),
|
||||||
_ => cx.tcx.sess.span_bug(pat_span, &format!("specialize: unexpected \
|
_ => span_bug!(pat_span, "specialize: unexpected \
|
||||||
definition {:?}", def)),
|
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();
|
let def = cx.tcx.def_map.borrow().get(&pat_id).unwrap().full_def();
|
||||||
match def {
|
match def {
|
||||||
Def::Const(..) | Def::AssociatedConst(..) =>
|
Def::Const(..) | Def::AssociatedConst(..) =>
|
||||||
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
|
span_bug!(pat_span, "const pattern should've \
|
||||||
been rewritten"),
|
been rewritten"),
|
||||||
Def::Variant(_, id) if *constructor != Variant(id) => None,
|
Def::Variant(_, id) if *constructor != Variant(id) => None,
|
||||||
Def::Variant(..) | Def::Struct(..) => {
|
Def::Variant(..) | Def::Struct(..) => {
|
||||||
Some(match args {
|
Some(match args {
|
||||||
|
@ -917,8 +916,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
||||||
}
|
}
|
||||||
|
|
||||||
PatKind::QPath(_, _) => {
|
PatKind::QPath(_, _) => {
|
||||||
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
|
span_bug!(pat_span, "const pattern should've been rewritten")
|
||||||
been rewritten")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PatKind::Struct(_, ref pattern_fields, _) => {
|
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) {
|
match is_useful(cx, &pats, &[DUMMY_WILD_PAT], ConstructWitness) {
|
||||||
UsefulWithWitness(pats) => Some(refutable(&pats[0])),
|
UsefulWithWitness(pats) => Some(refutable(&pats[0])),
|
||||||
NotUseful => None,
|
NotUseful => None,
|
||||||
Useful => unreachable!()
|
Useful => bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,12 +1117,11 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
|
||||||
PatKind::Ident(hir::BindByRef(_), _, _) => {
|
PatKind::Ident(hir::BindByRef(_), _, _) => {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
p.span,
|
p.span,
|
||||||
&format!("binding pattern {} is not an \
|
"binding pattern {} is not an identifier: {:?}",
|
||||||
identifier: {:?}",
|
p.id,
|
||||||
p.id,
|
p.node);
|
||||||
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())),
|
node: PatKind::Lit(P(expr.clone())),
|
||||||
span: span,
|
span: span,
|
||||||
})),
|
})),
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
let pats = try!(args.iter()
|
let pats = try!(args.iter()
|
||||||
.map(|expr| const_expr_to_pat(tcx, &**expr,
|
.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();
|
let (expr, _ty) = lookup_const_by_id(tcx, def_id, substs).unwrap();
|
||||||
return const_expr_to_pat(tcx, expr, pat_id, span);
|
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 {
|
IntTy::I64 => if n == I64_OVERFLOW {
|
||||||
return Ok(Integral(Isize(Is64(::std::i64::MIN))));
|
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::UnsignedInt(ty)) => ty_hint.checked_or(tcx.mk_mach_uint(ty)),
|
||||||
Some(IntType::SignedInt(ty)) => ty_hint.checked_or(tcx.mk_mach_int(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
|
// 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)?
|
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) => {
|
hir::ExprBlock(ref block) => {
|
||||||
match block.expr {
|
match block.expr {
|
||||||
Some(ref expr) => eval_const_expr_partial(tcx, &expr, ty_hint, fn_args)?,
|
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)?,
|
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_hint = ty_hint.checked_or(tcx.types.usize);
|
||||||
let idx = match eval_const_expr_partial(tcx, idx, idx_hint, fn_args)? {
|
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(Usize(i)) => i.as_u64(tcx.sess.target.uint_type),
|
||||||
Integral(_) => unreachable!(),
|
Integral(_) => bug!(),
|
||||||
_ => signal!(idx, IndexNotInt),
|
_ => signal!(idx, IndexNotInt),
|
||||||
};
|
};
|
||||||
assert_eq!(idx as usize as u64, idx);
|
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);
|
assert_eq!(n as usize as u64, n);
|
||||||
eval_const_expr_partial(tcx, &v[idx as usize], ty_hint, fn_args)?
|
eval_const_expr_partial(tcx, &v[idx as usize], ty_hint, fn_args)?
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
bug!()
|
||||||
},
|
},
|
||||||
|
|
||||||
Repeat(_, n) if idx >= n => signal!(e, IndexOutOfBounds),
|
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(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),
|
_ => signal!(e, IndexedNonVec),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -867,7 +867,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
||||||
signal!(e, TupleIndexOutOfBounds);
|
signal!(e, TupleIndexOutOfBounds);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
bug!()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
signal!(base, ExpectedConstTuple);
|
signal!(base, ExpectedConstTuple);
|
||||||
|
@ -888,7 +888,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
|
||||||
signal!(e, MissingStructField);
|
signal!(e, MissingStructField);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
bug!()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
signal!(base, ExpectedConstStruct);
|
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,
|
ti.span,
|
||||||
"resolve_trait_associated_const: unexpected vtable type")
|
"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());
|
let int_ty = tcx.enum_repr_type(hints.iter().next());
|
||||||
infer(Infer(n), tcx, &int_ty.to_ty(tcx).sty, span).map(Integral)
|
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)) => {
|
LitKind::Int(n, Unsigned(ity)) => {
|
||||||
|
@ -1140,7 +1140,7 @@ fn lit_to_const<'tcx>(lit: &ast::LitKind,
|
||||||
Ok(Float(x))
|
Ok(Float(x))
|
||||||
} else {
|
} else {
|
||||||
// FIXME(#31407) this is only necessary because float parsing is buggy
|
// 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)),
|
LitKind::Bool(b) => Ok(Bool(b)),
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#[macro_use] extern crate syntax;
|
#[macro_use] extern crate syntax;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
extern crate rustc;
|
#[macro_use] extern crate rustc;
|
||||||
extern crate rustc_front;
|
extern crate rustc_front;
|
||||||
extern crate rustc_back;
|
extern crate rustc_back;
|
||||||
extern crate rustc_const_math;
|
extern crate rustc_const_math;
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub enum MethodLateContext {
|
||||||
pub fn method_context(cx: &LateContext, id: ast::NodeId, span: Span) -> MethodLateContext {
|
pub fn method_context(cx: &LateContext, id: ast::NodeId, span: Span) -> MethodLateContext {
|
||||||
let def_id = cx.tcx.map.local_def_id(id);
|
let def_id = cx.tcx.map.local_def_id(id);
|
||||||
match cx.tcx.impl_or_trait_items.borrow().get(&def_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() {
|
Some(item) => match item.container() {
|
||||||
ty::TraitContainer(..) => MethodLateContext::TraitDefaultImpl,
|
ty::TraitContainer(..) => MethodLateContext::TraitDefaultImpl,
|
||||||
ty::ImplContainer(cid) => {
|
ty::ImplContainer(cid) => {
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl LateLintPass for TypeLimits {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => panic!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
ty::TyUint(t) => {
|
ty::TyUint(t) => {
|
||||||
|
@ -195,7 +195,7 @@ impl LateLintPass for TypeLimits {
|
||||||
// _v is u8, within range by definition
|
// _v is u8, within range by definition
|
||||||
ast::LitKind::Byte(_v) => return,
|
ast::LitKind::Byte(_v) => return,
|
||||||
ast::LitKind::Int(v, _) => v,
|
ast::LitKind::Int(v, _) => v,
|
||||||
_ => panic!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
if lit_val < min || lit_val > max {
|
if lit_val < min || lit_val > max {
|
||||||
cx.span_lint(OVERFLOWING_LITERALS, e.span,
|
cx.span_lint(OVERFLOWING_LITERALS, e.span,
|
||||||
|
@ -212,7 +212,7 @@ impl LateLintPass for TypeLimits {
|
||||||
Err(_) => return
|
Err(_) => return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => panic!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
if lit_val < min || lit_val > max {
|
if lit_val < min || lit_val > max {
|
||||||
cx.span_lint(OVERFLOWING_LITERALS, e.span,
|
cx.span_lint(OVERFLOWING_LITERALS, e.span,
|
||||||
|
@ -233,7 +233,7 @@ impl LateLintPass for TypeLimits {
|
||||||
hir::BiGt => v >= min && v < max,
|
hir::BiGt => v >= min && v < max,
|
||||||
hir::BiGe => v > min && v <= max,
|
hir::BiGe => v > min && v <= max,
|
||||||
hir::BiEq | hir::BiNe => 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,
|
ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => v as i64,
|
||||||
_ => return true
|
_ => return true
|
||||||
},
|
},
|
||||||
_ => panic!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
is_valid(norm_binop, lit_val, min, max)
|
is_valid(norm_binop, lit_val, min, max)
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ impl LateLintPass for TypeLimits {
|
||||||
ast::LitKind::Int(v, _) => v,
|
ast::LitKind::Int(v, _) => v,
|
||||||
_ => return true
|
_ => return true
|
||||||
},
|
},
|
||||||
_ => panic!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
is_valid(norm_binop, lit_val, min, max)
|
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::TyParam(..) | ty::TyInfer(..) | ty::TyError |
|
||||||
ty::TyClosure(..) | ty::TyProjection(..) |
|
ty::TyClosure(..) | ty::TyProjection(..) |
|
||||||
ty::TyFnDef(..) => {
|
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,
|
region: this.read_enum_variant_arg(1,
|
||||||
|this| Ok(this.read_region(dcx))).unwrap()
|
|this| Ok(this.read_region(dcx))).unwrap()
|
||||||
}),
|
}),
|
||||||
_ => panic!("bad enum variant for ty::UpvarCapture")
|
_ => bug!("bad enum variant for ty::UpvarCapture")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}).unwrap()
|
}).unwrap()
|
||||||
|
@ -1013,7 +1013,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
||||||
|
|
||||||
adjustment::AdjustDerefRef(auto_deref_ref)
|
adjustment::AdjustDerefRef(auto_deref_ref)
|
||||||
}
|
}
|
||||||
_ => panic!("bad enum variant for adjustment::AutoAdjustment")
|
_ => bug!("bad enum variant for adjustment::AutoAdjustment")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}).unwrap()
|
}).unwrap()
|
||||||
|
@ -1072,7 +1072,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|
||||||
|
|
||||||
adjustment::AutoUnsafe(m)
|
adjustment::AutoUnsafe(m)
|
||||||
}
|
}
|
||||||
_ => panic!("bad enum variant for adjustment::AutoRef")
|
_ => bug!("bad enum variant for adjustment::AutoRef")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}).unwrap()
|
}).unwrap()
|
||||||
|
@ -1140,9 +1140,7 @@ fn decode_side_tables(dcx: &DecodeContext,
|
||||||
let decoded_tag: Option<c::astencode_tag> = c::astencode_tag::from_u32(tag);
|
let decoded_tag: Option<c::astencode_tag> = c::astencode_tag::from_u32(tag);
|
||||||
match decoded_tag {
|
match decoded_tag {
|
||||||
None => {
|
None => {
|
||||||
dcx.tcx.sess.bug(
|
bug!("unknown tag found in side tables: {:x}", tag);
|
||||||
&format!("unknown tag found in side tables: {:x}",
|
|
||||||
tag));
|
|
||||||
}
|
}
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let val_dsr = &mut entry_dsr;
|
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.const_qualif_map.borrow_mut().insert(id, qualif);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
dcx.tcx.sess.bug(
|
bug!("unknown tag found in side tables: {:x}", tag);
|
||||||
&format!("unknown tag found in side tables: {:x}",
|
|
||||||
tag));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1404,6 +1400,6 @@ fn test_simplification() {
|
||||||
assert!(pprust::item_to_string(&item_out) ==
|
assert!(pprust::item_to_string(&item_out) ==
|
||||||
pprust::item_to_string(&item_exp));
|
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::parse;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::errors::FatalError;
|
|
||||||
use syntax::parse::token::InternedString;
|
use syntax::parse::token::InternedString;
|
||||||
use rustc_front::intravisit::Visitor;
|
use rustc_front::intravisit::Visitor;
|
||||||
use rustc_front::hir;
|
use rustc_front::hir;
|
||||||
|
@ -527,7 +526,7 @@ impl<'a> CrateReader<'a> {
|
||||||
load_ctxt.filesearch = self.sess.target_filesearch(PathKind::Crate);
|
load_ctxt.filesearch = self.sess.target_filesearch(PathKind::Crate);
|
||||||
load_ctxt.load_library_crate()
|
load_ctxt.load_library_crate()
|
||||||
}
|
}
|
||||||
None => { load_ctxt.report_load_errs(); unreachable!() },
|
None => { load_ctxt.report_load_errs(); },
|
||||||
};
|
};
|
||||||
|
|
||||||
let dylib = library.dylib.clone();
|
let dylib = library.dylib.clone();
|
||||||
|
@ -573,7 +572,8 @@ impl<'a> CrateReader<'a> {
|
||||||
Ok(body) => body,
|
Ok(body) => body,
|
||||||
Err(mut err) => {
|
Err(mut err) => {
|
||||||
err.emit();
|
err.emit();
|
||||||
panic!(FatalError);
|
self.sess.abort_if_errors();
|
||||||
|
unreachable!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let local_span = mk_sp(lo, p.last_span.hi);
|
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 {
|
fn lookup_item(&self, item_id: DefIndex) -> rbml::Doc {
|
||||||
match self.get_item(item_id) {
|
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
|
Some(d) => d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ fn item_family(item: rbml::Doc) -> Family {
|
||||||
'u' => Struct(VariantKind::Unit),
|
'u' => Struct(VariantKind::Unit),
|
||||||
'g' => PublicField,
|
'g' => PublicField,
|
||||||
'N' => InheritedField,
|
'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 {
|
match reader::doc_as_u8(visibility_doc) as char {
|
||||||
'y' => hir::Public,
|
'y' => hir::Public,
|
||||||
'i' => hir::Inherited,
|
'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 {
|
match reader::doc_as_u8(constness_doc) as char {
|
||||||
'c' => hir::Constness::Const,
|
'c' => hir::Constness::Const,
|
||||||
'n' => hir::Constness::NotConst,
|
'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 {
|
match reader::doc_as_u8(defaultness_doc) as char {
|
||||||
'd' => hir::Defaultness::Default,
|
'd' => hir::Defaultness::Default,
|
||||||
'f' => hir::Defaultness::Final,
|
'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,
|
item_id: DefIndex,
|
||||||
tcx: &TyCtxt<'tcx>) -> ty::AdtDefMaster<'tcx>
|
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) {
|
match family_to_variant_kind(family) {
|
||||||
Some(kind) => kind,
|
Some(kind) => kind,
|
||||||
_ => tcx.sess.bug(&format!("unexpected family: {:?}", family)),
|
_ => bug!("unexpected family: {:?}", family),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn get_enum_variants<'tcx>(intr: &IdentInterner,
|
fn get_enum_variants<'tcx>(intr: &IdentInterner,
|
||||||
cdata: Cmd,
|
cdata: Cmd,
|
||||||
doc: rbml::Doc,
|
doc: rbml::Doc) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
|
||||||
tcx: &TyCtxt<'tcx>) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
|
|
||||||
let mut disr_val = 0;
|
let mut disr_val = 0;
|
||||||
reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| {
|
reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| {
|
||||||
let did = translated_def_id(cdata, p);
|
let did = translated_def_id(cdata, p);
|
||||||
|
@ -411,22 +410,21 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
||||||
ty::VariantDefData {
|
ty::VariantDefData {
|
||||||
did: did,
|
did: did,
|
||||||
name: item_name(intr, item),
|
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),
|
disr_val: ConstInt::Infer(disr),
|
||||||
kind: expect_variant_kind(item_family(item), tcx),
|
kind: expect_variant_kind(item_family(item)),
|
||||||
}
|
}
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
fn get_variant_fields<'tcx>(intr: &IdentInterner,
|
fn get_variant_fields<'tcx>(intr: &IdentInterner,
|
||||||
cdata: Cmd,
|
cdata: Cmd,
|
||||||
doc: rbml::Doc,
|
doc: rbml::Doc) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
|
||||||
tcx: &TyCtxt<'tcx>) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
|
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
reader::tagged_docs(doc, tag_item_field).map(|f| {
|
reader::tagged_docs(doc, tag_item_field).map(|f| {
|
||||||
let ff = item_family(f);
|
let ff = item_family(f);
|
||||||
match ff {
|
match ff {
|
||||||
PublicField | InheritedField => {},
|
PublicField | InheritedField => {},
|
||||||
_ => tcx.sess.bug(&format!("expected field, found {:?}", ff))
|
_ => bug!("expected field, found {:?}", ff)
|
||||||
};
|
};
|
||||||
ty::FieldDefData::new(item_def_id(f, cdata),
|
ty::FieldDefData::new(item_def_id(f, cdata),
|
||||||
item_name(intr, f),
|
item_name(intr, f),
|
||||||
|
@ -442,14 +440,13 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
||||||
fn get_struct_variant<'tcx>(intr: &IdentInterner,
|
fn get_struct_variant<'tcx>(intr: &IdentInterner,
|
||||||
cdata: Cmd,
|
cdata: Cmd,
|
||||||
doc: rbml::Doc,
|
doc: rbml::Doc,
|
||||||
did: DefId,
|
did: DefId) -> ty::VariantDefData<'tcx, 'tcx> {
|
||||||
tcx: &TyCtxt<'tcx>) -> ty::VariantDefData<'tcx, 'tcx> {
|
|
||||||
ty::VariantDefData {
|
ty::VariantDefData {
|
||||||
did: did,
|
did: did,
|
||||||
name: item_name(intr, doc),
|
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),
|
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) {
|
let (kind, variants) = match item_family(doc) {
|
||||||
Enum => {
|
Enum => {
|
||||||
(ty::AdtKind::Enum,
|
(ty::AdtKind::Enum,
|
||||||
get_enum_variants(intr, cdata, doc, tcx))
|
get_enum_variants(intr, cdata, doc))
|
||||||
}
|
}
|
||||||
Struct(..) => {
|
Struct(..) => {
|
||||||
let ctor_did =
|
let ctor_did =
|
||||||
reader::maybe_get_doc(doc, tag_items_data_item_struct_ctor).
|
reader::maybe_get_doc(doc, tag_items_data_item_struct_ctor).
|
||||||
map_or(did, |ctor_doc| translated_def_id(cdata, ctor_doc));
|
map_or(did, |ctor_doc| translated_def_id(cdata, ctor_doc));
|
||||||
(ty::AdtKind::Struct,
|
(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(
|
_ => bug!("get_adt_def called on a non-ADT {:?} - {:?}",
|
||||||
&format!("get_adt_def called on a non-ADT {:?} - {:?}",
|
item_family(doc), did)
|
||||||
item_family(doc), did))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let adt = tcx.intern_adt_def(did, kind, variants);
|
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());
|
assert!(!inputs.has_escaping_regions());
|
||||||
inputs
|
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()) {
|
for (field, &ty) in variant.fields.iter().zip(field_tys.iter()) {
|
||||||
field.fulfill_ty(ty);
|
field.fulfill_ty(ty);
|
||||||
|
@ -915,7 +911,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory {
|
||||||
match ch as char {
|
match ch as char {
|
||||||
'i' => hir::MutImmutable,
|
'i' => hir::MutImmutable,
|
||||||
'm' => hir::MutMutable,
|
'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,
|
ty::ReEmpty,
|
||||||
get_mutability(string.as_bytes()[1]))
|
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('C') | Some('c') => ty::ConstTraitItemId(def_id),
|
||||||
Some('r') | Some('p') => ty::MethodTraitItemId(def_id),
|
Some('r') | Some('p') => ty::MethodTraitItemId(def_id),
|
||||||
Some('t') => ty::TypeTraitItemId(def_id),
|
Some('t') => ty::TypeTraitItemId(def_id),
|
||||||
_ => panic!("unknown impl item sort"),
|
_ => bug!("unknown impl item sort"),
|
||||||
}
|
}
|
||||||
}).collect()
|
}).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 ity = tcx.lookup_item_type(def_id).ty;
|
||||||
let fty = match ity.sty {
|
let fty = match ity.sty {
|
||||||
ty::TyFnDef(_, _, fty) => fty.clone(),
|
ty::TyFnDef(_, _, fty) => fty.clone(),
|
||||||
_ => tcx.sess.bug(&format!(
|
_ => bug!(
|
||||||
"the type {:?} of the method {:?} is not a function?",
|
"the type {:?} of the method {:?} is not a function?",
|
||||||
ity, name))
|
ity, name)
|
||||||
};
|
};
|
||||||
let explicit_self = get_explicit_self(item_doc);
|
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('C') | Some('c') => ty::ConstTraitItemId(def_id),
|
||||||
Some('r') | Some('p') => ty::MethodTraitItemId(def_id),
|
Some('r') | Some('p') => ty::MethodTraitItemId(def_id),
|
||||||
Some('t') => ty::TypeTraitItemId(def_id),
|
Some('t') => ty::TypeTraitItemId(def_id),
|
||||||
_ => panic!("unknown trait item sort"),
|
_ => bug!("unknown trait item sort"),
|
||||||
}
|
}
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
|
@ -1172,7 +1168,7 @@ fn struct_field_family_to_visibility(family: Family) -> hir::Visibility {
|
||||||
match family {
|
match family {
|
||||||
PublicField => hir::Public,
|
PublicField => hir::Public,
|
||||||
InheritedField => hir::Inherited,
|
InheritedField => hir::Inherited,
|
||||||
_ => panic!()
|
_ => bug!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1354,7 +1350,7 @@ pub fn translate_def_id(cdata: Cmd, did: DefId) -> DefId {
|
||||||
index: did.index,
|
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: ast::CrateNum = cnum.parse().unwrap();
|
||||||
let cnum = match cdata.cnum_map.borrow().get(&cnum) {
|
let cnum = match cdata.cnum_map.borrow().get(&cnum) {
|
||||||
Some(&n) => n,
|
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" {
|
result.push((cnum, if link == "d" {
|
||||||
LinkagePreference::RequireDynamic
|
LinkagePreference::RequireDynamic
|
||||||
|
@ -1772,7 +1768,7 @@ pub fn def_key(cdata: Cmd, id: DefIndex) -> hir_map::DefKey {
|
||||||
hir_map::DefKey::decode(&mut decoder).unwrap()
|
hir_map::DefKey::decode(&mut decoder).unwrap()
|
||||||
}
|
}
|
||||||
None => {
|
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,
|
tag_def_key,
|
||||||
item_family(item_doc))
|
item_family(item_doc))
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ fn encode_symbol(ecx: &EncodeContext,
|
||||||
rbml_w.wr_tagged_str(tag_items_data_item_symbol, x);
|
rbml_w.wr_tagged_str(tag_items_data_item_symbol, x);
|
||||||
}
|
}
|
||||||
None => {
|
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 rbml;
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
extern crate rustc;
|
extern crate rustc;
|
||||||
extern crate rustc_back;
|
extern crate rustc_back;
|
||||||
extern crate rustc_front;
|
extern crate rustc_front;
|
||||||
|
|
|
@ -300,16 +300,10 @@ impl<'a> Context<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_library_crate(&mut self) -> Library {
|
pub fn load_library_crate(&mut self) -> Library {
|
||||||
match self.find_library_crate() {
|
self.find_library_crate().unwrap_or_else(|| self.report_load_errs())
|
||||||
Some(t) => t,
|
|
||||||
None => {
|
|
||||||
self.report_load_errs();
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_load_errs(&mut self) {
|
pub fn report_load_errs(&mut self) -> ! {
|
||||||
let add = match self.root {
|
let add = match self.root {
|
||||||
&None => String::new(),
|
&None => String::new(),
|
||||||
&Some(ref r) => format!(" which `{}` depends on",
|
&Some(ref r) => format!(" which `{}` depends on",
|
||||||
|
@ -374,6 +368,7 @@ impl<'a> Context<'a> {
|
||||||
|
|
||||||
err.emit();
|
err.emit();
|
||||||
self.sess.abort_if_errors();
|
self.sess.abort_if_errors();
|
||||||
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_library_crate(&mut self) -> Option<Library> {
|
fn find_library_crate(&mut self) -> Option<Library> {
|
||||||
|
|
|
@ -167,7 +167,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
||||||
ty::BrFresh(id)
|
ty::BrFresh(id)
|
||||||
}
|
}
|
||||||
'e' => ty::BrEnv,
|
'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' => {
|
'e' => {
|
||||||
ty::ReStatic
|
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)
|
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() {
|
match self.next() {
|
||||||
'n' => None,
|
'n' => None,
|
||||||
's' => Some(f(self)),
|
'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,
|
'D' => return tcx.types.i64,
|
||||||
'f' => return tcx.types.f32,
|
'f' => return tcx.types.f32,
|
||||||
'F' => return tcx.types.f64,
|
'F' => return tcx.types.f64,
|
||||||
_ => panic!("parse_ty: bad numeric type")
|
_ => bug!("parse_ty: bad numeric type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'c' => return tcx.types.char,
|
'c' => return tcx.types.char,
|
||||||
|
@ -441,7 +441,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
||||||
'e' => {
|
'e' => {
|
||||||
return tcx.types.err;
|
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() {
|
let variadic = match self.next() {
|
||||||
'V' => true,
|
'V' => true,
|
||||||
'N' => false,
|
'N' => false,
|
||||||
r => panic!(format!("bad variadic: {}", r)),
|
r => bug!("bad variadic: {}", r),
|
||||||
};
|
};
|
||||||
let output = match self.peek() {
|
let output = match self.peek() {
|
||||||
'z' => {
|
'z' => {
|
||||||
|
@ -553,7 +553,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
|
||||||
assert_eq!(self.next(), '|');
|
assert_eq!(self.next(), '|');
|
||||||
ty::Predicate::ObjectSafe(def_id)
|
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()),
|
'R' => bounds.push(self.parse_region()),
|
||||||
'.' => { break; }
|
'.' => { break; }
|
||||||
c => {
|
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();
|
let region = self.parse_region();
|
||||||
ty::ObjectLifetimeDefault::Specific(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; }
|
'.' => { break; }
|
||||||
c => {
|
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;
|
return builtin_bounds;
|
||||||
}
|
}
|
||||||
c => {
|
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; }
|
while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1; }
|
||||||
if colon_idx == len {
|
if colon_idx == len {
|
||||||
error!("didn't find ':' when parsing def id");
|
error!("didn't find ':' when parsing def id");
|
||||||
panic!();
|
bug!();
|
||||||
}
|
}
|
||||||
|
|
||||||
let crate_part = &buf[0..colon_idx];
|
let crate_part = &buf[0..colon_idx];
|
||||||
|
@ -693,14 +693,14 @@ fn parse_defid(buf: &[u8]) -> DefId {
|
||||||
s.parse::<usize>().ok()
|
s.parse::<usize>().ok()
|
||||||
}) {
|
}) {
|
||||||
Some(cn) => cn as ast::CrateNum,
|
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)
|
crate_part)
|
||||||
};
|
};
|
||||||
let def_num = match str::from_utf8(def_part).ok().and_then(|s| {
|
let def_num = match str::from_utf8(def_part).ok().and_then(|s| {
|
||||||
s.parse::<usize>().ok()
|
s.parse::<usize>().ok()
|
||||||
}) {
|
}) {
|
||||||
Some(dn) => dn,
|
Some(dn) => dn,
|
||||||
None => panic!("internal error: parse_defid: id expected, found {:?}",
|
None => bug!("internal error: parse_defid: id expected, found {:?}",
|
||||||
def_part)
|
def_part)
|
||||||
};
|
};
|
||||||
let index = DefIndex::new(def_num);
|
let index = DefIndex::new(def_num);
|
||||||
|
@ -711,6 +711,6 @@ fn parse_unsafety(c: char) -> hir::Unsafety {
|
||||||
match c {
|
match c {
|
||||||
'u' => hir::Unsafety::Unsafe,
|
'u' => hir::Unsafety::Unsafe,
|
||||||
'n' => hir::Unsafety::Normal,
|
'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);
|
enc_bare_fn_ty(w, cx, f);
|
||||||
}
|
}
|
||||||
ty::TyInfer(_) => {
|
ty::TyInfer(_) => {
|
||||||
cx.diag.bug("cannot encode inference variable types");
|
bug!("cannot encode inference variable types");
|
||||||
}
|
}
|
||||||
ty::TyParam(ParamTy {space, idx, name}) => {
|
ty::TyParam(ParamTy {space, idx, name}) => {
|
||||||
write!(w, "p[{}|{}|{}]", idx, space.to_uint(), 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(..) => {
|
ty::ReVar(_) | ty::ReSkolemized(..) => {
|
||||||
// these should not crop up after typeck
|
// 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 } =>
|
ExprKind::Literal { literal } =>
|
||||||
Constant { span: span, ty: ty, literal: literal },
|
Constant { span: span, ty: ty, literal: literal },
|
||||||
_ =>
|
_ =>
|
||||||
this.hir.span_bug(
|
span_bug!(
|
||||||
span,
|
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 {
|
let temp_lifetime = match expr.temp_lifetime {
|
||||||
Some(t) => t,
|
Some(t) => t,
|
||||||
None => {
|
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);
|
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));
|
unpack!(block = self.simplify_candidate(block, &mut candidate));
|
||||||
|
|
||||||
if !candidate.match_pairs.is_empty() {
|
if !candidate.match_pairs.is_empty() {
|
||||||
self.hir.span_bug(candidate.match_pairs[0].pattern.span,
|
span_bug!(candidate.match_pairs[0].pattern.span,
|
||||||
&format!("match pairs {:?} remaining after simplifying \
|
"match pairs {:?} remaining after simplifying \
|
||||||
irrefutable pattern",
|
irrefutable pattern",
|
||||||
candidate.match_pairs));
|
candidate.match_pairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now apply the bindings, which will also declare the variables
|
// 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>) -> ! {
|
fn error_simplifyable<'pat>(&mut self, match_pair: &MatchPair<'pat, 'tcx>) -> ! {
|
||||||
self.hir.span_bug(match_pair.pattern.span,
|
span_bug!(match_pair.pattern.span,
|
||||||
&format!("simplifyable pattern found: {:?}", match_pair.pattern))
|
"simplifyable pattern found: {:?}",
|
||||||
|
match_pair.pattern)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,8 +218,8 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.all(|(index, block)| {
|
.all(|(index, block)| {
|
||||||
if block.terminator.is_none() {
|
if block.terminator.is_none() {
|
||||||
panic!("no terminator on block {:?} in fn {:?}",
|
bug!("no terminator on block {:?} in fn {:?}",
|
||||||
index, fn_id)
|
index, fn_id)
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -306,7 +306,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||||
debug!("exit_scope(extent={:?}, block={:?}, target={:?})", extent, block, target);
|
debug!("exit_scope(extent={:?}, block={:?}, target={:?})", extent, block, target);
|
||||||
let scope_count = 1 + self.scopes.iter().rev().position(|scope| scope.extent == extent)
|
let scope_count = 1 + self.scopes.iter().rev().position(|scope| scope.extent == extent)
|
||||||
.unwrap_or_else(||{
|
.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();
|
let tmp = self.get_unit_temp();
|
||||||
|
@ -345,7 +345,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||||
span: Span,
|
span: Span,
|
||||||
label: Option<CodeExtent>)
|
label: Option<CodeExtent>)
|
||||||
-> &mut LoopScope {
|
-> &mut LoopScope {
|
||||||
let Builder { ref mut loop_scopes, ref mut hir, .. } = *self;
|
let loop_scopes = &mut self.loop_scopes;
|
||||||
match label {
|
match label {
|
||||||
None => {
|
None => {
|
||||||
// no label? return the innermost loop scope
|
// no label? return the innermost loop scope
|
||||||
|
@ -358,7 +358,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||||
.filter(|loop_scope| loop_scope.extent == label)
|
.filter(|loop_scope| loop_scope.extent == label)
|
||||||
.next()
|
.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 {
|
pub fn innermost_scope_id(&self) -> ScopeId {
|
||||||
|
@ -410,8 +410,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||||
scope.invalidate_cache()
|
scope.invalidate_cache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.hir.span_bug(span,
|
span_bug!(span, "extent {:?} not in scope to drop {:?}", extent, lvalue);
|
||||||
&format!("extent {:?} not in scope to drop {:?}", extent, lvalue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Schedule dropping of a not-yet-fully-initialised box.
|
/// Schedule dropping of a not-yet-fully-initialised box.
|
||||||
|
@ -444,8 +443,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||||
scope.invalidate_cache();
|
scope.invalidate_cache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.hir.span_bug(span,
|
span_bug!(span, "extent {:?} not in scope to free {:?}", extent, value);
|
||||||
&format!("extent {:?} not in scope to free {:?}", extent, value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
@ -531,7 +529,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
||||||
let tup_ty = if let ty::TyRef(_, tyandmut) = ref_ty.sty {
|
let tup_ty = if let ty::TyRef(_, tyandmut) = ref_ty.sty {
|
||||||
tyandmut.ty
|
tyandmut.ty
|
||||||
} else {
|
} 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));
|
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 {
|
let tup_ty = if let ty::TyRef(_, tyandmut) = ref_ty.sty {
|
||||||
tyandmut.ty
|
tyandmut.ty
|
||||||
} else {
|
} 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));
|
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 {
|
let sig = match method.ty.sty {
|
||||||
ty::TyFnDef(_, _, fn_ty) => &fn_ty.sig,
|
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(|| {
|
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);
|
assert_eq!(sig.inputs.len(), 2);
|
||||||
|
@ -128,7 +128,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
||||||
hir::ExprAddrOf(mutbl, ref expr) => {
|
hir::ExprAddrOf(mutbl, ref expr) => {
|
||||||
let region = match expr_ty.sty {
|
let region = match expr_ty.sty {
|
||||||
ty::TyRef(r, _) => r,
|
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 {
|
ExprKind::Borrow {
|
||||||
region: *region,
|
region: *region,
|
||||||
|
@ -297,16 +297,18 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ref def => {
|
ref def => {
|
||||||
cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
self.span,
|
self.span,
|
||||||
&format!("unexpected def: {:?}", def));
|
"unexpected def: {:?}",
|
||||||
|
def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
self.span,
|
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 {
|
let (def_id, substs) = match closure_ty.sty {
|
||||||
ty::TyClosure(def_id, ref substs) => (def_id, substs),
|
ty::TyClosure(def_id, ref substs) => (def_id, substs),
|
||||||
_ => {
|
_ => {
|
||||||
cx.tcx.sess.span_bug(self.span,
|
span_bug!(self.span,
|
||||||
&format!("closure expr w/o closure type: {:?}",
|
"closure expr w/o closure type: {:?}",
|
||||||
closure_ty));
|
closure_ty);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let upvars = cx.tcx.with_freevars(self.id, |freevars| {
|
let upvars = cx.tcx.with_freevars(self.id, |freevars| {
|
||||||
|
@ -355,7 +357,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
||||||
span: c.span,
|
span: c.span,
|
||||||
value: match const_eval::eval_const_expr(cx.tcx, c) {
|
value: match const_eval::eval_const_expr(cx.tcx, c) {
|
||||||
ConstVal::Integral(ConstInt::Usize(u)) => u,
|
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, _) =>
|
ty::TyStruct(adt_def, _) =>
|
||||||
adt_def.variants[0].index_of_field_named(name.node),
|
adt_def.variants[0].index_of_field_named(name.node),
|
||||||
ref ty =>
|
ref ty =>
|
||||||
cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
self.span,
|
self.span,
|
||||||
&format!("field of non-struct: {:?}", ty)),
|
"field of non-struct: {:?}",
|
||||||
|
ty),
|
||||||
};
|
};
|
||||||
let index = index.unwrap_or_else(|| {
|
let index = index.unwrap_or_else(|| {
|
||||||
cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
self.span,
|
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) }
|
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 {
|
Some(ty::FnConverging(&ty::TyS {
|
||||||
sty: ty::TyRef(region, mt), ..
|
sty: ty::TyRef(region, mt), ..
|
||||||
})) => (region, mt.mutbl),
|
})) => (region, mt.mutbl),
|
||||||
_ => cx.tcx.sess.span_bug(
|
_ => span_bug!(expr.span, "autoderef returned bad type")
|
||||||
expr.span, "autoderef returned bad type")
|
|
||||||
};
|
};
|
||||||
|
|
||||||
expr = Expr {
|
expr = Expr {
|
||||||
|
@ -651,7 +654,7 @@ fn convert_path_expr<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr)
|
||||||
fields: vec![],
|
fields: vec![],
|
||||||
base: None
|
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 {
|
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
|
// 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
|
base: None
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
ref sty => panic!("unexpected sty: {:?}", sty)
|
ref sty => bug!("unexpected sty: {:?}", sty)
|
||||||
},
|
},
|
||||||
Def::Const(def_id) |
|
Def::Const(def_id) |
|
||||||
Def::AssociatedConst(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 @ Def::Upvar(..) => return convert_var(cx, expr, def),
|
||||||
|
|
||||||
def =>
|
def =>
|
||||||
cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("def `{:?}` not yet implemented", def)),
|
"def `{:?}` not yet implemented",
|
||||||
|
def),
|
||||||
};
|
};
|
||||||
ExprKind::Literal {
|
ExprKind::Literal {
|
||||||
literal: Literal::Item { def_id: def_id, substs: substs }
|
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 {
|
match expr.node {
|
||||||
hir::ExprClosure(_, _, ref body) => body.id,
|
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) {
|
let upvar_capture = match cx.tcx.upvar_capture(upvar_id) {
|
||||||
Some(c) => c,
|
Some(c) => c,
|
||||||
None => {
|
None => {
|
||||||
cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("no upvar_capture for {:?}", upvar_id));
|
"no upvar_capture for {:?}",
|
||||||
|
upvar_id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match upvar_capture {
|
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_::BiNe => BinOp::Ne,
|
||||||
hir::BinOp_::BiGe => BinOp::Ge,
|
hir::BinOp_::BiGe => BinOp::Ge,
|
||||||
hir::BinOp_::BiGt => BinOp::Gt,
|
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()) {
|
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),
|
Some(Def::Label(loop_id)) => cx.tcx.region_maps.node_extent(loop_id),
|
||||||
d => {
|
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::infer::InferCtxt;
|
||||||
use rustc::ty::subst::{Subst, Substs};
|
use rustc::ty::subst::{Subst, Substs};
|
||||||
use rustc::ty::{self, Ty, TyCtxt};
|
use rustc::ty::{self, Ty, TyCtxt};
|
||||||
use syntax::codemap::Span;
|
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
use rustc_front::hir;
|
use rustc_front::hir;
|
||||||
use rustc_const_math::{ConstInt, ConstUsize};
|
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> {
|
pub fn usize_literal(&mut self, value: u64) -> Literal<'tcx> {
|
||||||
match ConstUsize::new(value, self.tcx.sess.target.uint_type) {
|
match ConstUsize::new(value, self.tcx.sess.target.uint_type) {
|
||||||
Ok(val) => Literal::Value { value: ConstVal::Integral(ConstInt::Usize(val))},
|
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 {
|
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)
|
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> {
|
pub fn tcx(&self) -> &'a TyCtxt<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,21 +97,23 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
||||||
Ok(pat) =>
|
Ok(pat) =>
|
||||||
return self.to_pattern(&pat),
|
return self.to_pattern(&pat),
|
||||||
Err(_) =>
|
Err(_) =>
|
||||||
self.cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
pat.span, "illegal constant"),
|
pat.span, "illegal constant"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
pat.span,
|
pat.span,
|
||||||
&format!("cannot eval constant: {:?}", def_id))
|
"cannot eval constant: {:?}",
|
||||||
|
def_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ =>
|
_ =>
|
||||||
self.cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
pat.span,
|
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),
|
self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix),
|
||||||
|
|
||||||
ref sty =>
|
ref sty =>
|
||||||
self.cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
pat.span,
|
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 {
|
if let ty::TyRef(_, mt) = ty.sty {
|
||||||
ty = mt.ty;
|
ty = mt.ty;
|
||||||
} else {
|
} 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 {
|
let adt_def = match pat_ty.sty {
|
||||||
ty::TyStruct(adt_def, _) | ty::TyEnum(adt_def, _) => adt_def,
|
ty::TyStruct(adt_def, _) | ty::TyEnum(adt_def, _) => adt_def,
|
||||||
_ => {
|
_ => {
|
||||||
self.cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
pat.span,
|
pat.span,
|
||||||
"struct pattern not applied to struct or enum");
|
"struct pattern not applied to struct or enum");
|
||||||
}
|
}
|
||||||
|
@ -236,9 +239,10 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
||||||
.map(|field| {
|
.map(|field| {
|
||||||
let index = variant_def.index_of_field_named(field.node.name);
|
let index = variant_def.index_of_field_named(field.node.name);
|
||||||
let index = index.unwrap_or_else(|| {
|
let index = index.unwrap_or_else(|| {
|
||||||
self.cx.tcx.sess.span_bug(
|
span_bug!(
|
||||||
pat.span,
|
pat.span,
|
||||||
&format!("no field with name {:?}", field.node.name));
|
"no field with name {:?}",
|
||||||
|
field.node.name);
|
||||||
});
|
});
|
||||||
FieldPattern {
|
FieldPattern {
|
||||||
field: Field::new(index),
|
field: Field::new(index),
|
||||||
|
@ -251,7 +255,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
PatKind::QPath(..) => {
|
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,
|
span_bug!(pat.span, "inappropriate def for pattern: {:?}", def);
|
||||||
&format!("inappropriate def for pattern: {:?}", def));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
|
||||||
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
extern crate graphviz as dot;
|
extern crate graphviz as dot;
|
||||||
|
#[macro_use]
|
||||||
extern crate rustc;
|
extern crate rustc;
|
||||||
extern crate rustc_data_structures;
|
extern crate rustc_data_structures;
|
||||||
extern crate rustc_front;
|
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) {
|
let fn_sig = match cx.tcx().tables.borrow().liberated_fn_sigs.get(&fn_id) {
|
||||||
Some(f) => f.clone(),
|
Some(f) => f.clone(),
|
||||||
None => {
|
None => {
|
||||||
cx.tcx().sess.span_bug(span,
|
span_bug!(span, "no liberated fn sig for {:?}", fn_id);
|
||||||
&format!("no liberated fn sig for {:?}", fn_id));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,13 @@ impl<'a, 'v> Visitor<'v> for CheckBlock<'a> {
|
||||||
visit::walk_expr(self, e);
|
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,
|
fn visit_fn(&mut self,
|
||||||
_fk: FnKind<'v>,
|
_fk: FnKind<'v>,
|
||||||
_fd: &'v ast::FnDecl,
|
_fd: &'v ast::FnDecl,
|
||||||
_b: &'v ast::Block,
|
_b: &'v ast::Block,
|
||||||
_s: Span,
|
_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) {
|
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::Expr(ref expr, _) => expr.span,
|
||||||
ast::StmtKind::Semi(ref semi, _) => semi.span,
|
ast::StmtKind::Semi(ref semi, _) => semi.span,
|
||||||
ast::StmtKind::Mac(..) => unreachable!(),
|
ast::StmtKind::Mac(..) => bug!(),
|
||||||
};
|
};
|
||||||
span_err!(sess, span, E0016,
|
span_err!(sess, span, E0016,
|
||||||
"blocks in {}s are limited to items and tail expressions", kind);
|
"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::Const => "constant",
|
||||||
Mode::ConstFn => "constant function",
|
Mode::ConstFn => "constant function",
|
||||||
Mode::StaticMut | Mode::Static => "static",
|
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).
|
// The count is checked elsewhere (typeck).
|
||||||
let count = match node_ty.sty {
|
let count = match node_ty.sty {
|
||||||
ty::TyArray(_, n) => n,
|
ty::TyArray(_, n) => n,
|
||||||
_ => unreachable!()
|
_ => bug!()
|
||||||
};
|
};
|
||||||
// [element; 0] is always zero-sized.
|
// [element; 0] is always zero-sized.
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
|
@ -570,7 +570,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
|
||||||
hir::ExprCast(ref from, _) => {
|
hir::ExprCast(ref from, _) => {
|
||||||
debug!("Checking const cast(id={})", from.id);
|
debug!("Checking const cast(id={})", from.id);
|
||||||
match v.tcx.cast_kinds.borrow().get(&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) => {
|
Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
|
||||||
v.add_qualif(ConstQualif::NOT_CONST);
|
v.add_qualif(ConstQualif::NOT_CONST);
|
||||||
if v.mode != Mode::Var {
|
if v.mode != Mode::Var {
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
|
|
||||||
extern crate core;
|
extern crate core;
|
||||||
extern crate rustc;
|
#[macro_use] extern crate rustc;
|
||||||
extern crate rustc_front;
|
extern crate rustc_front;
|
||||||
extern crate rustc_const_eval;
|
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.
|
// borrow fall out of scope, so that we can reborrow farther down.
|
||||||
maybe_expr = (*get_expr).clone();
|
maybe_expr = (*get_expr).clone();
|
||||||
} else {
|
} else {
|
||||||
self.sess.span_bug(variant.span,
|
span_bug!(variant.span,
|
||||||
"`check_static_recursion` attempted to visit \
|
"`check_static_recursion` attempted to visit \
|
||||||
variant with unknown discriminant")
|
variant with unknown discriminant")
|
||||||
}
|
}
|
||||||
// If `maybe_expr` is `None`, that's because no discriminant is
|
// If `maybe_expr` is `None`, that's because no discriminant is
|
||||||
// specified that affects this variant. Thus, no risk of recursion.
|
// 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),
|
self.visit_impl_item(item),
|
||||||
ast_map::NodeForeignItem(_) => {},
|
ast_map::NodeForeignItem(_) => {},
|
||||||
_ => {
|
_ => {
|
||||||
self.sess.span_bug(
|
span_bug!(
|
||||||
e.span,
|
e.span,
|
||||||
&format!("expected item, found {}",
|
"expected item, found {}",
|
||||||
self.ast_map.node_to_string(node_id)));
|
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);
|
let variant = self.ast_map.expect_variant(variant_id);
|
||||||
self.visit_variant(variant, generics, enum_id);
|
self.visit_variant(variant, generics, enum_id);
|
||||||
} else {
|
} else {
|
||||||
self.sess.span_bug(e.span,
|
span_bug!(e.span,
|
||||||
"`check_static_recursion` found \
|
"`check_static_recursion` found \
|
||||||
non-enum in Def::Variant");
|
non-enum in Def::Variant");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
#[macro_use] extern crate syntax;
|
#[macro_use] extern crate syntax;
|
||||||
|
|
||||||
extern crate rustc;
|
#[macro_use] extern crate rustc;
|
||||||
extern crate rustc_front;
|
extern crate rustc_front;
|
||||||
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
|
@ -507,7 +507,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
|
||||||
Def::Label(..) |
|
Def::Label(..) |
|
||||||
Def::SelfTy(..) |
|
Def::SelfTy(..) |
|
||||||
Def::Err => {
|
Def::Err => {
|
||||||
panic!("didn't expect `{:?}`", def);
|
bug!("didn't expect `{:?}`", def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ extern crate arena;
|
||||||
#[no_link]
|
#[no_link]
|
||||||
extern crate rustc_bitflags;
|
extern crate rustc_bitflags;
|
||||||
extern crate rustc_front;
|
extern crate rustc_front;
|
||||||
|
#[macro_use]
|
||||||
extern crate rustc;
|
extern crate rustc;
|
||||||
|
|
||||||
use self::PatternBindingMode::*;
|
use self::PatternBindingMode::*;
|
||||||
|
@ -2375,11 +2376,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
// The below shouldn't happen because all
|
// The below shouldn't happen because all
|
||||||
// qualified paths should be in PatKind::QPath.
|
// qualified paths should be in PatKind::QPath.
|
||||||
TypecheckRequired =>
|
TypecheckRequired =>
|
||||||
self.session.span_bug(path.span,
|
span_bug!(path.span,
|
||||||
"resolve_possibly_assoc_item claimed that a path \
|
"resolve_possibly_assoc_item claimed that a path \
|
||||||
in PatKind::Path or PatKind::TupleStruct \
|
in PatKind::Path or PatKind::TupleStruct \
|
||||||
requires typecheck to resolve, but qualified \
|
requires typecheck to resolve, but qualified \
|
||||||
paths should be PatKind::QPath"),
|
paths should be PatKind::QPath"),
|
||||||
ResolveAttempt(resolution) => resolution,
|
ResolveAttempt(resolution) => resolution,
|
||||||
};
|
};
|
||||||
if let Some(path_res) = resolution {
|
if let Some(path_res) = resolution {
|
||||||
|
@ -2668,7 +2669,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
let mut def = local_def.def;
|
let mut def = local_def.def;
|
||||||
match def {
|
match def {
|
||||||
Def::Upvar(..) => {
|
Def::Upvar(..) => {
|
||||||
self.session.span_bug(span, &format!("unexpected {:?} in bindings", def))
|
span_bug!(span, "unexpected {:?} in bindings", def)
|
||||||
}
|
}
|
||||||
Def::Local(_, node_id) => {
|
Def::Local(_, node_id) => {
|
||||||
for rib in ribs {
|
for rib in ribs {
|
||||||
|
@ -3189,7 +3190,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(_) => {
|
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.push(segm);
|
||||||
paths
|
paths
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if !in_module_is_extern || name_binding.is_public() {
|
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);
|
debug!("(recording def) recording {:?} for {}", resolution, node_id);
|
||||||
if let Some(prev_res) = self.def_map.borrow_mut().insert(node_id, resolution) {
|
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);
|
let span = self.ast_map.opt_span(node_id).unwrap_or(codemap::DUMMY_SP);
|
||||||
self.session.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("path resolved multiple times ({:?} before, {:?} now)",
|
"path resolved multiple times ({:?} before, {:?} now)",
|
||||||
prev_res,
|
prev_res,
|
||||||
resolution));
|
resolution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,17 +20,6 @@ use rustc::ty;
|
||||||
use syntax::ast::{CrateNum, NodeId};
|
use syntax::ast::{CrateNum, NodeId};
|
||||||
use syntax::codemap::Span;
|
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 struct CrateData {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub number: u32,
|
pub number: u32,
|
||||||
|
|
|
@ -51,11 +51,11 @@ use super::span_utils::SpanUtils;
|
||||||
use super::recorder;
|
use super::recorder;
|
||||||
|
|
||||||
macro_rules! down_cast_data {
|
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 {
|
let $id = if let super::Data::$kind(data) = $id {
|
||||||
data
|
data
|
||||||
} else {
|
} 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
|
// looks up anything, not just a type
|
||||||
fn lookup_type_ref(&self, ref_id: NodeId) -> Option<DefId> {
|
fn lookup_type_ref(&self, ref_id: NodeId) -> Option<DefId> {
|
||||||
if !self.tcx.def_map.borrow().contains_key(&ref_id) {
|
if !self.tcx.def_map.borrow().contains_key(&ref_id) {
|
||||||
self.sess.bug(&format!("def_map has no key for {} in lookup_type_ref",
|
bug!("def_map has no key for {} in lookup_type_ref", ref_id);
|
||||||
ref_id));
|
|
||||||
}
|
}
|
||||||
let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def();
|
let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def();
|
||||||
match def {
|
match def {
|
||||||
|
@ -294,9 +293,9 @@ where D: Dump
|
||||||
|
|
||||||
let def_map = self.tcx.def_map.borrow();
|
let def_map = self.tcx.def_map.borrow();
|
||||||
if !def_map.contains_key(&ref_id) {
|
if !def_map.contains_key(&ref_id) {
|
||||||
self.sess.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("def_map has no key for {} in lookup_def_kind",
|
"def_map has no key for {} in lookup_def_kind",
|
||||||
ref_id));
|
ref_id);
|
||||||
}
|
}
|
||||||
let def = def_map.get(&ref_id).unwrap().full_def();
|
let def = def_map.get(&ref_id).unwrap().full_def();
|
||||||
match def {
|
match def {
|
||||||
|
@ -347,8 +346,9 @@ where D: Dump
|
||||||
Def::Method(..) |
|
Def::Method(..) |
|
||||||
Def::PrimTy(_) |
|
Def::PrimTy(_) |
|
||||||
Def::Err => {
|
Def::Err => {
|
||||||
self.sess.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("process_def_kind for unexpected item: {:?}", def));
|
"process_def_kind for unexpected item: {:?}",
|
||||||
|
def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -480,7 +480,7 @@ where D: Dump
|
||||||
ty_params: &ast::Generics,
|
ty_params: &ast::Generics,
|
||||||
body: &ast::Block) {
|
body: &ast::Block) {
|
||||||
if let Some(fn_data) = self.save_ctxt.get_item_data(item) {
|
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) {
|
if !self.span.filter_generated(Some(fn_data.span), item.span) {
|
||||||
self.dumper.function(item.span, fn_data.clone().normalize(&self.tcx));
|
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) {
|
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) {
|
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) {
|
if !self.span.filter_generated(Some(var_data.span), item.span) {
|
||||||
let mut var_data = var_data;
|
let mut var_data = var_data;
|
||||||
var_data.scope = normalize_node_id(&self.tcx, var_data.scope) as u32;
|
var_data.scope = normalize_node_id(&self.tcx, var_data.scope) as u32;
|
||||||
|
@ -578,7 +578,7 @@ where D: Dump
|
||||||
None => return,
|
None => return,
|
||||||
Some(data) => data,
|
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);
|
let normalized = enum_data.clone().normalize(&self.tcx);
|
||||||
if !self.span.filter_generated(Some(normalized.span), item.span) {
|
if !self.span.filter_generated(Some(normalized.span), item.span) {
|
||||||
self.dumper.enum_data(item.span, normalized);
|
self.dumper.enum_data(item.span, normalized);
|
||||||
|
@ -638,7 +638,7 @@ where D: Dump
|
||||||
impl_items: &[ast::ImplItem]) {
|
impl_items: &[ast::ImplItem]) {
|
||||||
let mut has_self_ref = false;
|
let mut has_self_ref = false;
|
||||||
if let Some(impl_data) = self.save_ctxt.get_item_data(item) {
|
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 {
|
if let Some(ref self_ref) = impl_data.self_ref {
|
||||||
has_self_ref = true;
|
has_self_ref = true;
|
||||||
if !self.span.filter_generated(Some(self_ref.span), item.span) {
|
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.
|
// `item` is the module in question, represented as an item.
|
||||||
fn process_mod(&mut self, item: &ast::Item) {
|
fn process_mod(&mut self, item: &ast::Item) {
|
||||||
if let Some(mod_data) = self.save_ctxt.get_item_data(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) {
|
if !self.span.filter_generated(Some(mod_data.span), item.span) {
|
||||||
self.dumper.mod_data(mod_data.normalize(&self.tcx));
|
self.dumper.mod_data(mod_data.normalize(&self.tcx));
|
||||||
}
|
}
|
||||||
|
@ -750,10 +750,9 @@ where D: Dump
|
||||||
let path_data = match path_data {
|
let path_data = match path_data {
|
||||||
Some(pd) => pd,
|
Some(pd) => pd,
|
||||||
None => {
|
None => {
|
||||||
self.tcx.sess.span_bug(path.span,
|
span_bug!(path.span,
|
||||||
&format!("Unexpected def kind while looking up path in \
|
"Unexpected def kind while looking up path in `{}`",
|
||||||
`{}`",
|
self.span.snippet(path.span))
|
||||||
self.span.snippet(path.span)))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -807,8 +806,7 @@ where D: Dump
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.sess.span_bug(path.span,
|
span_bug!(path.span, "Unexpected data: {:?}", path_data);
|
||||||
&format!("Unexpected data: {:?}", path_data));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,7 +842,7 @@ where D: Dump
|
||||||
self.write_sub_paths_truncated(path, false);
|
self.write_sub_paths_truncated(path, false);
|
||||||
|
|
||||||
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
|
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) {
|
if !self.span.filter_generated(Some(struct_lit_data.span), ex.span) {
|
||||||
self.dumper.type_ref(ex.span, struct_lit_data.normalize(&self.tcx));
|
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>>) {
|
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) {
|
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) {
|
if !self.span.filter_generated(Some(mcd.span), ex.span) {
|
||||||
self.dumper.method_call(ex.span, mcd.normalize(&self.tcx));
|
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);
|
self.visit_expr(&sub_ex);
|
||||||
|
|
||||||
if let Some(field_data) = self.save_ctxt.get_expr_data(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) {
|
if !self.span.filter_generated(Some(field_data.span), ex.span) {
|
||||||
self.dumper.variable_ref(ex.span, field_data.normalize(&self.tcx));
|
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(_) => {}
|
ty::TyTuple(_) => {}
|
||||||
_ => self.sess.span_bug(ex.span,
|
_ => span_bug!(ex.span,
|
||||||
&format!("Expected struct or tuple type, found {:?}",
|
"Expected struct or tuple type, found {:?}",
|
||||||
ty)),
|
ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::ExprKind::Closure(_, ref decl, ref body) => {
|
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) {
|
fn visit_mac(&mut self, mac: &ast::Mac) {
|
||||||
// These shouldn't exist in the AST at this point, log a span bug.
|
// 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) {
|
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 {
|
for &(id, ref p, immut, ref_kind) in &collector.collected_paths {
|
||||||
let def_map = self.tcx.def_map.borrow();
|
let def_map = self.tcx.def_map.borrow();
|
||||||
if !def_map.contains_key(&id) {
|
if !def_map.contains_key(&id) {
|
||||||
self.sess.span_bug(p.span,
|
span_bug!(p.span, "def_map has no key for {} in visit_arm", id);
|
||||||
&format!("def_map has no key for {} in visit_arm", id));
|
|
||||||
}
|
}
|
||||||
let def = def_map.get(&id).unwrap().full_def();
|
let def = def_map.get(&id).unwrap().full_def();
|
||||||
match def {
|
match def {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(staged_api)]
|
#![feature(staged_api)]
|
||||||
|
|
||||||
extern crate rustc;
|
#[macro_use] extern crate rustc;
|
||||||
extern crate rustc_front;
|
extern crate rustc_front;
|
||||||
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
@ -47,7 +47,6 @@ use syntax::visit::{self, Visitor};
|
||||||
use syntax::print::pprust::ty_to_string;
|
use syntax::print::pprust::ty_to_string;
|
||||||
|
|
||||||
mod csv_dumper;
|
mod csv_dumper;
|
||||||
#[macro_use]
|
|
||||||
mod data;
|
mod data;
|
||||||
mod dump;
|
mod dump;
|
||||||
mod dump_visitor;
|
mod dump_visitor;
|
||||||
|
@ -240,7 +239,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// FIXME
|
// FIXME
|
||||||
unimplemented!();
|
bug!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,21 +291,19 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx.sess.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("Container {:?} for method {} not \
|
"Container {:?} for method {} not an impl?",
|
||||||
an impl?",
|
impl_id,
|
||||||
impl_id,
|
id);
|
||||||
id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r => {
|
r => {
|
||||||
self.tcx.sess.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("Container {:?} for method {} is not a node \
|
"Container {:?} for method {} is not a node item {:?}",
|
||||||
item {:?}",
|
impl_id,
|
||||||
impl_id,
|
id,
|
||||||
id,
|
r);
|
||||||
r));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) {
|
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))
|
format!("::{}", self.tcx.item_path_str(def_id))
|
||||||
}
|
}
|
||||||
r => {
|
r => {
|
||||||
self.tcx.sess.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("Could not find container {:?} for \
|
"Could not find container {:?} for \
|
||||||
method {}, got {:?}",
|
method {}, got {:?}",
|
||||||
def_id,
|
def_id,
|
||||||
id,
|
id,
|
||||||
r));
|
r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.tcx.sess.span_bug(span,
|
span_bug!(span, "Could not find container for method {}", id);
|
||||||
&format!("Could not find container for method {}", id));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -443,7 +439,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// FIXME
|
// 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> {
|
pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Data> {
|
||||||
let def_map = self.tcx.def_map.borrow();
|
let def_map = self.tcx.def_map.borrow();
|
||||||
if !def_map.contains_key(&id) {
|
if !def_map.contains_key(&id) {
|
||||||
self.tcx.sess.span_bug(path.span,
|
span_bug!(path.span, "def_map has no key for {} in visit_expr", id);
|
||||||
&format!("def_map has no key for {} in visit_expr", id));
|
|
||||||
}
|
}
|
||||||
let def = def_map.get(&id).unwrap().full_def();
|
let def = def_map.get(&id).unwrap().full_def();
|
||||||
let sub_span = self.span_utils.span_for_last_ident(path.span);
|
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 {
|
pub fn get_data_for_id(&self, _id: &NodeId) -> Data {
|
||||||
// FIXME
|
// FIXME
|
||||||
unimplemented!();
|
bug!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lookup_ref_id(&self, ref_id: NodeId) -> Option<DefId> {
|
fn lookup_ref_id(&self, ref_id: NodeId) -> Option<DefId> {
|
||||||
if !self.tcx.def_map.borrow().contains_key(&ref_id) {
|
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",
|
bug!("def_map has no key for {} in lookup_type_ref", ref_id);
|
||||||
ref_id));
|
|
||||||
}
|
}
|
||||||
let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def();
|
let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def();
|
||||||
match def {
|
match def {
|
||||||
|
|
|
@ -223,12 +223,12 @@ impl<'a> SpanUtils<'a> {
|
||||||
}
|
}
|
||||||
if bracket_count != 0 {
|
if bracket_count != 0 {
|
||||||
let loc = self.sess.codemap().lookup_char_pos(span.lo);
|
let loc = self.sess.codemap().lookup_char_pos(span.lo);
|
||||||
self.sess.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("Mis-counted brackets when breaking path? Parsing '{}' \
|
"Mis-counted brackets when breaking path? Parsing '{}' \
|
||||||
in {}, line {}",
|
in {}, line {}",
|
||||||
self.snippet(span),
|
self.snippet(span),
|
||||||
loc.file.name,
|
loc.file.name,
|
||||||
loc.line));
|
loc.line);
|
||||||
}
|
}
|
||||||
if result.is_none() && prev.tok.is_ident() && bracket_count == 0 {
|
if result.is_none() && prev.tok.is_ident() && bracket_count == 0 {
|
||||||
return self.make_sub_span(span, Some(prev.sp));
|
return self.make_sub_span(span, Some(prev.sp));
|
||||||
|
@ -256,12 +256,12 @@ impl<'a> SpanUtils<'a> {
|
||||||
return vec!();
|
return vec!();
|
||||||
}
|
}
|
||||||
let loc = self.sess.codemap().lookup_char_pos(span.lo);
|
let loc = self.sess.codemap().lookup_char_pos(span.lo);
|
||||||
self.sess.span_bug(span,
|
span_bug!(span,
|
||||||
&format!("Mis-counted brackets when breaking path? \
|
"Mis-counted brackets when breaking path? \
|
||||||
Parsing '{}' in {}, line {}",
|
Parsing '{}' in {}, line {}",
|
||||||
self.snippet(span),
|
self.snippet(span),
|
||||||
loc.file.name,
|
loc.file.name,
|
||||||
loc.line));
|
loc.line);
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ impl<'a> SpanUtils<'a> {
|
||||||
loc.line);
|
loc.line);
|
||||||
self.err_count.set(self.err_count.get() + 1);
|
self.err_count.set(self.err_count.get() + 1);
|
||||||
if self.err_count.get() > 1000 {
|
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 {
|
fn eq(self, other: ConstantExpr<'a>, tcx: &TyCtxt) -> bool {
|
||||||
match compare_lit_exprs(tcx, self.0, other.0) {
|
match compare_lit_exprs(tcx, self.0, other.0) {
|
||||||
Some(result) => result == Ordering::Equal,
|
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) {
|
fn handle_fail(&self, bcx: Block) {
|
||||||
match *self {
|
match *self {
|
||||||
Infallible =>
|
Infallible =>
|
||||||
panic!("attempted to panic in a non-panicking panic handler!"),
|
bug!("attempted to panic in a non-panicking panic handler!"),
|
||||||
JumpToBasicBlock(basic_block) =>
|
JumpToBasicBlock(basic_block) =>
|
||||||
Br(bcx, basic_block, DebugLoc::None),
|
Br(bcx, basic_block, DebugLoc::None),
|
||||||
Unreachable =>
|
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)
|
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)",
|
Lvalue::new_with_hint("_match::insert_lllocals (match_input)",
|
||||||
bcx, binding_info.id, hint_kind)
|
bcx, binding_info.id, hint_kind)
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
let datum = Datum::new(llval, binding_info.ty, lvalue);
|
let datum = Datum::new(llval, binding_info.ty, lvalue);
|
||||||
call_lifetime_start(bcx, llbinding);
|
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 = r.bcx;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bcx.sess().bug(
|
bug!(
|
||||||
"in compile_submatch, expected \
|
"in compile_submatch, expected \
|
||||||
opt.trans() to return a SingleResult")
|
opt.trans() to return a SingleResult")
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ impl FnType {
|
||||||
Rust | RustCall => llvm::CCallConv,
|
Rust | RustCall => llvm::CCallConv,
|
||||||
|
|
||||||
// It's the ABI's job to select this, not us.
|
// 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,
|
Stdcall => llvm::X86StdcallCallConv,
|
||||||
Fastcall => llvm::X86FastcallCallConv,
|
Fastcall => llvm::X86FastcallCallConv,
|
||||||
|
@ -241,8 +241,8 @@ impl FnType {
|
||||||
&tupled_arguments[..]
|
&tupled_arguments[..]
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!("argument to function with \"rust-call\" ABI \
|
bug!("argument to function with \"rust-call\" ABI \
|
||||||
is not a tuple");
|
is not a tuple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -302,9 +302,8 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
// non-empty body, explicit discriminants should have
|
// non-empty body, explicit discriminants should have
|
||||||
// been rejected by a checker before this point.
|
// been rejected by a checker before this point.
|
||||||
if !cases.iter().enumerate().all(|(i,c)| c.discr == Disr::from(i)) {
|
if !cases.iter().enumerate().all(|(i,c)| c.discr == Disr::from(i)) {
|
||||||
cx.sess().bug(&format!("non-C-like enum {} with specified \
|
bug!("non-C-like enum {} with specified discriminants",
|
||||||
discriminants",
|
cx.tcx().item_path_str(def.did));
|
||||||
cx.tcx().item_path_str(def.did)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cases.len() == 1 {
|
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))
|
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 {
|
match hint {
|
||||||
attr::ReprInt(span, ity) => {
|
attr::ReprInt(span, ity) => {
|
||||||
if !bounds_usable(cx, ity, bounds) {
|
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;
|
return ity;
|
||||||
}
|
}
|
||||||
|
@ -632,10 +631,10 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
|
||||||
attempts = choose_shortest;
|
attempts = choose_shortest;
|
||||||
},
|
},
|
||||||
attr::ReprPacked => {
|
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 => {
|
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 {
|
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),
|
Type::array(&Type::i64(cx), align_units),
|
||||||
a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4),
|
a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4),
|
||||||
align_units),
|
align_units),
|
||||||
_ => panic!("unsupported enum alignment: {}", align)
|
_ => bug!("unsupported enum alignment: {}", align)
|
||||||
};
|
};
|
||||||
assert_eq!(machine::llalign_of_min(cx, fill_ty), 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
|
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)
|
C_integral(ll_inttype(bcx.ccx(), ity), discr.0, true)
|
||||||
}
|
}
|
||||||
Univariant(..) => {
|
Univariant(..) => {
|
||||||
bcx.ccx().sess().bug("no cases for univariants or structs")
|
bug!("no cases for univariants or structs")
|
||||||
}
|
}
|
||||||
RawNullablePointer { .. } |
|
RawNullablePointer { .. } |
|
||||||
StructWrappedNullablePointer { .. } => {
|
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.
|
// someday), it will need to return a possibly-new bcx as well.
|
||||||
match *r {
|
match *r {
|
||||||
CEnum(..) => {
|
CEnum(..) => {
|
||||||
bcx.ccx().sess().bug("element access in C-like enum")
|
bug!("element access in C-like enum")
|
||||||
}
|
}
|
||||||
Univariant(ref st, _dtor) => {
|
Univariant(ref st, _dtor) => {
|
||||||
assert_eq!(discr, Disr(0));
|
assert_eq!(discr, Disr(0));
|
||||||
|
@ -1279,7 +1278,7 @@ pub fn fold_variants<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||||
|
|
||||||
bcx_next
|
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);
|
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
|
||||||
datum::DatumBlock::new(bcx, expr_datum)
|
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),
|
Univariant(..) => Disr(0),
|
||||||
RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
|
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
|
/// (Not to be confused with `common::const_get_elt`, which operates on
|
||||||
/// raw LLVM-level structs and arrays.)
|
/// raw LLVM-level structs and arrays.)
|
||||||
pub fn const_get_field(ccx: &CrateContext, r: &Repr, val: ValueRef,
|
pub fn const_get_field(r: &Repr, val: ValueRef, _discr: Disr,
|
||||||
_discr: Disr, ix: usize) -> ValueRef {
|
ix: usize) -> ValueRef {
|
||||||
match *r {
|
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),
|
Univariant(..) => const_struct_field(val, ix),
|
||||||
General(..) => const_struct_field(val, ix + 1),
|
General(..) => const_struct_field(val, ix + 1),
|
||||||
RawNullablePointer { .. } => {
|
RawNullablePointer { .. } => {
|
||||||
|
|
|
@ -221,7 +221,7 @@ fn dump_graph(tcx: &TyCtxt) {
|
||||||
// Expect one of: "-> target", "source -> target", or "source ->".
|
// Expect one of: "-> target", "source -> target", or "source ->".
|
||||||
let parts: Vec<_> = string.split("->").collect();
|
let parts: Vec<_> = string.split("->").collect();
|
||||||
if parts.len() > 2 {
|
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 sources = node_set(&query, &parts[0]);
|
||||||
let targets = node_set(&query, &parts[1]);
|
let targets = node_set(&query, &parts[1]);
|
||||||
|
|
|
@ -187,8 +187,8 @@ pub fn link_binary(sess: &Session,
|
||||||
let mut out_filenames = Vec::new();
|
let mut out_filenames = Vec::new();
|
||||||
for &crate_type in sess.crate_types.borrow().iter() {
|
for &crate_type in sess.crate_types.borrow().iter() {
|
||||||
if invalid_output_for_target(sess, crate_type) {
|
if invalid_output_for_target(sess, crate_type) {
|
||||||
sess.bug(&format!("invalid output type `{:?}` for target os `{}`",
|
bug!("invalid output type `{:?}` for target os `{}`",
|
||||||
crate_type, sess.opts.target_triple));
|
crate_type, sess.opts.target_triple);
|
||||||
}
|
}
|
||||||
let out_file = link_binary_output(sess, trans, crate_type, outputs,
|
let out_file = link_binary_output(sess, trans, crate_type, outputs,
|
||||||
crate_name);
|
crate_name);
|
||||||
|
@ -282,7 +282,7 @@ pub fn each_linked_rlib(sess: &Session,
|
||||||
let fmts = fmts.get(&config::CrateTypeExecutable).or_else(|| {
|
let fmts = fmts.get(&config::CrateTypeExecutable).or_else(|| {
|
||||||
fmts.get(&config::CrateTypeStaticlib)
|
fmts.get(&config::CrateTypeStaticlib)
|
||||||
}).unwrap_or_else(|| {
|
}).unwrap_or_else(|| {
|
||||||
sess.bug("could not find formats for rlibs")
|
bug!("could not find formats for rlibs")
|
||||||
});
|
});
|
||||||
for (cnum, path) in crates {
|
for (cnum, path) in crates {
|
||||||
match fmts[cnum as usize - 1] {
|
match fmts[cnum as usize - 1] {
|
||||||
|
@ -895,7 +895,7 @@ fn add_local_native_libraries(cmd: &mut Linker, sess: &Session) {
|
||||||
match kind {
|
match kind {
|
||||||
NativeLibraryKind::NativeUnknown => cmd.link_dylib(l),
|
NativeLibraryKind::NativeUnknown => cmd.link_dylib(l),
|
||||||
NativeLibraryKind::NativeFramework => cmd.link_framework(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::NativeUnknown => cmd.link_dylib(lib),
|
||||||
NativeLibraryKind::NativeFramework => cmd.link_framework(lib),
|
NativeLibraryKind::NativeFramework => cmd.link_framework(lib),
|
||||||
NativeLibraryKind::NativeStatic => {
|
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) {
|
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) {
|
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]) {
|
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
|
// to be a value or type-def or something in there
|
||||||
// *somewhere*
|
// *somewhere*
|
||||||
ty_def_id.index = key.parent.unwrap_or_else(|| {
|
ty_def_id.index = key.parent.unwrap_or_else(|| {
|
||||||
panic!("finding type for {:?}, encountered def-id {:?} with no \
|
bug!("finding type for {:?}, encountered def-id {:?} with no \
|
||||||
parent", def_id, ty_def_id);
|
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) {
|
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
|
.cg
|
||||||
.relocation_model));
|
.relocation_model));
|
||||||
sess.abort_if_errors();
|
sess.abort_if_errors();
|
||||||
unreachable!();
|
bug!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
||||||
.cg
|
.cg
|
||||||
.code_model));
|
.code_model));
|
||||||
sess.abort_if_errors();
|
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