Skip to content

Commit 3f4e5b2

Browse files
committed
Rollup merge of rust-lang#50227 - sinkuu:ice_non_local_trait, r=estebank
Fix ICE with erroneous `impl Trait` in a trait impl Fixes rust-lang#49841.
2 parents d1faefc + 98c2e09 commit 3f4e5b2

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
@@ -732,8 +732,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
732732
if impl_ty.synthetic != trait_ty.synthetic {
733733
let impl_node_id = tcx.hir.as_local_node_id(impl_ty.def_id).unwrap();
734734
let impl_span = tcx.hir.span(impl_node_id);
735-
let trait_node_id = tcx.hir.as_local_node_id(trait_ty.def_id).unwrap();
736-
let trait_span = tcx.hir.span(trait_node_id);
735+
let trait_span = tcx.def_span(trait_ty.def_id);
737736
let mut err = struct_span_err!(tcx.sess,
738737
impl_span,
739738
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)