about summary refs log tree commit diff
path: root/src/librustc_middle
AgeCommit message (Collapse)AuthorLines
2020-05-31Auto merge of #72743 - lcnr:predicate_f, r=nikomatsakisbors-2/+2
fix EncodeWithShorthand for Predicate r? @nikomatsakis
2020-05-30Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkovRalf Jung-4/+15
Improve inline asm error diagnostics Previously we were just using the raw LLVM error output (with line, caret, etc) as the diagnostic message, which ends up looking rather out of place with our existing diagnostics. The new diagnostics properly format the diagnostics and also take advantage of LLVM's per-line `srcloc` attribute to map an error in inline assembly directly to the relevant line of source code. Incidentally also fixes #71639 by disabling `srcloc` metadata during LTO builds since we don't know what crate it might have come from. We can only resolve `srcloc`s from the currently crate since it indexes into the source map for the current crate. Fixes #72664 Fixes #71639 r? @petrochenkov ### Old style ```rust #![feature(llvm_asm)] fn main() { unsafe { let _x: i32; llvm_asm!( "mov $0, $1 invalid_instruction $0, $1 mov $0, $1" : "=&r" (_x) : "r" (0) :: "intel" ); } } ``` ``` error: <inline asm>:3:14: error: invalid instruction mnemonic 'invalid_instruction' invalid_instruction ecx, eax ^~~~~~~~~~~~~~~~~~~ --> src/main.rs:6:9 | 6 | / llvm_asm!( 7 | | "mov $0, $1 8 | | invalid_instruction $0, $1 9 | | mov $0, $1" ... | 12 | | :: "intel" 13 | | ); | |__________^ ``` ### New style ```rust #![feature(asm)] fn main() { unsafe { asm!( "mov {0}, {1} invalid_instruction {0}, {1} mov {0}, {1}", out(reg) _, in(reg) 0i64, ); } } ``` ``` error: invalid instruction mnemonic 'invalid_instruction' --> test.rs:7:14 | 7 | invalid_instruction {0}, {1} | ^ | note: instantiated into assembly here --> <inline asm>:3:14 | 3 | invalid_instruction rax, rcx | ^^^^^^^^^^^^^^^^^^^ ```
2020-05-30Account for returned `dyn Trait` evaluating to `'static` lifetimeEsteban Küber-27/+93
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-30miri errors: rename InvalidDiscriminant -> InvalidTagRalf Jung-3/+3
2020-05-30tag/niche terminology cleanupRalf Jung-29/+29
2020-05-30Rollup merge of #72563 - RalfJung:multi-return, r=matthewjasperRalf Jung-1/+2
multiple Return terminators are possible @ecstatic-morse mentioned in https://github.com/rust-lang/rust/issues/72515 that multiple `Return` terminators are possible. Update the docs accordingly. Cc @rust-lang/wg-mir-opt
2020-05-30Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, ↵Ralf Jung-6/+5
r=varkor mir: adjust conditional in recursion limit check Fixes #67552. This PR adjusts the condition used in the recursion limit check of the monomorphization collector, from `>` to `>=`. In #67552, the test case had infinite indirect recursion, repeating a handful of functions (from the perspective of the monomorphization collector): `rec` -> `identity` -> `Iterator::count` -> `Iterator::fold` -> `Iterator::next` -> `rec`. During this process, `resolve_associated_item` was invoked for `Iterator::fold` (during the construction of an `Instance`), and ICE'd due to substitutions needing inference. However, previous iterations of this recursion would have called this function for `Iterator::fold` - and did! - and succeeded in doing so (trivially checkable from debug logging, `()` is present where `_` is in the substs of the failing execution). The expected outcome of this test case would be a recursion limit error (which is present when the `identity` fn indirection is removed), and the recursion depth of `rec` is increasing (other functions finish collecting their neighbours and thus have their recursion depths reset). When the ICE occurs, the recursion depth of `rec` is 256 (which matches the recursion limit), which suggests perhaps that a different part of the compiler is using a `>=` comparison and returning a different result on this recursion rather than what it returned in every previous recursion, thus stopping the monomorphization collector from reporting an error on the next recursion, where `recursion_depth_of_rec > 256` would have been true. With grep and some educated guesses, we can determine that the recursion limit check at line 818 in `src/librustc_trait_selection/traits/project.rs` is the other check that is using a different comparison. Modifying either comparison to be `>` or `>=` respectively will fix the error, but changing the monomorphization collector produces the nicer error.
2020-05-30Rollup merge of #72299 - lcnr:sized_help, r=petrochenkovRalf Jung-2/+8
more `LocalDefId`s
2020-05-30Make TLS accesses explicit in MIROliver Scherer-1/+28
2020-05-30more `LocalDefId`sBastian Kauschke-2/+8
2020-05-30multiple Return terminators are possibleRalf Jung-1/+2
2020-05-30Rollup merge of #72752 - lcnr:remove-mk_bool, r=estebankYuki Okushi-5/+0
remove mk_bool
2020-05-30Rollup merge of #72419 - RalfJung:read-discriminant, r=oli-obk,eddybYuki Okushi-15/+24
Miri read_discriminant: return a scalar instead of raw underlying bytes r? @oli-obk @eddyb
2020-05-29Auto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJungbors-11/+40
Rollup of 9 pull requests Successful merges: - #67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes) - #71095 (impl From<[T; N]> for Box<[T]>) - #71500 (Make pointer offset methods/intrinsics const) - #71804 (linker: Support `-static-pie` and `-static -shared`) - #71862 (Implement RFC 2585: unsafe blocks in unsafe fn) - #72103 (borrowck `DefId` -> `LocalDefId`) - #72407 (Various minor improvements to Ipv6Addr::Display) - #72413 (impl Step for char (make Range*<char> iterable)) - #72439 (NVPTX support for new asm!) Failed merges: r? @ghost
2020-05-29Rollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, ↵Ralf Jung-2/+14
r=nikomatsakis Implement RFC 2585: unsafe blocks in unsafe fn Tracking issue: #71668 r? @RalfJung cc @nikomatsakis
2020-05-29Rollup merge of #71500 - josephlr:offset, r=oli-obk,RalfJungRalf Jung-9/+26
Make pointer offset methods/intrinsics const Implements #71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
2020-05-29remove trivial `mk_predicate`sBastian Kauschke-1/+2
2020-05-29remove mk_boolBastian Kauschke-5/+0
2020-05-29Rollup merge of #72591 - sexxi-goose:rename_upvar_list-to-closure_captures, ↵Dylan DPC-4/+4
r=matthewjasper librustc_middle: Rename upvar_list to closure_captures As part of supporting RFC 2229, we will be capturing all the places that are mentioned in a closure. Currently the `upvar_list` field gives access to a `FxIndexMap<HirId, Upvar>` map. Eventually this will change, with the `upvar_list` having a more general structure that expresses captured paths, not just the mentioned `upvars`. We will make those changes in subsequent PRs. This commit modifies the name of the `upvar_list` map to `closure_captures` in `TypeckTables`. r? @matthewjasper
2020-05-29Borrow<[T]> for Interned<'tcx, List<T>>Bastian Kauschke-48/+2
2020-05-29Move common code to `WhereClause`Esteban Küber-12/+1
2020-05-29fix encode with shorthand for PredicateBastian Kauschke-2/+2
2020-05-29Add Span to arena_types! for decoding &'tcx [Span]Amanieu d'Antras-0/+2
2020-05-29Improve inline asm error diagnosticsAmanieu d'Antras-4/+13
2020-05-29Rollup merge of #72636 - marmeladema:resolver-outputs-def-id, r=petrochenkovDylan DPC-12/+8
Cleanup `Resolver::<clone|into>_outputs` methods Follow-up cleanup work of https://github.com/rust-lang/rust/pull/72402 First commit has been split out from https://github.com/rust-lang/rust/pull/72552 r? @ecstatic-morse
2020-05-28Account for trailing comma when suggesting `where` clausesEsteban Küber-12/+9
Fix #72693.
2020-05-28add str to common typesBastian Kauschke-6/+3
2020-05-28standardize limit comparisons with `Limit` typeDavid Wood-6/+5
This commit introduces a `Limit` type which is used to ensure that all comparisons against limits within the compiler are consistent (which can result in ICEs if they aren't). Signed-off-by: David Wood <david@davidtw.co>
2020-05-27Add additional checks for isize overflowJoe Richey-2/+13
We now perform the correct checks even if the pointer size differs between the host and target. Signed-off-by: Joe Richey <joerichey@google.com>
2020-05-28Auto merge of #72494 - lcnr:predicate-cleanup, r=nikomatsakisbors-51/+62
Pass more `Copy` types by value. There are a lot of locations where we pass `&T where T: Copy` by reference, which should both be slightly less performant and less readable IMO. This PR currently consists of three fairly self contained commits: - passes `ty::Predicate` by value and stops depending on `AsRef<ty::Predicate>`. - changes `<&List<_>>::into_iter` to iterate over the elements by value. This would break `List`s of non copy types. But as the only list constructor requires `T` to be copy anyways, I think the improved readability is worth this potential future restriction. - passes `mir::PlaceElem` by value. Mir currently has quite a few copy types which are passed by reference, e.g. `Local`. As I don't have a lot of experience working with MIR, I mostly did this to get some feedback from people who use MIR more frequently - tries to reuse `ty::Predicate` in case it did not change in some places, which should hopefully fix the regression caused by #72055 r? @nikomatsakis for the first commit, which continues the work of #72055 and makes adding `PredicateKind::ForAll` slightly more pleasant. Feel free to reassign though
2020-05-27Use the lowest of `unsafe_op_in_unsafe_fn` and `safe_borrow_packed` for ↵LeSeulArtichaut-0/+4
packed borrows in unsafe fns
2020-05-27Apply suggestions from code reviewLeSeulArtichaut-2/+3
2020-05-27Implement RFC 2585LeSeulArtichaut-1/+8
2020-05-27Store `LocalDefId` directly in `rustc_resolve::Resolver` where possiblemarmeladema-12/+8
This commit also include the following changes: * Remove unused `hir::Map::as_local_node_id` method * Remove outdated comment about `hir::Map::local_def_id` method * Remove confusing `GlobMap` type alias * Use `LocalDefId` instead of `DefId` in `extern_crate_map` * Use `LocalDefId` instead of `DefId` in `maybe_unused_extern_crates` * Modify `extern_mod_stmt_cnum` query to accept a `LocalDefId` instead of a `DefId`
2020-05-26librustc_middle: Add function for computing unsigned absJoe Richey-8/+14
This is tricky to get right if we want to avoid panicking or wrapping. Signed-off-by: Joe Richey <joerichey@google.com>
2020-05-25Display information about captured variable in `FnMut` errorAaron Hill-1/+9
Fixes #69446 When we encounter a region error involving an `FnMut` closure, we display a specialized error message. However, we currently do not tell the user which upvar was captured. This makes it difficult to determine the cause of the error, especially when the closure is large. This commit records marks constraints involving closure upvars with `ConstraintCategory::ClosureUpvar`. When we decide to 'blame' a `ConstraintCategory::Return`, we additionall store the captured upvar if we found a `ConstraintCategory::ClosureUpvar` in the path. When generating an error message, we point to relevant spans if we have closure upvar information available. We further customize the message if an `async` closure is being returned, to make it clear that the captured variable is being returned indirectly.
2020-05-25Rename upvar_list to closure_capturesDhruv Jauhar-4/+4
As part of supporting RFC 2229, we will be capturing all the places that are mentioned in a closure. Currently the upvar_list field gives access to a FxIndexMap<HirId, Upvar> map. Eventually this will change, with the upvar_list having a more general structure that expresses captured paths, not just the mentioned upvars. We will make those changes in subsequent PRs. This commit modifies the name of the upvar_list map to closure_captures in TypeckTables. Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com> Co-authored-by: Aman Arora <me@aman-arora.com>
2020-05-25Rollup merge of #72538 - rakshith-ravi:refactor/remove-const-query, r=oli-obkDylan DPC-9/+0
Removed all instances of const_field. Fixes #72264 r? @oli-obk
2020-05-25Rollup merge of #72424 - RalfJung:mir-print-ice, r=oli-obkDylan DPC-10/+20
fix ICE when debug-printing MIR Fixes https://github.com/rust-lang/rust/issues/72105 This bug also makes debugging Miri harder as `MIRI_LOG=info` ICEs.
2020-05-25fix discriminant_ty for non-enumsRalf Jung-7/+15
2020-05-25Add helper method for determining the type of a discriminantRalf Jung-10/+11
2020-05-25Miri: refactor read_discriminant and make it return ScalarRalf Jung-2/+2
2020-05-25Rollup merge of #72544 - sexxi-goose:upvars_mentioned, r=matthewjasperRalf Jung-6/+6
librustc_middle: Rename upvars query to upvars_mentioned As part of supporting RFC 2229, we will be capturing all the Places that were mentioned in the closure. This commit modifies the name of the upvars query to upvars_mentioned. r? @nikomatsakis @blitzerr @matthewjasper
2020-05-25fix ICE when debug-printing MIRRalf Jung-10/+20
2020-05-24librustc_middle: Rename upvars query to upvars_mentionedAman Arora-6/+6
As part of supporting RFC 2229, we will be capturing all the Places that were mentioned in the closure. This commit modifies the name of the upvars query to upvars_mentioned. Co-authored-by: Aman Arora <me@aman-arora.com> Co-authored-by: Chris Pardy <chrispardy36@gmail.com>
2020-05-24Rollup merge of #72402 - marmeladema:resolver-outputs-def-id, r=ecstatic-morseRalf Jung-46/+15
Remove all uses of `NodeId` in `ResolverOutputs` cc #50928 r? @ecstatic-morse
2020-05-24Removed all instances of const_field.Rakshith Ravi-9/+0
2020-05-24Auto merge of #72362 - matthewjasper:remove-rescope, r=nikomatsakisbors-211/+13
Remove ReScope `ReScope` is unnecessary now that AST borrowck is gone and we're erasing the results of region inference in function bodies. This removes about as much of the old regionck code as possible without having to enable NLL fully. cc #68261 r? @nikomatsakis
2020-05-24Rollup merge of #72400 - Aaron1011:fix/asm-incr-ice, r=AmanieuDylan DPC-0/+6
Add missing ASM arena declarations to librustc_middle Fixes #72386 These types also need to get allocated on the `librustc_middle` arena when we deserialize MIR. @Amanieu: If we end up using your approach in https://github.com/rust-lang/rust/pull/72392 instead, feel free to copy the test I added over to your PR.
2020-05-23Add missing ASM arena declaration to librustc_middleAaron Hill-0/+6
Fixes #72386 This type also needs to get allocated on the `librustc_middle` arena when we deserialize MIR.