about summary refs log tree commit diff
path: root/src/librustc_passes
AgeCommit message (Collapse)AuthorLines
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
2018-03-08rustc_passes::consts -> rvalue_promotionOliver Schneider-2/+2
2018-03-08Nuke ConstInt and Const*sizeOliver Schneider-8/+0
2018-03-08Nuke the entire ctfe from orbit, it's the only way to be sureOliver Schneider-147/+1
2018-03-08Move librustc_const_eval to librustc_mirOliver Schneider-3/+3
2018-03-08Produce instead of pointersOliver Schneider-9/+14
2018-03-06make bounds on higher-kinded lifetimes a hard error in ast_validationRalf Jung-0/+41
Also move the check for not having type parameters into ast_validation. I was not sure what to do with compile-fail/issue-23046.rs: The issue looks like maybe the bounds actually played a role in triggering the ICE, but that seems unlikely given that the compiler seems to entirely ignore them. However, I couldn't find a testcase without the bounds, so I figured the best I could do is to just remove the bounds and make sure at least that keeps working.
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-3/+5
2018-02-24Rollup merge of #48084 - cramertj:impl-trait-errors, r=nikomatsakisManish Goregaokar-0/+137
Error on nested impl Trait and path projections from impl Trait cc #34511 r? @nikomatsakis
2018-02-24Rollup merge of #47987 - Zoxc:rm-recursion-checking, r=eddybManish Goregaokar-297/+0
Remove "static item recursion checking" in favor of relying on cycle checks in the query engine Tests are changed to use the cycle check error message instead. Some duplicate tests are removed. r? @eddyb
2018-02-23Auto merge of #47799 - topecongiro:fix-span-of-visibility, r=petrochenkovbors-15/+14
Fix span of visibility This PR 1. adds a closing parenthesis to the span of `Visibility::Crate` (e.g. `pub(crate)`). The current span only covers `pub(crate`. 2. adds a `span` field to `Visibility::Restricted`. This span covers the entire visibility expression (e.g. `pub (in self)`). Currently all we can have is a span for `Path`. This PR is motivated by the bug found in rustfmt (https://github.com/rust-lang-nursery/rustfmt/issues/2398). The first change is a strict improvement IMHO. The second change may not be desirable, as it adds a field which is currently not used by the compiler.
2018-02-20stage0 cfg cleanupMark Simulacrum-1/+0
2018-02-17Auto merge of #47408 - eddyb:deref-danger, r=nikomatsakisbors-13/+12
Don't promote to 'static the result of dereferences. This is a **breaking change**, removing copies out of dereferences from rvalue-to-`'static` promotion. With miri we won't easily know whether the dereference itself would see the same value at runtime as miri (e.g. after mutating a `static`) or even if it can be interpreted (e.g. integer pointers). One alternative to this ban is defining at least *some* of those situations as UB, i.e. you shouldn't have a reference in the first place, and you should work through raw pointers instead, to avoid promotion. **EDIT**: The other *may seem* to be to add some analysis which whitelists references-to-constant-values and assume any values produced by arbitrary computation to not be safe to promote dereferences thereof - but that means producing a reference from an associated constant or `const fn` would necessarily obscure it, and in the former case, this could still impact code that runs on stable today. What we do today to track "references to statics" only works because we restrict taking a reference to a `static` at all to other `static`s (which, again, are currently limited in that they can't be read at compile-time) and to runtime-only `fn`s (*not* `const fn`s). I'm primarily opening this PR with a conservative first approximation (e.g. `&(*r).a` is not allowed, only reborrows are, and in the old borrow only implicit ones from adjustments, at that) for cratering. r? @nikomatsakis
2018-02-18Change ast::Visibility to Spanned typeSeiichi Uchida-15/+14
2018-02-13Disallow projections from impl Trait typesTaylor Cramer-1/+68
2018-02-13Make nested impl Trait a hard errorTaylor Cramer-0/+70
2018-02-12Auto merge of #47843 - estebank:teach, r=nikomatsakisbors-4/+14
Add `-Zteach` documentation Add extra inline documentation to E0019, E0016, E0013, E0396, E0017, E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027. Follow up to #47652.
2018-02-10Remove "static item recursion checking" in favor of relying on cycle checks ↵John Kåre Alsaker-297/+0
in the query engine
2018-02-07Add `-Zteach` documentationEsteban Küber-4/+14
Add extra inline documentation to E0019, E0016, E0013, E0396, E0017, E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027.