about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2021-04-05 00:09:13 -0400
committerJason Newcomb <jsnewcomb@pm.me>2021-04-05 00:09:13 -0400
commita00de90cebedbf24e0cb75ca347f1752335aedca (patch)
tree3aa74be6f65bfacc318d4c1931211423127f696d
parenta15d987c8f9c0c9e911f112d21d55e36da3df370 (diff)
downloadrust-a00de90cebedbf24e0cb75ca347f1752335aedca.tar.gz
rust-a00de90cebedbf24e0cb75ca347f1752335aedca.zip
Fix ICE in `missing_panics_doc`
-rw-r--r--clippy_lints/src/doc.rs5
-rw-r--r--tests/ui/doc.rs21
2 files changed, 23 insertions, 3 deletions
diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs
index 69800f9d331..69d47850091 100644
--- a/clippy_lints/src/doc.rs
+++ b/clippy_lints/src/doc.rs
@@ -11,7 +11,7 @@ use rustc_errors::emitter::EmitterWriter;
 use rustc_errors::Handler;
 use rustc_hir as hir;
 use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
-use rustc_hir::{Expr, ExprKind, QPath};
+use rustc_hir::{AnonConst, Expr, ExprKind, QPath};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::hir::map::Map;
 use rustc_middle::lint::in_external_macro;
@@ -735,6 +735,9 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
         intravisit::walk_expr(self, expr);
     }
 
+    // Panics in const blocks will cause compilation to fail.
+    fn visit_anon_const(&mut self, _: &'tcx AnonConst) {}
+
     fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
         NestedVisitorMap::OnlyBodies(self.cx.tcx.hir())
     }
diff --git a/tests/ui/doc.rs b/tests/ui/doc.rs
index d2c666bd290..c946a047f1b 100644
--- a/tests/ui/doc.rs
+++ b/tests/ui/doc.rs
@@ -1,8 +1,8 @@
 //! This file tests for the `DOC_MARKDOWN` lint.
 
-#![allow(dead_code)]
+#![allow(dead_code, incomplete_features)]
 #![warn(clippy::doc_markdown)]
-#![feature(custom_inner_attributes)]
+#![feature(custom_inner_attributes, const_generics, const_evaluatable_checked, const_option)]
 #![rustfmt::skip]
 
 /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
@@ -202,3 +202,20 @@ fn issue_2343() {}
 /// This should not cause an ICE:
 /// __|_ _|__||_|
 fn pulldown_cmark_crash() {}
+
+// issue #7033 - const_evaluatable_checked ICE
+struct S<T, const N: usize>
+where [(); N.checked_next_power_of_two().unwrap()]: {
+    arr: [T; N.checked_next_power_of_two().unwrap()],
+    n: usize,
+}
+
+impl<T: Copy + Default, const N: usize> S<T, N>
+where [(); N.checked_next_power_of_two().unwrap()]: {
+    fn new() -> Self {
+        Self {
+            arr: [T::default(); N.checked_next_power_of_two().unwrap()],
+            n: 0,
+        }
+    }
+}