]> git.lizzy.rs Git - rust.git/commitdiff
Fixed issue with self: &Box<Self>
authorDuddino <rezziandrea106@gmail.com>
Thu, 16 Apr 2020 12:04:12 +0000 (14:04 +0200)
committerDuddino <rezziandrea106@gmail.com>
Thu, 16 Apr 2020 12:05:57 +0000 (14:05 +0200)
src/librustc_typeck/check/mod.rs
src/test/ui/missing/missing-items/auxiliary/m1.rs
src/test/ui/missing/missing-items/m2.stderr

index 19d3c6b4afd6d1c4df47ff40a9ef4236b03e372a..9bb81c322ab1b9ed9a127a389fdd2df169b9e773 100644 (file)
@@ -2260,13 +2260,19 @@ fn fn_sig_suggestion(
         .map(|(i, ty)| {
             Some(match ty.kind {
                 ty::Param(_) if assoc.fn_has_self_parameter && i == 0 => "self".to_string(),
-                ty::Ref(reg, _ref_ty, mutability) => {
+                ty::Ref(reg, ref_ty, mutability) if i == 0 => {
                     let reg = match &format!("{}", reg)[..] {
                         "'_" | "" => String::new(),
                         reg => format!("{} ", reg),
                     };
-                    if assoc.fn_has_self_parameter && i == 0 {
-                        format!("&{}{}self", reg, mutability.prefix_str())
+                    if assoc.fn_has_self_parameter {
+                        match ref_ty.kind {
+                            ty::Param(param) if param.name == kw::SelfUpper => {
+                                format!("&{}{}self", reg, mutability.prefix_str())
+                            }
+
+                            _ => format!("self: {}", ty),
+                        }
                     } else {
                         format!("_: {:?}", ty)
                     }
index 177506d917637678cf2de02e0b0494dff27fc0a1..fcf52c9e88743093482a5c5365b1cb158638557e 100644 (file)
@@ -5,4 +5,5 @@ pub trait X {
     fn method2(self: Box<Self>, s: String) -> Self::Type;
     fn method3(other: &Self, s: String) -> Self::Type;
     fn method4(&self, other: &Self) -> Self::Type;
+    fn method5(self: &Box<Self>) -> Self::Type;
 }
index 3231836bc88d516d336cac968ef0900ab3a0cca7..64e9530e61348276b9a7bc51ccb76b9d0697bdd4 100644 (file)
@@ -1,8 +1,8 @@
-error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`
+error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5`
   --> $DIR/m2.rs:9:1
    |
 LL | impl m1::X for X {
-   | ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4` in implementation
+   | ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5` in implementation
    |
    = help: implement the missing item: `const CONSTANT: u32 = 42;`
    = help: implement the missing item: `type Type = Type;`
@@ -10,6 +10,7 @@ LL | impl m1::X for X {
    = help: implement the missing item: `fn method2(self: std::boxed::Box<Self>, _: std::string::String) -> <Self as m1::X>::Type { todo!() }`
    = help: implement the missing item: `fn method3(_: &Self, _: std::string::String) -> <Self as m1::X>::Type { todo!() }`
    = help: implement the missing item: `fn method4(&self, _: &Self) -> <Self as m1::X>::Type { todo!() }`
+   = help: implement the missing item: `fn method5(self: &std::boxed::Box<Self>) -> <Self as m1::X>::Type { todo!() }`
 
 error: aborting due to previous error