diff options
| author | Shotaro Yamada <sinkuu@sinkuu.xyz> | 2018-04-23 13:54:09 +0900 |
|---|---|---|
| committer | Shotaro Yamada <sinkuu@sinkuu.xyz> | 2018-04-26 21:56:21 +0900 |
| commit | 98c2e0976d6c4d0d3bd22e477b504f1a6f9b4ffa (patch) | |
| tree | deba8b0da9bbf6ccd10bcb9683f4f7889e1711a7 /src | |
| parent | 81135c9dbc92dc78df747d5096ff07d867ef3b02 (diff) | |
| download | rust-98c2e0976d6c4d0d3bd22e477b504f1a6f9b4ffa.tar.gz rust-98c2e0976d6c4d0d3bd22e477b504f1a6f9b4ffa.zip | |
Do not ICE on generics mismatch with non-local traits
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 e1e3dea9a2a..2003e0cc3d2 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -730,8 +730,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() {} |
