Avoid an ICE and instead let the compiler report a useful error
This commit is contained in:
parent
42dcf70f99
commit
d2ea7e2059
3 changed files with 32 additions and 1 deletions
|
@ -662,7 +662,11 @@ where
|
||||||
match b.kind() {
|
match b.kind() {
|
||||||
ty::ConstKind::Infer(InferConst::Var(_)) if D::forbid_inference_vars() => {
|
ty::ConstKind::Infer(InferConst::Var(_)) if D::forbid_inference_vars() => {
|
||||||
// Forbid inference variables in the RHS.
|
// Forbid inference variables in the RHS.
|
||||||
bug!("unexpected inference var {:?}", b)
|
self.infcx.tcx.sess.delay_span_bug(
|
||||||
|
self.delegate.span(),
|
||||||
|
format!("unexpected inference var {:?}", b,),
|
||||||
|
);
|
||||||
|
Ok(a)
|
||||||
}
|
}
|
||||||
// FIXME(invariance): see the related FIXME above.
|
// FIXME(invariance): see the related FIXME above.
|
||||||
_ => self.infcx.super_combine_consts(self, a, b),
|
_ => self.infcx.super_combine_consts(self, a, b),
|
||||||
|
|
18
src/test/ui/issues/issue-98299.rs
Normal file
18
src/test/ui/issues/issue-98299.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
|
pub fn test_usage(p: ()) {
|
||||||
|
SmallCString::try_from(p).map(|cstr| cstr);
|
||||||
|
//~^ ERROR: type annotations needed
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SmallCString<const N: usize> {}
|
||||||
|
|
||||||
|
impl<const N: usize> TryFrom<()> for SmallCString<N> {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn try_from(path: ()) -> Result<Self, Self::Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
9
src/test/ui/issues/issue-98299.stderr
Normal file
9
src/test/ui/issues/issue-98299.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0282]: type annotations needed
|
||||||
|
--> $DIR/issue-98299.rs:4:5
|
||||||
|
|
|
||||||
|
LL | SmallCString::try_from(p).map(|cstr| cstr);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for enum `Result<SmallCString<{_: usize}>, ()>`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0282`.
|
Loading…
Add table
Add a link
Reference in a new issue