about summary refs log tree commit diff
path: root/src/librustc
AgeCommit message (Collapse)AuthorLines
2019-10-28self-profiling: Record something more useful for crate metadata generation ↵Michael Woerister-0/+1
event. Before this commit, we had an event that would only track the compression step for proc-macros and Rust dylibs. After the commit we measure the time for acutally generating the crate metadata bytes.
2019-10-28rustc: use IndexVec<DefIndex, T> instead of Vec<T>.Eduard-Mihai Burtescu-23/+17
2019-10-28Auto merge of #65188 - matthewjasper:stabilize-const-constructor, r=Centrilbors-8/+3
Stabilize `const_constructor` # Stabilization proposal I propose that we stabilize `#![feature(const_constructor)]`. Tracking issue: https://github.com/rust-lang/rust/issues/61456 Version target: 1.40 (2019-11-05 => beta, 2019-12-19 => stable). ## What is stabilized ### User guide Tuple struct and tuple variant constructors are now considered to be constant functions. As such a call expression where the callee has a tuple struct or variant constructor "function item" type can be called: ```rust const fn make_options() { // These already work because they are special cased: Some(0); (Option::Some)(1); // These also work now: let f = Option::Some; f(2); {Option::Some}(3); <Option<_>>::Some(5); } ``` ### Motivation Consistency with other `const fn`. Consistency between syntactic path forms. This should also ensure that constructors implement `const Fn` traits and can be coerced to `const fn` function pointers, if they are introduced. ## Tests * [ui/consts/const_constructor/const-construct-call.rs](https://github.com/rust-lang/rust/blob/0d75ab2293a106eb674ac01860910cfc1580837e/src/test/ui/consts/const_constructor/const-construct-call.rs) - Tests various syntactic forms, use in both `const fn` and `const` items, and constructors in both the current and extern crates. * [ui/consts/const_constructor/const_constructor_qpath.rs](https://github.com/rust-lang/rust/blob/1850dfcdabf8258a1f023f26c2c59e96b869dd95/src/test/ui/consts/const_constructor/const_constructor_qpath.rs) - Tests that type qualified paths to enum variants are also considered to be `const fn`.(#64247) r? @oli-obk Closes #61456 Closes #64247
2019-10-28Rollup merge of #65792 - Centril:split-syntax-2, r=petrochenkovMazdak Farrokhzad-15/+13
rustc, rustc_passes: reduce deps on rustc_expand Part of #65324. r? @petrochenkov
2019-10-28Rollup merge of #65664 - anp:panic-location, r=eddybMazdak Farrokhzad-0/+17
`std::panic::Location` is a lang_item, add `core::intrinsics::caller_location` (RFC 2091 3/N) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [RFC text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) @eddyb suggested doing this intrinsic implementation ahead of actually implementing the `#[track_caller]` attribute so that there's an easily tested intermediate step between adding the shim and wiring up the attribute.
2019-10-27Stabilize `const_constructor`Matthew Jasper-8/+3
2019-10-27Always use consteval to codegen caller_location.Adam Perry-0/+16
2019-10-27Implement core::intrinsics::caller_location.Adam Perry-0/+1
Returns a `&core::panic::Location` corresponding to where it was called, also making `Location` a lang item.
2019-10-27Auto merge of #65869 - Centril:rollup-bzlo74f, r=Centrilbors-4/+10
Rollup of 6 pull requests Successful merges: - #65566 (Use heuristics to suggest assignment) - #65738 (Coherence should allow fundamental types to impl traits when they are local) - #65777 (Don't ICE for completely unexpandable `impl Trait` types) - #65834 (Remove lint callback from driver) - #65839 (Clean up `check_consts` now that new promotion pass is implemented) - #65855 (Add long error explaination for E0666) Failed merges: r? @ghost
2019-10-27rustc, rustc_passes: don't depend on syntax_expand.Mazdak Farrokhzad-15/+13
This is done by moving some data definitions to syntax::expand.
2019-10-27Rollup merge of #65738 - ↵Mazdak Farrokhzad-4/+10
ohadravid:re-rebalance-coherence-allow-fundamental-local, r=nikomatsakis Coherence should allow fundamental types to impl traits when they are local After #64414, `impl<T> Remote for Box<T> { }` is disallowed, but it is also disallowed in liballoc, where `Box` is a local type! Enabling `#![feature(re_rebalance_coherence)]` in `liballoc` results in: ``` error[E0210]: type parameter `F` must be used as the type parameter for some local type (e.g., `MyStruct<F>`) --> src\liballoc\boxed.rs:1098:1 | 1098 | impl<F: ?Sized + Future + Unpin> Future for Box<F> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `F` must be used as the type parameter for some local type ``` This PR relaxes `uncover_fundamental_ty` to skip local fundamental types. I didn't add a test since `liballoc` already fails to compile, but I can add one if needed. r? @nikomatsakis cc #63599
2019-10-27Auto merge of #65541 - eddyb:spanned-inferred-outlives, r=nikomatsakisbors-2/+2
rustc: add `Span`s to `inferred_outlives_of` predicates. This would simplify #59789, and I suspect it has some potential in diagnostics (although we don't seem to use the predicate `Span`s much atm).
2019-10-27Auto merge of #65519 - pnkfelix:issue-63438-trait-based-structural-match, ↵bors-125/+226
r=matthewjasper trait-based structural match implementation Moves from using a `#[structural_match]` attribute to using a marker trait (or pair of such traits, really) instead. Fix #63438. (This however does not remove the hacks that I believe were put into place to support the previous approach of injecting the attribute based on the presence of both derives... I have left that for follow-on work.)
2019-10-27Auto merge of #65288 - estebank:point-at-assoc-type, r=nikomatsakisbors-34/+194
Point at associated type for some obligations Partially address #57663.
2019-10-26Update comments re type parameter hack in object safetyMichael Hewson-5/+7
To check if a method's receiver type is object safe, we create a new receiver type by substituting in a bogus type parameter (let's call it `U`) for `Self`, and checking that the unmodified receiver type implements `DispatchFromDyn<receiver type with Self = U>`. It would be better to use `dyn Trait` directly, and the only reason we don't is because it triggers another check that `Trait` is object safe, resulting in a query cycle. Once the feature `object_safe_for_dispatch` (tracking issue https://github.com/rust-lang/rust/issues/43561) is stabilized, this will no longer be the case, and we'll be able to use `dyn Trait` as the unsized `Self` type. I've updated the comments in object_safety.rs accordingly.
2019-10-26Rollup merge of #65828 - bjorn3:add_source_info_eq_hash, r=petrochenkovMazdak Farrokhzad-1/+3
Derive Eq and Hash for SourceInfo again In https://github.com/bjorn3/rustc_codegen_cranelift/blob/75c24b9c9677600422ec86fa9f4c78fe3678d2ce/src/common.rs#L368 I store it in a `indexmap::IndexSet`, which requires `Eq` and `Hash`. Unfortunately they were removed in https://github.com/rust-lang/rust/pull/65647, so I can't update to latest nightly.
2019-10-26Rollup merge of #65824 - eddyb:def-key-copy, r=varkorMazdak Farrokhzad-8/+8
rustc: make DefPathData (and friends) Copy (now that it uses Symbol). Spotted this while working on something else.
2019-10-26Rollup merge of #65772 - mark-i-m:final-readmes, r=nikomatsakisMazdak Farrokhzad-265/+4
Remove the last remaining READMEs cc https://github.com/rust-lang/rustc-guide/pull/481 closes #48478 r? @nikomatsakis
2019-10-26Coherence should allow fundamental types to impl traitsOhad Ravid-4/+10
2019-10-26Make inline associated constants a future compatibility warningvarkor-8/+26
2019-10-26Permit #[track_caller] on inherent methodsvarkor-12/+32
2019-10-25Correct handling of type flags with `ConstValue::Placeholder`varkor-7/+9
2019-10-25Permit `#[target_feature]` on method implementationsvarkor-1/+1
2019-10-25Move handling of `#[track_caller]` to `check_attr`varkor-24/+85
2019-10-25Update bitflagsvarkor-1/+1
2019-10-25Handle `ImplItem` in `check_attr`varkor-1/+16
2019-10-25Refactor `check_track_caller`varkor-6/+12
2019-10-25Improve commentsvarkor-2/+2
2019-10-25Emit warning for ignored #[inline] on foreign function prototypesvarkor-0/+18
2019-10-25Emit warning for ignored #[inline] on trait method prototypesvarkor-0/+40
2019-10-25Refactor check_attrvarkor-63/+75
2019-10-25Don't cast directly from `&[T; N]` to `*const T`Matthew Jasper-0/+3
Instead coerce to `*const [T; N]` and then cast.
2019-10-25Derive Eq and Hash for SourceInfo againbjorn3-1/+3
2019-10-26Rollup merge of #65800 - michaelwoerister:measureme-0.4.0, r=wesleywiserYuki Okushi-100/+30
self-profiling: Update measureme to 0.4.0 and remove non-RAII methods from profiler. This PR removes all non-RAII based profiling methods from `SelfProfilerRef` :tada: It also delegates the `TimingGuard` implementation to `measureme`, now that that is available there. r? @wesleywiser
2019-10-25rustc: replace a few `.cloned()` with `.copied()`.Eduard-Mihai Burtescu-3/+3
2019-10-25rustc: make DefPathData (and friends) Copy (now that it uses Symbol).Eduard-Mihai Burtescu-5/+5
2019-10-25Take out an insurance policy in case `iter.size_hint()`Mazdak Farrokhzad-1/+5
lies, underreporting the number of elements.
2019-10-25only relevant parts of type paths highlighted in E0308 type mismatch error ↵Kevyn Grasso-7/+42
message
2019-10-25Add new EFIAPI ABIroblabla-0/+2
Adds a new ABI for the EFIAPI calls. This ABI should reflect the latest version of the UEFI specification at the time of commit (UEFI spec 2.8, URL below). The specification says that for x86_64, we should follow the win64 ABI, while on all other supported platforms (ia32, itanium, arm, arm64 and risc-v), we should follow the C ABI. To simplify the implementation, we will simply follow the C ABI on all platforms except x86_64, even those technically unsupported by the UEFI specification. https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
2019-10-25Review feedback: elaborated comments.Felix S. Klock II-5/+21
2019-10-25Migrate from `#[structural_match]` attribute a lang-item trait.Felix S. Klock II-77/+152
(Or more precisely, a pair of such traits: one for `derive(PartialEq)` and one for `derive(Eq)`.) ((The addition of the second marker trait, `StructuralEq`, is largely a hack to work-around `fn (&T)` not implementing `PartialEq` and `Eq`; see also issue rust-lang/rust#46989; otherwise I would just check if `Eq` is implemented.)) Note: this does not use trait fulfillment error-reporting machinery; it just uses the trait system to determine if the ADT was tagged or not. (Nonetheless, I have kept an `on_unimplemented` message on the new trait for structural_match check, even though it is currently not used.) Note also: this does *not* resolve the ICE from rust-lang/rust#65466, as noted in a comment added in this commit. Further work is necessary to resolve that and other problems with the structural match checking, especially to do so without breaking stable code (adapted from test fn-ptr-is-structurally-matchable.rs): ```rust fn r_sm_to(_: &SM) {} fn main() { const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to); let input: Wrap<fn(&SM)> = Wrap(r_sm_to); match Wrap(input) { Wrap(CFN6) => {} Wrap(_) => {} }; } ``` where we would hit a problem with the strategy of unconditionally checking for `PartialEq` because the type `for <'a> fn(&'a SM)` does not currently even *implement* `PartialEq`. ---- added review feedback: * use an or-pattern * eschew `return` when tail position will do. * don't need fresh_expansion; just add `structural_match` to appropriate `allow_internal_unstable` attributes. also fixed example in doc comment so that it actually compiles.
2019-10-25Rollup merge of #65315 - spastorino:intern-place-projection, r=oli-obkMazdak Farrokhzad-65/+137
Intern place projection This should sit on top of https://github.com/rust-lang/rust/pull/65197. After that one merged, I'm gonna rebase on top of it. The important commits are the last three and there's a bunch of code repetition that I'm going to remove but for that I need to refactor some things that probably need to be added before this PR. Anyway this work helps as is because we can run perf tests :). r? @oli-obk /cc @nikomatsakis
2019-10-25Rollup merge of #65074 - Rantanen:json-byte-pos, r=matkladMazdak Farrokhzad-0/+19
Fix the start/end byte positions in the compiler JSON output Track the changes made during normalization in the `SourceFile` and use this information to correct the `start_byte` and `end_byte` fields in the JSON output. This should ensure the start/end byte fields can be used to index the original file, even if Rust normalized the source code for parsing purposes. Both CRLF to LF and BOM removal are handled with this one. The rough plan was discussed with @matklad in rust-lang-nursery/rustfix#176 - although I ended up going with `u32` offset tracking so I wouldn't need to deal with `u32 + i32` arithmetics when applying the offset to the span byte positions. Fixes #65029
2019-10-25refactor: move structural_match analysis into its own module.Felix S. Klock II-125/+135
2019-10-25self-profiling: Switch query-blocking measurements to RAII-style API.Michael Woerister-21/+19
2019-10-25RFC 2008: StabilizationDavid Wood-3/+1
This commit stabilizes RFC 2008 (#44109) by removing the feature gate. Signed-off-by: David Wood <david@davidtw.co>
2019-10-24remove the last remaining READMEsMark Mansi-265/+4
2019-10-24Rollup merge of #65627 - varkor:const-generics-forbid-non-structural_match, ↵Mazdak Farrokhzad-6/+128
r=petrochenkov Forbid non-`structural_match` types in const generics Fixes https://github.com/rust-lang/rust/issues/60286.
2019-10-24rustc_metadata: Minimize use of `Lrc` in crate storeVadim Petrochenkov-18/+11
Crate metadatas are still stored as `Lrc<CrateMetadata>` in `CStore` because crate store has to be cloneable due to `Resolver::clone_outputs`.
2019-10-24Turn crate store into a resolver outputVadim Petrochenkov-10/+10