Skip to content

Commit 774d2be

Browse files
committed
trans: use types from argument patterns instead of the function signature.
This fixes ICEs caused by late-bound lifetimes ending up in argument datum types and being used in cleanup - user Drop impl's would then fail to monomorphize if the type was used to look up the impl of a method call - which happens in trans now, I presume for multidispatch.
1 parent abb3b9c commit 774d2be

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use middle::trans::cleanup;
5050
use middle::trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral, C_nil};
5151
use middle::trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef};
5252
use middle::trans::common::{CrateContext, ExternMap, FunctionContext};
53-
use middle::trans::common::{NodeInfo, Result, SubstP, monomorphize_type};
53+
use middle::trans::common::{NodeInfo, Result, SubstP};
5454
use middle::trans::common::{node_id_type, param_substs, return_type_is_void};
5555
use middle::trans::common::{tydesc_info, type_is_immediate};
5656
use middle::trans::common::{type_is_zero_size, val_ty};
@@ -1794,7 +1794,6 @@ pub fn trans_closure(ccx: &CrateContext,
17941794
param_substs: &param_substs,
17951795
fn_ast_id: ast::NodeId,
17961796
_attributes: &[ast::Attribute],
1797-
arg_types: Vec<ty::t>,
17981797
output_type: ty::FnOutput,
17991798
abi: Abi,
18001799
has_env: bool,
@@ -1829,9 +1828,9 @@ pub fn trans_closure(ccx: &CrateContext,
18291828

18301829
// Set up arguments to the function.
18311830
let monomorphized_arg_types =
1832-
arg_types.iter()
1833-
.map(|at| monomorphize_type(bcx, *at))
1834-
.collect::<Vec<_>>();
1831+
decl.inputs.iter()
1832+
.map(|arg| node_id_type(bcx, arg.pat.id))
1833+
.collect::<Vec<_>>();
18351834
for monomorphized_arg_type in monomorphized_arg_types.iter() {
18361835
debug!("trans_closure: monomorphized_arg_type: {}",
18371836
ty_to_string(ccx.tcx(), *monomorphized_arg_type));
@@ -1933,7 +1932,6 @@ pub fn trans_fn(ccx: &CrateContext,
19331932
debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx()));
19341933
let _icx = push_ctxt("trans_fn");
19351934
let fn_ty = ty::node_id_to_type(ccx.tcx(), id);
1936-
let arg_types = ty::ty_fn_args(fn_ty);
19371935
let output_type = ty::ty_fn_ret(fn_ty);
19381936
let abi = ty::ty_fn_abi(fn_ty);
19391937
trans_closure(ccx,
@@ -1943,7 +1941,6 @@ pub fn trans_fn(ccx: &CrateContext,
19431941
param_substs,
19441942
id,
19451943
attrs,
1946-
arg_types,
19471944
output_type,
19481945
abi,
19491946
false,

src/librustc/middle/trans/closure.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
408408
bcx.fcx.param_substs,
409409
id,
410410
[],
411-
ty::ty_fn_args(fty),
412411
ty::ty_fn_ret(fty),
413412
ty::ty_fn_abi(fty),
414413
true,
@@ -501,7 +500,6 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
501500
bcx.fcx.param_substs,
502501
id,
503502
[],
504-
ty::ty_fn_args(function_type),
505503
ty::ty_fn_ret(function_type),
506504
ty::ty_fn_abi(function_type),
507505
true,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2014 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+
#![feature(unsafe_destructor)]
12+
13+
pub struct Foo<T>;
14+
15+
impl<T> Iterator<T> for Foo<T> {
16+
fn next(&mut self) -> Option<T> {
17+
None
18+
}
19+
}
20+
21+
#[unsafe_destructor]
22+
impl<T> Drop for Foo<T> {
23+
fn drop(&mut self) {
24+
self.next();
25+
}
26+
}
27+
28+
pub fn foo<'a>(_: Foo<&'a ()>) {}
29+
30+
pub fn main() {}

0 commit comments

Comments
 (0)