]> git.lizzy.rs Git - rust.git/commitdiff
lowering: bug! -> panic!
authorMazdak Farrokhzad <twingoow@gmail.com>
Sat, 21 Mar 2020 01:38:48 +0000 (02:38 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Sat, 21 Mar 2020 21:18:57 +0000 (22:18 +0100)
src/librustc_ast_lowering/expr.rs
src/librustc_ast_lowering/item.rs
src/librustc_ast_lowering/lib.rs
src/librustc_ast_lowering/path.rs

index a212f0a71077b32618db04b0f5ca676de90b4089..239dec9e9746bf45e43181ba1a30212976242b84 100644 (file)
@@ -1,6 +1,5 @@
 use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
 
-use rustc::bug;
 use rustc_ast::ast::*;
 use rustc_ast::attr;
 use rustc_ast::ptr::P as AstP;
@@ -757,7 +756,7 @@ fn generator_movability_for_fn(
                 Some(movability)
             }
             Some(hir::GeneratorKind::Async(_)) => {
-                bug!("non-`async` closure body turned `async` during lowering");
+                panic!("non-`async` closure body turned `async` during lowering");
             }
             None => {
                 if movability == Movability::Static {
index bf78d6e4aecf78f764eaad49eeb061102fa96676..e66770a5bee35da598ab0508ecc86b04aeb6c01e 100644 (file)
@@ -2,7 +2,6 @@
 use super::{ImplTraitContext, ImplTraitPosition, ImplTraitTypeIdVisitor};
 use crate::Arena;
 
-use rustc::bug;
 use rustc_ast::ast::*;
 use rustc_ast::attr;
 use rustc_ast::node_id::NodeMap;
@@ -432,7 +431,7 @@ fn lower_item_kind(
                 self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
             ),
             ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
-                bug!("`TyMac` should have been expanded by now")
+                panic!("`TyMac` should have been expanded by now")
             }
         }
 
@@ -784,7 +783,7 @@ fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem<'hir> {
 
                 (generics, kind)
             }
-            AssocItemKind::MacCall(..) => bug!("macro item shouldn't exist at this point"),
+            AssocItemKind::MacCall(..) => panic!("macro item shouldn't exist at this point"),
         };
 
         hir::TraitItem {
@@ -865,7 +864,7 @@ fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem<'hir> {
                 };
                 (generics, kind)
             }
-            AssocItemKind::MacCall(..) => bug!("`TyMac` should have been expanded by now"),
+            AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
         };
 
         hir::ImplItem {
index c541ddb7398cdb36bcf0fbb0dc0dd959e0c8d81c..5cd869f60ab8c9825d564fde30011eccde7ce3ed 100644 (file)
@@ -38,7 +38,6 @@
 
 use rustc::dep_graph::DepGraph;
 use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions};
-use rustc::{bug, span_bug};
 use rustc_ast::ast;
 use rustc_ast::ast::*;
 use rustc_ast::attr;
@@ -675,7 +674,7 @@ fn lower_res(&mut self, res: Res<NodeId>) -> Res {
     fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
         self.resolver.get_partial_res(id).map_or(Res::Err, |pr| {
             if pr.unresolved_segments() != 0 {
-                bug!("path not fully resolved: {:?}", pr);
+                panic!("path not fully resolved: {:?}", pr);
             }
             pr.base_res()
         })
@@ -1343,7 +1342,7 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_, 'hir>) ->
                     }
                 }
             }
-            TyKind::MacCall(_) => bug!("`TyKind::MacCall` should have been expanded by now"),
+            TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
             TyKind::CVarArgs => {
                 self.sess.delay_span_bug(
                     t.span,
@@ -1578,7 +1577,7 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
                         hir::LifetimeName::Param(param_name) => {
                             (param_name, hir::LifetimeParamKind::Explicit)
                         }
-                        _ => bug!("expected `LifetimeName::Param` or `ParamName::Plain`"),
+                        _ => panic!("expected `LifetimeName::Param` or `ParamName::Plain`"),
                     };
 
                     self.output_lifetime_params.push(hir::GenericParam {
@@ -2099,7 +2098,7 @@ fn lower_generic_param(
                     | hir::LifetimeName::Underscore
                     | hir::LifetimeName::Static => hir::ParamName::Plain(lt.name.ident()),
                     hir::LifetimeName::ImplicitObjectLifetimeDefault => {
-                        span_bug!(
+                        self.sess.diagnostic().span_bug(
                             param.ident.span,
                             "object-lifetime-default should not occur here",
                         );
@@ -2166,7 +2165,7 @@ fn lower_trait_ref(
     ) -> hir::TraitRef<'hir> {
         let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) {
             hir::QPath::Resolved(None, path) => path,
-            qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
+            qpath => panic!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
         };
         hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
     }
index b5b0a3089ce0f55054a9667bcf688e4e50bd76f0..44bde42ba11cf0895036ff8086068323e74db1aa 100644 (file)
@@ -1,7 +1,6 @@
 use super::{AnonymousLifetimeMode, ImplTraitContext, LoweringContext, ParamMode};
 use super::{GenericArgsCtor, ParenthesizedGenericArgs};
 
-use rustc::span_bug;
 use rustc_ast::ast::{self, *};
 use rustc_errors::{struct_span_err, Applicability};
 use rustc_hir as hir;
@@ -163,12 +162,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         }
 
         // We should've returned in the for loop above.
-        span_bug!(
+
+        self.sess.diagnostic().span_bug(
             p.span,
-            "lower_qpath: no final extension segment in {}..{}",
-            proj_start,
-            p.segments.len()
-        )
+            &format!(
+                "lower_qpath: no final extension segment in {}..{}",
+                proj_start,
+                p.segments.len()
+            ),
+        );
     }
 
     crate fn lower_path_extra(