Skip to content

Commit 67d984b

Browse files
Stabilize RTN
1 parent 7a08d03 commit 67d984b

File tree

95 files changed

+158
-407
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

+158
-407
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -954,17 +954,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
954954
}
955955
}
956956
};
957-
let mut err = self.dcx().create_err(err);
958-
if !self.tcx.features().return_type_notation()
959-
&& self.tcx.sess.is_nightly_build()
960-
{
961-
add_feature_diagnostics(
962-
&mut err,
963-
&self.tcx.sess,
964-
sym::return_type_notation,
965-
);
966-
}
967-
err.emit();
957+
self.dcx().emit_err(err);
968958
GenericArgsCtor {
969959
args: Default::default(),
970960
constraints: &[],

compiler/rustc_ast_lowering/src/path.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_hir::GenericArg;
66
use rustc_hir::def::{DefKind, PartialRes, Res};
77
use rustc_hir::def_id::DefId;
88
use rustc_middle::span_bug;
9-
use rustc_session::parse::add_feature_diagnostics;
109
use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, kw, sym};
1110
use smallvec::{SmallVec, smallvec};
1211
use tracing::{debug, instrument};
@@ -287,17 +286,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
287286
}
288287
}
289288
};
290-
let mut err = self.dcx().create_err(err);
291-
if !self.tcx.features().return_type_notation()
292-
&& self.tcx.sess.is_nightly_build()
293-
{
294-
add_feature_diagnostics(
295-
&mut err,
296-
&self.tcx.sess,
297-
sym::return_type_notation,
298-
);
299-
}
300-
err.emit();
289+
self.dcx().emit_err(err);
301290
(
302291
GenericArgsCtor {
303292
args: Default::default(),

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
498498
gate_all!(postfix_match, "postfix match is experimental");
499499
gate_all!(mut_ref, "mutable by-reference bindings are experimental");
500500
gate_all!(global_registration, "global registration is experimental");
501-
gate_all!(return_type_notation, "return type notation is experimental");
502501
gate_all!(pin_ergonomics, "pinned reference syntax is experimental");
503502
gate_all!(unsafe_fields, "`unsafe` fields are experimental");
504503
gate_all!(unsafe_binders, "unsafe binder types are experimental");

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ declare_features! (
364364
(accepted, result_ffi_guarantees, "1.84.0", Some(110503)),
365365
/// Allows return-position `impl Trait` in traits.
366366
(accepted, return_position_impl_trait_in_trait, "1.75.0", Some(91611)),
367+
/// Allows bounding the return type of AFIT/RPITIT.
368+
(accepted, return_type_notation, "CURRENT_RUSTC_VERSION", Some(109417)),
367369
/// Allows code like `let x: &'static u32 = &42` to work (RFC 1414).
368370
(accepted, rvalue_static_promotion, "1.21.0", Some(38865)),
369371
/// Allows `Self` in type definitions (RFC 2300).

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,6 @@ declare_features! (
616616
(incomplete, repr128, "1.16.0", Some(56071)),
617617
/// Allows `repr(simd)` and importing the various simd intrinsics.
618618
(unstable, repr_simd, "1.4.0", Some(27731)),
619-
/// Allows bounding the return type of AFIT/RPITIT.
620-
(unstable, return_type_notation, "1.70.0", Some(109417)),
621619
/// Allows `extern "rust-cold"`.
622620
(unstable, rust_cold_cc, "1.63.0", Some(97544)),
623621
/// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,11 @@ fn fn_sig_suggestion<'tcx>(
475475
""
476476
};
477477

478-
let output = if !output.is_unit() { format!(" -> {output}") } else { String::new() };
478+
let output = if !output.is_unit() {
479+
with_types_for_signature!(format!(" -> {output}"))
480+
} else {
481+
String::new()
482+
};
479483

480484
let safety = sig.safety.prefix_str();
481485
let (generics, where_clauses) = bounds_from_generic_predicates(tcx, predicates);

compiler/rustc_lint/src/async_fn_in_trait.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait {
9595
&& let hir::IsAsync::Async(async_span) = sig.header.asyncness
9696
{
9797
// RTN can be used to bound `async fn` in traits in a better way than "always"
98-
if cx.tcx.features().return_type_notation() {
98+
// TODO:
99+
if true {
99100
return;
100101
}
101102

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,15 +1339,17 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
13391339
def_id: DefId,
13401340
args: ty::GenericArgsRef<'tcx>,
13411341
) -> Result<(), PrintError> {
1342-
let fn_args = if self.tcx().features().return_type_notation()
1343-
&& let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) =
1344-
self.tcx().opt_rpitit_info(def_id)
1342+
let fn_args = if let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) =
1343+
self.tcx().opt_rpitit_info(def_id)
13451344
&& let ty::Alias(_, alias_ty) =
13461345
self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind()
13471346
&& alias_ty.def_id == def_id
13481347
&& let generics = self.tcx().generics_of(fn_def_id)
13491348
// FIXME(return_type_notation): We only support lifetime params for now.
1350-
&& generics.own_params.iter().all(|param| matches!(param.kind, ty::GenericParamDefKind::Lifetime))
1349+
&& generics
1350+
.own_params
1351+
.iter()
1352+
.all(|param| matches!(param.kind, ty::GenericParamDefKind::Lifetime))
13511353
{
13521354
let num_args = generics.count();
13531355
Some((fn_def_id, &args[..num_args]))

compiler/rustc_parse/src/parser/path.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,6 @@ impl<'a> Parser<'a> {
377377
self.expect(exp!(CloseParen))?;
378378
let span = lo.to(self.prev_token.span);
379379

380-
self.psess.gated_spans.gate(sym::return_type_notation, span);
381-
382380
let prev_lo = self.prev_token.span.shrink_to_hi();
383381
if self.eat_noexpect(&token::RArrow) {
384382
let lo = self.prev_token.span;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
524524
}
525525

526526
self.explain_hrtb_projection(&mut err, leaf_trait_predicate, obligation.param_env, &obligation.cause);
527-
self.suggest_desugaring_async_fn_in_trait(&mut err, main_trait_predicate);
528527

529528
// Return early if the trait is Debug or Display and the invocation
530529
// originates within a standard library macro, because the output

0 commit comments

Comments
 (0)