about summary refs log tree commit diff
path: root/src/librustc_passes
AgeCommit message (Collapse)AuthorLines
2018-06-03Do not promote union field accessesOliver Schneider-1/+8
2018-06-01also check `let` arms and nested patterns for mutable borrowsNiko Matsakis-5/+34
2018-05-31Auto merge of #51182 - eddyb:not-just-visibility, r=nikomatsakisbors-8/+8
[MIR] Change "scopes" from "visibility scopes" to "source scopes". These scopes are already used for source-oriented diagnostics, lint levels and unsafety checks. This PR generalizes the naming around scopes, making the type `SourceScope`, and flips (across several commits) the relationship/priority between `LocalDecl`'s "visibility" and "syntactic" scopes. r? @nikomatsakis
2018-05-30rustc: rename mir::VisibilityScope to mir::SourceScope.Eduard-Mihai Burtescu-8/+8
2018-05-30rustc: don't visit lifetime parameters through visit_lifetime.Eduard-Mihai Burtescu-0/+7
2018-05-29rust-lang/rust#27282: Add `StatementKind::ReadForMatch` to MIR.Felix S. Klock II-0/+1
(This is just the data structure changes and some boilerplate match code that followed from it; the actual emission of these statements comes in a follow-up commit.)
2018-05-25pacify the mercilous tidyNiko Matsakis-1/+2
2018-05-24restore emplacement syntax (obsolete)Niko Matsakis-0/+6
2018-05-24Enforce stability of const fn in promotedsOliver Schneider-4/+24
2018-05-23Rollup merge of #50849 - est31:visit_closure_args, r=michaelwoeristerkennytm-1/+2
CheckLoopVisitor: also visit closure arguments This turns the ICE #50581 in this code: ```rust fn main() { |_: [u8; break]| (); } ``` from ``` 'assertion failed: self.tcx.sess.err_count() > 0', librustc_typeck/check/mod.rs ``` to ``` librustc_mir/hair/cx/expr.rs:543: invalid loop id for break: not inside loop scope ``` which is an ICE as well but at a later stage during compilation and most importantly fixes of bug #50576 will fix this as well. As this "only" moves an ICE to a later stage, I didn't add any tests. Now I have manually verified the default impls of the visitor trait to check whether we have missed any other opportunity to visit more stuff and coudln't find anything (except the missing `break` visit I've fixed in #50829 but that one was already r+'d so I didn't want to push more commits).
2018-05-20Rollup merge of #50829 - est31:master, r=estebankkennytm-0/+2
CheckLoopVisitor: also visit break expressions Fixes #50802
2018-05-17CheckLoopVisitor: also visit closure argumentsest31-1/+2
This turns an ICE on this code: fn main() { |_: [u8; break]| (); } from 'assertion failed: self.tcx.sess.err_count() > 0', librustc_typeck/check/mod.rs to librustc_mir/hair/cx/expr.rs:543: invalid loop id for break: not inside loop scope which is at a later stage during compilation and most importantly fixes of bug #50576 will fix this as well.
2018-05-17Turn some functions from `token.rs` into methods on `Ident`Vadim Petrochenkov-4/+2
2018-05-17CheckLoopVisitor: also visit break expressionsest31-0/+2
Fixes #50802
2018-05-17Rollup merge of #50793 - jrlusby:master, r=petrochenkovkennytm-10/+95
tidy: Add a check for empty UI test files Check for empty `.stderr` and `.stdout` files in UI test directories. Empty files could still pass testing for `compile-pass` tests with no output so they can get into the repo accidentally, but they are not necessary and can be removed. This is very much an in progress pull request. I'm having an issue with rustfmt. It wanted to reformat the entire file for almost every file by default. And when I run tidy it just errors out because it catches the empty files that are already in the repo. My next step is goin got be to remove those empty file and see if running tidy again will actually reformat things outside of the context of `cargo fmt` Fixes https://github.com/rust-lang/rust/issues/50785
2018-05-17Rollup merge of #50788 - varkor:missing-const-cast, r=cramertjkennytm-1/+1
Fix an ICE when casting a nonexistent const Fixes https://github.com/rust-lang/rust/issues/50599.
2018-05-16Address review commentsest31-11/+11
2018-05-16Add feature gate label_break_valueest31-0/+1
2018-05-16Add E0696 for continue pointing to a labeled blockest31-2/+17
2018-05-16Extend error E0695 to unlabeled continue statementsest31-9/+17
2018-05-16Add E0695 for unlabeled breaksest31-0/+45
2018-05-16Make the compiler support the label-break-value featureest31-5/+21
No error checking or feature gating yet
2018-05-16label-break-value: Parsing and AST/HIR changesest31-2/+2
2018-05-16Fix an ICE when casting a nonexistent constvarkor-1/+1
2018-05-15Remove LoopIdResultest31-2/+1
It's redundant as Result already implements Encodable as well as Decodable.
2018-05-15Remove hir::ScopeTargetest31-16/+16
When we want to implement label-break-value, we can't really decide whether to emit ScopeTarget::Loop or ScopeTarget::Block in the code that is supposed to create it. So we get rid of it and reconstruct the information when needed.
2018-05-13Macros: Add a 'literal' fragment specifierDan Aloni-1/+1
Implements RFC 1576. See: https://github.com/rust-lang/rfcs/blob/master/text/1576-macros-literal-matcher.md Changes are mostly in libsyntax, docs, and tests. Feature gate is enabled for 1.27.0. Many thanks to Vadim Petrochenkov for following through code reviews and suggestions. Example: ````rust macro_rules! test_literal { ($l:literal) => { println!("literal: {}", $l); }; ($e:expr) => { println!("expr: {}", $e); }; } fn main() { let a = 1; test_literal!(a); test_literal!(2); test_literal!(-3); } ``` Output: ``` expr: 1 literal: 2 literal: -3 ```
2018-05-05Auto merge of #50418 - nnethercote:cmt, r=eddybbors-6/+6
Avoid many `cmt` allocations. `cmt` is a ref-counted wrapper around `cmt_` The use of refcounting keeps `cmt` handling simple, but a lot of `cmt` instances are very short-lived, and heap-allocating the short-lived ones takes up time. This patch changes things in the following ways. - Most of the functions that produced `cmt` instances now produce `cmt_` instances. The `Rc::new` calls that occurred within those functions now occur at their call sites (but only when necessary, which isn't that often). - Many of the functions that took `cmt` arguments now take `&cmt_` arguments. This includes all the methods in the `Delegate` trait. As a result, the vast majority of the heap allocations are avoided. In an extreme case, the number of calls to malloc in tuple-stress drops from 9.9M to 7.9M, a drop of 20%. And the compile times for many runs of coercions, deep-vector, and tuple-stress drop by 1--2%.
2018-05-03Avoid many `cmt` allocations.Nicholas Nethercote-6/+6
`cmt` is a ref-counted wrapper around `cmt_` The use of refcounting keeps `cmt` handling simple, but a lot of `cmt` instances are very short-lived, and heap-allocating the short-lived ones takes up time. This patch changes things in the following ways. - Most of the functions that produced `cmt` instances now produce `cmt_` instances. The `Rc::new` calls that occurred within those functions now occur at their call sites (but only when necessary, which isn't that often). - Many of the functions that took `cmt` arguments now take `&cmt_` arguments. This includes all the methods in the `Delegate` trait. As a result, the vast majority of the heap allocations are avoided. In an extreme case, the number of calls to malloc in tuple-stress drops from 9.9M to 7.9M, a drop of 20%. And the compile times for many runs of coercions, deep-vector, and tuple-stress drop by 1--2%.
2018-04-30Unify MIR assert messages and const eval errorsOliver Schneider-4/+9
2018-04-30Removed unused dependencies on rustc_const_mathOliver Schneider-2/+0
2018-04-23Auto merge of #49372 - Phlosioneer:inherent-impl-default-error-message, r=nagisabors-1/+3
Better error message when trying to write default impls Previously, if you tried to write this (using the specialization feature flag): default impl PartialEq<MyType> { ... } The compiler would give you the mysterious warning "inherent impls cannot be default". What it really means is that you're trying to write an impl for a Structure or *Trait Object*, and that cannot be "default". However, one of the ways to encounter this error (as shown by the above example) is when you forget to write "for MyType". This PR adds a help message that reads "maybe missing a `for` keyword?" This is useful, actionable advice that will help any user identify their mistake, and doesn't get in the way or mislead any user that really meant to use the "default" keyword for this weird purpose. In particular, this help message will be useful for any users who don't know the "inherent impl" terminology, and/or users who forget that inherent impls CAN be written for traits (they apply to the trait objects). Both of these are somewhat confusing, seldom- used concepts; a one-line error message without any error number for longer explanation is NOT the place to introduce these ideas. I wasn't quite sure what grammar / wording to use. I'm open to suggestions. CC @rust-lang/docs (I hope I'm doing that notation right) (Apparently not. :( )
2018-04-16Changed help message to notePhlosioneer-1/+1
2018-04-12AST/HIR: Merge field access expressions for named and numeric fieldsVadim Petrochenkov-1/+0
2018-04-08Move deny(warnings) into rustbuildMark Simulacrum-1/+0
This permits easier iteration without having to worry about warnings being denied. Fixes #49517
2018-04-06Remove more duplicated spansVadim Petrochenkov-17/+18
2018-04-03expand macro invocations in `extern {}` blocksAustin Bonander-1/+17
2018-03-27Add emit call to error messagePhlosioneer-1/+1
2018-03-26Better error message when trying to write default implsPhlosioneer-1/+3
Previously, if you tried to write this (using the specialization feature flag): default impl PartialEq<MyType> { ... } The compiler would give you the mysterious warning "inherent impls cannot be default". What it really means is that you're trying to write an impl for a Structure or *Trait Object*, and that cannot be "default". However, one of the ways to encounter this error (as shown by the above example) is when you forget to write "for MyType". This PR adds a help message that reads "maybe missing a `for` keyword?" This is useful, actionable advice that will help any user identify their mistake, and doesn't get in the way or mislead any user that really meant to use the "default" keyword for this weird purpose. In particular, this help message will be useful for any users who don't know the "inherent impl" terminology, and/or users who forget that inherent impls CAN be written for traits (they apply to the trait objects). Both of these are somewhat confusing, seldom- used concepts; a one-line error message without any error number for longer explanation is NOT the place to introduce these ideas.
2018-03-24Auto merge of #48482 - davidtwco:issue-47184, r=nikomatsakisbors-0/+1
NLL should identify and respect the lifetime annotations that the user wrote Part of #47184. r? @nikomatsakis
2018-03-23Merge branch 'master' of https://github.com/Lymia/rust into rollupAlex Crichton-2/+2
2018-03-22Added UserAssertTy statement.David Wood-0/+1
2018-03-21Fix type_dependent_defs ICE on method callsvarkor-4/+8
2018-03-19#49133 - Reworded the Error message: "`pub` not needed here" messageDileep Bapat-1/+1
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-2/+2
2018-03-17syntax: Make `_` an identifierVadim Petrochenkov-2/+4
2018-03-13refactor `ParamEnv::empty(Reveal)` into two distinct methodsNiko Matsakis-2/+1
- `ParamEnv::empty()` -- does not reveal all, good for typeck - `ParamEnv::reveal_all()` -- does, good for trans - `param_env.with_reveal_all()` -- converts an existing parameter environment
2018-03-09Auto merge of #48326 - RalfJung:generic-bounds, r=petrochenkovbors-0/+41
Warn about ignored generic bounds in `for` This adds a new lint to fix #42181. For consistency and to avoid code duplication, I also moved the existing "bounds in type aliases are ignored" here. Questions to the reviewer: * Is it okay to just remove a diagnostic error code like this? Should I instead keep the warning about type aliases where it is? The old code provided a detailed explanation of what's going on when asked, that information is now lost. On the other hand, `span_warn!` seems deprecated (after this patch, it has exactly one user left!). * Did I miss any syntactic construct that can appear as `for` in the surface syntax? I covered function types (`for<'a> fn(...)`), generic traits (`for <'a> Fn(...)`, can appear both as bounds as as trait objects) and bounds (`for<'a> F: ...`). * For the sake of backwards compatibility, this adds a warning, not an error. @nikomatsakis suggested an error in https://github.com/rust-lang/rust/issues/42181#issuecomment-306924389, but I feel that can only happen in a new epoch -- right? Cc @eddyb
2018-03-08Regenerate testsOliver Schneider-11/+2
2018-03-08TypoOliver Schneider-1/+1