Skip to content

Commit cc3fbce

Browse files
committed
Fix for issue 4875
1 parent 2ec958d commit cc3fbce

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/librustc/middle/typeck/check/writeback.rs

+4
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ pub fn resolve_type_vars_in_fn(fcx: @mut FnCtxt,
275275
|_bm, pat_id, span, _path| {
276276
resolve_type_vars_for_node(wbcx, span, pat_id);
277277
}
278+
// Privacy needs the type for the whole pattern, not just each binding
279+
if !pat_util::pat_is_binding(fcx.tcx().def_map, arg.pat) {
280+
resolve_type_vars_for_node(wbcx, arg.pat.span, arg.pat.id);
281+
}
278282
}
279283
return wbcx.success;
280284
}

src/librustc/middle/typeck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub struct CrateCtxt {
208208
// Functions that write types into the node type table
209209
pub fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, ty: ty::t) {
210210
debug!("write_ty_to_tcx(%d, %s)", node_id, ppaux::ty_to_str(tcx, ty));
211-
oldsmallintmap::insert(*tcx.node_types, node_id as uint, ty);
211+
tcx.node_types.insert(node_id as uint, ty);
212212
}
213213
pub fn write_substs_to_tcx(tcx: ty::ctxt,
214214
node_id: ast::node_id,

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

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2013 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 issue 4875
12+
13+
pub struct Foo<T> {
14+
data: T,
15+
}
16+
17+
fn foo<T>(Foo{_}: Foo<T>) {
18+
}
19+
20+
pub fn main() {
21+
}
22+

0 commit comments

Comments
 (0)