Commit graph

154044 commits

Author SHA1 Message Date
bors
226e181b80 Auto merge of #88550 - dpaoliello:dpaoliello/allocdebuginfo, r=estebank
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-04 12:27:45 +00:00
bors
72a51c39c6 Auto merge of #88547 - notriddle:notriddle/is-expr-delims-necessary, r=davidtwco
fix(rustc_lint): better detect when parens are necessary

Fixes #88519
2021-09-04 09:46:58 +00:00
bors
d295e36c38 Auto merge of #88538 - bjorn3:no_session_in_crate_loader, r=petrochenkov
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-04 07:17:12 +00:00
bors
065a3720b8 Auto merge of #88633 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum
Bump version to 1.57

r? `@Mark-Simulacrum`
2021-09-04 04:32:59 +00:00
Mark Rousskov
0d55188ebb Bump version to 1.57 2021-09-03 21:54:48 -04:00
bors
b4e8596e3e Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser
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-04 01:40:36 +00:00
bors
03c775c955 Auto merge of #88482 - athei:add-import-test, r=the8472
Add regression test for a spurious import

This PR adds a test that verifies that the bug described in the linked issue does not creep back into the code. In essence it checks that compiling some specific code (that uses 128 bit multiplication) with a specific set of compiler options does not lead to a spurious import of a panic function.

I noticed that other wasm tests use `# only-wasm32-bare` in their `Makefile`. This will skip the test for me. I did not find out how to run this test locally. Maybe someone can help.

closes #78744
r? `@jyn514`
2021-09-03 23:12:35 +00:00
bors
b7404c898a Auto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obk
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-03 20:31:43 +00:00
Matthew Jasper
4e2fd4fcb2 Update coverage tests 2021-09-03 19:51:27 +01:00
bors
4878034c00 Auto merge of #88454 - devnexen:sunos_asan, r=wesleywiser
sunos systems add sanitizer supported.
2021-09-03 17:50:51 +00:00
bors
577a76f003 Auto merge of #88597 - cjgillot:lower-global, r=petrochenkov
Move global analyses from lowering to resolution

Split off https://github.com/rust-lang/rust/pull/87234

r? `@petrochenkov`
2021-09-03 14:47:13 +00:00
Esteban Kuber
12ce6e9c60 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-03 14:43:04 +00:00
bors
c5799b2a73 Auto merge of #88618 - m-ou-se:rollup-6tss5z6, r=m-ou-se
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-03 11:37:52 +00:00
Mara Bos
2ce74b0bc0
Rollup merge of #88613 - m-ou-se:array-docs-2021, r=Amanieu
Update primitive docs for rust 2021.

Fixes https://github.com/rust-lang/rust/issues/87701
2021-09-03 13:30:51 +02:00
Mara Bos
e13b9c90c9
Rollup merge of #88610 - m-ou-se:array-into-iter-docs, r=Amanieu
Update outdated docs of array::IntoIter::new.
2021-09-03 13:30:50 +02:00
Mara Bos
01775b6027
Rollup merge of #88579 - ast-ral:master, r=m-ou-se
remove redundant / misplaced sentence from docs

Removes sentence that seems to have drifted down into the examples section. Luckily, someone already added an explanation of what happens with packed structs back into the initial section of the doc entry and this wayward sentence can likely just be deleted.
2021-09-03 13:30:49 +02:00
Mara Bos
4b5da4aefe
Rollup merge of #88557 - lcnr:const-generics-cleanup, r=BoxyUwU
small const generics cleanup
2021-09-03 13:30:48 +02:00
Mara Bos
80b572b5e5
Rollup merge of #88507 - atsuzaki:slice-fill-maybeuninit-test, r=RalfJung
Add test case for using `slice::fill` with MaybeUninit

Adds test for #87891

Looks alright? `@RalfJung`
Fixes #87891
2021-09-03 13:30:47 +02:00
Mara Bos
3ce205a9ed
Rollup merge of #88483 - jethrogb:jb/llvm-libunwind-self-contained, r=petrochenkov
Fix LLVM libunwind build for non-musl targets

Broken in #85600. AFAICT, [only musl, mingw, and wasm](673d0db5e3/compiler/rustc_target/src/spec/crt_objects.rs (L128-L132)) should use the “self-contained” logic in rustbuild.
2021-09-03 13:30:46 +02:00
Mara Bos
cb2be32dbd
Rollup merge of #88202 - azdavis:master, r=jyn514
Add an example for deriving PartialOrd on enums

For some reason, I always forget which variants are smaller and which
are larger when you derive PartialOrd on an enum. And the wording in the
current docs is not entirely clear to me.

So, I often end up making a small enum, deriving PartialOrd on it, and
then writing a `#[test]` with an assert that the top one is smaller than
the bottom one (or the other way around) to figure out which way the
deriving goes.

So then I figured, it would be great if the standard library docs just
had that example, so if I keep forgetting, at least I can figure it out
quickly by looking at std's docs.
2021-09-03 13:30:46 +02:00
Mara Bos
00c8da145c Update primitive docs for rust 2021. 2021-09-03 12:49:37 +02:00
Mara Bos
5ea45f35c0 Update outdated docs of array::IntoIter::new. 2021-09-03 11:24:52 +02:00
bors
e4e4179539 Auto merge of #86454 - tlyu:refactor-unsized-suggestions, r=davidtwco
Refactor unsized suggestions

`@rustbot` label +A-diagnostics +A-traits +A-typesystem +C-cleanup +T-compiler
2021-09-03 08:51:21 +00:00
bors
fbdff7fae9 Auto merge of #88428 - petrochenkov:stmtid, r=Aaron1011
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-03 06:10:27 +00:00
bors
29d8fb746d Auto merge of #88386 - estebank:unmatched-delims, r=jackh726
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-03 03:13:18 +00:00
bors
97f2698484 Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank
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-03 00:23:10 +00:00
bors
371f3cd3fe Auto merge of #85868 - Aaron1011:projection-cache, r=jackh726
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-02 21:26:59 +00:00
bors
b834c4c1ba Auto merge of #88596 - m-ou-se:rollup-cidzt4v, r=m-ou-se
Rollup of 12 pull requests

Successful merges:

 - #88177 (Stabilize std::os::unix::fs::chroot)
 - #88505 (Use `unwrap_unchecked` where possible)
 - #88512 (Upgrade array_into_iter lint to include Deref-to-array types.)
 - #88532 (Remove single use variables)
 - #88543 (Improve closure dummy capture suggestion in macros.)
 - #88560 (`fmt::Formatter::pad`: don't call chars().count() more than one time)
 - #88565 (Add regression test for issue 83190)
 - #88567 (Remove redundant `Span` in `QueryJobInfo`)
 - #88573 (rustdoc: Don't panic on ambiguous inherent associated types)
 - #88582 (Implement #88581)
 - #88589 (Correct doc comments inside `use_expr_visitor.rs`)
 - #88592 (Fix ICE in const check)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-09-02 18:58:12 +00:00
Camille GILLOT
5e3cd6a8b2 Bless ast-json tests. 2021-09-02 19:25:17 +02:00
Mara Bos
c082e157ca
Rollup merge of #88592 - b-naber:region_substs, r=oli-obk
Fix ICE in const check

Fixes https://github.com/rust-lang/rust/issues/88433
2021-09-02 19:10:24 +02:00
Mara Bos
8f88d44b0d
Rollup merge of #88589 - xFrednet:00000-correct-comment-to-doc, r=petrochenkov
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 🙃
2021-09-02 19:10:23 +02:00
Mara Bos
2159c5db63
Rollup merge of #88582 - jhpratt:int_roundings, r=joshtriplett
Implement #88581

See #88581 for details. This API was discussed on Zulip.

`@rustbot` label: +T-libs-api +S-waiting-on-review

r? `@joshtriplett`
2021-09-02 19:10:22 +02:00
Mara Bos
73162aabc7
Rollup merge of #88573 - camelid:rustdoc-assoc-panic, r=GuillaumeGomez
rustdoc: Don't panic on ambiguous inherent associated types

Instead, return `Type::Infer` since compilation should fail anyway.
That's how rustdoc handles `hir::TyKind::Err`s, so this just extends
that behavior to `ty::Err`s when analyzing associated types.

For some reason, the error is printed twice with rustdoc (though only
once with rustc). I'm not sure why that is, but it's better than
panicking.

This commit also makes rustdoc fail early in the non-projection,
non-error case, instead of returning a `Res::Err` that would likely
cause rustdoc to panic later on. This change is originally from #88379.

r? `@GuillaumeGomez`
2021-09-02 19:10:21 +02:00
Mara Bos
f4193346fe
Rollup merge of #88567 - camelid:query-job-info, r=cjgillot
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-02 19:10:20 +02:00
Mara Bos
e248c4d5d0
Rollup merge of #88565 - lqd:issue-83190, r=spastorino
Add regression test for issue 83190

Reduced from `bioyino-metric` by ````@hellow554```` and myself.

Closes #83190.

r? ````@spastorino````
2021-09-02 19:10:19 +02:00
Mara Bos
0d105c0e77
Rollup merge of #88560 - klensy:formatter-pad-shrink, r=m-ou-se
`fmt::Formatter::pad`: don't call chars().count() more than one time

First commit merges two branches of match to call chars().count() only once: that should be faster if this method hits place of 3rd (previous) branch, plus quarter shorter.
Second commit fixes some clippy lints while i'm here (should it be separate PR?).
2021-09-02 19:10:18 +02:00
Mara Bos
ffbce26e24
Rollup merge of #88543 - m-ou-se:closure-migration-macro-block-fragment, 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-02 19:10:17 +02:00
Mara Bos
afdaa2e8f5
Rollup merge of #88532 - ptrojahn:single_use, r=davidtwco
Remove single use variables
2021-09-02 19:10:16 +02:00
Mara Bos
ea82d0651a
Rollup merge of #88512 - m-ou-se:array-into-iter-deref-stuff, r=estebank
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-02 19:10:15 +02:00
Mara Bos
8fd1bf3323
Rollup merge of #88505 - ibraheemdev:use-unwrap-unchecked, r=kennytm
Use `unwrap_unchecked` where possible
2021-09-02 19:10:14 +02:00
Mara Bos
e50069ff4f
Rollup merge of #88177 - joshtriplett:stabilize-chroot, r=m-ou-se
Stabilize std::os::unix::fs::chroot

I've verified that this works as documented, and I've tested it in (a nightly
build of) production software as a replacement for an unsafe call to
`libc::chroot`. It's been available in nightly for a few releases. I think it's
ready to stabilize.

---

Tracking issue: https://github.com/rust-lang/rust/issues/84715
2021-09-02 19:10:12 +02:00
Aaron Hill
611191f54c
Report cycle error using 'deepest' obligation in the cycle 2021-09-02 11:49:32 -05:00
bors
1cf8fdd4f0 Auto merge of #87580 - ChrisDenton:win-arg-parse-2008, r=m-ou-se
Update Windows Argument Parsing

Fixes #44650

The Windows command line is passed to applications [as a single string](https://docs.microsoft.com/en-us/archive/blogs/larryosterman/the-windows-command-line-is-just-a-string) which the application then parses to get a list of arguments. The standard rules (as used by C/C++) for parsing the command line have slightly changed over the years, most recently in 2008 which added new escaping rules.

This PR implements the new rules as [described on MSDN](https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=msvc-160#parsing-c-command-line-arguments) and [further detailed here](https://daviddeley.com/autohotkey/parameters/parameters.htm#WIN). It has been tested against the behaviour of C++ by calling a C++ program that outputs its raw command line and the contents of `argv`. See [my repo](https://github.com/ChrisDenton/winarg/tree/std) if anyone wants to reproduce my work.

For an overview of how this PR changes argument parsing behavior and why we feel it is warranted see https://github.com/rust-lang/rust/pull/87580#issuecomment-893833893.

For some examples see: https://github.com/rust-lang/rust/pull/87580#issuecomment-894299249
2021-09-02 16:16:13 +00:00
Aaron Hill
f2d9ee9c34
Preserve most sub-obligations in the projection cache 2021-09-02 11:10:40 -05:00
b-naber
f825d6c6cc add test 2021-09-02 16:34:25 +02:00
b-naber
b5f680e748 do not resolve instances for trait fn ids 2021-09-02 16:29:49 +02:00
bors
fcce644119 Auto merge of #88530 - bjorn3:shrink_session, r=cjgillot
Shrink Session a bit

Remove a couple of unnecessary fields from `Session` and remove a `Lock<T>` for a field that is never mutated anyway.
2021-09-02 13:12:59 +00:00
xFrednet
a079ae2599 Correct doc comments inside use_expr_visitor.rs 2021-09-02 15:05:27 +02:00
Vadim Petrochenkov
9940758416 expand: Treat more macro calls as statement macro calls 2021-09-02 14:14:38 +03:00
bjorn3
74c7f1267b Add explanation for ctfe_backtrace lock 2021-09-02 12:29:12 +02:00