diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-22 06:56:10 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-22 07:31:20 +0100 |
commit | a973a628ec051ab9483fde7d694bb261bb793178 (patch) | |
tree | 82c5f0e1411e379d0f23fe1180dff523c1c282f3 | |
parent | 7136160b97be8f87f79a4e3c819ab887cf8411aa (diff) |
fix unconvertible type error span
-rw-r--r-- | src/transform.rs | 9 | ||||
-rw-r--r-- | ui-tests/src/bin/unconvertible_type.stderr | 4 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/transform.rs b/src/transform.rs index 69929cc..e8481bb 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -24,10 +24,9 @@ pub enum TransformError { impl AssocTypeConversions<'_> { pub fn parse_type_path(&self, type_: &mut Type) -> Result<TypeTransform, TransformError> { - let assoc_span = match iter_type(type_).filter_map(filter_map_assoc_paths).next() { - Some(path) => path.span(), - None => return Ok(TypeTransform::NoOp), - }; + if !iter_type(type_).any(match_assoc_type) { + return Ok(TypeTransform::NoOp); + } if let Type::Reference(TypeReference { lifetime: None, @@ -144,7 +143,7 @@ impl AssocTypeConversions<'_> { // the type contains an associated type but we // don't know how to deal with it so we abort - Err(TransformError::AssocTypeInUnsupportedType(assoc_span)) + Err(TransformError::AssocTypeInUnsupportedType(type_.span())) } } diff --git a/ui-tests/src/bin/unconvertible_type.stderr b/ui-tests/src/bin/unconvertible_type.stderr index 462b939..03c7f30 100644 --- a/ui-tests/src/bin/unconvertible_type.stderr +++ b/ui-tests/src/bin/unconvertible_type.stderr @@ -1,5 +1,5 @@ error: dynamize does not know how to convert this type - --> src/bin/unconvertible_type.rs:7:31 + --> src/bin/unconvertible_type.rs:7:27 | 7 | fn a(&self) -> Option<Foo<Self::A>>; - | ^^^^ + | ^^^ |