about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-06-13 21:35:54 +0200
committerGitHub <noreply@github.com>2022-06-13 21:35:54 +0200
commit89249b199edb8454fa566d9cd12e1ae770112a29 (patch)
tree751c353df33c73c1efa7ae47ee3af4c12515ab9e
parente13eeedefc1429b15af6320aa69de2c64e9c3afc (diff)
parent40913c6061c2826f31d7724e77c6011dc92aeb19 (diff)
Rollup merge of #97875 - JohnTitor:rm-infer-static-outlives-requirements, r=pnkfelix
Remove the `infer_static_outlives_requirements` feature

Closes #54185
r? ``@pnkfelix``
-rw-r--r--compiler/rustc_feature/src/active.rs2
-rw-r--r--compiler/rustc_feature/src/removed.rs3
-rw-r--r--compiler/rustc_lint/src/builtin.rs13
-rw-r--r--compiler/rustc_typeck/src/outlives/utils.rs11
-rw-r--r--src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md44
-rw-r--r--src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.rs12
-rw-r--r--src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr19
-rw-r--r--src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs4
-rw-r--r--src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr4
-rw-r--r--src/test/ui/rfc-2093-infer-outlives/infer-static.rs12
-rw-r--r--src/test/ui/rfc-2093-infer-outlives/infer-static.stderr12
11 files changed, 13 insertions, 123 deletions
diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs
index 35473b6e97a..56269a3c674 100644
--- a/compiler/rustc_feature/src/active.rs
+++ b/compiler/rustc_feature/src/active.rs
@@ -409,8 +409,6 @@ declare_features! (
     (active, if_let_guard, "1.47.0", Some(51114), None),
     /// Allows using imported `main` function
     (active, imported_main, "1.53.0", Some(28937), None),
-    /// Allows inferring `'static` outlives requirements (RFC 2093).
-    (active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),
     /// Allows associated types in inherent impls.
     (incomplete, inherent_associated_types, "1.52.0", Some(8995), None),
     /// Allow anonymous constants from an inline `const` block
diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs
index 7194416cd1d..54626caaf53 100644
--- a/compiler/rustc_feature/src/removed.rs
+++ b/compiler/rustc_feature/src/removed.rs
@@ -109,6 +109,9 @@ declare_features! (
     /// Allows in-band quantification of lifetime bindings (e.g., `fn foo(x: &'a u8) -> &'a u8`).
     (removed, in_band_lifetimes, "1.23.0", Some(44524), None,
      Some("removed due to unsolved ergonomic questions and added lifetime resolution complexity")),
+    /// Allows inferring `'static` outlives requirements (RFC 2093).
+    (removed, infer_static_outlives_requirements, "1.63.0", Some(54185), None,
+     Some("removed as it caused some confusion and discussion was inactive for years")),
     /// Lazily evaluate constants. This allows constants to depend on type parameters.
     (removed, lazy_normalization_consts, "1.46.0", Some(72219), None, Some("superseded by `generic_const_exprs`")),
     /// Allows using the `#[link_args]` attribute.
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs
index 205ca72aae8..29695caafb4 100644
--- a/compiler/rustc_lint/src/builtin.rs
+++ b/compiler/rustc_lint/src/builtin.rs
@@ -2113,7 +2113,6 @@ impl ExplicitOutlivesRequirements {
         tcx: TyCtxt<'tcx>,
         bounds: &hir::GenericBounds<'_>,
         inferred_outlives: &[ty::Region<'tcx>],
-        infer_static: bool,
     ) -> Vec<(usize, Span)> {
         use rustc_middle::middle::resolve_lifetime::Region;
 
@@ -2123,9 +2122,6 @@ impl ExplicitOutlivesRequirements {
             .filter_map(|(i, bound)| {
                 if let hir::GenericBound::Outlives(lifetime) = bound {
                     let is_inferred = match tcx.named_region(lifetime.hir_id) {
-                        Some(Region::Static) if infer_static => {
-                            inferred_outlives.iter().any(|r| matches!(**r, ty::ReStatic))
-                        }
                         Some(Region::EarlyBound(index, ..)) => inferred_outlives.iter().any(|r| {
                             if let ty::ReEarlyBound(ebr) = **r { ebr.index == index } else { false }
                         }),
@@ -2201,7 +2197,6 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
     fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
         use rustc_middle::middle::resolve_lifetime::Region;
 
-        let infer_static = cx.tcx.features().infer_static_outlives_requirements;
         let def_id = item.def_id;
         if let hir::ItemKind::Struct(_, ref hir_generics)
         | hir::ItemKind::Enum(_, ref hir_generics)
@@ -2262,12 +2257,8 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
                     continue;
                 }
 
-                let bound_spans = self.collect_outlives_bound_spans(
-                    cx.tcx,
-                    bounds,
-                    &relevant_lifetimes,
-                    infer_static,
-                );
+                let bound_spans =
+                    self.collect_outlives_bound_spans(cx.tcx, bounds, &relevant_lifetimes);
                 bound_count += bound_spans.len();
 
                 let drop_predicate = bound_spans.len() == bounds.len();
diff --git a/compiler/rustc_typeck/src/outlives/utils.rs b/compiler/rustc_typeck/src/outlives/utils.rs
index 54a5037b575..14e3048cadc 100644
--- a/compiler/rustc_typeck/src/outlives/utils.rs
+++ b/compiler/rustc_typeck/src/outlives/utils.rs
@@ -21,7 +21,7 @@ pub fn insert_outlives_predicate<'tcx>(
 ) {
     // If the `'a` region is bound within the field type itself, we
     // don't want to propagate this constraint to the header.
-    if !is_free_region(tcx, outlived_region) {
+    if !is_free_region(outlived_region) {
         return;
     }
 
@@ -119,7 +119,7 @@ pub fn insert_outlives_predicate<'tcx>(
         }
 
         GenericArgKind::Lifetime(r) => {
-            if !is_free_region(tcx, r) {
+            if !is_free_region(r) {
                 return;
             }
             required_predicates.entry(ty::OutlivesPredicate(kind, outlived_region)).or_insert(span);
@@ -131,7 +131,7 @@ pub fn insert_outlives_predicate<'tcx>(
     }
 }
 
-fn is_free_region(tcx: TyCtxt<'_>, region: Region<'_>) -> bool {
+fn is_free_region(region: Region<'_>) -> bool {
     // First, screen for regions that might appear in a type header.
     match *region {
         // These correspond to `T: 'a` relationships:
@@ -144,13 +144,12 @@ fn is_free_region(tcx: TyCtxt<'_>, region: Region<'_>) -> bool {
         ty::ReEarlyBound(_) => true,
 
         // These correspond to `T: 'static` relationships which can be
-        // rather surprising. We are therefore putting this behind a
-        // feature flag:
+        // rather surprising.
         //
         //     struct Foo<'a, T> {
         //         field: &'static T, // this would generate a ReStatic
         //     }
-        ty::ReStatic => tcx.sess.features_untracked().infer_static_outlives_requirements,
+        ty::ReStatic => false,
 
         // Late-bound regions can appear in `fn` types:
         //
diff --git a/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md b/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md
deleted file mode 100644
index 5f3f1b4dd8a..00000000000
--- a/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# `infer_static_outlives_requirements`
-
-The tracking issue for this feature is: [#54185]
-
-[#54185]: https://github.com/rust-lang/rust/issues/54185
-
-------------------------
-The `infer_static_outlives_requirements` feature indicates that certain
-`'static` outlives requirements can be inferred by the compiler rather than
-stating them explicitly.
-
-Note: It is an accompanying feature to `infer_outlives_requirements`,
-which must be enabled to infer outlives requirements.
-
-For example, currently generic struct definitions that contain
-references, require where-clauses of the form T: 'static. By using
-this feature the outlives predicates will be inferred, although
-they may still be written explicitly.
-
-```rust,ignore (pseudo-Rust)
-struct Foo<U> where U: 'static { // <-- currently required
-    bar: Bar<U>
-}
-struct Bar<T: 'static> {
-    x: T,
-}
-```
-
-
-## Examples:
-
-```rust,ignore (pseudo-Rust)
-#![feature(infer_outlives_requirements)]
-#![feature(infer_static_outlives_requirements)]
-
-#[rustc_outlives]
-// Implicitly infer U: 'static
-struct Foo<U> {
-    bar: Bar<U>
-}
-struct Bar<T: 'static> {
-    x: T,
-}
-```
diff --git a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.rs b/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.rs
deleted file mode 100644
index 65792a74ea4..00000000000
--- a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Needs an explicit where clause stating outlives condition. (RFC 2093)
-
-// Type T needs to outlive lifetime 'static.
-struct Foo<U> {
-    bar: Bar<U> //~ ERROR the parameter type `U` may not live long enough [E0310]
-}
-struct Bar<T: 'static> {
-    x: T,
-}
-
-
-fn main() { }
diff --git a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr b/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr
deleted file mode 100644
index 7ffebab4153..00000000000
--- a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0310]: the parameter type `U` may not live long enough
-  --> $DIR/feature-gate-infer_static_outlives_requirements.rs:5:10
-   |
-LL |     bar: Bar<U>
-   |          ^^^^^^ ...so that the type `U` will meet its required lifetime bounds...
-   |
-note: ...that is required by this bound
-  --> $DIR/feature-gate-infer_static_outlives_requirements.rs:7:15
-   |
-LL | struct Bar<T: 'static> {
-   |               ^^^^^^^
-help: consider adding an explicit lifetime bound...
-   |
-LL | struct Foo<U: 'static> {
-   |             +++++++++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0310`.
diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs
index 5297d0d9842..d3940b13b11 100644
--- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs
+++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs
@@ -1,7 +1,5 @@
 /*
- * We don't infer `T: 'static` outlives relationships by default.
- * Instead an additional feature gate `infer_static_outlives_requirements`
- * is required.
+ * We don't infer `T: 'static` outlives relationships.
  */
 
 struct Foo<U> {
diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
index 950ffd6c89b..0c388f5fe41 100644
--- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
+++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
@@ -1,11 +1,11 @@
 error[E0310]: the parameter type `U` may not live long enough
-  --> $DIR/dont-infer-static.rs:8:10
+  --> $DIR/dont-infer-static.rs:6:10
    |
 LL |     bar: Bar<U>
    |          ^^^^^^ ...so that the type `U` will meet its required lifetime bounds...
    |
 note: ...that is required by this bound
-  --> $DIR/dont-infer-static.rs:10:15
+  --> $DIR/dont-infer-static.rs:8:15
    |
 LL | struct Bar<T: 'static> {
    |               ^^^^^^^
diff --git a/src/test/ui/rfc-2093-infer-outlives/infer-static.rs b/src/test/ui/rfc-2093-infer-outlives/infer-static.rs
deleted file mode 100644
index bd778e3b136..00000000000
--- a/src/test/ui/rfc-2093-infer-outlives/infer-static.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![feature(rustc_attrs)]
-#![feature(infer_static_outlives_requirements)]
-
-#[rustc_outlives]
-struct Foo<U> { //~ ERROR rustc_outlives
-    bar: Bar<U>
-}
-struct Bar<T: 'static> {
-    x: T,
-}
-
-fn main() {}
diff --git a/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr
deleted file mode 100644
index 6fbb7cf4cb8..00000000000
--- a/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error: rustc_outlives
-  --> $DIR/infer-static.rs:5:1
-   |
-LL | / struct Foo<U> {
-LL | |     bar: Bar<U>
-LL | | }
-   | |_^
-   |
-   = note: U: 'static
-
-error: aborting due to previous error
-