Skip to content

Commit 01b069d

Browse files
authored
Rollup merge of #74703 - tmandry:issue-74047, r=oli-obk
Fix ICE while building MIR with type errors See #74047 (comment) for background. Replacing a binding with `PatKind::Wild` (introduced in #51789 and later refactored in #67439) caused an ICE downstream while building MIR. I noticed that taking this code out no longer triggers the ICEs it was added to prevent. I'm not sure what else changed, or if this change is _correct_, but it does seem to be passing ui tests at least. r? @oli-obk cc @estebank Fixes #74047.
2 parents 2406c93 + 62e75a1 commit 01b069d

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/librustc_mir_build/hair/pattern/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
509509
fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> {
510510
let mut ty = self.typeck_results.node_type(pat.hir_id);
511511

512-
if let ty::Error(_) = ty.kind {
513-
// Avoid ICEs (e.g., #50577 and #50585).
514-
return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) };
515-
}
516-
517512
let kind = match pat.kind {
518513
hir::PatKind::Wild => PatKind::Wild,
519514

src/test/ui/issue-74047.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// edition:2018
2+
3+
use std::convert::{TryFrom, TryInto};
4+
use std::io;
5+
6+
pub struct MyStream;
7+
pub struct OtherStream;
8+
9+
pub async fn connect() -> io::Result<MyStream> {
10+
let stream: MyStream = OtherStream.try_into()?;
11+
Ok(stream)
12+
}
13+
14+
impl TryFrom<OtherStream> for MyStream {}
15+
//~^ ERROR: missing
16+
17+
fn main() {}

src/test/ui/issue-74047.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0046]: not all trait items implemented, missing: `Error`, `try_from`
2+
--> $DIR/issue-74047.rs:14:1
3+
|
4+
LL | impl TryFrom<OtherStream> for MyStream {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Error`, `try_from` in implementation
6+
|
7+
= help: implement the missing item: `type Error = Type;`
8+
= help: implement the missing item: `fn try_from(_: T) -> std::result::Result<Self, <Self as std::convert::TryFrom<T>>::Error> { todo!() }`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)