Move bail into lint to prevent no-linting, move to unfixable
This commit is contained in:
parent
16f1cf8fd4
commit
b2c85b31bb
@ -80,11 +80,6 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
|
||||
&& cx.tcx.is_diagnostic_item(sym::Into, middle_trait_ref.def_id)
|
||||
&& !matches!(middle_trait_ref.substs.type_at(1).kind(), ty::Alias(ty::Opaque, _))
|
||||
{
|
||||
if !target_ty.find_self_aliases().is_empty() {
|
||||
// It's tricky to expand self-aliases correctly, we'll ignore it to not cause a
|
||||
// bad suggestion/fix.
|
||||
return;
|
||||
}
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
FROM_OVER_INTO,
|
||||
@ -161,6 +156,11 @@ fn convert_to_from(
|
||||
self_ty: &Ty<'_>,
|
||||
impl_item_ref: &ImplItemRef,
|
||||
) -> Option<Vec<(Span, String)>> {
|
||||
if !target_ty.find_self_aliases().is_empty() {
|
||||
// It's tricky to expand self-aliases correctly, we'll ignore it to not cause a
|
||||
// bad suggestion/fix.
|
||||
return None;
|
||||
}
|
||||
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
|
||||
let ImplItemKind::Fn(ref sig, body_id) = impl_item.kind else { return None };
|
||||
let body = cx.tcx.hir().body(body_id);
|
||||
|
@ -88,14 +88,4 @@ impl Into<Opaque> for IntoOpaque {
|
||||
fn into(self) -> Opaque {}
|
||||
}
|
||||
|
||||
pub struct Lval<T>(T);
|
||||
|
||||
pub struct Rval<T>(T);
|
||||
|
||||
impl<T> Into<Rval<Self>> for Lval<T> {
|
||||
fn into(self) -> Rval<Self> {
|
||||
Rval(self)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -88,14 +88,4 @@ impl Into<Opaque> for IntoOpaque {
|
||||
fn into(self) -> Opaque {}
|
||||
}
|
||||
|
||||
pub struct Lval<T>(T);
|
||||
|
||||
pub struct Rval<T>(T);
|
||||
|
||||
impl<T> Into<Rval<Self>> for Lval<T> {
|
||||
fn into(self) -> Rval<Self> {
|
||||
Rval(self)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -32,4 +32,14 @@ fn into(self) -> u8 {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Lval<T>(T);
|
||||
|
||||
pub struct Rval<T>(T);
|
||||
|
||||
impl<T> Into<Rval<Self>> for Lval<T> {
|
||||
fn into(self) -> Rval<Self> {
|
||||
Rval(self)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -25,5 +25,13 @@ LL | impl Into<u8> for ContainsVal {
|
||||
https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence
|
||||
= help: replace the `Into` implementation with `From<ContainsVal>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
|
||||
--> $DIR/from_over_into_unfixable.rs:39:1
|
||||
|
|
||||
LL | impl<T> Into<Rval<Self>> for Lval<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: replace the `Into` implementation with `From<Lval<T>>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user