Fix an ICE that I just made worse
This commit is contained in:
parent
a9f3c2209c
commit
4d9451b1d1
3 changed files with 29 additions and 9 deletions
|
@ -1,7 +1,6 @@
|
||||||
use rustc_errors::DelayDm;
|
use rustc_errors::DelayDm;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_index::vec::Idx;
|
use rustc_index::vec::Idx;
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
|
||||||
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
||||||
use rustc_middle::mir::{self, Field};
|
use rustc_middle::mir::{self, Field};
|
||||||
use rustc_middle::thir::{FieldPat, Pat, PatKind};
|
use rustc_middle::thir::{FieldPat, Pat, PatKind};
|
||||||
|
@ -227,13 +226,6 @@ impl<'tcx> ConstToPat<'tcx> {
|
||||||
// using `PartialEq::eq` in this scenario in the past.)
|
// using `PartialEq::eq` in this scenario in the past.)
|
||||||
let partial_eq_trait_id =
|
let partial_eq_trait_id =
|
||||||
self.tcx().require_lang_item(hir::LangItem::PartialEq, Some(self.span));
|
self.tcx().require_lang_item(hir::LangItem::PartialEq, Some(self.span));
|
||||||
let any_ty = self
|
|
||||||
.infcx
|
|
||||||
.next_ty_var(TypeVariableOrigin {
|
|
||||||
kind: TypeVariableOriginKind::MiscVariable,
|
|
||||||
span: self.span,
|
|
||||||
})
|
|
||||||
.into();
|
|
||||||
let obligation: PredicateObligation<'_> = predicate_for_trait_def(
|
let obligation: PredicateObligation<'_> = predicate_for_trait_def(
|
||||||
self.tcx(),
|
self.tcx(),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
|
@ -241,7 +233,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
||||||
partial_eq_trait_id,
|
partial_eq_trait_id,
|
||||||
0,
|
0,
|
||||||
ty,
|
ty,
|
||||||
[any_ty],
|
[ty.into()],
|
||||||
);
|
);
|
||||||
// FIXME: should this call a `predicate_must_hold` variant instead?
|
// FIXME: should this call a `predicate_must_hold` variant instead?
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#![allow(warnings)]
|
||||||
|
|
||||||
|
struct MyType;
|
||||||
|
|
||||||
|
impl PartialEq<usize> for MyType {
|
||||||
|
fn eq(&self, y: &usize) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const CONSTANT: &&MyType = &&MyType;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if let CONSTANT = &&MyType {
|
||||||
|
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||||
|
println!("semantic!");
|
||||||
|
} else {
|
||||||
|
println!("structural!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||||
|
--> $DIR/const-partial_eq-fallback-ice.rs:14:12
|
||||||
|
|
|
||||||
|
LL | if let CONSTANT = &&MyType {
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue