Only allow tait defining uses in function and method return position

This commit is contained in:
Oli Scherer 2021-03-12 12:02:29 +00:00
parent cdbb0ff8ca
commit 4a6dc8e203
41 changed files with 384 additions and 113 deletions

View File

@ -87,8 +87,26 @@ pub(super) fn check_fn<'a, 'tcx>(
let declared_ret_ty = fn_sig.output();
let revealed_ret_ty =
fcx.instantiate_opaque_types_from_value(fn_id, declared_ret_ty, decl.output.span());
let feature = match tcx.hir().get(fn_id) {
Node::Item(hir::Item { kind: ItemKind::Fn(..), .. }) |
Node::ImplItem(hir::ImplItem {
kind: hir::ImplItemKind::Fn(..), ..
}) => None,
// I don't know if TAIT uses in trait declarations make sense at all
Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Fn(..),
..
}) |
// Forbid TAIT in closure return position for now.
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);
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(revealed_ret_ty)));
fcx.ret_type_span = Some(decl.output.span());

View File

@ -26,11 +26,11 @@ use rustc_middle::ty::{
self, AdtKind, CanonicalUserType, DefIdTree, GenericParamDefKind, ToPolyTraitRef, ToPredicate,
Ty, UserType,
};
use rustc_session::lint;
use rustc_span::hygiene::DesugaringKind;
use rustc_session::{lint, parse::feature_err};
use rustc_span::source_map::{original_sp, DUMMY_SP};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{self, BytePos, MultiSpan, Span};
use rustc_span::{hygiene::DesugaringKind, Symbol};
use rustc_trait_selection::infer::InferCtxtExt as _;
use rustc_trait_selection::opaque_types::InferCtxtExt as _;
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
@ -362,6 +362,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
parent_id: hir::HirId,
value: T,
value_span: Span,
feature: Option<Symbol>,
) -> T {
let parent_def_id = self.tcx.hir().local_def_id(parent_id);
debug!(
@ -380,7 +381,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut opaque_types = self.opaque_types.borrow_mut();
let mut opaque_types_vars = self.opaque_types_vars.borrow_mut();
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 _ = opaque_types.insert(ty, decl);
let _ = opaque_types_vars.insert(decl.concrete_ty, decl.opaque_type);
}

View File

@ -4,7 +4,7 @@ use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::PatKind;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_middle::ty::Ty;
use rustc_span::Span;
use rustc_span::{sym, Span};
use rustc_trait_selection::traits;
use std::mem;
@ -58,11 +58,12 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
Some(ref ty) => {
let o_ty = self.fcx.to_ty(&ty);
let revealed_ty = if self.fcx.tcx.features().impl_trait_in_bindings {
self.fcx.instantiate_opaque_types_from_value(self.parent_id, o_ty, ty.span)
} else {
o_ty
};
let revealed_ty = self.fcx.instantiate_opaque_types_from_value(
self.parent_id,
o_ty,
ty.span,
Some(sym::impl_trait_in_bindings),
);
let c_ty =
self.fcx.inh.infcx.canonicalize_user_type_annotation(UserType::Ty(revealed_ty));

View File

@ -121,9 +121,9 @@ use rustc_middle::ty::{self, RegionKind, Ty, TyCtxt, UserType};
use rustc_session::config;
use rustc_session::parse::feature_err;
use rustc_session::Session;
use rustc_span::source_map::DUMMY_SP;
use rustc_span::symbol::{kw, Ident};
use rustc_span::{self, BytePos, MultiSpan, Span};
use rustc_span::{source_map::DUMMY_SP, sym};
use rustc_target::abi::VariantIdx;
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::traits;
@ -547,11 +547,12 @@ fn typeck_with_fallback<'tcx>(
let expected_type = fcx.normalize_associated_types_in(body.value.span, expected_type);
fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized);
let revealed_ty = if tcx.features().impl_trait_in_bindings {
fcx.instantiate_opaque_types_from_value(id, expected_type, body.value.span)
} else {
expected_type
};
let revealed_ty = fcx.instantiate_opaque_types_from_value(
id,
expected_type,
body.value.span,
Some(sym::impl_trait_in_bindings),
);
// Gather locals in statics (because of block expressions).
GatherLocalsVisitor::new(&fcx, id).visit_body(body);

View File

@ -13,7 +13,7 @@ fn define() -> Bar {
type Foo2 = impl Debug;
fn define2() {
let x = || -> Foo2 { 42 };
let x = || -> Foo2 { 42 }; //~ ERROR not permitted here
}
type Foo3 = impl Debug;
@ -31,7 +31,7 @@ type Foo4 = impl Debug;
fn define4() {
let y: Foo4 = 42;
//~^ ERROR mismatched types
//~^ ERROR not permitted here
}
fn main() {}

View File

@ -10,6 +10,15 @@ LL | Bar(42)
= note: expected opaque type `impl Debug`
found type `{integer}`
error[E0658]: type alias impl trait is not permitted here
--> $DIR/feature-gate-type_alias_impl_trait.rs:16:19
|
LL | let x = || -> Foo2 { 42 };
| ^^^^
|
= 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[E0308]: mismatched types
--> $DIR/feature-gate-type_alias_impl_trait.rs:23:18
|
@ -36,19 +45,14 @@ LL | define3(42)
= note: expected opaque type `impl Debug`
found type `{integer}`
error[E0308]: mismatched types
--> $DIR/feature-gate-type_alias_impl_trait.rs:33:19
error[E0658]: type alias impl trait is not permitted here
--> $DIR/feature-gate-type_alias_impl_trait.rs:33:12
|
LL | type Foo4 = impl Debug;
| ---------- the expected opaque type
...
LL | let y: Foo4 = 42;
| ---- ^^ expected opaque type, found integer
| |
| expected due to this
| ^^^^
|
= note: expected opaque type `impl Debug`
found type `{integer}`
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: could not find defining uses
--> $DIR/feature-gate-type_alias_impl_trait.rs:5:12
@ -68,6 +72,7 @@ error: could not find defining uses
LL | type Foo4 = impl Debug;
| ^^^^^^^^^^
error: aborting due to 7 previous errors
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0308`.
Some errors have detailed explanations: E0308, E0658.
For more information about an error, try `rustc --explain E0308`.

View File

@ -4,6 +4,37 @@ error[E0425]: cannot find value `Foo` in this scope
LL | let a = Foo;
| ^^^ not found in this scope
error: aborting due to previous error
error[E0658]: type alias impl trait is not permitted here
--> $DIR/layout-error.rs:31:27
|
LL | Task::spawn(&POOL, || cb());
| ^
|
= 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
For more information about this error, try `rustc --explain E0425`.
error[E0658]: type alias impl trait is not permitted here
--> $DIR/layout-error.rs:30:28
|
LL | static POOL: Task<F> = Task::new();
| ^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: concrete type differs from previous defining opaque type use
--> $DIR/layout-error.rs:31:24
|
LL | Task::spawn(&POOL, || cb());
| ^^^^^^^ expected `[type error]`, got `impl Future`
|
note: previous use here
--> $DIR/layout-error.rs:30:5
|
LL | static POOL: Task<F> = Task::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0425, E0658.
For more information about an error, try `rustc --explain E0425`.

View File

@ -12,7 +12,7 @@ use std::future::Future;
pub struct Task<F: Future>(F);
impl<F: Future> Task<F> {
fn new() -> Self {
const fn new() -> Self {
todo!()
}
fn spawn(&self, _: impl FnOnce() -> F) {
@ -27,6 +27,7 @@ fn main() {
type F = impl Future;
// Check that statics are inhabited computes they layout.
static POOL: Task<F> = Task::new();
Task::spawn(&POOL, || cb());
static POOL: Task<F> = Task::new(); //[min_tait]~ ERROR not permitted here
Task::spawn(&POOL, || cb()); //[min_tait]~ ERROR type alias impl trait is not permitted here
//[min_tait]~^ ERROR concrete type differs from previous
}

View File

@ -1,5 +1,5 @@
warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/metadata-sufficient-for-layout.rs:11:32
--> $DIR/metadata-sufficient-for-layout.rs:10:32
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^
@ -8,12 +8,18 @@ LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_binding
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/metadata-sufficient-for-layout.rs:11:55
--> $DIR/metadata-sufficient-for-layout.rs:10:55
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
warning: 2 warnings emitted
error: fatal error triggered by #[rustc_error]
--> $DIR/metadata-sufficient-for-layout.rs:29:1
|
LL | fn main() {}
| ^^^^^^^^^
error: aborting due to previous error; 2 warnings emitted

View File

@ -0,0 +1,24 @@
error[E0658]: type alias impl trait is not permitted here
--> $DIR/metadata-sufficient-for-layout.rs:22:23
|
LL | static A: Option<F> = None;
| ^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: concrete type differs from previous defining opaque type use
--> $DIR/metadata-sufficient-for-layout.rs:25:1
|
LL | fn f() -> F { metadata_sufficient_for_layout::g() }
| ^^^^^^^^^^^ expected `[type error]`, got `impl Generator`
|
note: previous use here
--> $DIR/metadata-sufficient-for-layout.rs:22:1
|
LL | static A: Option<F> = None;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -4,10 +4,9 @@
// Regression test for #80998.
//
// aux-build:metadata-sufficient-for-layout.rs
// check-pass
// revisions: min_tait full_tait
#![feature(min_type_alias_impl_trait)]
#![feature(min_type_alias_impl_trait, rustc_attrs)]
#![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
//[full_tait]~^ WARN incomplete
//[full_tait]~| WARN incomplete
@ -21,7 +20,10 @@ type F = impl Generator<(), Yield = (), Return = ()>;
// Static queries the layout of the generator.
static A: Option<F> = None;
//[min_tait]~^ ERROR not permitted here
fn f() -> F { metadata_sufficient_for_layout::g() }
//[min_tait]~^ ERROR concrete type differs
fn main() {}
#[rustc_error]
fn main() {} //[full_tait]~ ERROR

View File

@ -7,11 +7,15 @@ LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
error: fatal error triggered by #[rustc_error]
--> $DIR/issue-75053.rs:51:1
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-75053.rs:52:15
|
LL | fn main() {
| ^^^^^^^^^
LL | let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0658`.

View File

@ -8,7 +8,7 @@ LL | #![cfg_attr(in_bindings, feature(impl_trait_in_bindings))]
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
error[E0282]: type annotations needed
--> $DIR/issue-75053.rs:53:38
--> $DIR/issue-75053.rs:52:38
|
LL | type O;
| ------- `<Self as MyIndex<T>>::O` defined here

View File

@ -1,8 +1,12 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/issue-75053.rs:51:1
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-75053.rs:52:15
|
LL | fn main() {
| ^^^^^^^^^
LL | let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -49,7 +49,6 @@ impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
#[rustc_error]
fn main() {
//[min_tait,full_tait]~^ ERROR rustc_error
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index(); //[min_tait,full_tait]~ ERROR not permitted here
//[in_bindings]~^ ERROR type annotations needed
}

View File

@ -1,8 +1,17 @@
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-52843-closure-constrain.rs:13:22
|
LL | let null = || -> Opaque { 0 };
| ^^^^^^
|
= 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: concrete type differs from previous defining opaque type use
--> $DIR/issue-52843-closure-constrain.rs:13:16
|
LL | let null = || -> Opaque { 0 };
| ^^^^^^^^^^^^^^^^^^ expected `String`, got `i32`
| ^^^^^^^^^^^^^^^^^^ expected `String`, got `[type error]`
|
note: previous use here
--> $DIR/issue-52843-closure-constrain.rs:12:5
@ -10,5 +19,6 @@ note: previous use here
LL | fn _unused() -> Opaque { String::new() }
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -10,7 +10,7 @@ use std::fmt::Debug;
fn main() {
type Opaque = impl Debug;
fn _unused() -> Opaque { String::new() }
let null = || -> Opaque { 0 };
let null = || -> Opaque { 0 }; //[min_tait]~ ERROR: not permitted here
//~^ ERROR: concrete type differs from previous defining opaque type use
println!("{:?}", null());
}

View File

@ -1,5 +1,5 @@
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-53096.rs:5:32
--> $DIR/issue-53096.rs:4:32
|
LL | #![cfg_attr(full_tait, feature(impl_trait_in_bindings, type_alias_impl_trait))]
| ^^^^^^^^^^^^^^^^^^^^^^
@ -8,12 +8,18 @@ LL | #![cfg_attr(full_tait, feature(impl_trait_in_bindings, type_alias_impl_trai
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-53096.rs:5:56
--> $DIR/issue-53096.rs:4:56
|
LL | #![cfg_attr(full_tait, feature(impl_trait_in_bindings, type_alias_impl_trait))]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
warning: 2 warnings emitted
error: fatal error triggered by #[rustc_error]
--> $DIR/issue-53096.rs:14:1
|
LL | fn main() {}
| ^^^^^^^^^
error: aborting due to previous error; 2 warnings emitted

View File

@ -0,0 +1,12 @@
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-53096.rs:10:19
|
LL | const BAZR: Foo = bar();
| ^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,5 +1,4 @@
// check-pass
#![feature(const_impl_trait, const_fn_fn_ptr_basics)]
#![feature(const_impl_trait, const_fn_fn_ptr_basics, rustc_attrs)]
// revisions: min_tait full_tait
#![feature(min_type_alias_impl_trait)]
#![cfg_attr(full_tait, feature(impl_trait_in_bindings, type_alias_impl_trait))]
@ -9,5 +8,7 @@
type Foo = impl Fn() -> usize;
const fn bar() -> Foo { || 0usize }
const BAZR: Foo = bar();
//[min_tait]~^ ERROR not permitted here
fn main() {}
#[rustc_error]
fn main() {} //[full_tait]~ ERROR

View File

@ -1,5 +1,5 @@
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-53678-generator-and-const-fn.rs:6:32
--> $DIR/issue-53678-generator-and-const-fn.rs:4:32
|
LL | #![cfg_attr(full_tait, feature(impl_trait_in_bindings, type_alias_impl_trait))]
| ^^^^^^^^^^^^^^^^^^^^^^
@ -8,12 +8,18 @@ LL | #![cfg_attr(full_tait, feature(impl_trait_in_bindings, type_alias_impl_trai
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-53678-generator-and-const-fn.rs:6:56
--> $DIR/issue-53678-generator-and-const-fn.rs:4:56
|
LL | #![cfg_attr(full_tait, feature(impl_trait_in_bindings, type_alias_impl_trait))]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
warning: 2 warnings emitted
error: fatal error triggered by #[rustc_error]
--> $DIR/issue-53678-generator-and-const-fn.rs:23:1
|
LL | fn main() {}
| ^^^^^^^^^
error: aborting due to previous error; 2 warnings emitted

View File

@ -0,0 +1,12 @@
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-53678-generator-and-const-fn.rs:20:36
|
LL | const FOO: GenOnce<usize, usize> = const_generator(10, 100);
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,6 +1,4 @@
// check-pass
#![feature(const_impl_trait, generators, generator_trait)]
#![feature(const_impl_trait, generators, generator_trait, rustc_attrs)]
// revisions: min_tait full_tait
#![feature(min_type_alias_impl_trait)]
#![cfg_attr(full_tait, feature(impl_trait_in_bindings, type_alias_impl_trait))]
@ -19,6 +17,7 @@ const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> {
}
}
const FOO: GenOnce<usize, usize> = const_generator(10, 100);
const FOO: GenOnce<usize, usize> = const_generator(10, 100); //[min_tait]~ ERROR not permitted here
fn main() {}
#[rustc_error]
fn main() {} //[full_tait]~ ERROR

View File

@ -12,6 +12,7 @@ impl Bug for &() {
//~^^ ERROR could not find defining uses
const FUN: fn() -> Self::Item = || ();
//~^ ERROR type alias impl trait is not permitted here
}
fn main() {}

View File

@ -7,6 +7,15 @@ LL | type Item = impl Bug;
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
= help: add `#![feature(min_type_alias_impl_trait)]` to the crate attributes to enable
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-60371.rs:14:37
|
LL | const FUN: fn() -> Self::Item = || ();
| ^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error[E0277]: the trait bound `(): Bug` is not satisfied
--> $DIR/issue-60371.rs:10:17
|
@ -22,7 +31,7 @@ error: could not find defining uses
LL | type Item = impl Bug;
| ^^^^^^^^
error: aborting due to 3 previous errors
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.

View File

@ -1,5 +1,5 @@
warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-60407.rs:5:32
--> $DIR/issue-60407.rs:3:32
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^
@ -8,12 +8,18 @@ LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_binding
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-60407.rs:5:55
--> $DIR/issue-60407.rs:3:55
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
warning: 2 warnings emitted
error: fatal error triggered by #[rustc_error]
--> $DIR/issue-60407.rs:12:1
|
LL | fn main() {
| ^^^^^^^^^
error: aborting due to previous error; 2 warnings emitted

View File

@ -0,0 +1,24 @@
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-60407.rs:9:39
|
LL | static mut TEST: Option<Debuggable> = None;
| ^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: concrete type differs from previous defining opaque type use
--> $DIR/issue-60407.rs:16:1
|
LL | fn foo() -> Debuggable {
| ^^^^^^^^^^^^^^^^^^^^^^ expected `[type error]`, got `u32`
|
note: previous use here
--> $DIR/issue-60407.rs:9:1
|
LL | static mut TEST: Option<Debuggable> = None;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,19 +1,18 @@
// check-pass
// revisions: min_tait full_tait
#![feature(min_type_alias_impl_trait)]
#![feature(min_type_alias_impl_trait, rustc_attrs)]
#![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
//[full_tait]~^ WARN incomplete
//[full_tait]~| WARN incomplete
type Debuggable = impl core::fmt::Debug;
static mut TEST: Option<Debuggable> = None;
static mut TEST: Option<Debuggable> = None; //[min_tait]~ ERROR not permitted here
fn main() {
#[rustc_error]
fn main() { //[full_tait]~ ERROR
unsafe { TEST = Some(foo()) }
}
fn foo() -> Debuggable {
fn foo() -> Debuggable { //[min_tait]~ ERROR concrete type differs
0u32
}

View File

@ -1,3 +1,12 @@
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-63279.rs:11:11
|
LL | || -> Closure { || () }
| ^^^^^^^
|
= 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[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:11:5: 11:28] as FnOnce<()>>::Output == ()`
--> $DIR/issue-63279.rs:8:16
|
@ -7,6 +16,7 @@ LL | type Closure = impl FnOnce();
= note: expected opaque type `impl FnOnce<()>`
found unit type `()`
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.
Some errors have detailed explanations: E0271, E0658.
For more information about an error, try `rustc --explain E0271`.

View File

@ -8,7 +8,7 @@
type Closure = impl FnOnce(); //~ ERROR: type mismatch resolving
fn c() -> Closure {
|| -> Closure { || () }
|| -> Closure { || () } //[min_tait]~ ERROR: not permitted here
}
fn main() {}

View File

@ -1,5 +1,5 @@
warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-65679-inst-opaque-ty-from-val-twice.rs:6:32
--> $DIR/issue-65679-inst-opaque-ty-from-val-twice.rs:5:32
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^
@ -8,12 +8,18 @@ LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_binding
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-65679-inst-opaque-ty-from-val-twice.rs:6:55
--> $DIR/issue-65679-inst-opaque-ty-from-val-twice.rs:5:55
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
warning: 2 warnings emitted
error: fatal error triggered by #[rustc_error]
--> $DIR/issue-65679-inst-opaque-ty-from-val-twice.rs:19:1
|
LL | fn main() {
| ^^^^^^^^^
error: aborting due to previous error; 2 warnings emitted

View File

@ -0,0 +1,21 @@
error[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-65679-inst-opaque-ty-from-val-twice.rs:20:13
|
LL | take(|| {});
| ^
|
= 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[E0658]: type alias impl trait is not permitted here
--> $DIR/issue-65679-inst-opaque-ty-from-val-twice.rs:22:13
|
LL | take(|| {});
| ^
|
= 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: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,5 +1,4 @@
// compile-flags: -Zsave-analysis
// check-pass
// revisions: min_tait full_tait
#![feature(min_type_alias_impl_trait, rustc_attrs)]
@ -16,7 +15,10 @@ type T = impl Sized;
fn take(_: fn() -> T) {}
fn main() {
#[rustc_error]
fn main() { //[full_tait]~ ERROR fatal error triggered by #[rustc_error]
take(|| {});
//[min_tait]~^ ERROR not permitted here
take(|| {});
//[min_tait]~^ ERROR not permitted here
}

View File

@ -1,17 +1,25 @@
warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/no_inferrable_concrete_type.rs:6:32
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/no_inferrable_concrete_type.rs:6:55
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
error: could not find defining uses
--> $DIR/no_inferrable_concrete_type.rs:9:12
--> $DIR/no_inferrable_concrete_type.rs:10:12
|
LL | type Foo = impl Copy;
| ^^^^^^^^^
error: aborting due to previous error; 1 warning emitted
error: aborting due to previous error; 2 warnings emitted

View File

@ -1,8 +1,18 @@
error[E0658]: type alias impl trait is not permitted here
--> $DIR/no_inferrable_concrete_type.rs:16:12
|
LL | let _: Foo = std::mem::transmute(0u8);
| ^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: could not find defining uses
--> $DIR/no_inferrable_concrete_type.rs:9:12
--> $DIR/no_inferrable_concrete_type.rs:10:12
|
LL | type Foo = impl Copy;
| ^^^^^^^^^
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -3,8 +3,9 @@
// revisions: min_tait full_tait
#![feature(min_type_alias_impl_trait)]
#![cfg_attr(full_tait, feature(type_alias_impl_trait))]
#![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
//[full_tait]~^ WARN incomplete
//[full_tait]~| WARN incomplete
type Foo = impl Copy; //~ could not find defining uses
@ -12,5 +13,5 @@ type Foo = impl Copy; //~ could not find defining uses
fn bar(x: Foo) -> Foo { x }
fn main() {
let _: Foo = std::mem::transmute(0u8);
let _: Foo = std::mem::transmute(0u8); //[min_tait]~ ERROR not permitted here
}

View File

@ -1,8 +1,12 @@
error: `impl Send` cannot be used in patterns
--> $DIR/structural-match-no-leak.rs:19:9
error[E0658]: type alias impl trait is not permitted here
--> $DIR/structural-match-no-leak.rs:15:24
|
LL | LEAK_FREE => (),
| ^^^^^^^^^
LL | const LEAK_FREE: Bar = leak_free();
| ^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -12,12 +12,12 @@ type Bar = impl Send;
const fn leak_free() -> Bar {
7i32
}
const LEAK_FREE: Bar = leak_free();
const LEAK_FREE: Bar = leak_free(); //[min_tait]~ ERROR not permitted here
fn leak_free_test() {
match todo!() {
LEAK_FREE => (),
//~^ `impl Send` cannot be used in patterns
//[full_tait]~^ `impl Send` cannot be used in patterns
_ => (),
}
}

View File

@ -1,17 +1,25 @@
warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/structural-match.rs:4:36
--> $DIR/structural-match.rs:4:32
|
LL | #![cfg_attr(not(min_tait), feature(type_alias_impl_trait, min_type_alias_impl_trait))]
| ^^^^^^^^^^^^^^^^^^^^^
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/structural-match.rs:4:55
|
LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
error: `impl Send` cannot be used in patterns
--> $DIR/structural-match.rs:19:9
--> $DIR/structural-match.rs:20:9
|
LL | VALUE => (),
| ^^^^^
error: aborting due to previous error; 1 warning emitted
error: aborting due to previous error; 2 warnings emitted

View File

@ -1,8 +1,12 @@
error: `impl Send` cannot be used in patterns
--> $DIR/structural-match.rs:19:9
error[E0658]: type alias impl trait is not permitted here
--> $DIR/structural-match.rs:16:20
|
LL | VALUE => (),
| ^^^^^
LL | const VALUE: Foo = value();
| ^^^^^^^
|
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,8 +1,9 @@
#![feature(const_impl_trait)]
// revisions: min_tait full_tait
#![cfg_attr(min_tait, feature(min_type_alias_impl_trait))]
#![cfg_attr(not(min_tait), feature(type_alias_impl_trait, min_type_alias_impl_trait))]
#![feature(min_type_alias_impl_trait)]
#![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
//[full_tait]~^ WARN incomplete
//[full_tait]~| WARN incomplete
type Foo = impl Send;
@ -12,12 +13,12 @@ struct A;
const fn value() -> Foo {
A
}
const VALUE: Foo = value();
const VALUE: Foo = value(); //[min_tait]~ ERROR not permitted here
fn test() {
match todo!() {
VALUE => (),
//~^ `impl Send` cannot be used in patterns
//[full_tait]~^ `impl Send` cannot be used in patterns
_ => (),
}
}