Skip to content

Commit 61b6abd

Browse files
Stabilize RTN
1 parent 7a08d03 commit 61b6abd

File tree

91 files changed

+147
-394
lines changed

Some content is hidden

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

91 files changed

+147
-394
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/compare_impl_item.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
1313
use rustc_infer::traits::util;
1414
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1515
use rustc_middle::ty::fold::BottomUpFolder;
16+
use rustc_middle::ty::print::with_types_for_signature;
1617
use rustc_middle::ty::util::ExplicitSelf;
1718
use rustc_middle::ty::{
1819
self, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeFolder,
@@ -1058,11 +1059,12 @@ fn report_trait_method_mismatch<'tcx>(
10581059
let ap = Applicability::MachineApplicable;
10591060
match sig.decl.output {
10601061
hir::FnRetTy::DefaultReturn(sp) => {
1061-
let sugg = format!(" -> {}", trait_sig.output());
1062+
let sugg =
1063+
with_types_for_signature!(format!(" -> {}", trait_sig.output()));
10621064
diag.span_suggestion_verbose(sp, msg, sugg, ap);
10631065
}
10641066
hir::FnRetTy::Return(hir_ty) => {
1065-
let sugg = trait_sig.output();
1067+
let sugg = with_types_for_signature!(trait_sig.output().to_string());
10661068
diag.span_suggestion_verbose(hir_ty.span, msg, sugg, ap);
10671069
}
10681070
};

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint_defs::builtin::{REFINING_IMPL_TRAIT_INTERNAL, REFINING_IMPL_TRAIT_REACHABLE};
77
use rustc_middle::span_bug;
88
use rustc_middle::traits::ObligationCause;
9+
use rustc_middle::ty::print::with_types_for_signature;
910
use rustc_middle::ty::{
1011
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable,
1112
TypeVisitableExt, TypeVisitor, TypingMode,
@@ -333,7 +334,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
333334
});
334335

335336
let span = unmatched_bound.unwrap_or(span);
336-
tcx.emit_node_span_lint(
337+
with_types_for_signature!(tcx.emit_node_span_lint(
337338
if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE },
338339
tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()),
339340
span,
@@ -345,7 +346,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
345346
return_ty,
346347
unmatched_bound,
347348
},
348-
);
349+
));
349350
}
350351

351352
fn type_visibility<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<ty::Visibility<DefId>> {

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]))

0 commit comments

Comments
 (0)