review comments
This commit is contained in:
parent
96f5584b80
commit
8f12485335
@ -1741,8 +1741,7 @@ fn get_owner_return_paths(
|
||||
/// If all the return expressions evaluate to `!`, then we explain that the error will go away
|
||||
/// after changing it. This can happen when a user uses `panic!()` or similar as a placeholder.
|
||||
fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
||||
let mut err =
|
||||
struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type to a concrete type");
|
||||
let mut err = struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type");
|
||||
|
||||
let mut label = false;
|
||||
if let Some((hir_id, visitor)) = get_owner_return_paths(tcx, def_id) {
|
||||
@ -1751,7 +1750,6 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
||||
.returns
|
||||
.iter()
|
||||
.filter_map(|expr| tables.node_type_opt(expr.hir_id))
|
||||
.map(|ty| tcx.infer_ctxt().enter(|infcx| infcx.resolve_vars_if_possible(&ty)))
|
||||
.all(|ty| matches!(ty.kind, ty::Never))
|
||||
{
|
||||
let spans = visitor
|
||||
@ -1782,9 +1780,6 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
||||
.iter()
|
||||
.filter_map(|e| tables.node_type_opt(e.hir_id).map(|t| (e.span, t)))
|
||||
.filter(|(_, ty)| !matches!(ty.kind, ty::Never))
|
||||
.map(|(sp, ty)| {
|
||||
(sp, tcx.infer_ctxt().enter(|infcx| infcx.resolve_vars_if_possible(&ty)))
|
||||
})
|
||||
{
|
||||
struct VisitTypes(Vec<DefId>);
|
||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for VisitTypes {
|
||||
@ -1812,7 +1807,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
||||
}
|
||||
}
|
||||
if !label {
|
||||
err.span_label(span, "cannot resolve to a concrete type");
|
||||
err.span_label(span, "cannot resolve opaque type");
|
||||
}
|
||||
err.emit();
|
||||
}
|
||||
@ -1824,9 +1819,9 @@ fn binding_opaque_type_cycle_error(
|
||||
span: Span,
|
||||
partially_expanded_type: Ty<'tcx>,
|
||||
) {
|
||||
let mut err =
|
||||
struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type to a concrete type");
|
||||
err.span_label(span, "cannot resolve to a concrete type");
|
||||
let mut err = struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type");
|
||||
err.span_label(span, "cannot resolve opaque type");
|
||||
// Find the the owner that declared this `impl Trait` type.
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id);
|
||||
let mut prev_hir_id = hir_id;
|
||||
let mut hir_id = tcx.hir().get_parent_node(hir_id);
|
||||
@ -1855,15 +1850,12 @@ fn binding_opaque_type_cycle_error(
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id);
|
||||
let tables =
|
||||
tcx.typeck_tables_of(tcx.hir().local_def_id(tcx.hir().get_parent_item(hir_id)));
|
||||
let ty = tables.node_type_opt(expr.hir_id);
|
||||
if let Some(ty) =
|
||||
tcx.infer_ctxt().enter(|infcx| infcx.resolve_vars_if_possible(&ty))
|
||||
{
|
||||
if let Some(ty) = tables.node_type_opt(expr.hir_id) {
|
||||
err.span_label(
|
||||
expr.span,
|
||||
&format!(
|
||||
"this is of type `{}`, which doesn't constrain \
|
||||
`{}` enough to arrive to a concrete type",
|
||||
`{}` enough to arrive to a concrete type",
|
||||
ty, partially_expanded_type
|
||||
),
|
||||
);
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/binding-without-value.rs:5:13
|
||||
|
|
||||
LL | let _ : impl Copy;
|
||||
| - ^^^^^^^^^ cannot resolve to a concrete type
|
||||
| - ^^^^^^^^^ cannot resolve opaque type
|
||||
| |
|
||||
| this binding might not have a concrete type
|
||||
|
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/infinite-impl-trait-issue-38064.rs:8:13
|
||||
|
|
||||
LL | fn foo() -> impl Quux {
|
||||
@ -10,7 +10,7 @@ LL | Foo(bar())
|
||||
LL | fn bar() -> impl Quux {
|
||||
| --------- returning this opaque type `foo::Foo<impl Quux>`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/infinite-impl-trait-issue-38064.rs:14:13
|
||||
|
|
||||
LL | fn foo() -> impl Quux {
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-direct.rs:5:14
|
||||
|
|
||||
LL | fn test() -> impl Sized {
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:7:22
|
||||
|
|
||||
LL | fn option(i: i32) -> impl Sized {
|
||||
@ -9,7 +9,7 @@ LL | if i < 0 { None } else { Some((option(i - 1), i)) }
|
||||
| |
|
||||
| returning here with type `std::option::Option<(impl Sized, i32)>`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:12:15
|
||||
|
|
||||
LL | fn tuple() -> impl Sized {
|
||||
@ -18,7 +18,7 @@ LL |
|
||||
LL | (tuple(),)
|
||||
| ---------- returning here with type `(impl Sized,)`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:17:15
|
||||
|
|
||||
LL | fn array() -> impl Sized {
|
||||
@ -27,7 +27,7 @@ LL |
|
||||
LL | [array()]
|
||||
| --------- returning here with type `[impl Sized; 1]`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:22:13
|
||||
|
|
||||
LL | fn ptr() -> impl Sized {
|
||||
@ -36,7 +36,7 @@ LL |
|
||||
LL | &ptr() as *const _
|
||||
| ------------------ returning here with type `*const impl Sized`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:27:16
|
||||
|
|
||||
LL | fn fn_ptr() -> impl Sized {
|
||||
@ -45,7 +45,7 @@ LL |
|
||||
LL | fn_ptr as fn() -> _
|
||||
| ------------------- returning here with type `fn() -> impl Sized`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:32:25
|
||||
|
|
||||
LL | fn closure_capture() -> impl Sized {
|
||||
@ -56,7 +56,7 @@ LL | | x;
|
||||
LL | | }
|
||||
| |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 37:6 x:impl Sized]`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:40:29
|
||||
|
|
||||
LL | fn closure_ref_capture() -> impl Sized {
|
||||
@ -67,7 +67,7 @@ LL | | &x;
|
||||
LL | | }
|
||||
| |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 45:6 x:impl Sized]`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:48:21
|
||||
|
|
||||
LL | fn closure_sig() -> impl Sized {
|
||||
@ -76,7 +76,7 @@ LL |
|
||||
LL | || closure_sig()
|
||||
| ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:21]`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:53:23
|
||||
|
|
||||
LL | fn generator_sig() -> impl Sized {
|
||||
@ -85,7 +85,7 @@ LL |
|
||||
LL | || generator_sig()
|
||||
| ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:23]`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:58:27
|
||||
|
|
||||
LL | fn generator_capture() -> impl Sized {
|
||||
@ -97,7 +97,7 @@ LL | | x;
|
||||
LL | | }
|
||||
| |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 64:6 x:impl Sized {()}]`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:67:35
|
||||
|
|
||||
LL | fn substs_change<T: 'static>() -> impl Sized {
|
||||
@ -106,7 +106,7 @@ LL |
|
||||
LL | (substs_change::<&T>(),)
|
||||
| ------------------------ returning here with type `(impl Sized,)`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:72:24
|
||||
|
|
||||
LL | fn generator_hold() -> impl Sized {
|
||||
@ -119,7 +119,7 @@ LL | | x;
|
||||
LL | | }
|
||||
| |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 78:6 {impl Sized, ()}]`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:86:26
|
||||
|
|
||||
LL | fn mutual_recursion() -> impl Sync {
|
||||
@ -131,7 +131,7 @@ LL | mutual_recursion_b()
|
||||
LL | fn mutual_recursion_b() -> impl Sized {
|
||||
| ---------- returning this opaque type `impl Sized`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-indirect.rs:91:28
|
||||
|
|
||||
LL | fn mutual_recursion() -> impl Sync {
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:7:22
|
||||
|
|
||||
LL | fn id<T>(t: T) -> impl Sized { t }
|
||||
@ -9,7 +9,7 @@ LL | fn recursive_id() -> impl Sized {
|
||||
LL | id(recursive_id2())
|
||||
| ------------------- returning here with type `impl Sized`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:11:23
|
||||
|
|
||||
LL | fn id<T>(t: T) -> impl Sized { t }
|
||||
@ -20,7 +20,7 @@ LL | fn recursive_id2() -> impl Sized {
|
||||
LL | id(recursive_id())
|
||||
| ------------------ returning here with type `impl Sized`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:17:24
|
||||
|
|
||||
LL | fn wrap<T>(t: T) -> impl Sized { (t,) }
|
||||
@ -31,7 +31,7 @@ LL | fn recursive_wrap() -> impl Sized {
|
||||
LL | wrap(recursive_wrap2())
|
||||
| ----------------------- returning here with type `impl Sized`
|
||||
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/recursive-impl-trait-type-through-non-recursive.rs:21:25
|
||||
|
|
||||
LL | fn wrap<T>(t: T) -> impl Sized { (t,) }
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0720]: cannot resolve opaque type to a concrete type
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/where-allowed-2.rs:6:30
|
||||
|
|
||||
LL | fn in_adt_in_return() -> Vec<impl Debug> { panic!() }
|
||||
| ^^^^^^^^^^ -------- this returned value is of `!` type
|
||||
| |
|
||||
| cannot resolve to a concrete type
|
||||
| cannot resolve opaque type
|
||||
|
|
||||
= help: this error will resolve once the item's body returns a concrete type
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user