about summary refs log tree commit diff
path: root/src/librustc/middle
AgeCommit message (Collapse)AuthorLines
2018-05-18Auto merge of #50319 - nagisa:align_to, r=alexcrichtonbors-0/+3
Implement [T]::align_to Note that this PR deviates from what is accepted by RFC slightly by making `align_offset` to return an offset in elements, rather than bytes. This is necessary to sanely support `[T]::align_to` and also simply makes more sense™. The caveat is that trying to align a pointer of ZST is now an equivalent to `is_aligned` check, rather than anything else (as no number of ZST elements will align a misaligned ZST pointer). It also implements the `align_to` slightly differently than proposed in the RFC to properly handle cases where size of T and U aren’t co-prime. Furthermore, a promise is made that the slice containing `U`s will be as large as possible (contrary to the RFC) – otherwise the function is quite useless. The implementation uses quite a few underhanded tricks and takes advantage of the fact that alignment is a power-of-two quite heavily to optimise the machine code down to something that results in as few known-expensive instructions as possible. Currently calling `ptr.align_offset` with an unknown-at-compile-time `align` results in code that has just a single "expensive" modulo operation; the rest is "cheap" arithmetic and bitwise ops. cc https://github.com/rust-lang/rust/issues/44488 @oli-obk As mentioned in the commit message for align_offset, many thanks go to Chris McDonald.
2018-05-18Auto merge of #50307 - petrochenkov:keyhyg2, r=nikomatsakisbors-0/+3
Implement edition hygiene for keywords Determine "keywordness" of an identifier in its hygienic context. cc https://github.com/rust-lang/rust/pull/49611 I've resurrected `proc` as an Edition-2015-only keyword for testing purposes, but it should probably be buried again. EDIT: `proc` is removed again.
2018-05-18in which the unused shorthand field pattern debacle/saga continuesZack M. Davis-56/+50
In e4b1a79 (#47922), we corrected erroneous suggestions for unused shorthand field pattern bindings, suggesting `field: _` where the previous suggestion of `_field` wouldn't even have compiled (#47390). Soon, it was revealed that this was insufficient (#50303), and the fix was extended to references, slices, &c. (#50327) But even this proved inadequate, as the erroneous suggestions were still being issued for patterns in local (`let`) bindings (#50804). Here, we yank the shorthand-detection and variable/node registration code into a new common function that can be called while visiting both match arms and `let` bindings. Resolves #50804.
2018-05-17Keep crate edition in metadataVadim Petrochenkov-0/+3
2018-05-17Rollup merge of #50649 - nnethercote:tweak-nearest_common_ancestor, ↵Mark Simulacrum-59/+19
r=nikomatsakis Tweak `nearest_common_ancestor()`. - Remove the "no nearest common ancestor found" case, because it's never hit in practise. (This means `closure_is_enclosed_by` can also be removed.) - Add a comment about why `SmallVec` is used for the "seen" structures. - Use `&Scope` instead of `Scope` to avoid some `map()` calls. - Use `any(p)` instead of `position(p).is_some()`. r? @nikomatsakis
2018-05-17Change align_offset to support different stridesSimonas Kazlauskas-0/+3
This is necessary if we want to implement `[T]::align_to` and is more useful in general. This implementation effort has begun during the All Hands and represents a month of my futile efforts to do any sort of maths. Luckily, I found the very very nice Chris McDonald (cjm) on IRC who figured out the core formulas for me! All the thanks for existence of this PR go to them! Anyway… Those formulas were mangled by yours truly into the arcane forms you see here to squeeze out the best assembly possible on most of the modern architectures (x86 and ARM were evaluated in practice). I mean, just look at it: *one actual* modulo operation and everything else is just the cheap single cycle ops! Admitedly, the naive solution might be faster in some common scenarios, but this code absolutely butchers the naive solution on the worst case scenario. Alas, the result of this arcane magic also means that the code pretty heavily relies on the preconditions holding true and breaking those preconditions will unleash the UB-est of all UBs! So don’t.
2018-05-17Rename trans to codegen everywhere.Irina Popa-13/+13
2018-05-16label-break-value: Parsing and AST/HIR changesest31-3/+5
2018-05-16Auto merge of #50750 - est31:master, r=eddybbors-15/+5
Remove ScopeTarget and LoopIdResult * Remove ScopeTarget in preparation of label-break-value (PR #50045) * Replace LoopIdResult by Result which is possible now thanks to commit 8ac65af81f5f9cf6c5e2c2306705b50eed77cfb5 " Implement Encodable and Decodable for Result." r? @eddyb
2018-05-15Remove LoopIdResultest31-6/+4
It's redundant as Result already implements Encodable as well as Decodable.
2018-05-15Remove hir::ScopeTargetest31-13/+5
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-15Lift pure_wrt_drop to GenericParamDefvarkor-1/+1
2018-05-15Pull common parameters into GenericParamDefvarkor-4/+6
This leads to a lot of simplifications, as most code doesn't actually need to know about the specific lifetime/type data; rather, it's concerned with properties like name, index and def_id.
2018-05-15Inline get_typevarkor-2/+5
2018-05-15Eliminate ty::Generics::types()varkor-2/+5
And with one final incanation, the specific kind iterators were banished from ty::Generics, never to be seen again!
2018-05-15Generalise more cases of explicit iteration of specific kindsvarkor-1/+1
2018-05-15Generalise cases of explicit iteration of specific kindsvarkor-2/+2
2018-05-15Prefer iterator to vecvarkor-1/+0
2018-05-15Consolidate ty::Genericsvarkor-1/+1
2018-05-14Auto merge of #50675 - csmoe:var_span, r=oli-obkbors-7/+10
Reduce span highlighted code in unused_variables lint Fixes #50472 - [X] reduce var span - [ ] mark applicable Before: ``` mut unused_mut_var ^^^^^^^^^^^^^^^^^^ ``` After: ``` mut unused_mut_var ^^^^^^^^^^^^^^ ```
2018-05-13Revert "mark applicability"csmoe-4/+2
This reverts commit a8809711285d2375ee98177f9e78090047514fb2.
2018-05-13mark applicabilitycsmoe-2/+4
2018-05-13reduce variable spancsmoe-7/+10
2018-05-13Auto merge of #50235 - Zoxc:rayon, r=michaelwoeristerbors-1/+3
Add a Rayon thread pool r? @michaelwoerister
2018-05-13Add Sync bounds to the crate storeJohn Kåre Alsaker-1/+3
2018-05-12Better error reporting in Copy deriveleonardo.yvens-1/+1
In Copy derive, report all fulfillment erros when present and do not report errors for types tainted with `TyErr`. Also report all fields which are not Copy rather than just the first. Also refactored `fn fully_normalize`, removing the not very useful helper function along with a FIXME to the closed issue #26721 that's looks out of context now.
2018-05-11Introduce ConstValue and use it instead of miri's Value for constant valuesJohn Kåre Alsaker-23/+3
2018-05-11Tweak `nearest_common_ancestor()`.Nicholas Nethercote-59/+19
- Remove the "no nearest common ancestor found" case, because it's never hit in practise. (This means `closure_is_enclosed_by` can also be removed.) - Add a comment about why `SmallVec` is used for the "seen" structures. - Use `&Scope` instead of `Scope` to avoid some `map()` calls. - Use `any(p)` instead of `position(p).is_some()`.
2018-05-11Auto merge of #50440 - nikomatsakis:single-use-lifetimes, r=cramertjbors-60/+200
Improve single-use and zero-use lifetime lints The code now correctly identifies *when* to lint -- or more correctly, anyhow -- but it doesn't yet offer suggestions for how to fix. (I just remembered when writing this I had meant to go back over some of these cases around e.g. impl Trait and double check that everything is right...) cc #44752 r? @cramertj
2018-05-10ensure lint are issued in a stable orderNiko Matsakis-14/+14
2018-05-08Insert fields from TypeAndMut into TyRef to allow layout optimizationJohn Kåre Alsaker-5/+5
2018-05-05Auto merge of #50418 - nnethercote:cmt, r=eddybbors-83/+82
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-04add warnings for unused lifetime parametersNiko Matsakis-1/+19
2018-05-04fix single-use lintNiko Matsakis-31/+150
2018-05-03rustfmtNiko Matsakis-11/+13
2018-05-03fix commentsNiko Matsakis-18/+19
2018-05-03Auto merge of #50413 - kennytm:rollup, r=kennytmbors-5/+6
Rollup of 12 pull requests Successful merges: - #50302 (Add query search order check) - #50320 (Fix invalid path generation in rustdoc search) - #50349 (Rename "show type declaration" to "show declaration") - #50360 (Clarify wordings of the `unstable_name_collision` lint.) - #50365 (Use two vectors in nearest_common_ancestor.) - #50393 (Allow unaligned reads in constants) - #50401 (Revert "Implement FromStr for PathBuf") - #50406 (Forbid constructing empty identifiers from concat_idents) - #50407 (Always inline simple BytePos and CharPos methods.) - #50416 (check if the token is a lifetime before parsing) - #50417 (Update Cargo) - #50421 (Fix ICE when using a..=b in a closure.) Failed merges:
2018-05-04Rollup merge of #50365 - nnethercote:nearest_common_ancestor-two-vecs, ↵kennytm-5/+6
r=nikomatsakis Use two vectors in nearest_common_ancestor. When looking at any scope in scope chain A, we only need to look for matches among scopes previously seen in scope chain B, and vice versa. This halves the number of "seen before?" comparisons, speeding up some runs of style-servo, clap-rs, and syn by 1--2%. Thanks to @kirillkh for the suggestion. r? @nikomatsakis
2018-05-03Avoid many `cmt` allocations.Nicholas Nethercote-83/+82
`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-02Remove Option from the return type of Attribute::name()Seiichi Uchida-1/+1
2018-05-01Auto merge of #50198 - oli-obk:const_prop, r=eddybbors-12/+0
Remove some unused code
2018-05-01Use two vectors in nearest_common_ancestor.Nicholas Nethercote-5/+6
When looking at any scope in scope chain A, we only need to look for matches among scopes previously seen in scope chain B, and vice versa. This halves the number of "seen before?" comparisons, speeding up some runs of style-servo, clap-rs, and syn by 1--2%.
2018-04-30Remove unused const error variantOliver Schneider-9/+0
2018-04-30Remove unused error variantsOliver Schneider-4/+1
2018-04-30Correct unused field warning on struct match container patternsvarkor-7/+22
2018-04-30Correct unused field warning on box struct matchvarkor-2/+3
2018-04-30Correct unused field warning on &struct matchvarkor-9/+19
2018-04-26rustc_target: move in syntax::abi and flip dependency.Irina Popa-2/+2
2018-04-26Rename rustc_back::target to rustc_target::spec.Irina Popa-3/+3
2018-04-26rustc_back: move LinkerFlavor, PanicStrategy, and RelroLevel to target.Irina Popa-2/+2