1
Fork 0

Improve spans for RPITIT object-safety errors

This commit is contained in:
Michael Goulet 2022-11-19 02:32:55 +00:00
parent c4165f3a96
commit 9a9d0f40b8
5 changed files with 69 additions and 14 deletions

View file

@ -924,10 +924,13 @@ impl ObjectSafetyViolation {
}
ObjectSafetyViolation::Method(
name,
MethodViolationCode::ReferencesImplTraitInTrait,
MethodViolationCode::ReferencesImplTraitInTrait(_),
_,
) => format!("method `{}` references an `impl Trait` type in its return type", name)
.into(),
ObjectSafetyViolation::Method(name, MethodViolationCode::AsyncFn, _) => {
format!("method `{}` is `async`", name).into()
}
ObjectSafetyViolation::Method(
name,
MethodViolationCode::WhereClauseReferencesSelf,
@ -1035,7 +1038,10 @@ pub enum MethodViolationCode {
ReferencesSelfOutput,
/// e.g., `fn foo(&self) -> impl Sized`
ReferencesImplTraitInTrait,
ReferencesImplTraitInTrait(Span),
/// e.g., `async fn foo(&self)`
AsyncFn,
/// e.g., `fn foo(&self) where Self: Clone`
WhereClauseReferencesSelf,