Don't allow impls to force public types

This code in resolve accidentally forced all types with an impl to become
public. This fixes it by default inheriting the privacy of what was previously
there and then becoming `true` if nothing else exits.

Closes #10545
This commit is contained in:
Alex Crichton 2013-12-16 23:32:37 -08:00
parent d5798b3902
commit eabf11b9cb
10 changed files with 35 additions and 10 deletions

View file

@ -932,7 +932,8 @@ fn size_hint(&self) -> (uint, Option<uint>) {
mod tests {
use extra::test::BenchHarness;
use bitv::*;
use bitv::{Bitv, SmallBitv, BigBitv, BitvSet, from_bools, from_fn,
from_bytes};
use bitv;
use std::uint;

View file

@ -407,7 +407,7 @@ fn clone(&self) -> BranchElt<K, V> {
#[cfg(test)]
mod test_btree{
use super::*;
use super::{BTree, LeafElt};
///Tests the functionality of the add methods (which are unfinished).
#[test]

View file

@ -329,7 +329,7 @@ pub fn access_cond<U>(&self, blk: |c: &Condvar| -> U) -> U {
****************************************************************************/
/// A counting, blocking, bounded-waiting semaphore.
struct Semaphore { priv sem: Sem<()> }
pub struct Semaphore { priv sem: Sem<()> }
impl Clone for Semaphore {

View file

@ -670,7 +670,6 @@ fn should_sort_failures_before_printing_them() {
use std::io::Decorator;
use std::io::mem::MemWriter;
use std::str;
fn dummy() {}
let test_a = TestDesc {
name: StaticTestName("a"),
@ -1296,8 +1295,6 @@ fn parse_ignored_flag() {
#[test]
pub fn filter_for_ignored_option() {
fn dummy() {}
// When we run ignored tests the test filter should filter out all the
// unignored tests and flip the ignore flag on the rest to false
@ -1441,6 +1438,7 @@ pub fn test_metricmap_compare() {
assert_eq!(diff2.len(), 7);
}
#[test]
pub fn ratchet_test() {
let dpth = TempDir::new("test-ratchet").expect("missing test for ratchet");

View file

@ -884,7 +884,7 @@ fn extend<Iter: Iterator<T>>(&mut self, iter: &mut Iter) {
#[cfg(test)]
mod test_treemap {
use super::*;
use super::{TreeMap, TreeNode};
use std::rand::Rng;
use std::rand;

View file

@ -1258,11 +1258,16 @@ fn build_reduced_graph_for_item(&mut self,
let parent_link =
self.get_parent_link(new_parent, ident);
let def_id = local_def(item.id);
let ns = TypeNS;
let is_public =
!name_bindings.defined_in_namespace(ns) ||
name_bindings.defined_in_public_namespace(ns);
name_bindings.define_module(parent_link,
Some(def_id),
ImplModuleKind,
false,
true,
is_public,
sp);
ModuleReducedGraphParent(

View file

@ -130,7 +130,7 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
_InsnCtxt { _x: () }
}
struct StatRecorder<'a> {
pub struct StatRecorder<'a> {
ccx: @mut CrateContext,
name: &'a str,
start: u64,

View file

@ -303,6 +303,7 @@ fn reset(&mut self) {
mod tests {
use super::*;
use prelude::*;
use super::SipState;
// Hash just the bytes of the slice, without length prefix
struct Bytes<'a>(&'a [u8]);

View file

@ -51,7 +51,7 @@ struct State<T> {
pad3: [u8, ..64],
}
struct Queue<T> {
pub struct Queue<T> {
priv state: UnsafeArc<State<T>>,
}

View file

@ -0,0 +1,20 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
mod a {
struct S;
impl S { }
}
fn foo(_: a::S) { //~ ERROR: type `S` is private
}
fn main() {}