Skip to content

Commit 612eeb1

Browse files
committed
Fix NLL issue 50716 and add a regression test.
1 parent 142c98d commit 612eeb1

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
873873
);
874874
}
875875
self.check_rvalue(mir, rv, location);
876+
let trait_ref = ty::TraitRef {
877+
def_id: tcx.lang_items().sized_trait().unwrap(),
878+
substs: tcx.mk_substs_trait(place_ty, &[]),
879+
};
880+
self.prove_trait_ref(trait_ref, location);
876881
}
877882
StatementKind::SetDiscriminant {
878883
ref place,
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2012 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+
// Regression test for the issue #50716: NLL ignores lifetimes bounds
12+
// derived from `Sized` requirements
13+
14+
trait A {
15+
type X: ?Sized;
16+
}
17+
18+
fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
19+
where
20+
for<'b> &'b T: A,
21+
<&'static T as A>::X: Sized
22+
{
23+
let _x = *s; //~ ERROR mismatched types [E0308]
24+
}
25+
26+
fn main() {}

0 commit comments

Comments
 (0)