Skip to content

Commit e8c04b4

Browse files
committed
Remove impl_trait_in_bindings feature flag
1 parent 75585b4 commit e8c04b4

File tree

63 files changed

+384
-737
lines changed

Some content is hidden

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

63 files changed

+384
-737
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,20 +1460,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14601460
}),
14611461
))
14621462
}
1463-
ImplTraitContext::Disallowed(pos) => {
1463+
ImplTraitContext::Disallowed(_) => {
14641464
let mut err = struct_span_err!(
14651465
self.sess,
14661466
t.span,
14671467
E0562,
14681468
"`impl Trait` not allowed outside of {}",
14691469
"function and inherent method return types",
14701470
);
1471-
if pos == ImplTraitPosition::Binding && self.sess.is_nightly_build() {
1472-
err.help(
1473-
"add `#![feature(impl_trait_in_bindings)]` to the crate \
1474-
attributes to enable",
1475-
);
1476-
}
14771471
err.emit();
14781472
hir::TyKind::Err
14791473
}

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,6 @@ declare_features! (
455455
/// Allows non-builtin attributes in inner attribute position.
456456
(active, custom_inner_attributes, "1.30.0", Some(54726), None),
457457

458-
/// Allows `impl Trait` in bindings (`let`, `const`, `static`).
459-
(incomplete, impl_trait_in_bindings, "1.30.0", Some(63065), None),
460-
461458
/// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.
462459
(active, lint_reasons, "1.31.0", Some(54503), None),
463460

compiler/rustc_feature/src/removed.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ declare_features! (
148148
(removed, const_raw_ptr_to_usize_cast, "1.55.0", Some(51910), None,
149149
Some("at compile-time, pointers do not have an integer value, so these casts cannot be properly supported")),
150150

151+
/// Allows `impl Trait` in bindings (`let`, `const`, `static`).
152+
(removed, impl_trait_in_bindings, "1.55.0", Some(63065), None,
153+
Some("removed due to being incomplete and unstable")),
154+
151155
// -------------------------------------------------------------------------
152156
// feature-group-end: removed features
153157
// -------------------------------------------------------------------------

compiler/rustc_typeck/src/check/check.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ pub(super) fn check_fn<'a, 'tcx>(
221221
fcx.resume_yield_tys = Some((resume_ty, yield_ty));
222222
}
223223

224-
let outer_def_id = tcx.closure_base_def_id(hir.local_def_id(fn_id).to_def_id()).expect_local();
225-
let outer_hir_id = hir.local_def_id_to_hir_id(outer_def_id);
226-
GatherLocalsVisitor::new(&fcx, outer_hir_id).visit_body(body);
224+
GatherLocalsVisitor::new(&fcx).visit_body(body);
227225

228226
// C-variadic fns also have a `VaList` input that's not listed in `fn_sig`
229227
// (as it's created inside the body itself, not passed in from outside).

compiler/rustc_typeck/src/check/gather_locals.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
44
use rustc_hir::PatKind;
55
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
66
use rustc_middle::ty::Ty;
7-
use rustc_span::{sym, Span};
7+
use rustc_span::Span;
88
use rustc_trait_selection::traits;
99

1010
pub(super) struct GatherLocalsVisitor<'a, 'tcx> {
1111
fcx: &'a FnCtxt<'a, 'tcx>,
12-
parent_id: hir::HirId,
1312
// parameters are special cases of patterns, but we want to handle them as
1413
// *distinct* cases. so track when we are hitting a pattern *within* an fn
1514
// parameter.
1615
outermost_fn_param_pat: Option<Span>,
1716
}
1817

1918
impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
20-
pub(super) fn new(fcx: &'a FnCtxt<'a, 'tcx>, parent_id: hir::HirId) -> Self {
21-
Self { fcx, parent_id, outermost_fn_param_pat: None }
19+
pub(super) fn new(fcx: &'a FnCtxt<'a, 'tcx>) -> Self {
20+
Self { fcx, outermost_fn_param_pat: None }
2221
}
2322

2423
fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
@@ -57,26 +56,15 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
5756
Some(ref ty) => {
5857
let o_ty = self.fcx.to_ty(&ty);
5958

60-
let revealed_ty = self.fcx.instantiate_opaque_types_from_value(
61-
self.parent_id,
62-
o_ty,
63-
ty.span,
64-
Some(sym::impl_trait_in_bindings),
65-
);
66-
67-
let c_ty =
68-
self.fcx.inh.infcx.canonicalize_user_type_annotation(UserType::Ty(revealed_ty));
69-
debug!(
70-
"visit_local: ty.hir_id={:?} o_ty={:?} revealed_ty={:?} c_ty={:?}",
71-
ty.hir_id, o_ty, revealed_ty, c_ty
72-
);
59+
let c_ty = self.fcx.inh.infcx.canonicalize_user_type_annotation(UserType::Ty(o_ty));
60+
debug!("visit_local: ty.hir_id={:?} o_ty={:?} c_ty={:?}", ty.hir_id, o_ty, c_ty);
7361
self.fcx
7462
.typeck_results
7563
.borrow_mut()
7664
.user_provided_types_mut()
7765
.insert(ty.hir_id, c_ty);
7866

79-
Some(LocalTy { decl_ty: o_ty, revealed_ty })
67+
Some(LocalTy { decl_ty: o_ty, revealed_ty: o_ty })
8068
}
8169
None => None,
8270
};

compiler/rustc_typeck/src/check/mod.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ use rustc_middle::ty::{self, Ty, TyCtxt, UserType};
118118
use rustc_session::config;
119119
use rustc_session::parse::feature_err;
120120
use rustc_session::Session;
121+
use rustc_span::source_map::DUMMY_SP;
121122
use rustc_span::symbol::{kw, Ident};
122123
use rustc_span::{self, BytePos, MultiSpan, Span};
123-
use rustc_span::{source_map::DUMMY_SP, sym};
124124
use rustc_target::abi::VariantIdx;
125125
use rustc_target::spec::abi::Abi;
126126
use rustc_trait_selection::traits;
@@ -441,19 +441,12 @@ fn typeck_with_fallback<'tcx>(
441441
let expected_type = fcx.normalize_associated_types_in(body.value.span, expected_type);
442442
fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized);
443443

444-
let revealed_ty = fcx.instantiate_opaque_types_from_value(
445-
id,
446-
expected_type,
447-
body.value.span,
448-
Some(sym::impl_trait_in_bindings),
449-
);
450-
451444
// Gather locals in statics (because of block expressions).
452-
GatherLocalsVisitor::new(&fcx, id).visit_body(body);
445+
GatherLocalsVisitor::new(&fcx).visit_body(body);
453446

454-
fcx.check_expr_coercable_to_type(&body.value, revealed_ty, None);
447+
fcx.check_expr_coercable_to_type(&body.value, expected_type, None);
455448

456-
fcx.write_ty(id, revealed_ty);
449+
fcx.write_ty(id, expected_type);
457450

458451
fcx
459452
};

src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)