about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2021-09-06Clean up the fix a bitThePuzzlemaker-8/+12
Use register_predicate_obligations rather than a for loop, since I didn't see that before. Also destructure in the `let` rather than projecting the fields individually
2021-09-06Normalize assoc types when checking ret ty of mainThePuzzlemaker-1/+17
This fixes #88609. Previously, the return type of `fn main()` would not have any associated type projections within normalized before checking if it implements the standard library trait `std::process::Termination`. This commit appears to fix it. This feels vaguely symptomatic of a problem in the underlying trait solving engine, but I am not sure how I would solve that. I am unsure why the example in #88609 with `assert_impl_termination` and `fn foo()` work, but simply `fn main()` doesn't. The way that I solved this is also probably not the best way to do this, so please let me know if there is a better way to do this. I have added a build-pass regression test for this issue.
2021-09-06Auto merge of #88686 - rylev:rollup-m1tf9ir, r=m-ou-sebors-1/+1
Rollup of 6 pull requests Successful merges: - #88602 (Add tests for some const generics issues) - #88647 (Document when to use Windows' `symlink_dir` vs. `symlink_file`) - #88659 (Remove SmallVector mention) - #88661 (Correct typo) - #88673 (Fix typo: needede -> needed) - #88685 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-06Auto merge of #88678 - matthewjasper:if-boolean-scoping, r=oli-obkbors-5/+5
Change scope of temporaries in match guards Each pattern in a match arm has its own copy of the match guard in MIR, with its own temporary, so it has to be dropped before the the guards are joined to the single copy of the arm. This PR changes `then_else_break` to allow it to put the temporary in the innermost scope possible. This change isn't done for `if` expressions because that affects a large number of mir-opt tests and could more significantly affect performance. closes #88649 r? `@oli-obk`
2021-09-06Rollup merge of #88659 - est31:update_smallvec_name, r=matthewjasperRyan Levick-1/+1
Remove SmallVector mention SmallVector is long gone, as it's been first replaced by OneVector in commit e5e6375352636360add297c1f5a1f37ce71506e9, which then has been removed entirely in favour of SmallVec in commit 130a32fa7259d348dc3a684b38e688da398c30bb.
2021-09-06Auto merge of #88631 - camelid:sugg-span, r=davidtwcobors-6/+10
Improve structured tuple struct suggestion Previously, the span was just for the constructor name, which meant it would result in syntactically-invalid code when applied. Now, the span is for the entire expression. I also changed it to use `span_suggestion_verbose`, for two reasons: 1. Now that the suggestion span has been corrected, the output is a bit cluttered and hard to read. Putting the suggestion its own window creates more space. 2. It's easier to see what's being suggested, since now the version after the suggestion is applied is shown. r? `@davidtwco`
2021-09-06Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebankbors-1/+50
Fix #88256 remove duplicated diagnostics Fix #88256
2021-09-05Auto merge of #88435 - cjgillot:no-walk-crate, r=Aaron1011bors-110/+81
Avoid invoking the hir_crate query to traverse the HIR Walking the HIR tree is done using the `hir_crate` query. However, this is unnecessary, since `hir_owner(CRATE_DEF_ID)` provides the same information. Since depending on `hir_crate` forces dependents to always be executed, this leads to unnecessary work. By splitting HIR and attributes visits, we can avoid an edge to `hir_crate` when trying to visit the HIR tree.
2021-09-05Auto merge of #88552 - nbdd0121:vtable, r=nagisabors-38/+68
Stop allocating vtable entries for non-object-safe methods Current a vtable entry is allocated for all associated fns, even if the method is not object-safe: https://godbolt.org/z/h7vx6f35T As a result, each vtable for `Iterator`' currently consumes 74 `usize`s. This PR stops allocating vtable entries for those methods, reducing vtable size of each `Iterator` vtable to 7 `usize`s. Note that this PR introduces will cause more invocations of `is_vtable_safe_method`. So a perf run might be needed. If result isn't favorable then we might need to query-ify `is_vtable_safe_method`.
2021-09-05Change scope of temporaries in match guardsMatthew Jasper-5/+5
Each pattern in a match arm has its own copy of the match guard in MIR, with its own temporary, so it has to be dropped before the the guards are joined to the single copy of the arm.
2021-09-05Add query `own_existential_vtable_entries`Gary Guo-45/+70
2021-09-05Stop allocating vtable entries for non-object-safe methodsGary Guo-8/+13
2021-09-05Auto merge of #88499 - eddyb:layout-off, r=nagisabors-203/+238
Provide `layout_of` automatically (given tcx + param_env + error handling). After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit. This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context. After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type: * `TyCtxt`, via `HasTyCtxt` * `ParamEnv`, via `HasParamEnv` * a way to transform `LayoutError`s into the desired error type * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`) When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform. (**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it) Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts. r? `@nagisa` cc `@oli-obk` `@bjorn3`
2021-09-05Rollup merge of #88657 - camelid:fix-dyn-sugg, r=m-ou-seMara Bos-4/+4
Fix 2021 `dyn` suggestion that used code as label The arguments to `span_suggestion` were in the wrong order, so the error looked like this: error[E0783]: trait objects without an explicit `dyn` are deprecated --> src/test/ui/editions/dyn-trait-sugg-2021.rs:10:5 | 10 | Foo::hi(123); | ^^^ help: <dyn Foo>: `use `dyn`` Now the error looks like this, as expected: error[E0783]: trait objects without an explicit `dyn` are deprecated --> src/test/ui/editions/dyn-trait-sugg-2021.rs:10:5 | 10 | Foo::hi(123); | ^^^ help: use `dyn`: `<dyn Foo>` This issue was only present in the 2021 error; the 2018 lint was correct. r? `@m-ou-se`
2021-09-05Rollup merge of #88257 - estebank:invalid-attr-error, r=oli-obkMara Bos-21/+119
Provide more context on incorrect inner attribute Suggest changing an inner attribute into an outer attribute if followed by an item.
2021-09-05Auto merge of #88559 - bjorn3:archive_logic_dedup, r=cjgillotbors-163/+84
Move add_rlib and add_native_library to cg_ssa This deduplicates logic between codegen backends. cc `@antoyo` and `@khyperia` for cg_gcc and rust-gpu.
2021-09-05Remove SmallVector mentionest31-1/+1
SmallVector is long gone, as it's been first replaced by OneVector in commit e5e6375352636360add297c1f5a1f37ce71506e9, which then has been removed entirely in favour of SmallVec in commit 130a32fa7259d348dc3a684b38e688da398c30bb.
2021-09-04Fix 2021 `dyn` suggestion that used code as labelNoah Lev-4/+4
The arguments to `span_suggestion` were in the wrong order, so the error looked like this: error[E0783]: trait objects without an explicit `dyn` are deprecated --> src/test/ui/editions/dyn-trait-sugg-2021.rs:10:5 | 10 | Foo::hi(123); | ^^^ help: <dyn Foo>: `use `dyn`` Now the error looks like this, as expected: error[E0783]: trait objects without an explicit `dyn` are deprecated --> src/test/ui/editions/dyn-trait-sugg-2021.rs:10:5 | 10 | Foo::hi(123); | ^^^ help: use `dyn`: `<dyn Foo>` This issue was only present in the 2021 error; the 2018 lint was correct.
2021-09-04Auto merge of #88626 - cjgillot:lfitb, r=petrochenkovbors-235/+195
Simplify lifetimes_from_impl_trait_bounds Part of https://github.com/rust-lang/rust/pull/87234 r? `@petrochenkov`
2021-09-04Auto merge of #88550 - dpaoliello:dpaoliello/allocdebuginfo, r=estebankbors-41/+66
Include debug info for the allocator shim Issue Details: In some cases it is necessary to generate an "allocator shim" to forward various Rust allocation functions (e.g., `__rust_alloc`) to an underlying function (e.g., `malloc`). However, since this allocator shim is a manually created LLVM module it is not processed via the normal module processing code and so no debug info is generated for it (if debugging info is enabled). Fix Details: * Modify the `debuginfo` code to allow creating debug info for a module without a `CodegenCx` (since it is difficult, and expensive, to create one just to emit some debug info). * After creating the allocator shim add in basic debug info.
2021-09-04Fix #88256, remove duplicated diagnosticyukang-1/+50
2021-09-04Auto merge of #88547 - notriddle:notriddle/is-expr-delims-necessary, r=davidtwcobors-7/+10
fix(rustc_lint): better detect when parens are necessary Fixes #88519
2021-09-04Auto merge of #88538 - bjorn3:no_session_in_crate_loader, r=petrochenkovbors-94/+77
CrateLocator refactorings This makes the `CrateLocator` a lot cleaner IMHO and much more self-contained. The last commit removes `extra_filename` from the crate metadata. This is an **insta-stable** change as it allows a crate like `libfoo-abc.rlib` to be used as dependency and then be renamed as `libfoo-bcd.rlib` while still being found as indirect dependency. This may reduce performance when there are a lot of versions of the same crate available as the extra filename won't be used to do an early rejection of crates before trying to load metadata, but it makes the logic to find the right filename a lot cleaner.
2021-09-04Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiserbors-5/+55
Detect bare blocks with type ascription that were meant to be a `struct` literal Address part of #34255. Potential improvement: silence the other knock down errors in `issue-34255-1.rs`.
2021-09-03Replace Vec by Option.Camille GILLOT-35/+14
2021-09-03Simplify lifetimes_from_impl_trait_bounds.Camille GILLOT-200/+181
2021-09-03Auto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obkbors-115/+195
Fix drop handling for `if let` expressions MIR lowering for `if let` expressions is now more complicated now that `if let` exists in HIR. This PR adds a scope for the variables bound in an `if let` expression and then uses an approach similar to how we handle loops to ensure that we reliably drop the correct variables. Closes #88307 cc `@flip1995` `@richkadel` `@c410-f3r`
2021-09-03Auto merge of #88454 - devnexen:sunos_asan, r=wesleywiserbors-2/+4
sunos systems add sanitizer supported.
2021-09-03Auto merge of #88597 - cjgillot:lower-global, r=petrochenkovbors-151/+103
Move global analyses from lowering to resolution Split off https://github.com/rust-lang/rust/pull/87234 r? `@petrochenkov`
2021-09-03Detect bare blocks with type ascription that were meant to be a `struct` literalEsteban Kuber-5/+55
Address part of #34255. Potential improvement: silence the other knock down errors in `issue-34255-1.rs`.
2021-09-03Auto merge of #88618 - m-ou-se:rollup-6tss5z6, r=m-ou-sebors-31/+6
Rollup of 7 pull requests Successful merges: - #88202 (Add an example for deriving PartialOrd on enums) - #88483 (Fix LLVM libunwind build for non-musl targets) - #88507 (Add test case for using `slice::fill` with MaybeUninit) - #88557 (small const generics cleanup) - #88579 (remove redundant / misplaced sentence from docs) - #88610 (Update outdated docs of array::IntoIter::new.) - #88613 (Update primitive docs for rust 2021.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-03Rollup merge of #88557 - lcnr:const-generics-cleanup, r=BoxyUwUMara Bos-31/+6
small const generics cleanup
2021-09-03Auto merge of #86454 - tlyu:refactor-unsized-suggestions, r=davidtwcobors-67/+112
Refactor unsized suggestions `@rustbot` label +A-diagnostics +A-traits +A-typesystem +C-cleanup +T-compiler
2021-09-03Auto merge of #88428 - petrochenkov:stmtid, r=Aaron1011bors-55/+83
expand: Treat more macro calls as statement macro calls This PR implements the suggestion from https://github.com/rust-lang/rust/pull/87981#issuecomment-906641052 and treats fn-like macro calls inside `StmtKind::Item` and `StmtKind::Semi` as statement macro calls, which is consistent with treatment of attribute invocations in the same positions and with token-based macro expansion model in general. This also allows to remove a special case in `NodeId` assignment (previously tried in #87779), and to use statement `NodeId`s for linting (`assign_id!`). r? `@Aaron1011`
2021-09-03Auto merge of #88386 - estebank:unmatched-delims, r=jackh726bors-3/+18
Point at unclosed delimiters as part of the primary MultiSpan Both the place where the parser encounters a needed closed delimiter and the unclosed opening delimiter are important, so they should get the same level of highlighting in the output. _Context: https://twitter.com/mwk4/status/1430631546432675840_
2021-09-03Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebankbors-36/+63
Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. This PR fixes a regression (#87745) with `--remap-path-prefix` where the flag stopped causing diagnostic messages to be remapped as well. The regression was introduced in https://github.com/rust-lang/rust/pull/83813 where we erroneously assumed that remapping of diagnostic messages was not desired anymore (because #70642 partially undid that functionality with nobody objecting). The issue is fixed by making `--remap-path-prefix` remap diagnostic messages again, including for paths that have been remapped in upstream crates (e.g. the standard library). This means that "sysroot-localization" (implemented in #70642) is also disabled if `rustc` is invoked with `--remap-path-prefix`. The assumption is that once someone starts explicitly remapping paths they also don't want paths to their local Rust installation in their build output. In the future we might want to give more fine-grained control over this behavior via compiler flags (see https://github.com/rust-lang/rfcs/pull/3127 for a related RFC). For now this PR is intended as a regression fix. This PR is an alternative to https://github.com/rust-lang/rust/pull/88191, which makes diagnostic messages be remapped unconditionally. That approach, however, would effectively revert #70642. Fixes https://github.com/rust-lang/rust/issues/87745. cc `@cbeuw` r? `@ghost`
2021-09-02Auto merge of #85868 - Aaron1011:projection-cache, r=jackh726bors-50/+29
Preserve most sub-obligations in the projection cache Fixes https://github.com/rust-lang/rust/issues/85360 When we evaluate a projection predicate, we may produce sub-obligations. During trait evaluation, evaluating these sub-obligations might cause us to produce `EvaluatedToOkModuloRegions`. When we cache the result of projection in our projection cache, we try to throw away some of the sub-obligations, so that we don't need to re-evaluate/process them the next time we need to perform this particular projection. However, we may end up throwing away predicates that will (recursively) evaluate to `EvaluatedToOkModuloRegions`. If we do, then the result of evaluating a predicate will depend on the state of the predicate cache - this is global untracked state, which interacts badly with incremental compilation. To fix this, we now only discard global predicates that evaluate to `EvaluatedToOk`. This ensures that any predicates that (may) evaluate to `EvaluatedToOkModuloRegions` are kept in the cache, and influence the results of any queries which perform this projection.
2021-09-02Provide more context on incorrect inner attributeEsteban Kuber-21/+119
Suggest changing an inner attribute into an outer attribute if followed by an item.
2021-09-02Rename walk_crate.Camille GILLOT-12/+12
2021-09-02Rollup merge of #88592 - b-naber:region_substs, r=oli-obkMara Bos-17/+19
Fix ICE in const check Fixes https://github.com/rust-lang/rust/issues/88433
2021-09-02Rollup merge of #88589 - xFrednet:00000-correct-comment-to-doc, r=petrochenkovMara Bos-39/+39
Correct doc comments inside `use_expr_visitor.rs` Just a simple update. I haven't changed any content inside the comments, as they still seem correct. Have a wonderful rest of the day :upside_down_face:
2021-09-02Rollup merge of #88567 - camelid:query-job-info, r=cjgillotMara Bos-11/+8
Remove redundant `Span` in `QueryJobInfo` Previously, `QueryJobInfo` was composed of two parts: a `QueryInfo` and a `QueryJob`. However, both `QueryInfo` and `QueryJob` have a `span` field, which seem to be the same. So, the `span` was recorded twice. Now, `QueryJobInfo` is composed of a `QueryStackFrame` (the other field of `QueryInfo`) and a `QueryJob`. So, now, the `span` is only recorded once.
2021-09-02Rollup merge of #88543 - m-ou-se:closure-migration-macro-block-fragment, ↵Mara Bos-9/+26
r=estebank Improve closure dummy capture suggestion in macros. Fixes some cases of https://github.com/rust-lang/rust/issues/88440 Fixes https://crater-reports.s3.amazonaws.com/pr-87190-3/try%23a7a572ce3edd6d476191fbfe92c9c1986e009b34/reg/rcodec-1.0.1/log.txt
2021-09-02Rollup merge of #88532 - ptrojahn:single_use, r=davidtwcoMara Bos-5/+2
Remove single use variables
2021-09-02Rollup merge of #88512 - m-ou-se:array-into-iter-deref-stuff, r=estebankMara Bos-24/+30
Upgrade array_into_iter lint to include Deref-to-array types. Fixes https://github.com/rust-lang/rust/issues/88099 Fixes the issue mentioned here: https://github.com/rust-lang/rust/pull/84147#issuecomment-819000436
2021-09-02Drop walk_crate_and_attributes.Camille GILLOT-20/+10
2021-09-02Directly access the module for use suggestions.Camille GILLOT-62/+34
2021-09-02Stop using walk_crate.Camille GILLOT-33/+42
2021-09-02Report cycle error using 'deepest' obligation in the cycleAaron Hill-1/+3
2021-09-02Preserve most sub-obligations in the projection cacheAaron Hill-49/+26