2013-02-28 13:15:32 +00:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-03 16:48:01 -08:00
|
|
|
// 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-01-07 21:17:52 -08:00
|
|
|
|
2014-07-01 07:12:04 -07:00
|
|
|
#![crate_name = "rustc"]
|
2015-08-13 10:21:36 -07:00
|
|
|
#![unstable(feature = "rustc_private", issue = "27812")]
|
2014-03-21 18:05:05 -07:00
|
|
|
#![crate_type = "dylib"]
|
|
|
|
#![crate_type = "rlib"]
|
2015-08-09 14:15:05 -07:00
|
|
|
#![doc(html_logo_url = "https://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",
|
2015-08-09 14:15:05 -07:00
|
|
|
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2011-05-05 22:44:00 -04:00
|
|
|
|
2015-04-28 16:36:22 -07:00
|
|
|
#![feature(associated_consts)]
|
2015-02-10 22:52:44 +01:00
|
|
|
#![feature(box_patterns)]
|
2015-01-07 15:15:34 +01:00
|
|
|
#![feature(box_syntax)]
|
2015-12-02 17:31:49 -08:00
|
|
|
#![feature(cell_extras)]
|
2015-06-09 14:39:23 -07:00
|
|
|
#![feature(clone_from_slice)]
|
2015-01-22 18:22:03 -08:00
|
|
|
#![feature(collections)]
|
2015-05-29 09:42:32 -04:00
|
|
|
#![feature(const_fn)]
|
2015-06-09 14:39:23 -07:00
|
|
|
#![feature(enumset)]
|
2015-06-09 18:15:22 -07:00
|
|
|
#![feature(hashmap_hasher)]
|
2015-04-28 16:36:22 -07:00
|
|
|
#![feature(into_cow)]
|
2015-06-10 13:33:52 -07:00
|
|
|
#![feature(iter_arith)]
|
2015-01-22 18:22:03 -08:00
|
|
|
#![feature(libc)]
|
2015-07-22 20:10:18 +03:00
|
|
|
#![feature(nonzero)]
|
2015-06-09 11:18:03 -07:00
|
|
|
#![feature(num_bits_bytes)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(quote)]
|
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2015-01-22 18:22:03 -08:00
|
|
|
#![feature(rustc_private)]
|
2015-06-17 00:33:10 +03:00
|
|
|
#![feature(scoped_tls)]
|
2015-04-28 16:36:22 -07:00
|
|
|
#![feature(slice_patterns)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(staged_api)]
|
2015-03-10 16:29:02 -07:00
|
|
|
#![feature(str_char)]
|
2015-12-02 17:31:49 -08:00
|
|
|
#![feature(time2)]
|
2015-06-09 11:18:03 -07:00
|
|
|
#![feature(wrapping)]
|
2015-01-24 09:15:42 -08:00
|
|
|
#![cfg_attr(test, feature(test))]
|
2015-03-06 15:11:59 -08: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-02-14 10:10:06 -08:00
|
|
|
extern crate arena;
|
2015-07-22 20:10:18 +03:00
|
|
|
extern crate core;
|
2014-05-22 11:28:01 -07:00
|
|
|
extern crate flate;
|
2015-01-10 23:51:27 +05:30
|
|
|
extern crate fmt_macros;
|
2014-05-22 11:28:01 -07:00
|
|
|
extern crate getopts;
|
2014-04-17 21:00:08 +02:00
|
|
|
extern crate graphviz;
|
2014-05-22 11:28:01 -07:00
|
|
|
extern crate libc;
|
2015-12-01 16:07:15 +01:00
|
|
|
extern crate rbml;
|
2014-09-06 11:54:11 -07:00
|
|
|
extern crate rustc_llvm;
|
|
|
|
extern crate rustc_back;
|
2015-07-31 00:04:06 -07:00
|
|
|
extern crate rustc_front;
|
2015-04-07 06:10:53 -04:00
|
|
|
extern crate rustc_data_structures;
|
2014-02-14 10:10:06 -08:00
|
|
|
extern crate serialize;
|
2014-12-17 10:16:10 -05:00
|
|
|
extern crate collections;
|
2015-01-06 09:24:46 -08:00
|
|
|
#[macro_use] extern crate log;
|
|
|
|
#[macro_use] extern crate syntax;
|
2015-01-16 12:20:03 -08:00
|
|
|
#[macro_use] #[no_link] extern crate rustc_bitflags;
|
2014-07-01 18:39:41 +02:00
|
|
|
|
2015-03-24 18:13:54 -07:00
|
|
|
extern crate serialize as rustc_serialize; // used by deriving
|
2014-12-18 22:52:48 -08:00
|
|
|
|
2014-07-29 16:31:39 -07:00
|
|
|
#[cfg(test)]
|
|
|
|
extern crate test;
|
|
|
|
|
2014-09-06 11:54:11 -07:00
|
|
|
pub use rustc_llvm as llvm;
|
|
|
|
|
2015-04-17 15:32:42 -07:00
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
|
2015-01-16 15:54:58 -08:00
|
|
|
// NB: This module needs to be declared first so diagnostics are
|
|
|
|
// registered before they are used.
|
|
|
|
pub mod diagnostics;
|
2014-05-24 21:15:16 -07:00
|
|
|
|
2014-07-04 19:41:54 -07:00
|
|
|
pub mod back {
|
|
|
|
pub use rustc_back::abi;
|
2014-07-06 18:01:16 -07:00
|
|
|
pub use rustc_back::rpath;
|
2014-07-04 19:41:54 -07:00
|
|
|
pub use rustc_back::svh;
|
|
|
|
}
|
|
|
|
|
2015-07-31 00:04:06 -07:00
|
|
|
pub mod front {
|
2015-09-25 15:25:59 +09:00
|
|
|
pub mod check_attr;
|
2015-07-31 00:04:06 -07:00
|
|
|
pub mod map;
|
|
|
|
}
|
2015-06-10 02:40:45 +03:00
|
|
|
|
2013-01-29 15:16:07 -08:00
|
|
|
pub mod middle {
|
2014-11-26 04:52:02 -05:00
|
|
|
pub mod astconv_util;
|
2015-11-22 22:14:09 +02:00
|
|
|
pub mod expr_use_visitor; // STAGE0: increase glitch immunity
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod cfg;
|
|
|
|
pub mod check_const;
|
2014-09-14 17:21:25 -07:00
|
|
|
pub mod check_static_recursion;
|
2013-01-29 15:16:07 -08:00
|
|
|
pub mod check_loop;
|
|
|
|
pub mod check_match;
|
2015-08-20 17:47:21 -05:00
|
|
|
pub mod check_no_asm;
|
2014-09-02 15:55:07 +12:00
|
|
|
pub mod check_rvalues;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod const_eval;
|
2015-11-25 00:00:26 +02:00
|
|
|
pub mod cstore;
|
2013-04-17 18:05:17 -04:00
|
|
|
pub mod dataflow;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod dead;
|
|
|
|
pub mod def;
|
2015-08-16 06:31:58 -04:00
|
|
|
pub mod def_id;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod dependency_format;
|
|
|
|
pub mod effect;
|
|
|
|
pub mod entry;
|
2015-04-18 11:23:14 -04:00
|
|
|
pub mod free_region;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod intrinsicck;
|
2014-11-25 16:59:02 -05:00
|
|
|
pub mod infer;
|
2015-04-18 11:23:14 -04:00
|
|
|
pub mod implicator;
|
2013-01-29 15:16:07 -08:00
|
|
|
pub mod lang_items;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod liveness;
|
|
|
|
pub mod mem_categorization;
|
|
|
|
pub mod pat_util;
|
2013-01-29 15:16:07 -08:00
|
|
|
pub mod privacy;
|
2013-06-14 18:21:47 -07:00
|
|
|
pub mod reachable;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod region;
|
2014-12-02 12:57:38 -05:00
|
|
|
pub mod recursion_limit;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod resolve_lifetime;
|
Add stability inheritance
This commit makes several changes to the stability index infrastructure:
* Stability levels are now inherited lexically, i.e., each item's
stability level becomes the default for any nested items.
* The computed stability level for an item is stored as part of the
metadata. When using an item from an external crate, this data is
looked up and cached.
* The stability lint works from the computed stability level, rather
than manual stability attribute annotations. However, the lint still
checks only a limited set of item uses (e.g., it does not check every
component of a path on import). This will be addressed in a later PR,
as part of issue #8962.
* The stability lint only applies to items originating from external
crates, since the stability index is intended as a promise to
downstream crates.
* The "experimental" lint is now _allow_ by default. This is because
almost all existing crates have been marked "experimental", pending
library stabilization. With inheritance in place, this would generate
a massive explosion of warnings for every Rust program.
The lint should be changed back to deny-by-default after library
stabilization is complete.
* The "deprecated" lint still warns by default.
The net result: we can begin tracking stability index for the standard
libraries as we stabilize, without impacting most clients.
Closes #13540.
2014-06-11 17:23:11 -07:00
|
|
|
pub mod stability;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod subst;
|
2014-09-12 10:53:35 -04:00
|
|
|
pub mod traits;
|
2014-07-13 15:12:47 +02:00
|
|
|
pub mod ty;
|
|
|
|
pub mod weak_lang_items;
|
2011-04-19 16:40:46 -07:00
|
|
|
}
|
|
|
|
|
2015-11-19 16:37:34 +01:00
|
|
|
pub mod mir {
|
|
|
|
pub mod repr;
|
|
|
|
pub mod tcx;
|
2015-11-24 14:35:34 +01:00
|
|
|
pub mod visit;
|
2015-11-19 16:37:34 +01:00
|
|
|
}
|
|
|
|
|
2014-11-15 20:30:33 -05:00
|
|
|
pub mod session;
|
2010-06-23 21:03:09 -07:00
|
|
|
|
2014-06-01 15:58:06 -07:00
|
|
|
pub mod lint;
|
|
|
|
|
2013-01-29 15:16:07 -08:00
|
|
|
pub mod util {
|
2014-07-06 22:21:04 -07:00
|
|
|
pub use rustc_back::sha2;
|
2014-07-06 22:13:55 -07:00
|
|
|
|
2013-01-29 15:16:07 -08:00
|
|
|
pub mod common;
|
|
|
|
pub mod ppaux;
|
2014-02-28 14:34:26 -08:00
|
|
|
pub mod nodemap;
|
2015-04-17 15:32:42 -07:00
|
|
|
pub mod num;
|
2015-05-05 15:19:36 -07:00
|
|
|
pub mod fs;
|
2010-08-18 11:34:47 -07:00
|
|
|
}
|
|
|
|
|
2013-01-29 15:16:07 -08:00
|
|
|
pub mod lib {
|
2014-07-05 13:24:57 -07:00
|
|
|
pub use llvm;
|
2010-07-12 17:47:40 -07:00
|
|
|
}
|
|
|
|
|
2014-06-04 14:35:58 -07:00
|
|
|
// A private module so that macro-expanded idents like
|
|
|
|
// `::rustc::lint::Lint` will also work in `rustc` itself.
|
|
|
|
//
|
|
|
|
// `libstd` uses the same trick.
|
|
|
|
#[doc(hidden)]
|
|
|
|
mod rustc {
|
|
|
|
pub use lint;
|
|
|
|
}
|
2015-04-28 12:48:22 +10:00
|
|
|
|
2015-08-11 11:48:43 -07:00
|
|
|
// FIXME(#27438): right now the unit tests of librustc don't refer to any actual
|
|
|
|
// functions generated in librustc_data_structures (all
|
|
|
|
// references are through generic functions), but statics are
|
|
|
|
// referenced from time to time. Due to this bug we won't
|
|
|
|
// actually correctly link in the statics unless we also
|
|
|
|
// reference a function, so be sure to reference a dummy
|
|
|
|
// function.
|
|
|
|
#[test]
|
|
|
|
fn noop() {
|
|
|
|
rustc_data_structures::__noop_fix_for_27438();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-28 12:48:22 +10:00
|
|
|
// Build the diagnostics array at the end so that the metadata includes error use sites.
|
|
|
|
__build_diagnostic_array! { librustc, DIAGNOSTICS }
|