2023-04-20 09:37:15 -05:00
|
|
|
//@run-rustfix
|
2022-10-14 17:50:23 -05:00
|
|
|
|
2022-11-28 23:20:53 -06:00
|
|
|
#![feature(type_alias_impl_trait)]
|
2020-12-19 08:49:42 -06:00
|
|
|
#![warn(clippy::from_over_into)]
|
2022-10-14 17:50:23 -05:00
|
|
|
#![allow(unused)]
|
2020-12-19 08:49:42 -06:00
|
|
|
|
|
|
|
// this should throw an error
|
|
|
|
struct StringWrapper(String);
|
|
|
|
|
|
|
|
impl Into<StringWrapper> for String {
|
|
|
|
fn into(self) -> StringWrapper {
|
|
|
|
StringWrapper(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-14 17:50:23 -05:00
|
|
|
struct SelfType(String);
|
|
|
|
|
|
|
|
impl Into<SelfType> for String {
|
|
|
|
fn into(self) -> SelfType {
|
|
|
|
SelfType(Self::new())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
struct X;
|
|
|
|
|
|
|
|
impl X {
|
|
|
|
const FOO: &'static str = "a";
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SelfKeywords;
|
|
|
|
|
|
|
|
impl Into<SelfKeywords> for X {
|
|
|
|
fn into(self) -> SelfKeywords {
|
2023-05-03 13:07:02 -05:00
|
|
|
let _ = Self;
|
2022-10-14 17:50:23 -05:00
|
|
|
let _ = Self::FOO;
|
|
|
|
let _: Self = self;
|
|
|
|
|
|
|
|
SelfKeywords
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ExplicitPaths(bool);
|
|
|
|
|
|
|
|
impl core::convert::Into<bool> for crate::ExplicitPaths {
|
|
|
|
fn into(mut self) -> bool {
|
|
|
|
let in_closure = || self.0;
|
|
|
|
|
|
|
|
self.0 = false;
|
|
|
|
self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-19 08:49:42 -06:00
|
|
|
// 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 Into<String> for PathInExpansion {
|
|
|
|
fn into(self) -> String {
|
|
|
|
// non self/Self paths in expansions are fine
|
|
|
|
panic!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-19 06:50:02 -06:00
|
|
|
#[clippy::msrv = "1.40"]
|
2022-10-21 16:35:39 -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-11-19 06:50:02 -06:00
|
|
|
#[clippy::msrv = "1.41"]
|
2022-10-21 16:35:39 -05:00
|
|
|
fn msrv_1_41() {
|
|
|
|
struct FromOverInto<T>(Vec<T>);
|
|
|
|
|
|
|
|
impl<T> Into<FromOverInto<T>> for Vec<T> {
|
|
|
|
fn into(self) -> FromOverInto<T> {
|
|
|
|
FromOverInto(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-28 23:20:53 -06:00
|
|
|
type Opaque = impl Sized;
|
|
|
|
struct IntoOpaque;
|
|
|
|
impl Into<Opaque> for IntoOpaque {
|
|
|
|
fn into(self) -> Opaque {}
|
|
|
|
}
|
|
|
|
|
2020-12-19 08:49:42 -06:00
|
|
|
fn main() {}
|