about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBryanskiy <ivakin.kir@gmail.com>2024-03-26 18:59:03 +0300
committerBryanskiy <ivakin.kir@gmail.com>2024-03-27 15:51:48 +0300
commit0cd9708de60fb0f92561e0a6ed0a8c5991fd871d (patch)
tree824071f197d56742ec3f8e2d6360a36fd06fdc98
parent10a7aa14fed9b528b74b0f098c4899c37c09a9c7 (diff)
downloadrust-0cd9708de60fb0f92561e0a6ed0a8c5991fd871d.tar.gz
rust-0cd9708de60fb0f92561e0a6ed0a8c5991fd871d.zip
Delegation: fix ICE on wrong instantiation
-rw-r--r--compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs11
-rw-r--r--tests/ui/delegation/bad-resolve.rs10
-rw-r--r--tests/ui/delegation/bad-resolve.stderr37
-rw-r--r--tests/ui/delegation/duplicate-definition-inside-trait-impl.rs2
-rw-r--r--tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr11
-rw-r--r--tests/ui/delegation/explicit-paths-in-traits-pass.rs2
-rw-r--r--tests/ui/delegation/explicit-paths-in-traits-pass.stderr11
-rw-r--r--tests/ui/delegation/explicit-paths-pass.rs13
-rw-r--r--tests/ui/delegation/explicit-paths-pass.stderr11
-rw-r--r--tests/ui/delegation/explicit-paths-signature-pass.rs2
-rw-r--r--tests/ui/delegation/explicit-paths-signature-pass.stderr11
-rw-r--r--tests/ui/delegation/explicit-paths.rs79
-rw-r--r--tests/ui/delegation/explicit-paths.stderr137
-rw-r--r--tests/ui/delegation/not-supported.rs2
-rw-r--r--tests/ui/delegation/not-supported.stderr11
-rw-r--r--tests/ui/delegation/parse.rs2
-rw-r--r--tests/ui/delegation/parse.stderr11
-rw-r--r--tests/ui/delegation/target-expr-pass.rs2
-rw-r--r--tests/ui/delegation/target-expr-pass.stderr11
-rw-r--r--tests/ui/delegation/target-expr.rs6
-rw-r--r--tests/ui/delegation/target-expr.stderr31
21 files changed, 236 insertions, 177 deletions
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
index a83b5b78f9c..8886a78c6ec 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -2212,6 +2212,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
             try_emit("delegation with early bound generics");
         }
 
+        // There is no way to instantiate `Self` param for caller if
+        // 1. callee is a trait method
+        // 2. delegation item isn't an associative item
+        if let DefKind::AssocFn = self.tcx().def_kind(sig_id)
+            && let DefKind::Fn = self.tcx().def_kind(self.item_def_id())
+            && self.tcx().associated_item(sig_id).container
+                == ty::AssocItemContainer::TraitContainer
+        {
+            try_emit("delegation to a trait method from a free function");
+        }
+
         if self.tcx().asyncness(sig_id) == ty::Asyncness::Yes {
             try_emit("delegation to async functions");
         }
diff --git a/tests/ui/delegation/bad-resolve.rs b/tests/ui/delegation/bad-resolve.rs
index df456f94507..d2723dc32e0 100644
--- a/tests/ui/delegation/bad-resolve.rs
+++ b/tests/ui/delegation/bad-resolve.rs
@@ -1,5 +1,5 @@
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 trait Trait {
     const C: u32 = 0;
@@ -34,14 +34,6 @@ impl Trait for S {
 
     reuse foo { &self.0 }
     //~^ ERROR cannot find function `foo` in this scope
-    reuse F::foo { &self.0 }
-    //~^ ERROR cannot find function `foo` in `F`
-    //~| ERROR duplicate definitions with name `foo`
-}
-
-impl S {
-    reuse F::foo { &self.0 }
-    //~^ ERROR cannot find function `foo` in `F`
 }
 
 fn main() {}
diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr
index d5206637310..f669ac3730e 100644
--- a/tests/ui/delegation/bad-resolve.stderr
+++ b/tests/ui/delegation/bad-resolve.stderr
@@ -25,18 +25,6 @@ LL |     reuse <F as Trait>::baz;
    |     |                   help: there is an associated function with a similar name: `bar`
    |     not a member of trait `Trait`
 
-error[E0201]: duplicate definitions with name `foo`:
-  --> $DIR/bad-resolve.rs:37:5
-   |
-LL |     fn foo(&self, x: i32) -> i32 { x }
-   |     ---------------------------------- item in trait
-...
-LL |     reuse foo { &self.0 }
-   |     --------------------- previous definition here
-LL |
-LL |     reuse F::foo { &self.0 }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition
-
 error[E0423]: expected function, found associated constant `Trait::C`
   --> $DIR/bad-resolve.rs:24:11
    |
@@ -66,27 +54,6 @@ error[E0425]: cannot find function `foo` in this scope
 LL |     reuse foo { &self.0 }
    |           ^^^ not found in this scope
 
-error[E0425]: cannot find function `foo` in `F`
-  --> $DIR/bad-resolve.rs:37:14
-   |
-LL |     reuse F::foo { &self.0 }
-   |              ^^^ not found in `F`
-
-error[E0425]: cannot find function `foo` in `F`
-  --> $DIR/bad-resolve.rs:43:14
-   |
-LL |     reuse F::foo { &self.0 }
-   |              ^^^ not found in `F`
-
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/bad-resolve.rs:1:12
-   |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
-   |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
-
 error[E0046]: not all trait items implemented, missing: `Type`
   --> $DIR/bad-resolve.rs:22:1
    |
@@ -96,7 +63,7 @@ LL |     type Type;
 LL | impl Trait for S {
    | ^^^^^^^^^^^^^^^^ missing `Type` in implementation
 
-error: aborting due to 11 previous errors; 1 warning emitted
+error: aborting due to 8 previous errors
 
-Some errors have detailed explanations: E0046, E0201, E0324, E0407, E0423, E0425, E0575, E0576.
+Some errors have detailed explanations: E0046, E0324, E0407, E0423, E0425, E0575, E0576.
 For more information about an error, try `rustc --explain E0046`.
diff --git a/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs b/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs
index bd685b40b2f..9c7afcef3ec 100644
--- a/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs
+++ b/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs
@@ -1,5 +1,5 @@
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 trait Trait {
     fn foo(&self) -> u32 { 0 }
diff --git a/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr b/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr
index a5f9e6ad0bf..a0f157800cb 100644
--- a/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr
+++ b/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr
@@ -9,15 +9,6 @@ LL |     reuse to_reuse::foo { self }
 LL |     reuse Trait::foo;
    |     ^^^^^^^^^^^^^^^^^ duplicate definition
 
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/duplicate-definition-inside-trait-impl.rs:1:12
-   |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
-   |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
-
-error: aborting due to 1 previous error; 1 warning emitted
+error: aborting due to 1 previous error
 
 For more information about this error, try `rustc --explain E0201`.
diff --git a/tests/ui/delegation/explicit-paths-in-traits-pass.rs b/tests/ui/delegation/explicit-paths-in-traits-pass.rs
index 4abcc18b9b2..7d281ad150a 100644
--- a/tests/ui/delegation/explicit-paths-in-traits-pass.rs
+++ b/tests/ui/delegation/explicit-paths-in-traits-pass.rs
@@ -1,7 +1,7 @@
 //@ run-pass
 
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 trait ToReuse {
     fn foo(&self, x: i32) -> i32 { x }
diff --git a/tests/ui/delegation/explicit-paths-in-traits-pass.stderr b/tests/ui/delegation/explicit-paths-in-traits-pass.stderr
deleted file mode 100644
index 8a320b44e63..00000000000
--- a/tests/ui/delegation/explicit-paths-in-traits-pass.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/explicit-paths-in-traits-pass.rs:3:12
-   |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
-   |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/delegation/explicit-paths-pass.rs b/tests/ui/delegation/explicit-paths-pass.rs
index 140605a2bc5..fada793bd11 100644
--- a/tests/ui/delegation/explicit-paths-pass.rs
+++ b/tests/ui/delegation/explicit-paths-pass.rs
@@ -1,7 +1,7 @@
 //@ run-pass
 
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 trait Trait {
     fn bar(&self, x: i32) -> i32 { x }
@@ -10,7 +10,6 @@ trait Trait {
     }
     fn static_method(x: i32) -> i32 { x }
     fn static_method2(x: i32, y: i32) -> i32 { x + y }
-    fn baz<'a>(&self, x: &'a i32) -> &'a i32 { x }
 }
 
 struct F;
@@ -29,11 +28,9 @@ impl Trait for S {
     reuse Trait::description { &self.0 }
     reuse <F as Trait>::static_method;
     reuse <F as Trait>::static_method2 { S::static_method(self) }
-    reuse Trait::baz { &self.0 }
 }
 
 impl S {
-    reuse Trait::baz { &self.0 }
     reuse <F as Trait>::static_method { to_reuse::foo(self) }
 }
 
@@ -49,16 +46,8 @@ fn main() {
     assert_eq!(42, <S as Trait>::static_method(42));
     assert_eq!(21, S::static_method2(10, 10));
 
-    reuse <S as Trait>::static_method;
-    reuse <S as Trait>::static_method2 { static_method(self) }
     #[inline]
     reuse to_reuse::foo;
-    assert_eq!(42, static_method(42));
-    assert_eq!(21, static_method2(10, 10));
     assert_eq!(43, foo(42));
     assert_eq!(15, zero_args());
-
-    let x: i32 = 15;
-    assert_eq!(&x, <S as Trait>::baz(&s, &x));
-    assert_eq!(&x, S::baz(&s, &x));
 }
diff --git a/tests/ui/delegation/explicit-paths-pass.stderr b/tests/ui/delegation/explicit-paths-pass.stderr
deleted file mode 100644
index 6d25fb4a5a5..00000000000
--- a/tests/ui/delegation/explicit-paths-pass.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/explicit-paths-pass.rs:3:12
-   |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
-   |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/delegation/explicit-paths-signature-pass.rs b/tests/ui/delegation/explicit-paths-signature-pass.rs
index b53e5779924..8c16ad92393 100644
--- a/tests/ui/delegation/explicit-paths-signature-pass.rs
+++ b/tests/ui/delegation/explicit-paths-signature-pass.rs
@@ -1,7 +1,7 @@
 //@ run-pass
 
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 mod to_reuse {
     use crate::S;
diff --git a/tests/ui/delegation/explicit-paths-signature-pass.stderr b/tests/ui/delegation/explicit-paths-signature-pass.stderr
deleted file mode 100644
index 6c81a2ea0af..00000000000
--- a/tests/ui/delegation/explicit-paths-signature-pass.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/explicit-paths-signature-pass.rs:3:12
-   |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
-   |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/delegation/explicit-paths.rs b/tests/ui/delegation/explicit-paths.rs
index 1feaaa73f79..a91ca4cb931 100644
--- a/tests/ui/delegation/explicit-paths.rs
+++ b/tests/ui/delegation/explicit-paths.rs
@@ -1,25 +1,84 @@
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 trait Trait {
-    fn bar(&self) -> i32 { 42 }
+    fn foo1(&self, x: i32) -> i32 { x }
+    fn foo2(x: i32) -> i32 { x }
 }
 
 struct F;
 impl Trait for F {}
-
 struct S(F);
 
-impl Trait for S {
-    reuse <F as Trait>::bar;
-    //~^ ERROR mismatched types
+pub mod to_reuse {
+    pub fn foo3() {}
+}
+
+impl F {
+    fn foo4(&self) {}
+}
+
+mod fn_to_other {
+    use super::*;
+
+    reuse Trait::foo1;
+    //~^ ERROR delegation to a trait method from a free function is not supported yet
+    reuse <S as Trait>::foo2;
+    //~^ ERROR delegation to a trait method from a free function is not supported yet
+    reuse to_reuse::foo3;
+    reuse S::foo4;
+    //~^ ERROR cannot find function `foo4` in `S`
+}
+
+mod inherent_impl_assoc_fn_to_other {
+    use crate::*;
+
+    impl S {
+        reuse Trait::foo1 { &self.0 }
+        reuse <S as Trait>::foo2;
+        reuse to_reuse::foo3;
+        reuse F::foo4 { &self.0 }
+        //~^ ERROR cannot find function `foo4` in `F`
+    }
+}
+
+mod trait_impl_assoc_fn_to_other {
+    use crate::*;
+
+    impl Trait for S {
+        reuse Trait::foo1 { &self.0 }
+        reuse <F as Trait>::foo2;
+        reuse to_reuse::foo3;
+        //~^ ERROR method `foo3` is not a member of trait `Trait`
+        reuse F::foo4 { &self.0 }
+        //~^ ERROR method `foo4` is not a member of trait `Trait`
+        //~| ERROR cannot find function `foo4` in `F`
+    }
+}
+
+mod trait_assoc_fn_to_other {
+    use crate::*;
+
+    trait Trait2 : Trait {
+        reuse <F as Trait>::foo1 { self }
+        //~^ ERROR mismatched types
+        reuse <F as Trait>::foo2;
+        reuse to_reuse::foo3;
+        reuse F::foo4 { &F }
+        //~^ ERROR cannot find function `foo4` in `F`
+    }
 }
 
-struct S2(F);
+mod type_mismatch {
+    use crate::*;
 
-impl Trait for S2 {
-    reuse <S2 as Trait>::bar { &self.0 }
-    //~^ ERROR mismatched types
+    struct S2;
+    impl Trait for S {
+    //~^ ERROR conflicting implementations of trait `Trait` for type `S`
+        reuse <S2 as Trait>::foo1;
+        //~^ ERROR mismatched types
+        //~| ERROR the trait bound `S2: Trait` is not satisfied
+    }
 }
 
 fn main() {}
diff --git a/tests/ui/delegation/explicit-paths.stderr b/tests/ui/delegation/explicit-paths.stderr
index 2994b2390de..30891c94c0e 100644
--- a/tests/ui/delegation/explicit-paths.stderr
+++ b/tests/ui/delegation/explicit-paths.stderr
@@ -1,38 +1,129 @@
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/explicit-paths.rs:1:12
+error[E0407]: method `foo3` is not a member of trait `Trait`
+  --> $DIR/explicit-paths.rs:51:9
    |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
+LL |         reuse to_reuse::foo3;
+   |         ^^^^^^^^^^^^^^^^----^
+   |         |               |
+   |         |               help: there is an associated function with a similar name: `foo1`
+   |         not a member of trait `Trait`
+
+error[E0407]: method `foo4` is not a member of trait `Trait`
+  --> $DIR/explicit-paths.rs:53:9
+   |
+LL |         reuse F::foo4 { &self.0 }
+   |         ^^^^^^^^^----^^^^^^^^^^^^
+   |         |        |
+   |         |        help: there is an associated function with a similar name: `foo1`
+   |         not a member of trait `Trait`
+
+error[E0425]: cannot find function `foo4` in `S`
+  --> $DIR/explicit-paths.rs:29:14
+   |
+LL |     reuse S::foo4;
+   |              ^^^^ not found in `S`
+
+error[E0425]: cannot find function `foo4` in `F`
+  --> $DIR/explicit-paths.rs:40:18
+   |
+LL |         reuse F::foo4 { &self.0 }
+   |                  ^^^^ not found in `F`
+   |
+note: function `fn_to_other::foo4` exists but is inaccessible
+  --> $DIR/explicit-paths.rs:29:5
+   |
+LL |     reuse S::foo4;
+   |     ^^^^^^^^^^^^^^ not accessible
+
+error[E0425]: cannot find function `foo4` in `F`
+  --> $DIR/explicit-paths.rs:53:18
+   |
+LL |         reuse F::foo4 { &self.0 }
+   |                  ^^^^ not found in `F`
+   |
+note: function `fn_to_other::foo4` exists but is inaccessible
+  --> $DIR/explicit-paths.rs:29:5
+   |
+LL |     reuse S::foo4;
+   |     ^^^^^^^^^^^^^^ not accessible
+
+error[E0425]: cannot find function `foo4` in `F`
+  --> $DIR/explicit-paths.rs:67:18
+   |
+LL |         reuse F::foo4 { &F }
+   |                  ^^^^ not found in `F`
+   |
+note: function `fn_to_other::foo4` exists but is inaccessible
+  --> $DIR/explicit-paths.rs:29:5
    |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
+LL |     reuse S::foo4;
+   |     ^^^^^^^^^^^^^^ not accessible
+
+error[E0119]: conflicting implementations of trait `Trait` for type `S`
+  --> $DIR/explicit-paths.rs:76:5
+   |
+LL |     impl Trait for S {
+   |     ---------------- first implementation here
+...
+LL |     impl Trait for S {
+   |     ^^^^^^^^^^^^^^^^ conflicting implementation for `S`
+
+error: delegation to a trait method from a free function is not supported yet
+  --> $DIR/explicit-paths.rs:24:18
+   |
+LL |     fn foo1(&self, x: i32) -> i32 { x }
+   |     ----------------------------- callee defined here
+...
+LL |     reuse Trait::foo1;
+   |                  ^^^^
+
+error: delegation to a trait method from a free function is not supported yet
+  --> $DIR/explicit-paths.rs:26:25
+   |
+LL |     fn foo2(x: i32) -> i32 { x }
+   |     ---------------------- callee defined here
+...
+LL |     reuse <S as Trait>::foo2;
+   |                         ^^^^
 
 error[E0308]: mismatched types
-  --> $DIR/explicit-paths.rs:14:25
+  --> $DIR/explicit-paths.rs:63:36
    |
-LL |     reuse <F as Trait>::bar;
-   |           --------------^^^
-   |           |             |
-   |           |             expected `&F`, found `&S`
-   |           arguments to this function are incorrect
+LL |     trait Trait2 : Trait {
+   |     -------------------- found this type parameter
+LL |         reuse <F as Trait>::foo1 { self }
+   |                                    ^^^^ expected `&F`, found `&Self`
    |
    = note: expected reference `&F`
-              found reference `&S`
-note: method defined here
-  --> $DIR/explicit-paths.rs:5:8
+              found reference `&Self`
+
+error[E0277]: the trait bound `S2: Trait` is not satisfied
+  --> $DIR/explicit-paths.rs:78:16
    |
-LL |     fn bar(&self) -> i32 { 42 }
-   |        ^^^ -----
+LL |         reuse <S2 as Trait>::foo1;
+   |                ^^ the trait `Trait` is not implemented for `S2`
+   |
+   = help: the following other types implement trait `Trait`:
+             F
+             S
 
 error[E0308]: mismatched types
-  --> $DIR/explicit-paths.rs:21:32
+  --> $DIR/explicit-paths.rs:78:30
    |
-LL |     reuse <S2 as Trait>::bar { &self.0 }
-   |                                ^^^^^^^ expected `&S2`, found `&F`
+LL |         reuse <S2 as Trait>::foo1;
+   |               ---------------^^^^
+   |               |              |
+   |               |              expected `&S2`, found `&S`
+   |               arguments to this function are incorrect
    |
    = note: expected reference `&S2`
-              found reference `&F`
+              found reference `&S`
+note: method defined here
+  --> $DIR/explicit-paths.rs:5:8
+   |
+LL |     fn foo1(&self, x: i32) -> i32 { x }
+   |        ^^^^ -----
 
-error: aborting due to 2 previous errors; 1 warning emitted
+error: aborting due to 12 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
+Some errors have detailed explanations: E0119, E0277, E0308, E0407, E0425.
+For more information about an error, try `rustc --explain E0119`.
diff --git a/tests/ui/delegation/not-supported.rs b/tests/ui/delegation/not-supported.rs
index 23081b1e1fc..9dccb12b57a 100644
--- a/tests/ui/delegation/not-supported.rs
+++ b/tests/ui/delegation/not-supported.rs
@@ -1,6 +1,6 @@
 #![feature(c_variadic)]
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 mod generics {
     trait GenericTrait<T> {
diff --git a/tests/ui/delegation/not-supported.stderr b/tests/ui/delegation/not-supported.stderr
index 324b79f3c53..f6c49366899 100644
--- a/tests/ui/delegation/not-supported.stderr
+++ b/tests/ui/delegation/not-supported.stderr
@@ -1,12 +1,3 @@
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/not-supported.rs:2:12
-   |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
-   |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
-
 error: delegation with early bound generics is not supported yet
   --> $DIR/not-supported.rs:16:29
    |
@@ -178,7 +169,7 @@ LL |         pub reuse to_reuse2::foo;
 LL |     reuse to_reuse1::foo;
    |                      ^^^
 
-error: aborting due to 19 previous errors; 1 warning emitted
+error: aborting due to 19 previous errors
 
 Some errors have detailed explanations: E0049, E0195.
 For more information about an error, try `rustc --explain E0049`.
diff --git a/tests/ui/delegation/parse.rs b/tests/ui/delegation/parse.rs
index 5e8026c5532..72b00bf6e0d 100644
--- a/tests/ui/delegation/parse.rs
+++ b/tests/ui/delegation/parse.rs
@@ -2,7 +2,7 @@
 
 #![feature(decl_macro)]
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 macro_rules! reuse { {} => {} }
 
diff --git a/tests/ui/delegation/parse.stderr b/tests/ui/delegation/parse.stderr
deleted file mode 100644
index 1e420ceeec7..00000000000
--- a/tests/ui/delegation/parse.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/parse.rs:4:12
-   |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
-   |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/delegation/target-expr-pass.rs b/tests/ui/delegation/target-expr-pass.rs
index 1f2edf0dc13..9e326a19b8f 100644
--- a/tests/ui/delegation/target-expr-pass.rs
+++ b/tests/ui/delegation/target-expr-pass.rs
@@ -1,7 +1,7 @@
 //@ run-pass
 
 #![feature(fn_delegation)]
-//~^ WARN the feature `fn_delegation` is incomplete
+#![allow(incomplete_features)]
 
 mod to_reuse {
     pub fn foo(x: i32) -> i32 { x }
diff --git a/tests/ui/delegation/target-expr-pass.stderr b/tests/ui/delegation/target-expr-pass.stderr
index dd1f3a14e0b..c8d73ec6e5a 100644
--- a/tests/ui/delegation/target-expr-pass.stderr
+++ b/tests/ui/delegation/target-expr-pass.stderr
@@ -1,12 +1,3 @@
-warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/target-expr-pass.rs:3:12
-   |
-LL | #![feature(fn_delegation)]
-   |            ^^^^^^^^^^^^^
-   |
-   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
-   = note: `#[warn(incomplete_features)]` on by default
-
 warning: trait `Trait` is never used
   --> $DIR/target-expr-pass.rs:17:7
    |
@@ -27,5 +18,5 @@ warning: struct `S` is never constructed
 LL | struct S(F);
    |        ^
 
-warning: 4 warnings emitted
+warning: 3 warnings emitted
 
diff --git a/tests/ui/delegation/target-expr.rs b/tests/ui/delegation/target-expr.rs
index b9c6fe92810..fd7ea943b9d 100644
--- a/tests/ui/delegation/target-expr.rs
+++ b/tests/ui/delegation/target-expr.rs
@@ -14,8 +14,9 @@ fn foo(x: i32) -> i32 { x }
 
 fn bar<T: Default>(_: T) {
     reuse Trait::static_method {
-        //~^ ERROR delegation with early bound generics is not supported yet
-        //~| ERROR mismatched types
+    //~^ ERROR delegation to a trait method from a free function is not supported yet
+    //~| ERROR delegation with early bound generics is not supported yet
+    //~| ERROR mismatched types
         let _ = T::Default();
         //~^ ERROR can't use generic parameters from outer item
     }
@@ -24,6 +25,7 @@ fn bar<T: Default>(_: T) {
 fn main() {
     let y = 0;
     reuse <S as Trait>::static_method {
+    //~^ ERROR delegation to a trait method from a free function is not supported yet
         let x = y;
         //~^ ERROR can't capture dynamic environment in a fn item
         foo(self);
diff --git a/tests/ui/delegation/target-expr.stderr b/tests/ui/delegation/target-expr.stderr
index da0fac2f5e4..b30f0c474c6 100644
--- a/tests/ui/delegation/target-expr.stderr
+++ b/tests/ui/delegation/target-expr.stderr
@@ -1,5 +1,5 @@
 error[E0401]: can't use generic parameters from outer item
-  --> $DIR/target-expr.rs:19:17
+  --> $DIR/target-expr.rs:20:17
    |
 LL | fn bar<T: Default>(_: T) {
    |        - type parameter from outer item
@@ -10,7 +10,7 @@ LL |         let _ = T::Default();
    |                 ^^^^^^^^^^ use of generic parameter from outer item
 
 error[E0434]: can't capture dynamic environment in a fn item
-  --> $DIR/target-expr.rs:27:17
+  --> $DIR/target-expr.rs:29:17
    |
 LL |         let x = y;
    |                 ^
@@ -18,7 +18,7 @@ LL |         let x = y;
    = help: use the `|| { ... }` closure form instead
 
 error[E0424]: expected value, found module `self`
-  --> $DIR/target-expr.rs:34:5
+  --> $DIR/target-expr.rs:36:5
    |
 LL | fn main() {
    |    ---- this function can't have a `self` parameter
@@ -27,13 +27,13 @@ LL |     self.0;
    |     ^^^^ `self` value is a keyword only available in methods with a `self` parameter
 
 error[E0425]: cannot find value `x` in this scope
-  --> $DIR/target-expr.rs:36:13
+  --> $DIR/target-expr.rs:38:13
    |
 LL |     let z = x;
    |             ^
    |
 help: the binding `x` is available in a different scope in the same function
-  --> $DIR/target-expr.rs:27:13
+  --> $DIR/target-expr.rs:29:13
    |
 LL |         let x = y;
    |             ^
@@ -47,6 +47,24 @@ LL |     fn static_method(x: i32) -> i32 { x }
 LL |     reuse Trait::static_method {
    |                  ^^^^^^^^^^^^^
 
+error: delegation to a trait method from a free function is not supported yet
+  --> $DIR/target-expr.rs:16:18
+   |
+LL |     fn static_method(x: i32) -> i32 { x }
+   |     ------------------------------- callee defined here
+...
+LL |     reuse Trait::static_method {
+   |                  ^^^^^^^^^^^^^
+
+error: delegation to a trait method from a free function is not supported yet
+  --> $DIR/target-expr.rs:27:25
+   |
+LL |     fn static_method(x: i32) -> i32 { x }
+   |     ------------------------------- callee defined here
+...
+LL |     reuse <S as Trait>::static_method {
+   |                         ^^^^^^^^^^^^^
+
 error[E0308]: mismatched types
   --> $DIR/target-expr.rs:16:32
    |
@@ -54,12 +72,13 @@ LL |       reuse Trait::static_method {
    |  ________________________________^
 LL | |
 LL | |
+LL | |
 LL | |         let _ = T::Default();
 LL | |
 LL | |     }
    | |_____^ expected `i32`, found `()`
 
-error: aborting due to 6 previous errors
+error: aborting due to 8 previous errors
 
 Some errors have detailed explanations: E0308, E0401, E0424, E0425, E0434.
 For more information about an error, try `rustc --explain E0308`.