Skip to content

Commit c63f3fe

Browse files
Stabilize associated type bounds
1 parent a655e64 commit c63f3fe

File tree

95 files changed

+147
-533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+147
-533
lines changed

compiler/rustc_ast/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![doc(rust_logo)]
1212
#![allow(internal_features)]
1313
#![feature(rustdoc_internals)]
14-
#![feature(associated_type_bounds)]
14+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
1515
#![feature(associated_type_defaults)]
1616
#![feature(box_patterns)]
1717
#![feature(if_let_guard)]

compiler/rustc_ast_passes/src/feature_gate.rs

-8
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
452452
constraint.span,
453453
"return type notation is experimental"
454454
);
455-
} else {
456-
gate!(
457-
&self,
458-
associated_type_bounds,
459-
constraint.span,
460-
"associated type bounds are unstable"
461-
);
462455
}
463456
}
464457
visit::walk_assoc_constraint(self, constraint)
@@ -604,7 +597,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
604597
}
605598

606599
gate_all_legacy_dont_use!(trait_alias, "trait aliases are experimental");
607-
gate_all_legacy_dont_use!(associated_type_bounds, "associated type bounds are unstable");
608600
// Despite being a new feature, `where T: Trait<Assoc(): Sized>`, which is RTN syntax now,
609601
// used to be gated under associated_type_bounds, which are right above, so RTN needs to
610602
// be too.

compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(rustdoc_internals)]
55
#![doc(rust_logo)]
66
#![feature(assert_matches)]
7-
#![feature(associated_type_bounds)]
7+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
88
#![feature(box_patterns)]
99
#![feature(control_flow_enum)]
1010
#![feature(let_chains)]

compiler/rustc_codegen_gcc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#![feature(
1919
rustc_private,
2020
decl_macro,
21-
associated_type_bounds,
2221
never_type,
2322
trusted_len,
2423
hash_raw_entry
2524
)]
25+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
2626
#![allow(broken_intra_doc_links)]
2727
#![recursion_limit="256"]
2828
#![warn(rust_2018_idioms)]

compiler/rustc_codegen_ssa/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![allow(internal_features)]
55
#![allow(rustc::diagnostic_outside_of_impl)]
66
#![allow(rustc::untranslatable_diagnostic)]
7-
#![feature(associated_type_bounds)]
7+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
88
#![feature(box_patterns)]
99
#![feature(if_let_guard)]
1010
#![feature(let_chains)]

compiler/rustc_error_codes/src/error_codes/E0719.md

-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ An associated type value was specified more than once.
33
Erroneous code example:
44

55
```compile_fail,E0719
6-
#![feature(associated_type_bounds)]
7-
86
trait FooTrait {}
97
trait BarTrait {}
108
@@ -19,8 +17,6 @@ specify the associated type with the new trait.
1917
Corrected example:
2018

2119
```
22-
#![feature(associated_type_bounds)]
23-
2420
trait FooTrait {}
2521
trait BarTrait {}
2622
trait FooBarTrait: FooTrait + BarTrait {}

compiler/rustc_expand/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![doc(rust_logo)]
22
#![feature(rustdoc_internals)]
33
#![feature(array_windows)]
4-
#![feature(associated_type_bounds)]
4+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
55
#![feature(associated_type_defaults)]
66
#![feature(if_let_guard)]
77
#![feature(let_chains)]

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ declare_features! (
5959
(accepted, asm_sym, "1.66.0", Some(93333)),
6060
/// Allows the definition of associated constants in `trait` or `impl` blocks.
6161
(accepted, associated_consts, "1.20.0", Some(29646)),
62+
/// Allows the user of associated type bounds.
63+
(accepted, associated_type_bounds, "CURRENT_RUSTC_VERSION", Some(52662)),
6264
/// Allows using associated `type`s in `trait`s.
6365
(accepted, associated_types, "1.0.0", None),
6466
/// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ declare_features! (
351351
(unstable, asm_unwind, "1.58.0", Some(93334)),
352352
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
353353
(unstable, associated_const_equality, "1.58.0", Some(92827)),
354-
/// Allows the user of associated type bounds.
355-
(unstable, associated_type_bounds, "1.34.0", Some(52662)),
356354
/// Allows associated type defaults.
357355
(unstable, associated_type_defaults, "1.2.0", Some(29661)),
358356
/// Allows `async || body` closures.

compiler/rustc_infer/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#![allow(internal_features)]
1919
#![allow(rustc::diagnostic_outside_of_impl)]
2020
#![allow(rustc::untranslatable_diagnostic)]
21-
#![feature(associated_type_bounds)]
21+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
2222
#![feature(box_patterns)]
2323
#![feature(control_flow_enum)]
2424
#![feature(extend_one)]

compiler/rustc_middle/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#![feature(trusted_len)]
4949
#![feature(type_alias_impl_trait)]
5050
#![feature(strict_provenance)]
51-
#![feature(associated_type_bounds)]
51+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
5252
#![feature(rustc_attrs)]
5353
#![feature(control_flow_enum)]
5454
#![feature(trait_upcasting)]

compiler/rustc_mir_build/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![allow(rustc::diagnostic_outside_of_impl)]
66
#![allow(rustc::untranslatable_diagnostic)]
77
#![feature(assert_matches)]
8-
#![feature(associated_type_bounds)]
8+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
99
#![feature(box_patterns)]
1010
#![feature(if_let_guard)]
1111
#![feature(let_chains)]

compiler/rustc_parse/src/parser/path.rs

-2
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,6 @@ impl<'a> Parser<'a> {
639639
&& matches!(args.output, ast::FnRetTy::Default(..))
640640
{
641641
self.psess.gated_spans.gate(sym::return_type_notation, span);
642-
} else {
643-
self.psess.gated_spans.gate(sym::associated_type_bounds, span);
644642
}
645643
}
646644
let constraint =

compiler/rustc_serialize/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#![doc(rust_logo)]
99
#![allow(internal_features)]
1010
#![feature(rustdoc_internals)]
11-
#![feature(associated_type_bounds)]
11+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
1212
#![feature(const_option)]
1313
#![feature(core_intrinsics)]
1414
#![feature(generic_nonzero)]

compiler/rustc_trait_selection/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![allow(rustc::diagnostic_outside_of_impl)]
1818
#![allow(rustc::untranslatable_diagnostic)]
1919
#![feature(assert_matches)]
20-
#![feature(associated_type_bounds)]
20+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
2121
#![feature(associated_type_defaults)]
2222
#![feature(box_patterns)]
2323
#![feature(control_flow_enum)]

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
194194
sugg.extend(ty_spans.into_iter().map(|s| (s, type_param_name.to_string())));
195195

196196
// Suggest `fn foo<T: Trait>(t: T) where <T as Trait>::A: Bound`.
197-
// FIXME: once `#![feature(associated_type_bounds)]` is stabilized, we should suggest
198-
// `fn foo(t: impl Trait<A: Bound>)` instead.
197+
// FIXME: we should suggest `fn foo(t: impl Trait<A: Bound>)` instead.
199198
err.multipart_suggestion(
200199
"introduce a type parameter with a trait bound instead of using `impl Trait`",
201200
sugg,

library/alloc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@
172172
//
173173
// Language features:
174174
// tidy-alphabetical-start
175+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
175176
#![cfg_attr(not(test), feature(coroutine_trait))]
176177
#![cfg_attr(test, feature(panic_update_hook))]
177178
#![cfg_attr(test, feature(test))]
178179
#![feature(allocator_internals)]
179180
#![feature(allow_internal_unstable)]
180-
#![feature(associated_type_bounds)]
181181
#![feature(c_unwind)]
182182
#![feature(cfg_sanitize)]
183183
#![feature(const_mut_refs)]

library/alloc/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
12
#![feature(allocator_api)]
23
#![feature(alloc_layout_extra)]
34
#![feature(iter_array_chunks)]
@@ -21,7 +22,6 @@
2122
#![feature(trusted_len)]
2223
#![feature(try_reserve_kind)]
2324
#![feature(unboxed_closures)]
24-
#![feature(associated_type_bounds)]
2525
#![feature(binary_heap_into_iter_sorted)]
2626
#![feature(binary_heap_drain_sorted)]
2727
#![feature(slice_ptr_get)]

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@
202202
//
203203
// Language features:
204204
// tidy-alphabetical-start
205+
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
205206
#![cfg_attr(bootstrap, feature(diagnostic_namespace))]
206207
#![cfg_attr(bootstrap, feature(platform_intrinsics))]
207208
#![feature(abi_unadjusted)]
208209
#![feature(adt_const_params)]
209210
#![feature(allow_internal_unsafe)]
210211
#![feature(allow_internal_unstable)]
211212
#![feature(asm_const)]
212-
#![feature(associated_type_bounds)]
213213
#![feature(auto_traits)]
214214
#![feature(c_unwind)]
215215
#![feature(cfg_sanitize)]

tests/rustdoc-ui/issues/issue-110900.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ check-pass
22

33
#![crate_type="lib"]
4-
#![feature(associated_type_bounds)]
54

65
trait A<'a> {}
76
trait B<'b> {}

tests/ui/associated-consts/issue-93835.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ fn e() {
66
//~| ERROR cannot find value
77
//~| ERROR associated const equality
88
//~| ERROR cannot find trait `p` in this scope
9-
//~| ERROR associated type bounds
109
}
1110

1211
fn main() {}

tests/ui/associated-consts/issue-93835.stderr

+1-11
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,7 @@ LL | type_ascribe!(p, a<p:p<e=6>>);
2626
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
2727
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2828

29-
error[E0658]: associated type bounds are unstable
30-
--> $DIR/issue-93835.rs:4:24
31-
|
32-
LL | type_ascribe!(p, a<p:p<e=6>>);
33-
| ^^^^^^^^
34-
|
35-
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
36-
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
37-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
38-
39-
error: aborting due to 5 previous errors
29+
error: aborting due to 4 previous errors
4030

4131
Some errors have detailed explanations: E0405, E0412, E0425, E0658.
4232
For more information about an error, try `rustc --explain E0405`.

tests/ui/associated-type-bounds/ambiguous-associated-type.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![feature(associated_type_bounds)]
4-
53
pub struct Flatten<I>
64
where
75
I: Iterator<Item: IntoIterator>,

tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// Additionally, as reported in https://github.com/rust-lang/rust/issues/63594,
99
// we check that the spans for the error message are sane here.
1010

11-
#![feature(associated_type_bounds)]
12-
1311
fn main() {}
1412

1513
trait Bar {

tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: associated type bounds are not allowed in `dyn` types
2-
--> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:30:28
2+
--> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:28:28
33
|
44
LL | type Out = Box<dyn Bar<Assoc: Copy>>;
55
| ^^^^^^^^^^^

tests/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![feature(associated_type_bounds)]
4-
53
use std::fmt::Debug;
64
use std::iter::Once;
75

tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(associated_type_bounds)]
2-
31
trait B {
42
type AssocType;
53
}

tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: associated type bounds are not allowed in `dyn` types
2-
--> $DIR/bad-universal-in-dyn-in-where-clause.rs:9:19
2+
--> $DIR/bad-universal-in-dyn-in-where-clause.rs:7:19
33
|
44
LL | dyn for<'j> B<AssocType: 'j>:,
55
| ^^^^^^^^^^^^^

tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(associated_type_bounds)]
2-
31
trait Trait {
42
type Item;
53
}

tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: associated type bounds are not allowed in `dyn` types
2-
--> $DIR/bad-universal-in-impl-sig.rs:10:16
2+
--> $DIR/bad-universal-in-impl-sig.rs:8:16
33
|
44
LL | impl dyn Trait<Item: Trait2> {}
55
| ^^^^^^^^^^^^

tests/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![feature(associated_type_bounds)]
4-
53
use std::fmt::Debug;
64
use std::iter::Empty;
75
use std::ops::Range;

tests/ui/associated-type-bounds/consts.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(associated_type_bounds)]
2-
31
pub fn accept(_: impl Trait<K: Copy>) {}
42
//~^ ERROR expected type, found constant
53

tests/ui/associated-type-bounds/consts.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: expected type, found constant
2-
--> $DIR/consts.rs:3:29
2+
--> $DIR/consts.rs:1:29
33
|
44
LL | pub fn accept(_: impl Trait<K: Copy>) {}
55
| ^------ bounds are not allowed on associated constants
66
| |
77
| unexpected constant
88
|
99
note: the associated constant is defined here
10-
--> $DIR/consts.rs:7:5
10+
--> $DIR/consts.rs:5:5
1111
|
1212
LL | const K: i32;
1313
| ^^^^^^^^^^^^

tests/ui/associated-type-bounds/duplicate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(associated_type_bounds)]
21
#![feature(type_alias_impl_trait)]
32

43
use std::iter;

0 commit comments

Comments
 (0)