Skip to content

Commit fcaefcf

Browse files
liveness: substitute bound regions with free ones before normalizing the return type
Fixes #32323
1 parent b12b4e4 commit fcaefcf

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/librustc/middle/liveness.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ use middle::pat_util;
115115
use middle::ty::{self, TyCtxt, ParameterEnvironment};
116116
use middle::traits::{self, ProjectionMode};
117117
use middle::infer;
118+
use middle::subst::Subst;
118119
use lint;
119120
use util::nodemap::NodeMap;
120121

@@ -1495,14 +1496,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
14951496
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() => {
14961497

14971498
let param_env = ParameterEnvironment::for_item(&self.ir.tcx, id);
1499+
let t_ret_subst = t_ret.subst(&self.ir.tcx, &param_env.free_substs);
14981500
let infcx = infer::new_infer_ctxt(&self.ir.tcx,
14991501
&self.ir.tcx.tables,
15001502
Some(param_env),
15011503
ProjectionMode::Any);
15021504
let cause = traits::ObligationCause::dummy();
15031505
let norm = traits::fully_normalize(&infcx,
15041506
cause,
1505-
&t_ret);
1507+
&t_ret_subst);
15061508

15071509
if norm.unwrap().is_nil() {
15081510
// for nil return types, it is ok to not return a value expl.

src/test/compile-fail/issue-32323.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2016 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+
pub trait Tr<'a> {
12+
type Out;
13+
}
14+
15+
pub fn f<'a, T: Tr<'a>>() -> <T as Tr<'a>>::Out {}
16+
//~^ ERROR not all control paths return a value
17+
18+
pub fn main() {}

0 commit comments

Comments
 (0)