Skip to content

Commit

Permalink
Rollup merge of #74703 - tmandry:issue-74047, r=oli-obk
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JohnTitor authored Jul 24, 2020
2 parents 2406c93 + 62e75a1 commit 01b069d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/librustc_mir_build/hair/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> {
let mut ty = self.typeck_results.node_type(pat.hir_id);

if let ty::Error(_) = ty.kind {
// Avoid ICEs (e.g., #50577 and #50585).
return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) };
}

let kind = match pat.kind {
hir::PatKind::Wild => PatKind::Wild,

Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/issue-74047.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// edition:2018

use std::convert::{TryFrom, TryInto};
use std::io;

pub struct MyStream;
pub struct OtherStream;

pub async fn connect() -> io::Result<MyStream> {
let stream: MyStream = OtherStream.try_into()?;
Ok(stream)
}

impl TryFrom<OtherStream> for MyStream {}
//~^ ERROR: missing

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/issue-74047.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0046]: not all trait items implemented, missing: `Error`, `try_from`
--> $DIR/issue-74047.rs:14:1
|
LL | impl TryFrom<OtherStream> for MyStream {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Error`, `try_from` in implementation
|
= help: implement the missing item: `type Error = Type;`
= help: implement the missing item: `fn try_from(_: T) -> std::result::Result<Self, <Self as std::convert::TryFrom<T>>::Error> { todo!() }`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0046`.

0 comments on commit 01b069d

Please sign in to comment.