check that first arg to panic!() in const is &str

This commit is contained in:
Austin Bonander
2021-01-05 13:54:28 -08:00
parent da305a2b00
commit 5a33f531cd
8 changed files with 114 additions and 6 deletions

View File

@@ -360,6 +360,18 @@ impl NonConstOp for Panic {
}
}
/// A call to a `panic()` lang item where the first argument is _not_ a `&str`.
#[derive(Debug)]
pub struct PanicNonStr;
impl NonConstOp for PanicNonStr {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
ccx.tcx.sess.struct_span_err(
span,
"argument to `panic!()` in a const context must have type `&str`",
)
}
}
#[derive(Debug)]
pub struct RawPtrComparison;
impl NonConstOp for RawPtrComparison {