2014-11-16 01:30:33 +00:00
|
|
|
// Copyright 2012-2013 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 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-11-26 02:17:11 +00:00
|
|
|
//! The Rust compiler.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2015-03-05 16:53:51 +00:00
|
|
|
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
|
|
|
|
#![cfg_attr(stage0, feature(custom_attribute))]
|
2014-11-16 01:30:33 +00:00
|
|
|
#![crate_name = "rustc_trans"]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![unstable(feature = "rustc_private")]
|
Preliminary feature staging
This partially implements the feature staging described in the
[release channel RFC][rc]. It does not yet fully conform to the RFC as
written, but does accomplish its goals sufficiently for the 1.0 alpha
release.
It has three primary user-visible effects:
* On the nightly channel, use of unstable APIs generates a warning.
* On the beta channel, use of unstable APIs generates a warning.
* On the beta channel, use of feature gates generates a warning.
Code that does not trigger these warnings is considered 'stable',
modulo pre-1.0 bugs.
Disabling the warnings for unstable APIs continues to be done in the
existing (i.e. old) style, via `#[allow(...)]`, not that specified in
the RFC. I deem this marginally acceptable since any code that must do
this is not using the stable dialect of Rust.
Use of feature gates is itself gated with the new 'unstable_features'
lint, on nightly set to 'allow', and on beta 'warn'.
The attribute scheme used here corresponds to an older version of the
RFC, with the `#[staged_api]` crate attribute toggling the staging
behavior of the stability attributes, but the user impact is only
in-tree so I'm not concerned about having to make design changes later
(and I may ultimately prefer the scheme here after all, with the
`#[staged_api]` crate attribute).
Since the Rust codebase itself makes use of unstable features the
compiler and build system to a midly elaborate dance to allow it to
bootstrap while disobeying these lints (which would otherwise be
errors because Rust builds with `-D warnings`).
This patch includes one significant hack that causes a
regression. Because the `format_args!` macro emits calls to unstable
APIs it would trigger the lint. I added a hack to the lint to make it
not trigger, but this in turn causes arguments to `println!` not to be
checked for feature gates. I don't presently understand macro
expansion well enough to fix. This is bug #20661.
Closes #16678
[rc]: https://github.com/rust-lang/rfcs/blob/master/text/0507-release-channels.md
2015-01-06 14:26:08 +00:00
|
|
|
#![staged_api]
|
2014-11-16 01:30:33 +00:00
|
|
|
#![crate_type = "dylib"]
|
|
|
|
#![crate_type = "rlib"]
|
|
|
|
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
|
|
|
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
|
|
|
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
|
|
|
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(alloc)]
|
2015-02-10 21:52:44 +00:00
|
|
|
#![feature(box_patterns)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(box_syntax)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(collections)]
|
|
|
|
#![feature(core)]
|
|
|
|
#![feature(libc)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(quote)]
|
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(rustc_private)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(staged_api)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(unicode)]
|
std: Stabilize the `fs` module
This commit performs a stabilization pass over the `std::fs` module now that
it's had some time to bake. The change was largely just adding `#[stable]` tags,
but there are a few APIs that remain `#[unstable]`.
The following apis are now marked `#[stable]`:
* `std::fs` (the name)
* `File`
* `Metadata`
* `ReadDir`
* `DirEntry`
* `OpenOptions`
* `Permissions`
* `File::{open, create}`
* `File::{sync_all, sync_data}`
* `File::set_len`
* `File::metadata`
* Trait implementations for `File` and `&File`
* `OpenOptions::new`
* `OpenOptions::{read, write, append, truncate, create}`
* `OpenOptions::open` - this function was modified, however, to not attempt to
reject cross-platform openings of directories. This means that some platforms
will succeed in opening a directory and others will fail.
* `Metadata::{is_dir, is_file, len, permissions}`
* `Permissions::{readonly, set_readonly}`
* `Iterator for ReadDir`
* `DirEntry::path`
* `remove_file` - like with `OpenOptions::open`, the extra windows code to
remove a readonly file has been removed. This means that removing a readonly
file will succeed on some platforms but fail on others.
* `metadata`
* `rename`
* `copy`
* `hard_link`
* `soft_link`
* `read_link`
* `create_dir`
* `create_dir_all`
* `remove_dir`
* `remove_dir_all`
* `read_dir`
The following apis remain `#[unstable]`.
* `WalkDir` and `walk` - there are many methods by which a directory walk can be
constructed, and it's unclear whether the current semantics are the right
ones. For example symlinks are not handled super well currently. This is now
behind a new `fs_walk` feature.
* `File::path` - this is an extra abstraction which the standard library
provides on top of what the system offers and it's unclear whether we should
be doing so. This is now behind a new `file_path` feature.
* `Metadata::{accessed, modified}` - we do not currently have a good
abstraction for a moment in time which is what these APIs should likely be
returning, so these remain `#[unstable]` for now. These are now behind a new
`fs_time` feature
* `set_file_times` - like with `Metadata::accessed`, we do not currently have
the appropriate abstraction for the arguments here so this API remains
unstable behind the `fs_time` feature gate.
* `PathExt` - the precise set of methods on this trait may change over time and
some methods may be removed. This API remains unstable behind the `path_ext`
feature gate.
* `set_permissions` - we may wish to expose a more granular ability to set the
permissions on a file instead of just a blanket "set all permissions" method.
This function remains behind the `fs` feature.
The following apis are now `#[deprecated]`
* The `TempDir` type is now entirely deprecated and is [located on
crates.io][tempdir] as the `tempdir` crate with [its source][github] at
rust-lang/tempdir.
[tempdir]: https://crates.io/crates/tempdir
[github]: https://github.com/rust-lang/tempdir
The stability of some of these APIs has been questioned over the past few weeks
in using these APIs, and it is intentional that the majority of APIs here are
marked `#[stable]`. The `std::fs` module has a lot of room to grow and the
material is [being tracked in a RFC issue][rfc-issue].
[rfc-issue]: https://github.com/rust-lang/rfcs/issues/939
[breaking-change]
2015-03-04 03:18:29 +00:00
|
|
|
#![feature(path_ext)]
|
|
|
|
#![feature(fs)]
|
2015-03-09 15:49:10 +00:00
|
|
|
#![feature(path_relative_from)]
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2015-03-23 22:23:34 +00:00
|
|
|
#![allow(trivial_casts)]
|
Add trivial cast lints.
This permits all coercions to be performed in casts, but adds lints to warn in those cases.
Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference.
[breaking change]
* Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed.
* The unused casts lint has gone.
* Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are:
- You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_`
- Casts do not influence inference of integer types. E.g., the following used to type check:
```
let x = 42;
let y = &x as *const u32;
```
Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information:
```
let x: u32 = 42;
let y = &x as *const u32;
```
2015-03-20 04:15:27 +00:00
|
|
|
|
2014-11-16 01:30:33 +00:00
|
|
|
extern crate arena;
|
|
|
|
extern crate flate;
|
|
|
|
extern crate getopts;
|
|
|
|
extern crate graphviz;
|
|
|
|
extern crate libc;
|
|
|
|
extern crate rustc;
|
|
|
|
extern crate rustc_back;
|
|
|
|
extern crate serialize;
|
2015-03-25 01:13:54 +00:00
|
|
|
extern crate rustc_llvm as llvm;
|
2014-11-16 01:30:33 +00:00
|
|
|
|
2015-01-06 17:24:46 +00:00
|
|
|
#[macro_use] extern crate log;
|
|
|
|
#[macro_use] extern crate syntax;
|
2015-01-01 04:43:46 +00:00
|
|
|
|
2014-11-16 01:30:33 +00:00
|
|
|
pub use rustc::session;
|
|
|
|
pub use rustc::metadata;
|
|
|
|
pub use rustc::middle;
|
|
|
|
pub use rustc::lint;
|
|
|
|
pub use rustc::plugin;
|
|
|
|
pub use rustc::util;
|
|
|
|
|
|
|
|
pub mod back {
|
|
|
|
pub use rustc_back::abi;
|
|
|
|
pub use rustc_back::archive;
|
|
|
|
pub use rustc_back::arm;
|
|
|
|
pub use rustc_back::mips;
|
|
|
|
pub use rustc_back::mipsel;
|
|
|
|
pub use rustc_back::rpath;
|
|
|
|
pub use rustc_back::svh;
|
|
|
|
pub use rustc_back::target_strs;
|
|
|
|
pub use rustc_back::x86;
|
|
|
|
pub use rustc_back::x86_64;
|
|
|
|
|
|
|
|
pub mod link;
|
|
|
|
pub mod lto;
|
|
|
|
pub mod write;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod trans;
|
|
|
|
pub mod save;
|
|
|
|
|
|
|
|
pub mod lib {
|
|
|
|
pub use llvm;
|
|
|
|
}
|