Skip to content

Commit

Permalink
Rollup merge of rust-lang#50227 - sinkuu:ice_non_local_trait, r=estebank
Browse files Browse the repository at this point in the history
Fix ICE with erroneous `impl Trait` in a trait impl

Fixes rust-lang#49841.
  • Loading branch information
kennytm committed Apr 27, 2018
2 parents d1faefc + 98c2e09 commit 3f4e5b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
if impl_ty.synthetic != trait_ty.synthetic {
let impl_node_id = tcx.hir.as_local_node_id(impl_ty.def_id).unwrap();
let impl_span = tcx.hir.span(impl_node_id);
let trait_node_id = tcx.hir.as_local_node_id(trait_ty.def_id).unwrap();
let trait_span = tcx.hir.span(trait_node_id);
let trait_span = tcx.def_span(trait_ty.def_id);
let mut err = struct_span_err!(tcx.sess,
impl_span,
E0643,
Expand Down
11 changes: 11 additions & 0 deletions src/test/compile-fail/impl-trait/impl-generic-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,15 @@ impl Bar for () {
//~^ Error method `bar` has incompatible signature for trait
}

// With non-local trait (#49841):

use std::hash::{Hash, Hasher};

struct X;

impl Hash for X {
fn hash(&self, hasher: &mut impl Hasher) {}
//~^ Error method `hash` has incompatible signature for trait
}

fn main() {}

0 comments on commit 3f4e5b2

Please sign in to comment.