mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 17:18:32 +03:00
The path from a type to itself is Self
This commit is contained in:
@@ -3256,6 +3256,8 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
|
||||
None
|
||||
}
|
||||
})))
|
||||
} else if go_up_by == 0 && path.is_empty() {
|
||||
String::from("Self")
|
||||
} else {
|
||||
join_path_syms(repeat_n(kw::Super, go_up_by).chain(path))
|
||||
}
|
||||
|
||||
@@ -643,3 +643,12 @@ where
|
||||
{
|
||||
maybe.map(|x| visitor(x));
|
||||
}
|
||||
|
||||
trait Issue16360: Sized {
|
||||
fn method(&self);
|
||||
|
||||
fn ice_machine(array: [Self; 1]) {
|
||||
array.iter().for_each(Self::method);
|
||||
//~^ redundant_closure_for_method_calls
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,3 +643,12 @@ async fn issue13892<'a, T, F>(maybe: Option<&'a T>, visitor: F)
|
||||
{
|
||||
maybe.map(|x| visitor(x));
|
||||
}
|
||||
|
||||
trait Issue16360: Sized {
|
||||
fn method(&self);
|
||||
|
||||
fn ice_machine(array: [Self; 1]) {
|
||||
array.iter().for_each(|item| item.method());
|
||||
//~^ redundant_closure_for_method_calls
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -256,5 +256,11 @@ error: redundant closure
|
||||
LL | .map(|n| f(n))
|
||||
| ^^^^^^^^ help: replace the closure with the function itself: `f`
|
||||
|
||||
error: aborting due to 42 previous errors
|
||||
error: redundant closure
|
||||
--> tests/ui/eta.rs:651:31
|
||||
|
|
||||
LL | array.iter().for_each(|item| item.method());
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `Self::method`
|
||||
|
||||
error: aborting due to 43 previous errors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user