diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 108e20ed145..47f4777fdfe 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -636,6 +636,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred))) if traits.contains(&trait_pred.def_id()) => { + let trait_pred = self.resolve_vars_if_possible(trait_pred); if unsize_did == trait_pred.def_id() { let self_ty = trait_pred.self_ty(); let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty(); @@ -662,7 +663,6 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // Uncertain or unimplemented. Ok(None) => { if trait_pred.def_id() == unsize_did { - let trait_pred = self.resolve_vars_if_possible(trait_pred); let self_ty = trait_pred.self_ty(); let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty(); debug!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred); diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 55bf38110a6..c3a63952841 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -10,7 +10,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. -const ISSUES_ENTRY_LIMIT: usize = 1896; +const ISSUES_ENTRY_LIMIT: usize = 1894; const ROOT_ENTRY_LIMIT: usize = 870; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ diff --git a/tests/ui/issues/issue-11515.stderr b/tests/ui/traits/trait-upcasting/issue-11515.current.stderr similarity index 94% rename from tests/ui/issues/issue-11515.stderr rename to tests/ui/traits/trait-upcasting/issue-11515.current.stderr index accd47f0f5f..97d66cccb25 100644 --- a/tests/ui/issues/issue-11515.stderr +++ b/tests/ui/traits/trait-upcasting/issue-11515.current.stderr @@ -1,5 +1,5 @@ error[E0658]: cannot cast `dyn Fn()` to `dyn FnMut()`, trait upcasting coercion is experimental - --> $DIR/issue-11515.rs:9:38 + --> $DIR/issue-11515.rs:10:38 | LL | let test = Box::new(Test { func: closure }); | ^^^^^^^ diff --git a/tests/ui/traits/trait-upcasting/issue-11515.next.stderr b/tests/ui/traits/trait-upcasting/issue-11515.next.stderr new file mode 100644 index 00000000000..97d66cccb25 --- /dev/null +++ b/tests/ui/traits/trait-upcasting/issue-11515.next.stderr @@ -0,0 +1,13 @@ +error[E0658]: cannot cast `dyn Fn()` to `dyn FnMut()`, trait upcasting coercion is experimental + --> $DIR/issue-11515.rs:10:38 + | +LL | let test = Box::new(Test { func: closure }); + | ^^^^^^^ + | + = note: see issue #65991 for more information + = help: add `#![feature(trait_upcasting)]` to the crate attributes to enable + = note: required when coercing `Box<(dyn Fn() + 'static)>` into `Box<(dyn FnMut() + 'static)>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/issues/issue-11515.rs b/tests/ui/traits/trait-upcasting/issue-11515.rs similarity index 77% rename from tests/ui/issues/issue-11515.rs rename to tests/ui/traits/trait-upcasting/issue-11515.rs index b5c942f96a7..723f3a24fd4 100644 --- a/tests/ui/issues/issue-11515.rs +++ b/tests/ui/traits/trait-upcasting/issue-11515.rs @@ -1,9 +1,10 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + struct Test { func: Box, } - - fn main() { let closure: Box = Box::new(|| ()); let test = Box::new(Test { func: closure }); //~ ERROR trait upcasting coercion is experimental [E0658]