rustc: Fix a number of stability lint holes

There are a number of holes that the stability lint did not previously cover,
including:

* Types
* Bounds on type parameters on functions and impls
* Where clauses
* Imports
* Patterns (structs and enums)

These holes have all been fixed by overriding the `visit_path` function on the
AST visitor instead of a few specialized cases. This change also necessitated a
few stability changes:

* The `collections::fmt` module is now stable (it was already supposed to be).
* The `thread_local:👿:Key` type is now stable (it was already supposed to
  be).
* The `std::rt::{begin_unwind, begin_unwind_fmt}` functions are now stable.
  These are required via the `panic!` macro.
* The `std::old_io::stdio::{println, println_args}` functions are now stable.
  These are required by the `print!` and `println!` macros.
* The `ops::{FnOnce, FnMut, Fn}` traits are now `#[stable]`. This is required to
  make bounds with these traits stable. Note that manual implementations of
  these traits are still gated by default, this stability only allows bounds
  such as `F: FnOnce()`.

Additionally, the compiler now has special logic to ignore its own generated
`__test` module for the `--test` harness in terms of stability.

Closes #8962
Closes #16360
Closes #20327

[breaking-change]
This commit is contained in:
Alex Crichton
2015-02-09 16:33:19 -08:00
parent 446bc899b2
commit bbbb571fee
35 changed files with 187 additions and 127 deletions

View File

@@ -436,40 +436,28 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> {
let sp = ignored_span(cx, DUMMY_SP);
let ecx = &cx.ext_cx;
// std::slice::AsSlice
let as_slice_path = ecx.path(sp, vec![token::str_to_ident("std"),
token::str_to_ident("slice"),
token::str_to_ident("AsSlice")]);
// test::test_main_static
let test_main_path = ecx.path(sp, vec![token::str_to_ident("test"),
token::str_to_ident("test_main_static")]);
// ::std::os::args
// ::std::env::args
let os_args_path = ecx.path_global(sp, vec![token::str_to_ident("std"),
token::str_to_ident("os"),
token::str_to_ident("env"),
token::str_to_ident("args")]);
// use std::slice::AsSlice
let as_slice_path = P(nospan(ast::ViewPathSimple(token::str_to_ident("AsSlice"),
as_slice_path)));
let use_as_slice = ecx.item_use(sp, ast::Inherited, as_slice_path);
let use_as_slice = ecx.stmt_item(sp, use_as_slice);
// ::std::os::args()
// ::std::env::args()
let os_args_path_expr = ecx.expr_path(os_args_path);
let call_os_args = ecx.expr_call(sp, os_args_path_expr, vec![]);
// ::std::os::args().as_slice()
let call_as_slice = ecx.expr_method_call(sp, call_os_args,
token::str_to_ident("as_slice"), vec![]);
// test::test_main_static(...)
let test_main_path_expr = ecx.expr_path(test_main_path);
let tests_ident_expr = ecx.expr_ident(sp, token::str_to_ident("TESTS"));
let call_test_main = ecx.expr_call(sp, test_main_path_expr,
vec![call_as_slice, tests_ident_expr]);
vec![call_os_args, tests_ident_expr]);
let call_test_main = ecx.stmt_expr(call_test_main);
// #![main]
let main_meta = ecx.meta_word(sp, token::intern_and_get_ident("main"));
let main_attr = ecx.attribute(sp, main_meta);
// pub fn main() { ... }
let main_ret_ty = ecx.ty(sp, ast::TyTup(vec![]));
let main_body = ecx.block_all(sp, vec![use_as_slice, call_test_main], None);
let main_body = ecx.block_all(sp, vec![call_test_main], None);
let main = ast::ItemFn(ecx.fn_decl(vec![], main_ret_ty),
ast::Unsafety::Normal, ::abi::Rust, empty_generics(), main_body);
let main = P(ast::Item {