2022-12-17 07:12:54 -06:00
|
|
|
#![feature(type_alias_impl_trait)]
|
2022-10-23 08:18:45 -05:00
|
|
|
#![warn(clippy::from_over_into)]
|
|
|
|
#![allow(unused)]
|
|
|
|
|
|
|
|
// this should throw an error
|
|
|
|
struct StringWrapper(String);
|
|
|
|
|
|
|
|
impl From<String> for StringWrapper {
|
|
|
|
fn from(val: String) -> Self {
|
|
|
|
StringWrapper(val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SelfType(String);
|
|
|
|
|
|
|
|
impl From<String> for SelfType {
|
|
|
|
fn from(val: String) -> Self {
|
|
|
|
SelfType(String::new())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
struct X;
|
|
|
|
|
|
|
|
impl X {
|
|
|
|
const FOO: &'static str = "a";
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SelfKeywords;
|
|
|
|
|
|
|
|
impl From<X> for SelfKeywords {
|
|
|
|
fn from(val: X) -> Self {
|
2023-05-05 10:45:49 -05:00
|
|
|
let _ = X;
|
2022-10-23 08:18:45 -05:00
|
|
|
let _ = X::FOO;
|
|
|
|
let _: X = val;
|
|
|
|
|
|
|
|
SelfKeywords
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ExplicitPaths(bool);
|
|
|
|
|
|
|
|
impl core::convert::From<crate::ExplicitPaths> for bool {
|
|
|
|
fn from(mut val: crate::ExplicitPaths) -> Self {
|
|
|
|
let in_closure = || val.0;
|
|
|
|
|
|
|
|
val.0 = false;
|
|
|
|
val.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is fine
|
|
|
|
struct A(String);
|
|
|
|
|
|
|
|
impl From<String> for A {
|
|
|
|
fn from(s: String) -> A {
|
|
|
|
A(s)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-28 16:50:08 -05:00
|
|
|
struct PathInExpansion;
|
|
|
|
|
|
|
|
impl From<PathInExpansion> for String {
|
|
|
|
fn from(val: PathInExpansion) -> Self {
|
|
|
|
// non self/Self paths in expansions are fine
|
|
|
|
panic!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 11:29:38 -06:00
|
|
|
#[clippy::msrv = "1.40"]
|
2022-10-23 08:18:45 -05:00
|
|
|
fn msrv_1_40() {
|
|
|
|
struct FromOverInto<T>(Vec<T>);
|
|
|
|
|
|
|
|
impl<T> Into<FromOverInto<T>> for Vec<T> {
|
|
|
|
fn into(self) -> FromOverInto<T> {
|
|
|
|
FromOverInto(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 11:29:38 -06:00
|
|
|
#[clippy::msrv = "1.41"]
|
2022-10-23 08:18:45 -05:00
|
|
|
fn msrv_1_41() {
|
|
|
|
struct FromOverInto<T>(Vec<T>);
|
|
|
|
|
|
|
|
impl<T> From<Vec<T>> for FromOverInto<T> {
|
|
|
|
fn from(val: Vec<T>) -> Self {
|
|
|
|
FromOverInto(val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|