Skip to content

Commit

Permalink
Auto merge of #24910 - steveklabnik:remove_static_assert, r=alexcrichton
Browse files Browse the repository at this point in the history
This was always a weird feature, and isn't being used in the compiler.
Static assertions should be done better than this.

Fixes #13951
Fixes #23008
Fixes #6676

This is behind a feature gate, but that's still a

[breaking-change]

(It's not entirely clear to me that this should or shouldn't have an RFC, but if it does, I'm fine blocking on such a thing.)
  • Loading branch information
bors committed Jun 3, 2015
2 parents 9a2f68e + 5235065 commit b70f49b
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 130 deletions.
9 changes: 0 additions & 9 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1943,9 +1943,6 @@ macro scope.
- `simd` - on certain tuple structs, derive the arithmetic operators, which
lower to the target's SIMD instructions, if any; the `simd` feature gate
is necessary to use this attribute.
- `static_assert` - on statics whose type is `bool`, terminates compilation
with an error if it is not initialized to `true`. To use this, the `static_assert`
feature gate must be enabled.
- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
destructors from being run twice. Destructors might be run multiple times on
the same object with this attribute. To use this, the `unsafe_no_drop_flag` feature
Expand Down Expand Up @@ -2301,12 +2298,6 @@ The currently implemented features of the reference compiler are:
crate. Stability markers are also attributes: `#[stable]`,
`#[unstable]`, and `#[deprecated]` are the three levels.

* `static_assert` - The `#[static_assert]` functionality is experimental and
unstable. The attribute can be attached to a `static` of
type `bool` and the compiler will error if the `bool` is
`false` at compile time. This version of this functionality
is unintuitive and suboptimal.

* `start` - Allows use of the `#[start]` attribute, which changes the entry point
into a Rust program. This capability, especially the signature for the
annotated function, is subject to change.
Expand Down
22 changes: 0 additions & 22 deletions src/librustc_trans/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2032,28 +2032,6 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {

let g = consts::trans_static(ccx, m, item.id);
update_linkage(ccx, g, Some(item.id), OriginalTranslation);

// Do static_assert checking. It can't really be done much earlier
// because we need to get the value of the bool out of LLVM
if attr::contains_name(&item.attrs, "static_assert") {
if !ty::type_is_bool(ty::expr_ty(ccx.tcx(), expr)) {
ccx.sess().span_fatal(expr.span,
"can only have static_assert on a static \
with type `bool`");
}
if m == ast::MutMutable {
ccx.sess().span_fatal(expr.span,
"cannot have static_assert on a mutable \
static");
}

let v = ccx.static_values().borrow().get(&item.id).unwrap().clone();
unsafe {
if !(llvm::LLVMConstIntGetZExtValue(v) != 0) {
ccx.sess().span_fatal(expr.span, "static assertion failed");
}
}
}
},
ast::ItemForeignMod(ref foreign_mod) => {
foreign::trans_foreign_mod(ccx, foreign_mod);
Expand Down
5 changes: 0 additions & 5 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
// Allows the use of rustc_* attributes; RFC 572
("rustc_attrs", "1.0.0", Active),

// Allows the use of `static_assert`
("static_assert", "1.0.0", Active),

// Allows the use of #[allow_internal_unstable]. This is an
// attribute on macro_rules! and can't use the attribute handling
// below (it has to be checked before expansion possibly makes
Expand Down Expand Up @@ -261,8 +258,6 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[
("no_builtins", Whitelisted),
("no_mangle", Whitelisted),
("no_stack_check", Whitelisted),
("static_assert", Gated("static_assert",
"`#[static_assert]` is an experimental feature, and has a poor API")),
("no_debug", Whitelisted),
("omit_gdb_pretty_printer_section", Whitelisted),
("unsafe_no_drop_flag", Gated("unsafe_no_drop_flag",
Expand Down
14 changes: 0 additions & 14 deletions src/test/compile-fail/feature-gate-static-assert.rs

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/compile-fail/nonbool_static_assert.rs

This file was deleted.

18 changes: 0 additions & 18 deletions src/test/compile-fail/static-assert.rs

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/compile-fail/static-assert2.rs

This file was deleted.

28 changes: 0 additions & 28 deletions src/test/run-pass/static-assert.rs

This file was deleted.

0 comments on commit b70f49b

Please sign in to comment.