Eagerly resolve vars in predicate during coercion loop
This commit is contained in:
parent
77c3cf1bfd
commit
a071044562
@ -636,6 +636,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||||||
Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)))
|
Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)))
|
||||||
if traits.contains(&trait_pred.def_id()) =>
|
if traits.contains(&trait_pred.def_id()) =>
|
||||||
{
|
{
|
||||||
|
let trait_pred = self.resolve_vars_if_possible(trait_pred);
|
||||||
if unsize_did == trait_pred.def_id() {
|
if unsize_did == trait_pred.def_id() {
|
||||||
let self_ty = trait_pred.self_ty();
|
let self_ty = trait_pred.self_ty();
|
||||||
let unsize_ty = trait_pred.trait_ref.substs[1].expect_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.
|
// Uncertain or unimplemented.
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
if trait_pred.def_id() == unsize_did {
|
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 self_ty = trait_pred.self_ty();
|
||||||
let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty();
|
let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty();
|
||||||
debug!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred);
|
debug!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred);
|
||||||
|
@ -10,7 +10,7 @@ use std::path::{Path, PathBuf};
|
|||||||
|
|
||||||
const ENTRY_LIMIT: usize = 900;
|
const ENTRY_LIMIT: usize = 900;
|
||||||
// FIXME: The following limits should be reduced eventually.
|
// 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 ROOT_ENTRY_LIMIT: usize = 870;
|
||||||
|
|
||||||
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
|
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0658]: cannot cast `dyn Fn()` to `dyn FnMut()`, trait upcasting coercion is experimental
|
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 });
|
LL | let test = Box::new(Test { func: closure });
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
13
tests/ui/traits/trait-upcasting/issue-11515.next.stderr
Normal file
13
tests/ui/traits/trait-upcasting/issue-11515.next.stderr
Normal file
@ -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 <https://github.com/rust-lang/rust/issues/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`.
|
@ -1,9 +1,10 @@
|
|||||||
|
// revisions: current next
|
||||||
|
//[next] compile-flags: -Ztrait-solver=next
|
||||||
|
|
||||||
struct Test {
|
struct Test {
|
||||||
func: Box<dyn FnMut() + 'static>,
|
func: Box<dyn FnMut() + 'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let closure: Box<dyn Fn() + 'static> = Box::new(|| ());
|
let closure: Box<dyn Fn() + 'static> = Box::new(|| ());
|
||||||
let test = Box::new(Test { func: closure }); //~ ERROR trait upcasting coercion is experimental [E0658]
|
let test = Box::new(Test { func: closure }); //~ ERROR trait upcasting coercion is experimental [E0658]
|
Loading…
x
Reference in New Issue
Block a user