Skip to content

Commit f8b6108

Browse files
committed
Stabilize static in const
Closes #35897.
1 parent 10f6a5c commit f8b6108

File tree

7 files changed

+3
-34
lines changed

7 files changed

+3
-34
lines changed

src/librustc/middle/resolve_lifetime.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,6 @@ enum Elide {
238238
FreshLateAnon(Cell<u32>),
239239
/// Always use this one lifetime.
240240
Exact(Region),
241-
/// Like `Exact(Static)` but requires `#![feature(static_in_const)]`.
242-
Static,
243241
/// Less or more than one lifetime were found, error on unspecified.
244242
Error(Vec<ElisionFailureInfo>)
245243
}
@@ -324,7 +322,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
324322
hir::ItemConst(..) => {
325323
// No lifetime parameters, but implied 'static.
326324
let scope = Scope::Elision {
327-
elide: Elide::Static,
325+
elide: Elide::Exact(Region::Static),
328326
s: ROOT_SCOPE
329327
};
330328
self.with(scope, |_, this| intravisit::walk_item(this, item));
@@ -1307,16 +1305,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
13071305
return;
13081306
}
13091307
Elide::Exact(l) => l.shifted(late_depth),
1310-
Elide::Static => {
1311-
if !self.sess.features.borrow().static_in_const {
1312-
self.sess
1313-
.struct_span_err(span,
1314-
"this needs a `'static` lifetime or the \
1315-
`static_in_const` feature, see #35897")
1316-
.emit();
1317-
}
1318-
Region::Static
1319-
}
13201308
Elide::Error(ref e) => break Some(e)
13211309
};
13221310
for lifetime_ref in lifetime_refs {

src/libsyntax/feature_gate.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ declare_features! (
281281
// Allows untagged unions `union U { ... }`
282282
(active, untagged_unions, "1.13.0", Some(32836)),
283283

284-
// elide `'static` lifetimes in `static`s and `const`s
285-
(active, static_in_const, "1.13.0", Some(35897)),
286-
287284
// Used to identify the `compiler_builtins` crate
288285
// rustc internal
289286
(active, compiler_builtins, "1.13.0", None),
@@ -382,6 +379,8 @@ declare_features! (
382379
(accepted, item_like_imports, "1.14.0", Some(35120)),
383380
// Allows using `Self` and associated types in struct expressions and patterns.
384381
(accepted, more_struct_aliases, "1.16.0", Some(37544)),
382+
// elide `'static` lifetimes in `static`s and `const`s
383+
(accepted, static_in_const, "1.17.0", Some(35897)),
385384
);
386385
// (changing above list without updating src/doc/reference.md makes @cmr sad)
387386

src/test/compile-fail/feature-gate-static-in-const.rs

-14
This file was deleted.

src/test/compile-fail/rfc1623.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
#![feature(static_in_const)]
1110
#![allow(dead_code)]
1211

1312
fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 {

src/test/incremental/change_add_field/struct_point.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#![feature(rustc_attrs)]
2020
#![feature(stmt_expr_attributes)]
21-
#![feature(static_in_const)]
2221
#![allow(dead_code)]
2322

2423
// These are expected to require translation.

src/test/incremental/change_pub_inherent_method_sig/struct_point.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#![feature(rustc_attrs)]
1717
#![feature(stmt_expr_attributes)]
18-
#![feature(static_in_const)]
1918
#![allow(dead_code)]
2019

2120
// These are expected to require translation.

src/test/run-pass/rfc1623.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(static_in_const)]
1211
#![allow(dead_code)]
1312

1413
// very simple test for a 'static static with default lifetime

0 commit comments

Comments
 (0)