Skip to content

Commit e002634

Browse files
committed
register fn-ptr coercion obligations out of a snapshot
Fixes #43923.
1 parent a7e0018 commit e002634

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/librustc_typeck/check/coercion.rs

+1-2
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.

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)