2014-11-15 20:30:33 -05: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-25 21:17:11 -05:00
|
|
|
//! The Rust compiler.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
2014-11-15 20:30:33 -05:00
|
|
|
|
2015-03-05 11:53:51 -05:00
|
|
|
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
|
|
|
|
#![cfg_attr(stage0, feature(custom_attribute))]
|
2014-11-15 20:30:33 -05:00
|
|
|
#![crate_name = "rustc_trans"]
|
2015-01-22 18:22:03 -08: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 06:26:08 -08:00
|
|
|
#![staged_api]
|
2014-11-15 20:30:33 -05:00
|
|
|
#![crate_type = "dylib"]
|
|
|
|
#![crate_type = "rlib"]
|
|
|
|
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
2015-05-15 16:04:01 -07:00
|
|
|
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
|
2014-11-15 20:30:33 -05:00
|
|
|
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
|
|
|
|
2015-02-10 22:52:44 +01:00
|
|
|
#![feature(box_patterns)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(box_syntax)]
|
2015-05-29 09:42:32 -04:00
|
|
|
#![feature(const_fn)]
|
2015-06-09 11:18:03 -07:00
|
|
|
#![feature(fs)]
|
|
|
|
#![feature(iter_cmp)]
|
|
|
|
#![feature(iter_sum)]
|
|
|
|
#![feature(iter_unfold)]
|
2015-01-22 18:22:03 -08:00
|
|
|
#![feature(libc)]
|
2015-06-09 18:15:22 -07:00
|
|
|
#![feature(once_new)]
|
2015-06-09 11:18:03 -07:00
|
|
|
#![feature(path_ext)]
|
|
|
|
#![feature(path_ext)]
|
|
|
|
#![feature(path_relative_from)]
|
|
|
|
#![feature(path_relative_from)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(quote)]
|
2015-06-09 11:52:41 -07:00
|
|
|
#![feature(rc_weak)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2015-01-22 18:22:03 -08:00
|
|
|
#![feature(rustc_private)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(staged_api)]
|
2015-06-09 11:18:03 -07:00
|
|
|
#![feature(unicode)]
|
|
|
|
#![feature(unicode)]
|
2015-06-09 14:39:23 -07:00
|
|
|
#![feature(vec_push_all)]
|
2014-11-15 20:30:33 -05:00
|
|
|
|
2015-03-24 11:23:34 +13: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 17:15:27 +13:00
|
|
|
|
2014-11-15 20:30:33 -05: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-24 18:13:54 -07:00
|
|
|
extern crate rustc_llvm as llvm;
|
2014-11-15 20:30:33 -05:00
|
|
|
|
2015-01-06 09:24:46 -08:00
|
|
|
#[macro_use] extern crate log;
|
|
|
|
#[macro_use] extern crate syntax;
|
2014-12-31 20:43:46 -08:00
|
|
|
|
2014-11-15 20:30:33 -05: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;
|
|
|
|
|
2015-05-08 15:31:23 -07:00
|
|
|
pub mod linker;
|
2014-11-15 20:30:33 -05:00
|
|
|
pub mod link;
|
|
|
|
pub mod lto;
|
|
|
|
pub mod write;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod trans;
|
|
|
|
pub mod save;
|
|
|
|
|
|
|
|
pub mod lib {
|
|
|
|
pub use llvm;
|
|
|
|
}
|