Skip to content

Commit 214fd33

Browse files
sinkuupietroalbini
authored andcommitted
Do not ICE on generics mismatch with non-local traits
Fixes rust-lang#49841
1 parent 2899344 commit 214fd33

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/librustc_typeck/check/compare_method.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
730730
if impl_ty.synthetic != trait_ty.synthetic {
731731
let impl_node_id = tcx.hir.as_local_node_id(impl_ty.def_id).unwrap();
732732
let impl_span = tcx.hir.span(impl_node_id);
733-
let trait_node_id = tcx.hir.as_local_node_id(trait_ty.def_id).unwrap();
734-
let trait_span = tcx.hir.span(trait_node_id);
733+
let trait_span = tcx.def_span(trait_ty.def_id);
735734
let mut err = struct_span_err!(tcx.sess,
736735
impl_span,
737736
E0643,

src/test/compile-fail/impl-trait/impl-generic-mismatch.rs

+11
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,15 @@ impl Bar for () {
2828
//~^ Error method `bar` has incompatible signature for trait
2929
}
3030

31+
// With non-local trait (#49841):
32+
33+
use std::hash::{Hash, Hasher};
34+
35+
struct X;
36+
37+
impl Hash for X {
38+
fn hash(&self, hasher: &mut impl Hasher) {}
39+
//~^ Error method `hash` has incompatible signature for trait
40+
}
41+
3142
fn main() {}

0 commit comments

Comments
 (0)