From dd4781547852c9bf34ffcf5362b1e25da84ecc51 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 27 Sep 2016 20:00:08 +0000 Subject: [PATCH 1/2] Avoid re-export errors in the generated test harness. --- src/librustc_resolve/resolve_imports.rs | 5 ++--- src/libsyntax/test.rs | 10 +++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index ba45b773c09f3..1fc9c45de9306 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -683,9 +683,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { }; match (value_result, type_result) { - // With `#![feature(item_like_imports)]`, all namespaces - // must be re-exported with extra visibility for an error to occur. - (Ok(value_binding), Ok(type_binding)) if self.new_import_semantics => { + // All namespaces must be re-exported with extra visibility for an error to occur. + (Ok(value_binding), Ok(type_binding)) => { let vis = directive.vis.get(); if !value_binding.pseudo_vis().is_at_least(vis, self) && !type_binding.pseudo_vis().is_at_least(vis, self) { diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 6327e8f71bcd5..b3d3667fd42cc 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -19,7 +19,7 @@ use std::iter; use std::slice; use std::mem; use std::vec; -use attr; +use attr::{self, HasAttrs}; use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos}; use std::rc::Rc; @@ -243,12 +243,20 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec, tested_submods: Vec<(ast::Ident, ast::Ident)>) -> (P, ast::Ident) { let super_ = token::str_to_ident("super"); + // Generate imports with `#[allow(private_in_public)]` to work around issue #36768. + let allow_private_in_public = cx.ext_cx.attribute(DUMMY_SP, cx.ext_cx.meta_list( + DUMMY_SP, + InternedString::new("allow"), + vec![cx.ext_cx.meta_list_item_word(DUMMY_SP, InternedString::new("private_in_public"))], + )); let items = tests.into_iter().map(|r| { cx.ext_cx.item_use_simple(DUMMY_SP, ast::Visibility::Public, cx.ext_cx.path(DUMMY_SP, vec![super_, r])) + .map_attrs(|_| vec![allow_private_in_public.clone()]) }).chain(tested_submods.into_iter().map(|(r, sym)| { let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, sym]); cx.ext_cx.item_use_simple_(DUMMY_SP, ast::Visibility::Public, r, path) + .map_attrs(|_| vec![allow_private_in_public.clone()]) })).collect(); let reexport_mod = ast::Mod { From 28393be8df89dec9f78ec8bcbd73e399c6021098 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Tue, 27 Sep 2016 20:06:37 +0000 Subject: [PATCH 2/2] Add regression test. --- src/test/run-pass/issue-36768.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/run-pass/issue-36768.rs diff --git a/src/test/run-pass/issue-36768.rs b/src/test/run-pass/issue-36768.rs new file mode 100644 index 0000000000000..bb4d12919a1c2 --- /dev/null +++ b/src/test/run-pass/issue-36768.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +// compile-flags:--test +#![deny(private_in_public)] + +#[test] fn foo() {} +mod foo {} + +#[test] fn core() {} +extern crate core;