diff options
| author | kennytm <kennytm@gmail.com> | 2018-04-27 14:16:45 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-04-27 16:23:24 +0800 |
| commit | 3f4e5b28b9d78c6863a93e5b2982defd47dd33c6 (patch) | |
| tree | 3b549dd4a9e37f208d151add264274394c792e97 /src | |
| parent | d1faefcbc3513be81be8445df20501245889e6de (diff) | |
| parent | 98c2e0976d6c4d0d3bd22e477b504f1a6f9b4ffa (diff) | |
| download | rust-3f4e5b28b9d78c6863a93e5b2982defd47dd33c6.tar.gz rust-3f4e5b28b9d78c6863a93e5b2982defd47dd33c6.zip | |
Rollup merge of #50227 - sinkuu:ice_non_local_trait, r=estebank
Fix ICE with erroneous `impl Trait` in a trait impl Fixes #49841.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/compare_method.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/impl-trait/impl-generic-mismatch.rs | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index c9e53fa7674..91264849cad 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -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, diff --git a/src/test/compile-fail/impl-trait/impl-generic-mismatch.rs b/src/test/compile-fail/impl-trait/impl-generic-mismatch.rs index eea7ca20957..d6707f59011 100644 --- a/src/test/compile-fail/impl-trait/impl-generic-mismatch.rs +++ b/src/test/compile-fail/impl-trait/impl-generic-mismatch.rs @@ -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() {} |
