Skip to content

Commit

Permalink
Rename optin_builtin_traits to auto_traits
Browse files Browse the repository at this point in the history
They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.

There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.

Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
  • Loading branch information
camelid committed Nov 23, 2020
1 parent 32da90b commit 810324d
Show file tree
Hide file tree
Showing 54 changed files with 78 additions and 62 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::ItemKind::Trait(ast::IsAuto::Yes, ..) => {
gate_feature_post!(
&self,
optin_builtin_traits,
auto_traits,
i.span,
"auto traits are experimental and possibly buggy"
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/example/mini_core.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
untagged_unions, decl_macro, rustc_attrs, transparent_unions, optin_builtin_traits,
untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits,
thread_local,
)]
#![no_core]
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#![feature(fn_traits)]
#![feature(int_bits_const)]
#![feature(min_specialization)]
#![feature(optin_builtin_traits)]
#![cfg_attr(bootstrap, feature(optin_builtin_traits))]
#![cfg_attr(not(bootstrap), feature(auto_traits))]
#![feature(nll)]
#![feature(allow_internal_unstable)]
#![feature(hash_raw_entry)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0198.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ unsafe.
This will compile:

```ignore (ignore auto_trait future compatibility warning)
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
struct Foo;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0321.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ or enum type.
Erroneous code example:

```compile_fail,E0321
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
struct Foo;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0567.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Generics have been used on an auto trait.
Erroneous code example:

```compile_fail,E0567
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
auto trait Generic<T> {} // error!
# fn main() {}
Expand All @@ -16,7 +16,7 @@ parameters.
To fix this issue, just remove the generics:

```
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
auto trait Generic {} // ok!
# fn main() {}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0568.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A super trait has been added to an auto trait.
Erroneous code example:

```compile_fail,E0568
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
auto trait Bound : Copy {} // error!
Expand All @@ -18,7 +18,7 @@ all the existing types could implement `Bound` because very few of them have the
To fix this issue, just remove the super trait:

```
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
auto trait Bound {} // ok!
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ declare_features! (
/// Allows using the `#[linkage = ".."]` attribute.
(active, linkage, "1.0.0", Some(29603), None),

/// Allows features specific to OIBIT (auto traits).
(active, optin_builtin_traits, "1.0.0", Some(13231), None),

/// Allows using `box` in patterns (RFC 469).
(active, box_patterns, "1.0.0", Some(29641), None),

Expand Down Expand Up @@ -215,6 +212,10 @@ declare_features! (
/// purpose as `#[allow_internal_unstable]`.
(active, rustc_allow_const_fn_unstable, "1.49.0", Some(69399), None),

/// Allows features specific to auto traits.
/// Renamed from `optin_builtin_traits`.
(active, auto_traits, "1.50.0", Some(13231), None),

// no-tracking-issue-end

// -------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ declare_features! (
/// Allows using custom attributes (RFC 572).
(removed, custom_attribute, "1.0.0", Some(29642), None,
Some("removed in favor of `#![register_tool]` and `#![register_attr]`")),
/// Allows features specific to OIBIT (now called auto traits).
/// Renamed to `auto_traits`.
(removed, optin_builtin_traits, "1.0.0", Some(13231), None,
Some("renamed to `auto_traits`")),
(removed, pushpop_unsafe, "1.2.0", None, None, None),
(removed, needs_allocator, "1.4.0", Some(27389), None,
Some("subsumed by `#![feature(allocator_internals)]`")),
Expand Down Expand Up @@ -113,7 +117,6 @@ declare_features! (
Some("removed in favor of `#![feature(marker_trait_attr)]`")),
/// Allows `#[no_debug]`.
(removed, no_debug, "1.43.0", Some(29721), None, Some("removed due to lack of demand")),

/// Allows comparing raw pointers during const eval.
(removed, const_compare_raw_pointers, "1.46.0", Some(53020), None,
Some("cannot be allowed in const eval in any meaningful way")),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ symbols! {
attr_literals,
attributes,
augmented_assignments,
auto_traits,
automatically_derived,
avx512_target_feature,
await_macro,
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
#![feature(never_type)]
#![feature(nll)]
#![feature(nonnull_slice_from_raw_parts)]
#![feature(optin_builtin_traits)]
#![cfg_attr(bootstrap, feature(optin_builtin_traits))]
#![cfg_attr(not(bootstrap), feature(auto_traits))]
#![feature(or_patterns)]
#![feature(pattern)]
#![feature(ptr_internals)]
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
#![feature(nll)]
#![feature(exhaustive_patterns)]
#![feature(no_core)]
#![feature(optin_builtin_traits)]
#![cfg_attr(bootstrap, feature(optin_builtin_traits))]
#![cfg_attr(not(bootstrap), feature(auto_traits))]
#![feature(or_patterns)]
#![feature(prelude_import)]
#![feature(repr_simd, platform_intrinsics)]
Expand Down
3 changes: 2 additions & 1 deletion library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#![feature(extern_types)]
#![feature(in_band_lifetimes)]
#![feature(negative_impls)]
#![feature(optin_builtin_traits)]
#![cfg_attr(bootstrap, feature(optin_builtin_traits))]
#![cfg_attr(not(bootstrap), feature(auto_traits))]
#![feature(restricted_std)]
#![feature(rustc_attrs)]
#![feature(min_specialization)]
Expand Down
7 changes: 5 additions & 2 deletions library/rtstartup/rsbegin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
// headers or footers.
//
// Note that the actual module entry point is located in the C runtime startup
// object (usually called `crtX.o), which then invokes initialization callbacks
// object (usually called `crtX.o`), which then invokes initialization callbacks
// of other runtime components (registered via yet another special image section).

#![feature(no_core, lang_items, optin_builtin_traits)]
#![feature(no_core)]
#![feature(lang_items)]
#![cfg_attr(bootstrap, feature(optin_builtin_traits))]
#![cfg_attr(not(bootstrap), feature(auto_traits))]
#![crate_type = "rlib"]
#![no_core]
#![allow(non_camel_case_types)]
Expand Down
5 changes: 4 additions & 1 deletion library/rtstartup/rsend.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// See rsbegin.rs for details.

#![feature(no_core, lang_items, optin_builtin_traits)]
#![feature(no_core)]
#![feature(lang_items)]
#![cfg_attr(bootstrap, feature(optin_builtin_traits))]
#![cfg_attr(not(bootstrap), feature(auto_traits))]
#![crate_type = "rlib"]
#![no_core]

Expand Down
3 changes: 2 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@
#![feature(nll)]
#![feature(nonnull_slice_from_raw_parts)]
#![feature(once_cell)]
#![feature(optin_builtin_traits)]
#![cfg_attr(bootstrap, feature(optin_builtin_traits))]
#![cfg_attr(not(bootstrap), feature(auto_traits))]
#![feature(or_patterns)]
#![feature(panic_info_message)]
#![feature(panic_internals)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# `optin_builtin_traits`
# `auto_traits`

The tracking issue for this feature is [#13231]

[#13231]: https://github.com/rust-lang/rust/issues/13231

----

The `optin_builtin_traits` feature gate allows you to define auto traits.
The `auto_traits` feature gate allows you to define auto traits.

Auto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits
that are automatically implemented for every type, unless the type, or a type it contains,
Expand All @@ -24,7 +24,7 @@ Example:

```rust
#![feature(negative_impls)]
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

auto trait Valid {}

Expand Down
2 changes: 1 addition & 1 deletion src/test/pretty/auto-trait.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

// pp-exact

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/simd-ffi/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![crate_type = "lib"]
// we can compile to a variety of platforms, because we don't need
// cross-compiled standard libraries.
#![feature(no_core, optin_builtin_traits)]
#![feature(no_core, auto_traits)]
#![no_core]
#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)]

Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/target-specs/foo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(lang_items, no_core, optin_builtin_traits)]
#![feature(lang_items, no_core, auto_traits)]
#![no_core]

#[lang="copy"]
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/auto-traits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// aux-build:auto-traits.rs

#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

#![crate_name = "foo"]

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/auto_aliases.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

// @has auto_aliases/trait.Bar.html '//h3[@aliases="auto_aliases::Foo"]' 'impl Bar for Foo'
pub struct Foo;
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/auxiliary/auto-traits.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

pub unsafe auto trait Bar {}
2 changes: 1 addition & 1 deletion src/test/rustdoc/auxiliary/rustdoc-default-impl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

pub mod bar {
use std::marker;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

pub auto trait AnOibit {}
2 changes: 1 addition & 1 deletion src/test/rustdoc/impl-parts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(negative_impls)]
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

pub auto trait AnOibit {}

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/synthetic_auto/crate-local.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

pub auto trait Banana {}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-64130-3-other.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]
// edition:2018

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/auto-traits/auto-trait-validation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]

auto trait Generic<T> {}
//~^ auto traits cannot have generic parameters [E0567]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/auto-traits/auto-traits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-pass
#![allow(unused_doc_comments)]
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait Auto {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/auto-traits/issue-23080-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

unsafe auto trait Trait {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/auto-traits/issue-23080.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

unsafe auto trait Trait {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait Magic : Sized where Option<Self> : Magic {} //~ ERROR E0568
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// println!("{:?} {:?}", a, b);
// }

#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait Magic: Copy {} //~ ERROR E0568
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait MyTrait {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait MyTrait {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait MyTrait {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// other words, the auto impl only applies if there are no existing
// impls whose types unify.

#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait Defaulted { }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence-default-trait-impl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

auto trait MySafeTrait {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

// Test for issue #56934 - that it is impossible to redundantly
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(auto_traits)]
#![feature(negative_impls)]

// Test for issue #56934 - that it is impossible to redundantly
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Test that default and negative trait implementations are gated by
// `optin_builtin_traits` feature gate
// `auto_traits` feature gate

struct DummyStruct;

Expand Down
Loading

0 comments on commit 810324d

Please sign in to comment.