From cc3fbcee512b34616c6f830ce33c51d9d87a6658 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 19 Feb 2013 14:29:50 -0500 Subject: [PATCH] Fix for issue 4875 --- src/librustc/middle/typeck/check/writeback.rs | 4 ++++ src/librustc/middle/typeck/mod.rs | 2 +- src/test/run-pass/issue-4875.rs | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/issue-4875.rs diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 1b27619938146..8046442121471 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -275,6 +275,10 @@ pub fn resolve_type_vars_in_fn(fcx: @mut FnCtxt, |_bm, pat_id, span, _path| { resolve_type_vars_for_node(wbcx, span, pat_id); } + // Privacy needs the type for the whole pattern, not just each binding + if !pat_util::pat_is_binding(fcx.tcx().def_map, arg.pat) { + resolve_type_vars_for_node(wbcx, arg.pat.span, arg.pat.id); + } } return wbcx.success; } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index fa02c14b6c906..2f6d6975f4154 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -208,7 +208,7 @@ pub struct CrateCtxt { // Functions that write types into the node type table pub fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, ty: ty::t) { debug!("write_ty_to_tcx(%d, %s)", node_id, ppaux::ty_to_str(tcx, ty)); - oldsmallintmap::insert(*tcx.node_types, node_id as uint, ty); + tcx.node_types.insert(node_id as uint, ty); } pub fn write_substs_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, diff --git a/src/test/run-pass/issue-4875.rs b/src/test/run-pass/issue-4875.rs new file mode 100644 index 0000000000000..51c23e7680826 --- /dev/null +++ b/src/test/run-pass/issue-4875.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// regression test for issue 4875 + +pub struct Foo { + data: T, +} + +fn foo(Foo{_}: Foo) { +} + +pub fn main() { +} +