diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index bacfa0bbfce4f..895268f96c8a8 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -439,13 +439,19 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P, Option) { let item_ = ast::ItemMod(testmod); let mod_ident = token::gensym_ident("__test"); + let allow_unstable = { + let unstable = P(nospan(ast::MetaWord(InternedString::new("unstable")))); + let allow = P(nospan(ast::MetaList(InternedString::new("allow"), + vec![unstable]))); + attr::mk_attr_inner(attr::mk_attr_id(), allow) + }; let item = ast::Item { ident: mod_ident, - attrs: Vec::new(), id: ast::DUMMY_NODE_ID, node: item_, vis: ast::Public, span: DUMMY_SP, + attrs: vec![allow_unstable], }; let reexport = cx.reexport_test_harness_main.as_ref().map(|s| { // building `use = __test::main` diff --git a/src/test/run-pass/issue-20823.rs b/src/test/run-pass/issue-20823.rs new file mode 100644 index 0000000000000..73b7fc264a529 --- /dev/null +++ b/src/test/run-pass/issue-20823.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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(unstable)] + +#[test] +fn foo() {}