Skip to content

Commit 469a6f9

Browse files
committed
Auto merge of #44013 - arielb1:coerce-snapshot, r=eddyb
Register fn-ptr coercion obligations out of a snapshot Fixes #43923. beta-nominating because regression. r? @eddyb
2 parents a24e0f2 + b47bcc2 commit 469a6f9

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

src/librustc_typeck/check/coercion.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
807807
let lub_ty = self.commit_if_ok(|_| {
808808
self.at(cause, self.param_env)
809809
.lub(prev_ty, new_ty)
810-
.map(|ok| self.register_infer_ok_obligations(ok))
811-
});
810+
}).map(|ok| self.register_infer_ok_obligations(ok));
812811

813812
if lub_ty.is_ok() {
814813
// We have a LUB of prev_ty and new_ty, just return it.
@@ -884,8 +883,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
884883
return self.commit_if_ok(|_| {
885884
self.at(cause, self.param_env)
886885
.lub(prev_ty, new_ty)
887-
.map(|ok| self.register_infer_ok_obligations(ok))
888-
});
886+
}).map(|ok| self.register_infer_ok_obligations(ok));
889887
}
890888
}
891889

@@ -898,8 +896,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
898896
self.commit_if_ok(|_| {
899897
self.at(cause, self.param_env)
900898
.lub(prev_ty, new_ty)
901-
.map(|ok| self.register_infer_ok_obligations(ok))
902-
})
899+
}).map(|ok| self.register_infer_ok_obligations(ok))
903900
}
904901
}
905902
Ok(ok) => {

src/librustc_typeck/check/regionck.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1814,12 +1814,12 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
18141814
// check whether this predicate applies to our current projection
18151815
let cause = self.fcx.misc(span);
18161816
match self.at(&cause, self.fcx.param_env).eq(outlives.0, ty) {
1817-
Ok(ok) => {
1818-
self.register_infer_ok_obligations(ok);
1819-
Ok(outlives.1)
1820-
}
1821-
Err(_) => { Err(()) }
1817+
Ok(ok) => Ok((ok, outlives.1)),
1818+
Err(_) => Err(())
18221819
}
1820+
}).map(|(ok, result)| {
1821+
self.register_infer_ok_obligations(ok);
1822+
result
18231823
});
18241824

18251825
debug!("projection_bounds: region_result={:?}",

src/test/run-pass/issue-43923.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct A<T: ?Sized> { ptr: T }
12+
13+
fn foo<T>(x: &A<[T]>) {}
14+
15+
fn main() {
16+
let a = foo;
17+
let b = A { ptr: [a, a, a] };
18+
a(&A { ptr: [()] });
19+
}

0 commit comments

Comments
 (0)