about summary refs log tree commit diff
path: root/src/librustc/session
AgeCommit message (Collapse)AuthorLines
2016-04-11std: Stabilize APIs for the 1.9 releaseAlex Crichton-3/+3
This commit applies all stabilizations, renamings, and deprecations that the library team has decided on for the upcoming 1.9 release. All tracking issues have gone through a cycle-long "final comment period" and the specific APIs stabilized/deprecated are: Stable * `std::panic` * `std::panic::catch_unwind` (renamed from `recover`) * `std::panic::resume_unwind` (renamed from `propagate`) * `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`) * `std::panic::UnwindSafe` (renamed from `RecoverSafe`) * `str::is_char_boundary` * `<*const T>::as_ref` * `<*mut T>::as_ref` * `<*mut T>::as_mut` * `AsciiExt::make_ascii_uppercase` * `AsciiExt::make_ascii_lowercase` * `char::decode_utf16` * `char::DecodeUtf16` * `char::DecodeUtf16Error` * `char::DecodeUtf16Error::unpaired_surrogate` * `BTreeSet::take` * `BTreeSet::replace` * `BTreeSet::get` * `HashSet::take` * `HashSet::replace` * `HashSet::get` * `OsString::with_capacity` * `OsString::clear` * `OsString::capacity` * `OsString::reserve` * `OsString::reserve_exact` * `OsStr::is_empty` * `OsStr::len` * `std::os::unix::thread` * `RawPthread` * `JoinHandleExt` * `JoinHandleExt::as_pthread_t` * `JoinHandleExt::into_pthread_t` * `HashSet::hasher` * `HashMap::hasher` * `CommandExt::exec` * `File::try_clone` * `SocketAddr::set_ip` * `SocketAddr::set_port` * `SocketAddrV4::set_ip` * `SocketAddrV4::set_port` * `SocketAddrV6::set_ip` * `SocketAddrV6::set_port` * `SocketAddrV6::set_flowinfo` * `SocketAddrV6::set_scope_id` * `<[T]>::copy_from_slice` * `ptr::read_volatile` * `ptr::write_volatile` * The `#[deprecated]` attribute * `OpenOptions::create_new` Deprecated * `std::raw::Slice` - use raw parts of `slice` module instead * `std::raw::Repr` - use raw parts of `slice` module instead * `str::char_range_at` - use slicing plus `chars()` plus `len_utf8` * `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8` * `str::char_at` - use slicing plus `chars()` * `str::char_at_reverse` - use slicing plus `chars().rev()` * `str::slice_shift_char` - use `chars()` plus `Chars::as_str` * `CommandExt::session_leader` - use `before_exec` instead. Closes #27719 cc #27751 (deprecating the `Slice` bits) Closes #27754 Closes #27780 Closes #27809 Closes #27811 Closes #27830 Closes #28050 Closes #29453 Closes #29791 Closes #29935 Closes #30014 Closes #30752 Closes #31262 cc #31398 (still need to deal with `before_exec`) Closes #31405 Closes #31572 Closes #31755 Closes #31756
2016-04-10Remove an extra command from the usage messageMatt Kraai-1/+1
2016-04-09Introduce the `init_llvm` functionAndrea Canciani-0/+57
Extract the code that performs the initialization of the LLVM backend and invoke it before computing the available features. The initialization is required to happen before the features are added to the configuration, because they are computed by LLVM, therefore is is now performed when creating the `Session` object.
2016-04-07Auto merge of #32016 - nikomatsakis:incr-comp-save, r=mwbors-12/+19
Save/load incremental compilation dep graph Contains the code to serialize/deserialize the dep graph to disk between executions. We also hash the item contents and compare to the new hashes. Also includes a unit test harness. There are definitely some known limitations, such as https://github.com/rust-lang/rust/issues/32014 and https://github.com/rust-lang/rust/issues/32015, but I am leaving those for follow-up work. Note that this PR builds on https://github.com/rust-lang/rust/pull/32007, so the overlapping commits can be excluded from review. r? @michaelwoerister
2016-04-06restructure rustc options relating to incr. comp.Niko Matsakis-12/+19
You can now pass `-Z incremental=dir` as well as saying `-Z query-dep-graph` if you want to enable queries for some other purpose. Accessor functions take the place of computed boolean flags.
2016-04-05Centralize nightly compiler flags handlingGuillaume Gomez-21/+85
2016-03-31librustc: excise Session's now-unused bug methodsBenjamin Herr-17/+0
2016-03-31librustc: replace panic!() with bug!()Benjamin Herr-2/+2
2016-03-31librustc: replace unreachable! with bug!()Benjamin Herr-1/+1
2016-03-31librustc: replace tcx.sess.bug calls with bug!()Benjamin Herr-1/+1
2016-03-31librustc: add {span_,}bug! macrosBenjamin Herr-0/+34
... as single "internal compiler error" entry point. The macros pass `file!()`, `line!()` and `format_args!(...)` on to a cold, never-inlined function, ultimately calling `bug()` or `span_bug()` on the `Handler` from `session::diagnostic()` via the tcx in tls or, failing that, panicking directly.
2016-03-31Rollup merge of #32494 - pnkfelix:gate-parser-recovery-via-debugflag, r=nrcManish Goregaokar-0/+6
Gate parser recovery via debugflag Gate parser recovery via debugflag Put in `-Z continue_parse_after_error` This works by adding a method, `fn abort_if_no_parse_recovery`, to the diagnostic handler in `syntax::errors`, and calling it after each error is emitted in the parser. (We might consider adding a debugflag to do such aborts in other places where we are currently attempting recovery, such as resolve, but I think the parser is the really important case to handle in the face of #31994 and the parser bugs of varying degrees that were injected by parse error recovery.) r? @nikomatsakis
2016-03-30Put in `-Z continue-parse-after-error`Felix S. Klock II-0/+6
This works by adding a boolean flag, `continue_after_error`, to `syntax::errors::Handler` that can be imperatively set to `true` or `false` via a new `fn set_continue_after_error`. The flag starts off true (since we generally try to recover from compiler errors, and `Handler` is shared across all phases). Then, during the `phase_1_parse_input`, we consult the setting of the `-Z continue-parse-after-error` debug flag to determine whether we should leave the flag set to `true` or should change it to `false`. ---- (We might consider adding a debugflag to do such aborts in other places where we are currently attempting recovery, such as resolve, but I think the parser is the really important case to handle in the face of #31994 and the parser bugs of varying degrees that were injected by parse error recovery.)
2016-03-29Remove unnecessary dependencies on rustc_llvm.Eduard Burtescu-6/+0
2016-03-28Auto merge of #32267 - durka:inclusive-range-error, r=nrcbors-0/+4
melt the ICE when lowering an impossible range Emit a fatal error instead of panicking when HIR lowering encounters a range with no `end` point. This involved adding a method to wire up `LoweringContext::span_fatal`. Fixes #32245 (cc @nodakai). r? @nrc
2016-03-26Rollup merge of #32199 - nikomatsakis:limiting-constants-in-patterns-2, ↵Manish Goregaokar-1/+7
r=pnkfelix Restrict constants in patterns This implements [RFC 1445](https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md). The primary change is to limit the types of constants used in patterns to those that *derive* `Eq` (note that implementing `Eq` is not sufficient). This has two main effects: 1. Floating point constants are linted, and will eventually be disallowed. This is because floating point constants do not implement `Eq` but only `PartialEq`. This check replaces the existing special case code that aimed to detect the use of `NaN`. 2. Structs and enums must derive `Eq` to be usable within a match. This is a [breaking-change]: if you encounter a problem, you are most likely using a constant in an expression where the type of the constant is some struct that does not currently implement `Eq`. Something like the following: ```rust struct SomeType { ... } const SOME_CONST: SomeType = ...; match foo { SOME_CONST => ... } ``` The easiest and most future compatible fix is to annotate the type in question with `#[derive(Eq)]` (note that merely *implementing* `Eq` is not enough, it must be *derived*): ```rust struct SomeType { ... } const SOME_CONST: SomeType = ...; match foo { SOME_CONST => ... } ``` Another good option is to rewrite the match arm to use an `if` condition (this is also particularly good for floating point types, which implement `PartialEq` but not `Eq`): ```rust match foo { c if c == SOME_CONST => ... } ``` Finally, a third alternative is to tag the type with `#[structural_match]`; but this is not recommended, as the attribute is never expected to be stabilized. Please see RFC #1445 for more details. cc https://github.com/rust-lang/rust/issues/31434 r? @pnkfelix
2016-03-25store krate information more uniformlyNiko Matsakis-2/+3
make DefPath store krate and enable uniform access to crate_name/crate_disambiguator
2016-03-25Compute a salt from arguments passed via -Cmetadata.Michael Woerister-2/+7
2016-03-25suppress duplicate lintsNiko Matsakis-1/+7
2016-03-24fatal error instead of ICE for impossible range during HIR loweringAlex Burka-0/+4
End-less ranges (`a...`) don't parse but bad syntax extensions could conceivably produce them. Unbounded ranges (`...`) do parse and are caught here. The other panics in HIR lowering are all for unexpanded macros, which cannot be constructed by bad syntax extensions.
2016-03-23allow dumping intermediate IR with -Z dump-mirNiko Matsakis-0/+2
2016-03-17Add -Z orbit for forcing MIR for everything, unless #[rustc_no_mir] is used.Eduard Burtescu-0/+2
2016-03-14Auto merge of #32169 - mitaa:anon-tip, r=nrcbors-3/+7
Allow custom filenames for anonymous inputs This came out of #29253 but doesn't fix it. I thought it might be worth merging on its own nonetheless.
2016-03-14Allow custom filenames for anonymous inputsmitaa-3/+7
2016-03-13Auto merge of #32229 - Manishearth:rollup, r=Manishearthbors-0/+4
Rollup of 4 pull requests - Successful merges: #32164, #32179, #32212, #32218 - Failed merges:
2016-03-12Don't allow values for codegen-units less than 1 (fixes #32191)Manish Goregaokar-0/+4
2016-03-04Add Pass manager for MIRSimonas Kazlauskas-3/+3
2016-03-02Add usage documentation for `--print cfg`Andrea Canciani-1/+1
The `--print` flag was extended in #31278 to accept `cfg`, but the usage message was not updated.
2016-02-24rustc: Refactor how unstable flags are handledAlex Crichton-64/+117
This commit adds support for *truly* unstable options in the compiler, as well as adding warnings for the start of the deprecation path of unstable-but-not-really options. Specifically, the following behavior is now in place for handling unstable options: * As before, an unconditional error is emitted if an unstable option is passed and the `-Z unstable-options` flag is not present. Note that passing another `-Z` flag does not require passing `-Z unstable-options` as well. * New flags added to the compiler will be in the `Unstable` category as opposed to the `UnstableButNotReally` category which means they will unconditionally emit an error when used on stable. * All current flags are in a category where they will emit warnings when used that the option will soon be a hard error. Also as before, it is intended that `-Z` is akin to `#![feature]` in a crate where it is required to unlock unstable functionality. A nightly compiler which is used without any `-Z` flags should only be exercising stable behavior.
2016-02-20add -Z mir-opt-level to disable MIR optimizationsAriel Ben-Yehuda-0/+6
setting -Z mir-opt-level=0 will disable all MIR optimizations for easier debugging
2016-02-16Fix wrong help message left in #31368Johan Lorenzo-1/+1
2016-02-14Stricter matching of `--cfg` options on rustcDirk Gadsden-4/+14
Includes compile-fail test to check that it fails on incomplete `--cfg` matches. Fixes #31497.
2016-02-13Auto merge of #31358 - japaric:print-targets, r=alexcrichtonbors-1/+3
that prints a list of all the triples supported by the `--target` flag r? @alexcrichton
2016-02-12Auto merge of #31550 - Stebalien:fix-color, r=nrcbors-6/+6
Fixes #31546
2016-02-12rustc: add a `--print target-list` commandJorge Aparicio-1/+3
2016-02-12Auto merge of #31368 - JohanLorenzo:dont-strip-if-test-build, r=alexcrichtonbors-0/+2
Tools which rely on DWARF for generating code coverage report, don't generate accurate numbers on test builds. For instance, [this sample main](https://github.com/JohanLorenzo/rust-testing-example/blob/757bdbf3887f43db9771c20cb72dfc32aa8f4321/src/main.rs) returns [100% coverage](https://coveralls.io/builds/4940156/source?filename=main.rs) when [kcov](https://github.com/SimonKagstrom/kcov/) runs. With @pnkfelix 's great help, we could narrow down the issue: The linker strips unused function during phase 6. Here's a patch which stops stripping when someone calls `rustc --test $ARGS`. @pnkfelix wasn't sure if we should add a new flag, or just use --test. What do you think @alexcrichton ? Also, I'm not too sure: where is the best place to add a test for this addition? Thanks for the help!
2016-02-11[breaking-change] don't glob export ast::{UintTy, IntTy} variantsOliver Schneider-2/+2
2016-02-11Add -C link-dead-code option r=alexcrichtonJohan Lorenzo-0/+2
Turning gc-sections off improves code coverage based for tools which use DWARF debugging information (like kcov). Otherwise dead code is stripped and kcov returns a coverage percentage that doesn't reflect reality.
2016-02-10Don't assume color=always when explicitally specifiedSteven Allen-6/+6
Fixes #31546
2016-02-09Allow registering MIR-passes through compiler pluginsOliver Schneider-0/+3
2016-02-08rustc: Implement a new `--print cfg` flagAlex Crichton-0/+2
This commit is an implementation of the new compiler flags required by [RFC 1361][rfc]. This specifically adds a new `cfg` option to the `--print` flag to the compiler. This new directive will print the defined `#[cfg]` directives by the compiler for the target in question. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1361-cargo-cfg-dependencies.md
2016-02-05Instrument the AST map so that it registers reads when data isNiko Matsakis-3/+8
acccessed.
2016-02-03Improve wording of --target helpSimonas Kazlauskas-5/+1
2016-02-02Auto merge of #31279 - DanielJCampbell:MacroReferencing, r=nrcbors-1/+7
r? @nrc
2016-02-02Reviewer requested changes and test fixesNick Cameron-4/+4
2016-02-01Implemented macro referencing for save analysisDaniel Campbell-1/+7
2016-02-01Replace some aborts with ResultsNick Cameron-11/+12
Fixes #31207 by removing abort_if_new_errors
2016-01-29Auto merge of #30900 - michaelwoerister:trans_item_collect, r=nikomatsakisbors-0/+2
The purpose of the translation item collector is to find all monomorphic instances of functions, methods and statics that need to be translated into LLVM IR in order to compile the current crate. So far these instances have been discovered lazily during the trans path. For incremental compilation we want to know the set of these instances in advance, and that is what the trans::collect module provides. In the future, incremental and regular translation will be driven by the collector implemented here. r? @nikomatsakis cc @rust-lang/compiler Translation Item Collection =========================== This module is responsible for discovering all items that will contribute to to code generation of the crate. The important part here is that it not only needs to find syntax-level items (functions, structs, etc) but also all their monomorphized instantiations. Every non-generic, non-const function maps to one LLVM artifact. Every generic function can produce from zero to N artifacts, depending on the sets of type arguments it is instantiated with. This also applies to generic items from other crates: A generic definition in crate X might produce monomorphizations that are compiled into crate Y. We also have to collect these here. The following kinds of "translation items" are handled here: - Functions - Methods - Closures - Statics - Drop glue The following things also result in LLVM artifacts, but are not collected here, since we instantiate them locally on demand when needed in a given codegen unit: - Constants - Vtables - Object Shims General Algorithm ----------------- Let's define some terms first: - A "translation item" is something that results in a function or global in the LLVM IR of a codegen unit. Translation items do not stand on their own, they can reference other translation items. For example, if function `foo()` calls function `bar()` then the translation item for `foo()` references the translation item for function `bar()`. In general, the definition for translation item A referencing a translation item B is that the LLVM artifact produced for A references the LLVM artifact produced for B. - Translation items and the references between them for a directed graph, where the translation items are the nodes and references form the edges. Let's call this graph the "translation item graph". - The translation item graph for a program contains all translation items that are needed in order to produce the complete LLVM IR of the program. The purpose of the algorithm implemented in this module is to build the translation item graph for the current crate. It runs in two phases: 1. Discover the roots of the graph by traversing the HIR of the crate. 2. Starting from the roots, find neighboring nodes by inspecting the MIR representation of the item corresponding to a given node, until no more new nodes are found. The roots of the translation item graph correspond to the non-generic syntactic items in the source code. We find them by walking the HIR of the crate, and whenever we hit upon a function, method, or static item, we create a translation item consisting of the items DefId and, since we only consider non-generic items, an empty type-substitution set. Given a translation item node, we can discover neighbors by inspecting its MIR. We walk the MIR and any time we hit upon something that signifies a reference to another translation item, we have found a neighbor. Since the translation item we are currently at is always monomorphic, we also know the concrete type arguments of its neighbors, and so all neighbors again will be monomorphic. The specific forms a reference to a neighboring node can take in MIR are quite diverse. Here is an overview: The most obvious form of one translation item referencing another is a function or method call (represented by a CALL terminator in MIR). But calls are not the only thing that might introduce a reference between two function translation items, and as we will see below, they are just a specialized of the form described next, and consequently will don't get any special treatment in the algorithm. A function does not need to actually be called in order to be a neighbor of another function. It suffices to just take a reference in order to introduce an edge. Consider the following example: ```rust fn print_val<T: Display>(x: T) { println!("{}", x); } fn call_fn(f: &Fn(i32), x: i32) { f(x); } fn main() { let print_i32 = print_val::<i32>; call_fn(&print_i32, 0); } ``` The MIR of none of these functions will contain an explicit call to `print_val::<i32>`. Nonetheless, in order to translate this program, we need an instance of this function. Thus, whenever we encounter a function or method in operand position, we treat it as a neighbor of the current translation item. Calls are just a special case of that. In a way, closures are a simple case. Since every closure object needs to be constructed somewhere, we can reliably discover them by observing `RValue::Aggregate` expressions with `AggregateKind::Closure`. This is also true for closures inlined from other crates. Drop glue translation items are introduced by MIR drop-statements. The generated translation item will again have drop-glue item neighbors if the type to be dropped contains nested values that also need to be dropped. It might also have a function item neighbor for the explicit `Drop::drop` implementation of its type. A subtle way of introducing neighbor edges is by casting to a trait object. Since the resulting fat-pointer contains a reference to a vtable, we need to instantiate all object-save methods of the trait, as we need to store pointers to these functions even if they never get called anywhere. This can be seen as a special case of taking a function reference. Since `Box` expression have special compiler support, no explicit calls to `exchange_malloc()` and `exchange_free()` may show up in MIR, even if the compiler will generate them. We have to observe `Rvalue::Box` expressions and Box-typed drop-statements for that purpose. Interaction with Cross-Crate Inlining ------------------------------------- The binary of a crate will not only contain machine code for the items defined in the source code of that crate. It will also contain monomorphic instantiations of any extern generic functions and of functions marked with The collection algorithm handles this more or less transparently. When constructing a neighbor node for an item, the algorithm will always call `inline::get_local_instance()` before proceeding. If no local instance can be acquired (e.g. for a function that is just linked to) no node is created; which is exactly what we want, since no machine code should be generated in the current crate for such an item. On the other hand, if we can successfully inline the function, we subsequently can just treat it like a local item, walking it's MIR et cetera. Eager and Lazy Collection Mode ------------------------------ Translation item collection can be performed in one of two modes: - Lazy mode means that items will only be instantiated when actually referenced. The goal is to produce the least amount of machine code possible. - Eager mode is meant to be used in conjunction with incremental compilation where a stable set of translation items is more important than a minimal one. Thus, eager mode will instantiate drop-glue for every drop-able type in the crate, even of no drop call for that type exists (yet). It will also instantiate default implementations of trait methods, something that otherwise is only done on demand. Open Issues ----------- Some things are not yet fully implemented in the current version of this module. Since no MIR is constructed yet for initializer expressions of constants and statics we cannot inspect these properly. Ideally, no translation item should be generated for const fns unless there is a call to them that cannot be evaluated at compile time. At the moment this is not implemented however: a translation item will be produced regardless of whether it is actually needed or not. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/rust-lang/rust/30900) <!-- Reviewable:end -->
2016-01-28Auto merge of #30411 - mitaa:multispan, r=nrcbors-44/+44
This allows to render multiple spans on one line, or to splice multiple replacements into a code suggestion. fixes #28124
2016-01-28Implement MultiSpan error reportingmitaa-44/+44
This allows to render multiple spans on one line, or to splice multiple replacements into a code suggestion.