Skip to content

Commit 14f9d1f

Browse files
committed
auto merge of #20828 : alexcrichton/rust/issue-20823, r=brson
This will temporarily prevent warnings generated from expanding to code that the test harness itself uses. This solution will require tweaking around the beta cycle, but it will prevent spurious warnings for now. Closes #20823
2 parents c133b21 + 9cc847d commit 14f9d1f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/libsyntax/test.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,19 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<ast::ViewItem>) {
439439
let item_ = ast::ItemMod(testmod);
440440

441441
let mod_ident = token::gensym_ident("__test");
442+
let allow_unstable = {
443+
let unstable = P(nospan(ast::MetaWord(InternedString::new("unstable"))));
444+
let allow = P(nospan(ast::MetaList(InternedString::new("allow"),
445+
vec![unstable])));
446+
attr::mk_attr_inner(attr::mk_attr_id(), allow)
447+
};
442448
let item = ast::Item {
443449
ident: mod_ident,
444-
attrs: Vec::new(),
445450
id: ast::DUMMY_NODE_ID,
446451
node: item_,
447452
vis: ast::Public,
448453
span: DUMMY_SP,
454+
attrs: vec![allow_unstable],
449455
};
450456
let reexport = cx.reexport_test_harness_main.as_ref().map(|s| {
451457
// building `use <ident> = __test::main`

src/test/run-pass/issue-20823.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: --test
12+
13+
#![deny(unstable)]
14+
15+
#[test]
16+
fn foo() {}

0 commit comments

Comments
 (0)