Skip to content

Commit c091b5c

Browse files
committed
Remove a useless feature gateing
With the planned lazy TAIT system, this will not really make sense anymore anyway.
1 parent a30b548 commit c091b5c

File tree

6 files changed

+5
-100
lines changed

6 files changed

+5
-100
lines changed

compiler/rustc_typeck/src/check/check.rs

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -94,69 +94,8 @@ pub(super) fn check_fn<'a, 'tcx>(
9494

9595
let declared_ret_ty = fn_sig.output();
9696

97-
let feature = match tcx.hir().get(fn_id) {
98-
// TAIT usage in function return position.
99-
// Example:
100-
//
101-
// ```rust
102-
// type Foo = impl Debug;
103-
// fn bar() -> Foo { 42 }
104-
// ```
105-
Node::Item(hir::Item { kind: ItemKind::Fn(..), .. }) |
106-
// TAIT usage in associated function return position.
107-
//
108-
// Example with a free type alias:
109-
//
110-
// ```rust
111-
// type Foo = impl Debug;
112-
// impl SomeTrait for SomeType {
113-
// fn bar() -> Foo { 42 }
114-
// }
115-
// ```
116-
//
117-
// Example with an associated TAIT:
118-
//
119-
// ```rust
120-
// impl SomeTrait for SomeType {
121-
// type Foo = impl Debug;
122-
// fn bar() -> Self::Foo { 42 }
123-
// }
124-
// ```
125-
Node::ImplItem(hir::ImplItem {
126-
kind: hir::ImplItemKind::Fn(..), ..
127-
}) => None,
128-
// Forbid TAIT in trait declarations for now.
129-
// Examples:
130-
//
131-
// ```rust
132-
// type Foo = impl Debug;
133-
// trait Bar {
134-
// fn bar() -> Foo;
135-
// }
136-
// trait Bop {
137-
// type Bop: PartialEq<Foo>;
138-
// }
139-
// ```
140-
Node::TraitItem(hir::TraitItem {
141-
kind: hir::TraitItemKind::Fn(..),
142-
..
143-
}) |
144-
// Forbid TAIT in closure return position for now.
145-
// Example:
146-
//
147-
// ```rust
148-
// type Foo = impl Debug;
149-
// let x = |y| -> Foo { 42 + y };
150-
// ```
151-
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => Some(sym::type_alias_impl_trait),
152-
node => bug!("Item being checked wasn't a function/closure: {:?}", node),
153-
};
154-
let revealed_ret_ty = fcx.instantiate_opaque_types_from_value(
155-
fn_id,
156-
declared_ret_ty,
157-
decl.output.span(),
158-
feature,
159-
);
97+
let revealed_ret_ty =
98+
fcx.instantiate_opaque_types_from_value(fn_id, declared_ret_ty, decl.output.span());
16099
debug!("check_fn: declared_ret_ty: {}, revealed_ret_ty: {}", declared_ret_ty, revealed_ret_ty);
161100
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(revealed_ret_ty)));
162101
fcx.ret_type_span = Some(decl.output.span());

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ use rustc_middle::ty::{
2929
};
3030
use rustc_session::lint;
3131
use rustc_session::lint::builtin::BARE_TRAIT_OBJECTS;
32-
use rustc_session::parse::feature_err;
3332
use rustc_span::edition::Edition;
33+
use rustc_span::hygiene::DesugaringKind;
3434
use rustc_span::source_map::{original_sp, DUMMY_SP};
3535
use rustc_span::symbol::{kw, sym, Ident};
3636
use rustc_span::{self, BytePos, MultiSpan, Span};
37-
use rustc_span::{hygiene::DesugaringKind, Symbol};
3837
use rustc_trait_selection::infer::InferCtxtExt as _;
3938
use rustc_trait_selection::opaque_types::InferCtxtExt as _;
4039
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
@@ -368,7 +367,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
368367
parent_id: hir::HirId,
369368
value: T,
370369
value_span: Span,
371-
feature: Option<Symbol>,
372370
) -> T {
373371
let parent_def_id = self.tcx.hir().local_def_id(parent_id);
374372
debug!(
@@ -388,19 +386,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
388386
let mut infcx = self.infcx.inner.borrow_mut();
389387

390388
for (ty, decl) in opaque_type_map {
391-
if let Some(feature) = feature {
392-
if let hir::OpaqueTyOrigin::TyAlias = decl.origin {
393-
if !self.tcx.features().enabled(feature) {
394-
feature_err(
395-
&self.tcx.sess.parse_sess,
396-
feature,
397-
value_span,
398-
"type alias impl trait is not permitted here",
399-
)
400-
.emit();
401-
}
402-
}
403-
}
404389
let _ = infcx.opaque_types.insert(ty, decl);
405390
let _ = infcx.opaque_types_vars.insert(decl.concrete_ty, decl.opaque_type);
406391
}

src/test/ui/type-alias-impl-trait/issue-60371.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ impl Bug for &() {
1111
//~^ ERROR the trait bound `(): Bug` is not satisfied
1212

1313
const FUN: fn() -> Self::Item = || ();
14-
//~^ ERROR type alias impl trait is not permitted here
1514
}
1615

1716
fn main() {}

src/test/ui/type-alias-impl-trait/issue-60371.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ LL | type Item = impl Bug;
77
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
88
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
99

10-
error[E0658]: type alias impl trait is not permitted here
11-
--> $DIR/issue-60371.rs:13:40
12-
|
13-
LL | const FUN: fn() -> Self::Item = || ();
14-
| ^
15-
|
16-
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
17-
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
18-
1910
error[E0277]: the trait bound `(): Bug` is not satisfied
2011
--> $DIR/issue-60371.rs:10:17
2112
|
@@ -25,7 +16,7 @@ LL | type Item = impl Bug;
2516
= help: the following implementations were found:
2617
<&() as Bug>
2718

28-
error: aborting due to 3 previous errors
19+
error: aborting due to 2 previous errors
2920

3021
Some errors have detailed explanations: E0277, E0658.
3122
For more information about an error, try `rustc --explain E0277`.

src/test/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// compile-flags: -Zsave-analysis
2+
// check-pass
23

34
#![feature(type_alias_impl_trait, rustc_attrs)]
45

@@ -11,9 +12,7 @@ type T = impl Sized;
1112

1213
fn take(_: fn() -> T) {}
1314

14-
#[rustc_error]
1515
fn main() {
16-
//~^ ERROR fatal error triggered by #[rustc_error]
1716
take(|| {});
1817
take(|| {});
1918
}

src/test/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.stderr

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

0 commit comments

Comments
 (0)