about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2023-07-08 12:10:12 +0900
committerYuki Okushi <jtitor@2k36.org>2023-07-08 12:10:12 +0900
commita088e7961cc2b2176dd470cc5599f7c8f886abff (patch)
treed197d232b642997bab3fe3555dab24ba58a67c7c
parenteee6b31c0c3b7c3ad8733957eaa122ae1a07e299 (diff)
downloadrust-a088e7961cc2b2176dd470cc5599f7c8f886abff.tar.gz
rust-a088e7961cc2b2176dd470cc5599f7c8f886abff.zip
Remove `default_free_fn` feature
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
-rw-r--r--library/core/src/default.rs45
-rw-r--r--src/doc/unstable-book/src/library-features/default-free-fn.md47
-rw-r--r--tests/ui/resolve/issue-2356.stderr21
3 files changed, 6 insertions, 107 deletions
diff --git a/library/core/src/default.rs b/library/core/src/default.rs
index 1f7be85d38a..5242e97eb9a 100644
--- a/library/core/src/default.rs
+++ b/library/core/src/default.rs
@@ -133,51 +133,6 @@ pub trait Default: Sized {
     fn default() -> Self;
 }
 
-/// Return the default value of a type according to the `Default` trait.
-///
-/// The type to return is inferred from context; this is equivalent to
-/// `Default::default()` but shorter to type.
-///
-/// For example:
-/// ```
-/// #![feature(default_free_fn)]
-///
-/// use std::default::default;
-///
-/// #[derive(Default)]
-/// struct AppConfig {
-///     foo: FooConfig,
-///     bar: BarConfig,
-/// }
-///
-/// #[derive(Default)]
-/// struct FooConfig {
-///     foo: i32,
-/// }
-///
-/// #[derive(Default)]
-/// struct BarConfig {
-///     bar: f32,
-///     baz: u8,
-/// }
-///
-/// fn main() {
-///     let options = AppConfig {
-///         foo: default(),
-///         bar: BarConfig {
-///             bar: 10.1,
-///             ..default()
-///         },
-///     };
-/// }
-/// ```
-#[unstable(feature = "default_free_fn", issue = "73014")]
-#[must_use]
-#[inline]
-pub fn default<T: Default>() -> T {
-    Default::default()
-}
-
 /// Derive macro generating an impl of the trait `Default`.
 #[rustc_builtin_macro(Default, attributes(default))]
 #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
diff --git a/src/doc/unstable-book/src/library-features/default-free-fn.md b/src/doc/unstable-book/src/library-features/default-free-fn.md
deleted file mode 100644
index bafc9ac4d0d..00000000000
--- a/src/doc/unstable-book/src/library-features/default-free-fn.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# `default_free_fn`
-
-The tracking issue for this feature is: [#73014]
-
-[#73014]: https://github.com/rust-lang/rust/issues/73014
-
-------------------------
-
-Adds a free `default()` function to the `std::default` module.  This function
-just forwards to [`Default::default()`], but may remove repetition of the word
-"default" from the call site.
-
-[`Default::default()`]: ../../std/default/trait.Default.html#tymethod.default
-
-Here is an example:
-
-```rust
-#![feature(default_free_fn)]
-use std::default::default;
-
-#[derive(Default)]
-struct AppConfig {
-    foo: FooConfig,
-    bar: BarConfig,
-}
-
-#[derive(Default)]
-struct FooConfig {
-    foo: i32,
-}
-
-#[derive(Default)]
-struct BarConfig {
-    bar: f32,
-    baz: u8,
-}
-
-fn main() {
-    let options = AppConfig {
-        foo: default(),
-        bar: BarConfig {
-            bar: 10.1,
-            ..default()
-        },
-    };
-}
-```
diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr
index 313b3e30dd9..30f5f059526 100644
--- a/tests/ui/resolve/issue-2356.stderr
+++ b/tests/ui/resolve/issue-2356.stderr
@@ -1,18 +1,3 @@
-error[E0425]: cannot find function `default` in this scope
-  --> $DIR/issue-2356.rs:31:5
-   |
-LL |     default();
-   |     ^^^^^^^
-   |
-help: you might have meant to call the associated function
-   |
-LL |     Self::default();
-   |     ~~~~~~~~~~~~~
-help: consider importing this function
-   |
-LL + use std::default::default;
-   |
-
 error[E0425]: cannot find value `whiskers` in this scope
   --> $DIR/issue-2356.rs:39:5
    |
@@ -64,6 +49,12 @@ error[E0425]: cannot find function `clone` in this scope
 LL |     clone();
    |     ^^^^^ help: you might have meant to call the method: `self.clone`
 
+error[E0425]: cannot find function `default` in this scope
+  --> $DIR/issue-2356.rs:31:5
+   |
+LL |     default();
+   |     ^^^^^^^ help: you might have meant to call the associated function: `Self::default`
+
 error[E0425]: cannot find function `shave` in this scope
   --> $DIR/issue-2356.rs:41:5
    |