Remove a useless feature gateing
With the planned lazy TAIT system, this will not really make sense anymore anyway.
This commit is contained in:
parent
a30b548919
commit
c091b5c84c
6 changed files with 5 additions and 100 deletions
|
@ -94,69 +94,8 @@ pub(super) fn check_fn<'a, 'tcx>(
|
||||||
|
|
||||||
let declared_ret_ty = fn_sig.output();
|
let declared_ret_ty = fn_sig.output();
|
||||||
|
|
||||||
let feature = match tcx.hir().get(fn_id) {
|
let revealed_ret_ty =
|
||||||
// TAIT usage in function return position.
|
fcx.instantiate_opaque_types_from_value(fn_id, declared_ret_ty, decl.output.span());
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// ```rust
|
|
||||||
// type Foo = impl Debug;
|
|
||||||
// fn bar() -> Foo { 42 }
|
|
||||||
// ```
|
|
||||||
Node::Item(hir::Item { kind: ItemKind::Fn(..), .. }) |
|
|
||||||
// TAIT usage in associated function return position.
|
|
||||||
//
|
|
||||||
// Example with a free type alias:
|
|
||||||
//
|
|
||||||
// ```rust
|
|
||||||
// type Foo = impl Debug;
|
|
||||||
// impl SomeTrait for SomeType {
|
|
||||||
// fn bar() -> Foo { 42 }
|
|
||||||
// }
|
|
||||||
// ```
|
|
||||||
//
|
|
||||||
// Example with an associated TAIT:
|
|
||||||
//
|
|
||||||
// ```rust
|
|
||||||
// impl SomeTrait for SomeType {
|
|
||||||
// type Foo = impl Debug;
|
|
||||||
// fn bar() -> Self::Foo { 42 }
|
|
||||||
// }
|
|
||||||
// ```
|
|
||||||
Node::ImplItem(hir::ImplItem {
|
|
||||||
kind: hir::ImplItemKind::Fn(..), ..
|
|
||||||
}) => None,
|
|
||||||
// Forbid TAIT in trait declarations for now.
|
|
||||||
// Examples:
|
|
||||||
//
|
|
||||||
// ```rust
|
|
||||||
// type Foo = impl Debug;
|
|
||||||
// trait Bar {
|
|
||||||
// fn bar() -> Foo;
|
|
||||||
// }
|
|
||||||
// trait Bop {
|
|
||||||
// type Bop: PartialEq<Foo>;
|
|
||||||
// }
|
|
||||||
// ```
|
|
||||||
Node::TraitItem(hir::TraitItem {
|
|
||||||
kind: hir::TraitItemKind::Fn(..),
|
|
||||||
..
|
|
||||||
}) |
|
|
||||||
// Forbid TAIT in closure return position for now.
|
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// ```rust
|
|
||||||
// type Foo = impl Debug;
|
|
||||||
// let x = |y| -> Foo { 42 + y };
|
|
||||||
// ```
|
|
||||||
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => Some(sym::type_alias_impl_trait),
|
|
||||||
node => bug!("Item being checked wasn't a function/closure: {:?}", node),
|
|
||||||
};
|
|
||||||
let revealed_ret_ty = fcx.instantiate_opaque_types_from_value(
|
|
||||||
fn_id,
|
|
||||||
declared_ret_ty,
|
|
||||||
decl.output.span(),
|
|
||||||
feature,
|
|
||||||
);
|
|
||||||
debug!("check_fn: declared_ret_ty: {}, revealed_ret_ty: {}", declared_ret_ty, revealed_ret_ty);
|
debug!("check_fn: declared_ret_ty: {}, revealed_ret_ty: {}", declared_ret_ty, revealed_ret_ty);
|
||||||
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(revealed_ret_ty)));
|
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(revealed_ret_ty)));
|
||||||
fcx.ret_type_span = Some(decl.output.span());
|
fcx.ret_type_span = Some(decl.output.span());
|
||||||
|
|
|
@ -29,12 +29,11 @@ use rustc_middle::ty::{
|
||||||
};
|
};
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use rustc_session::lint::builtin::BARE_TRAIT_OBJECTS;
|
use rustc_session::lint::builtin::BARE_TRAIT_OBJECTS;
|
||||||
use rustc_session::parse::feature_err;
|
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
|
use rustc_span::hygiene::DesugaringKind;
|
||||||
use rustc_span::source_map::{original_sp, DUMMY_SP};
|
use rustc_span::source_map::{original_sp, DUMMY_SP};
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
use rustc_span::{self, BytePos, MultiSpan, Span};
|
use rustc_span::{self, BytePos, MultiSpan, Span};
|
||||||
use rustc_span::{hygiene::DesugaringKind, Symbol};
|
|
||||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::opaque_types::InferCtxtExt as _;
|
use rustc_trait_selection::opaque_types::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
|
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
|
||||||
|
@ -368,7 +367,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
parent_id: hir::HirId,
|
parent_id: hir::HirId,
|
||||||
value: T,
|
value: T,
|
||||||
value_span: Span,
|
value_span: Span,
|
||||||
feature: Option<Symbol>,
|
|
||||||
) -> T {
|
) -> T {
|
||||||
let parent_def_id = self.tcx.hir().local_def_id(parent_id);
|
let parent_def_id = self.tcx.hir().local_def_id(parent_id);
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -388,19 +386,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut infcx = self.infcx.inner.borrow_mut();
|
let mut infcx = self.infcx.inner.borrow_mut();
|
||||||
|
|
||||||
for (ty, decl) in opaque_type_map {
|
for (ty, decl) in opaque_type_map {
|
||||||
if let Some(feature) = feature {
|
|
||||||
if let hir::OpaqueTyOrigin::TyAlias = decl.origin {
|
|
||||||
if !self.tcx.features().enabled(feature) {
|
|
||||||
feature_err(
|
|
||||||
&self.tcx.sess.parse_sess,
|
|
||||||
feature,
|
|
||||||
value_span,
|
|
||||||
"type alias impl trait is not permitted here",
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let _ = infcx.opaque_types.insert(ty, decl);
|
let _ = infcx.opaque_types.insert(ty, decl);
|
||||||
let _ = infcx.opaque_types_vars.insert(decl.concrete_ty, decl.opaque_type);
|
let _ = infcx.opaque_types_vars.insert(decl.concrete_ty, decl.opaque_type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ impl Bug for &() {
|
||||||
//~^ ERROR the trait bound `(): Bug` is not satisfied
|
//~^ ERROR the trait bound `(): Bug` is not satisfied
|
||||||
|
|
||||||
const FUN: fn() -> Self::Item = || ();
|
const FUN: fn() -> Self::Item = || ();
|
||||||
//~^ ERROR type alias impl trait is not permitted here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,15 +7,6 @@ LL | type Item = impl Bug;
|
||||||
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
|
||||||
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
|
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: type alias impl trait is not permitted here
|
|
||||||
--> $DIR/issue-60371.rs:13:40
|
|
||||||
|
|
|
||||||
LL | const FUN: fn() -> Self::Item = || ();
|
|
||||||
| ^
|
|
||||||
|
|
|
||||||
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
|
|
||||||
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error[E0277]: the trait bound `(): Bug` is not satisfied
|
error[E0277]: the trait bound `(): Bug` is not satisfied
|
||||||
--> $DIR/issue-60371.rs:10:17
|
--> $DIR/issue-60371.rs:10:17
|
||||||
|
|
|
|
||||||
|
@ -25,7 +16,7 @@ LL | type Item = impl Bug;
|
||||||
= help: the following implementations were found:
|
= help: the following implementations were found:
|
||||||
<&() as Bug>
|
<&() as Bug>
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0658.
|
Some errors have detailed explanations: E0277, E0658.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// compile-flags: -Zsave-analysis
|
// compile-flags: -Zsave-analysis
|
||||||
|
// check-pass
|
||||||
|
|
||||||
#![feature(type_alias_impl_trait, rustc_attrs)]
|
#![feature(type_alias_impl_trait, rustc_attrs)]
|
||||||
|
|
||||||
|
@ -11,9 +12,7 @@ type T = impl Sized;
|
||||||
|
|
||||||
fn take(_: fn() -> T) {}
|
fn take(_: fn() -> T) {}
|
||||||
|
|
||||||
#[rustc_error]
|
|
||||||
fn main() {
|
fn main() {
|
||||||
//~^ ERROR fatal error triggered by #[rustc_error]
|
|
||||||
take(|| {});
|
take(|| {});
|
||||||
take(|| {});
|
take(|| {});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
error: fatal error triggered by #[rustc_error]
|
|
||||||
--> $DIR/issue-65679-inst-opaque-ty-from-val-twice.rs:15:1
|
|
||||||
|
|
|
||||||
LL | fn main() {
|
|
||||||
| ^^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue