Skip to content

Commit dd47815

Browse files
committed
Avoid re-export errors in the generated test harness.
1 parent d0623cf commit dd47815

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/librustc_resolve/resolve_imports.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
683683
};
684684

685685
match (value_result, type_result) {
686-
// With `#![feature(item_like_imports)]`, all namespaces
687-
// must be re-exported with extra visibility for an error to occur.
688-
(Ok(value_binding), Ok(type_binding)) if self.new_import_semantics => {
686+
// All namespaces must be re-exported with extra visibility for an error to occur.
687+
(Ok(value_binding), Ok(type_binding)) => {
689688
let vis = directive.vis.get();
690689
if !value_binding.pseudo_vis().is_at_least(vis, self) &&
691690
!type_binding.pseudo_vis().is_at_least(vis, self) {

src/libsyntax/test.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::iter;
1919
use std::slice;
2020
use std::mem;
2121
use std::vec;
22-
use attr;
22+
use attr::{self, HasAttrs};
2323
use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos};
2424
use std::rc::Rc;
2525

@@ -243,12 +243,20 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
243243
tested_submods: Vec<(ast::Ident, ast::Ident)>) -> (P<ast::Item>, ast::Ident) {
244244
let super_ = token::str_to_ident("super");
245245

246+
// Generate imports with `#[allow(private_in_public)]` to work around issue #36768.
247+
let allow_private_in_public = cx.ext_cx.attribute(DUMMY_SP, cx.ext_cx.meta_list(
248+
DUMMY_SP,
249+
InternedString::new("allow"),
250+
vec![cx.ext_cx.meta_list_item_word(DUMMY_SP, InternedString::new("private_in_public"))],
251+
));
246252
let items = tests.into_iter().map(|r| {
247253
cx.ext_cx.item_use_simple(DUMMY_SP, ast::Visibility::Public,
248254
cx.ext_cx.path(DUMMY_SP, vec![super_, r]))
255+
.map_attrs(|_| vec![allow_private_in_public.clone()])
249256
}).chain(tested_submods.into_iter().map(|(r, sym)| {
250257
let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, sym]);
251258
cx.ext_cx.item_use_simple_(DUMMY_SP, ast::Visibility::Public, r, path)
259+
.map_attrs(|_| vec![allow_private_in_public.clone()])
252260
})).collect();
253261

254262
let reexport_mod = ast::Mod {

0 commit comments

Comments
 (0)