]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #88559 - bjorn3:archive_logic_dedup, r=cjgillot
bors [Sun, 5 Sep 2021 04:37:12 +0000 (04:37 +0000)]
Auto merge of #88559 - bjorn3:archive_logic_dedup, r=cjgillot

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.

2 years agoAuto merge of #88469 - patrick-gu:master, r=dtolnay
bors [Sun, 5 Sep 2021 01:56:25 +0000 (01:56 +0000)]
Auto merge of #88469 - patrick-gu:master, r=dtolnay

Add links in docs for some primitive types

This pull request adds additional links in existing documentation of some of the primitive types.

Where items are linked only once, I have used the `[link](destination)` format. For items in `std`, I have linked directly to the HTML, since although the primitives are in `core`, they are not displayed on `core` documentation. I was unsure of what length I should keep lines of documentation to, so I tried to keep them within reason.

Additionally, I have avoided excessively linking to keywords like `self` when they are not relevant to the documentation. I can add these links if it would be an improvement.

I hope this can improve Rust. Please let me know if there's anything I did wrong!

2 years agoAuto merge of #88626 - cjgillot:lfitb, r=petrochenkov
bors [Sat, 4 Sep 2021 23:11:07 +0000 (23:11 +0000)]
Auto merge of #88626 - cjgillot:lfitb, r=petrochenkov

Simplify lifetimes_from_impl_trait_bounds

Part of https://github.com/rust-lang/rust/pull/87234

r? `@petrochenkov`

2 years agoAuto merge of #88364 - pietroalbini:llvm-install-filecheck, r=Mark-Simulacrum
bors [Sat, 4 Sep 2021 20:44:41 +0000 (20:44 +0000)]
Auto merge of #88364 - pietroalbini:llvm-install-filecheck, r=Mark-Simulacrum

Make sure FileCheck is copied in the LLVM output directory

The tool, which is needed by parts of our test suite, is built as part of LLVM but is *not* copied to the directory containing the output LLVM binaries. This adds a flag to ensure the binary is copied. This shouldn't add any extra built time, as the flag just installs extra binaries that were already compiled.

This is not strictly needed for the test suite to work (as it also checks `build/$target/llvm/build/bin` for the binary), but it allows deleting the `build/$TARGET/llvm/build` directory (which also contains the intermediary build artifacts) without affecting the test suite, saving disk space.

2 years agoAuto merge of #88574 - camelid:box-genericarg-const, r=GuillaumeGomez
bors [Sat, 4 Sep 2021 18:18:00 +0000 (18:18 +0000)]
Auto merge of #88574 - camelid:box-genericarg-const, r=GuillaumeGomez

rustdoc: Box `GenericArg::Const` to reduce enum size

This should reduce the amount of memory allocated in the common cases
where the `GenericArg` is a lifetime or type.

2 years agoAuto merge of #88550 - dpaoliello:dpaoliello/allocdebuginfo, r=estebank
bors [Sat, 4 Sep 2021 12:27:45 +0000 (12:27 +0000)]
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.

2 years agoAuto merge of #88547 - notriddle:notriddle/is-expr-delims-necessary, r=davidtwco
bors [Sat, 4 Sep 2021 09:46:58 +0000 (09:46 +0000)]
Auto merge of #88547 - notriddle:notriddle/is-expr-delims-necessary, r=davidtwco

fix(rustc_lint): better detect when parens are necessary

Fixes #88519

2 years agoAuto merge of #88538 - bjorn3:no_session_in_crate_loader, r=petrochenkov
bors [Sat, 4 Sep 2021 07:17:12 +0000 (07:17 +0000)]
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.

2 years agoAuto merge of #88633 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum
bors [Sat, 4 Sep 2021 04:32:59 +0000 (04:32 +0000)]
Auto merge of #88633 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum

Bump version to 1.57

r? `@Mark-Simulacrum`

2 years agoBump version to 1.57
Mark Rousskov [Sat, 4 Sep 2021 01:54:48 +0000 (21:54 -0400)]
Bump version to 1.57

2 years agoAuto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser
bors [Sat, 4 Sep 2021 01:40:36 +0000 (01:40 +0000)]
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`.

2 years agoFix accidentally deleted part
patrick-gu [Sat, 4 Sep 2021 00:13:42 +0000 (17:13 -0700)]
Fix accidentally deleted part

2 years agoAdd a missing backtick
patrick-gu [Sat, 4 Sep 2021 00:11:57 +0000 (17:11 -0700)]
Add a missing backtick

2 years agoRemove excessive linking
patrick-gu [Sat, 4 Sep 2021 00:09:37 +0000 (17:09 -0700)]
Remove excessive linking

2 years agoAuto merge of #88482 - athei:add-import-test, r=the8472
bors [Fri, 3 Sep 2021 23:12:35 +0000 (23:12 +0000)]
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`

2 years agoReplace Vec by Option.
Camille GILLOT [Thu, 1 Apr 2021 17:42:27 +0000 (19:42 +0200)]
Replace Vec by Option.

2 years agoSimplify lifetimes_from_impl_trait_bounds.
Camille GILLOT [Thu, 15 Jul 2021 21:00:42 +0000 (23:00 +0200)]
Simplify lifetimes_from_impl_trait_bounds.

2 years agorustdoc: Box `GenericArg::Const` to reduce enum size
Noah Lev [Wed, 1 Sep 2021 22:26:07 +0000 (15:26 -0700)]
rustdoc: Box `GenericArg::Const` to reduce enum size

2 years agoAuto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obk
bors [Fri, 3 Sep 2021 20:31:43 +0000 (20:31 +0000)]
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`

2 years agoUpdate coverage tests
Matthew Jasper [Fri, 3 Sep 2021 18:51:27 +0000 (19:51 +0100)]
Update coverage tests

2 years agoAuto merge of #88454 - devnexen:sunos_asan, r=wesleywiser
bors [Fri, 3 Sep 2021 17:50:51 +0000 (17:50 +0000)]
Auto merge of #88454 - devnexen:sunos_asan, r=wesleywiser

sunos systems add sanitizer supported.

2 years agoAuto merge of #88597 - cjgillot:lower-global, r=petrochenkov
bors [Fri, 3 Sep 2021 14:47:13 +0000 (14:47 +0000)]
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`

2 years agoDetect bare blocks with type ascription that were meant to be a `struct` literal
Esteban Kuber [Thu, 2 Sep 2021 18:34:03 +0000 (18:34 +0000)]
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`.

2 years agoAuto merge of #88618 - m-ou-se:rollup-6tss5z6, r=m-ou-se
bors [Fri, 3 Sep 2021 11:37:52 +0000 (11:37 +0000)]
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

2 years agoRollup merge of #88613 - m-ou-se:array-docs-2021, r=Amanieu
Mara Bos [Fri, 3 Sep 2021 11:30:51 +0000 (13:30 +0200)]
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

2 years agoRollup merge of #88610 - m-ou-se:array-into-iter-docs, r=Amanieu
Mara Bos [Fri, 3 Sep 2021 11:30:50 +0000 (13:30 +0200)]
Rollup merge of #88610 - m-ou-se:array-into-iter-docs, r=Amanieu

Update outdated docs of array::IntoIter::new.

2 years agoRollup merge of #88579 - ast-ral:master, r=m-ou-se
Mara Bos [Fri, 3 Sep 2021 11:30:49 +0000 (13:30 +0200)]
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.

2 years agoRollup merge of #88557 - lcnr:const-generics-cleanup, r=BoxyUwU
Mara Bos [Fri, 3 Sep 2021 11:30:48 +0000 (13:30 +0200)]
Rollup merge of #88557 - lcnr:const-generics-cleanup, r=BoxyUwU

small const generics cleanup

2 years agoRollup merge of #88507 - atsuzaki:slice-fill-maybeuninit-test, r=RalfJung
Mara Bos [Fri, 3 Sep 2021 11:30:47 +0000 (13:30 +0200)]
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

2 years agoRollup merge of #88483 - jethrogb:jb/llvm-libunwind-self-contained, r=petrochenkov
Mara Bos [Fri, 3 Sep 2021 11:30:46 +0000 (13:30 +0200)]
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](https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/compiler/rustc_target/src/spec/crt_objects.rs#L128-L132) should use the “self-contained” logic in rustbuild.

2 years agoRollup merge of #88202 - azdavis:master, r=jyn514
Mara Bos [Fri, 3 Sep 2021 11:30:46 +0000 (13:30 +0200)]
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.

2 years agoUpdate primitive docs for rust 2021.
Mara Bos [Fri, 3 Sep 2021 10:49:37 +0000 (12:49 +0200)]
Update primitive docs for rust 2021.

2 years agoUpdate outdated docs of array::IntoIter::new.
Mara Bos [Fri, 3 Sep 2021 09:24:52 +0000 (11:24 +0200)]
Update outdated docs of array::IntoIter::new.

2 years agoAuto merge of #86454 - tlyu:refactor-unsized-suggestions, r=davidtwco
bors [Fri, 3 Sep 2021 08:51:21 +0000 (08:51 +0000)]
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

2 years agoAuto merge of #88428 - petrochenkov:stmtid, r=Aaron1011
bors [Fri, 3 Sep 2021 06:10:27 +0000 (06:10 +0000)]
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`

2 years agoAuto merge of #88386 - estebank:unmatched-delims, r=jackh726
bors [Fri, 3 Sep 2021 03:13:18 +0000 (03:13 +0000)]
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_

2 years agoAuto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank
bors [Fri, 3 Sep 2021 00:23:10 +0000 (00:23 +0000)]
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`

2 years agoAuto merge of #85868 - Aaron1011:projection-cache, r=jackh726
bors [Thu, 2 Sep 2021 21:26:59 +0000 (21:26 +0000)]
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.

2 years agoAuto merge of #88596 - m-ou-se:rollup-cidzt4v, r=m-ou-se
bors [Thu, 2 Sep 2021 18:58:12 +0000 (18:58 +0000)]
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

2 years agoBless ast-json tests.
Camille GILLOT [Wed, 1 Sep 2021 18:06:08 +0000 (20:06 +0200)]
Bless ast-json tests.

2 years agoRollup merge of #88592 - b-naber:region_substs, r=oli-obk
Mara Bos [Thu, 2 Sep 2021 17:10:24 +0000 (19:10 +0200)]
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

2 years agoRollup merge of #88589 - xFrednet:00000-correct-comment-to-doc, r=petrochenkov
Mara Bos [Thu, 2 Sep 2021 17:10:23 +0000 (19:10 +0200)]
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 :upside_down_face:

2 years agoRollup merge of #88582 - jhpratt:int_roundings, r=joshtriplett
Mara Bos [Thu, 2 Sep 2021 17:10:22 +0000 (19:10 +0200)]
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`

2 years agoRollup merge of #88573 - camelid:rustdoc-assoc-panic, r=GuillaumeGomez
Mara Bos [Thu, 2 Sep 2021 17:10:21 +0000 (19:10 +0200)]
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`

2 years agoRollup merge of #88567 - camelid:query-job-info, r=cjgillot
Mara Bos [Thu, 2 Sep 2021 17:10:20 +0000 (19:10 +0200)]
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.

2 years agoRollup merge of #88565 - lqd:issue-83190, r=spastorino
Mara Bos [Thu, 2 Sep 2021 17:10:19 +0000 (19:10 +0200)]
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````

2 years agoRollup merge of #88560 - klensy:formatter-pad-shrink, r=m-ou-se
Mara Bos [Thu, 2 Sep 2021 17:10:18 +0000 (19:10 +0200)]
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?).

2 years agoRollup merge of #88543 - m-ou-se:closure-migration-macro-block-fragment, r=estebank
Mara Bos [Thu, 2 Sep 2021 17:10:17 +0000 (19:10 +0200)]
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

2 years agoRollup merge of #88532 - ptrojahn:single_use, r=davidtwco
Mara Bos [Thu, 2 Sep 2021 17:10:16 +0000 (19:10 +0200)]
Rollup merge of #88532 - ptrojahn:single_use, r=davidtwco

Remove single use variables

2 years agoRollup merge of #88512 - m-ou-se:array-into-iter-deref-stuff, r=estebank
Mara Bos [Thu, 2 Sep 2021 17:10:15 +0000 (19:10 +0200)]
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

2 years agoRollup merge of #88505 - ibraheemdev:use-unwrap-unchecked, r=kennytm
Mara Bos [Thu, 2 Sep 2021 17:10:14 +0000 (19:10 +0200)]
Rollup merge of #88505 - ibraheemdev:use-unwrap-unchecked, r=kennytm

Use `unwrap_unchecked` where possible

2 years agoRollup merge of #88177 - joshtriplett:stabilize-chroot, r=m-ou-se
Mara Bos [Thu, 2 Sep 2021 17:10:12 +0000 (19:10 +0200)]
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

2 years agoReport cycle error using 'deepest' obligation in the cycle
Aaron Hill [Fri, 27 Aug 2021 22:34:48 +0000 (17:34 -0500)]
Report cycle error using 'deepest' obligation in the cycle

2 years agoAuto merge of #87580 - ChrisDenton:win-arg-parse-2008, r=m-ou-se
bors [Thu, 2 Sep 2021 16:16:13 +0000 (16:16 +0000)]
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

2 years agoPreserve most sub-obligations in the projection cache
Aaron Hill [Mon, 31 May 2021 18:22:40 +0000 (13:22 -0500)]
Preserve most sub-obligations in the projection cache

2 years agoadd test
b-naber [Thu, 2 Sep 2021 14:29:04 +0000 (16:29 +0200)]
add test

2 years agodo not resolve instances for trait fn ids
b-naber [Thu, 2 Sep 2021 10:22:23 +0000 (12:22 +0200)]
do not resolve instances for trait fn ids

2 years agoAuto merge of #88530 - bjorn3:shrink_session, r=cjgillot
bors [Thu, 2 Sep 2021 13:12:59 +0000 (13:12 +0000)]
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.

2 years agoCorrect doc comments inside `use_expr_visitor.rs`
xFrednet [Thu, 2 Sep 2021 12:59:14 +0000 (14:59 +0200)]
Correct doc comments inside `use_expr_visitor.rs`

2 years agoexpand: Treat more macro calls as statement macro calls
Vadim Petrochenkov [Thu, 26 Aug 2021 14:18:03 +0000 (17:18 +0300)]
expand: Treat more macro calls as statement macro calls

2 years agoAdd explanation for ctfe_backtrace lock
bjorn3 [Tue, 31 Aug 2021 13:06:59 +0000 (15:06 +0200)]
Add explanation for ctfe_backtrace lock

2 years agoUse in_incr_comp_dir_sess in cg_clif
bjorn3 [Mon, 30 Aug 2021 13:06:56 +0000 (15:06 +0200)]
Use in_incr_comp_dir_sess in cg_clif

2 years agoRemove print_fuel_crate field of Session
bjorn3 [Mon, 30 Aug 2021 12:41:09 +0000 (14:41 +0200)]
Remove print_fuel_crate field of Session

2 years agoRemove optimization_fuel_crate from Session
bjorn3 [Mon, 30 Aug 2021 12:36:24 +0000 (14:36 +0200)]
Remove optimization_fuel_crate from Session

2 years agoAuto merge of #88516 - matthiaskrgr:clippy_perf_end_august, r=jyn514,GuillaumeGomez
bors [Thu, 2 Sep 2021 10:27:44 +0000 (10:27 +0000)]
Auto merge of #88516 - matthiaskrgr:clippy_perf_end_august, r=jyn514,GuillaumeGomez

some low hanging clippy::perf fixes

2 years agoRemove unused argument from resolve_crate
bjorn3 [Tue, 31 Aug 2021 15:18:06 +0000 (17:18 +0200)]
Remove unused argument from resolve_crate

2 years agoIntroduce CrateRejections struct
bjorn3 [Tue, 31 Aug 2021 15:02:36 +0000 (17:02 +0200)]
Introduce CrateRejections struct

2 years agoRemove root field from CrateLocator
bjorn3 [Tue, 31 Aug 2021 14:50:00 +0000 (16:50 +0200)]
Remove root field from CrateLocator

2 years agoRemove host_hash from CrateLocator
bjorn3 [Tue, 31 Aug 2021 13:22:21 +0000 (15:22 +0200)]
Remove host_hash from CrateLocator

2 years agoRefactor CrateLocator.is_proc_macro
bjorn3 [Mon, 30 Aug 2021 16:11:09 +0000 (18:11 +0200)]
Refactor CrateLocator.is_proc_macro

This also fixes a (theoretical) bug where a proc-macro may be loaded as
plugin if it exports a symbol with the right name.

2 years agoDon't store Session in CrateLocator
bjorn3 [Mon, 30 Aug 2021 16:05:15 +0000 (18:05 +0200)]
Don't store Session in CrateLocator

2 years agoBless 32bit MIR opt tests
Matthew Jasper [Thu, 2 Sep 2021 09:18:08 +0000 (10:18 +0100)]
Bless 32bit MIR opt tests

2 years agoRemove TODO
Matthew Jasper [Thu, 2 Sep 2021 08:21:16 +0000 (09:21 +0100)]
Remove TODO

2 years agoAuto merge of #87114 - cjgillot:abilint, r=estebank
bors [Thu, 2 Sep 2021 06:06:24 +0000 (06:06 +0000)]
Auto merge of #87114 - cjgillot:abilint, r=estebank

Lint missing Abi in ast validation instead of lowering.

2 years agoImplement #88581
Jacob Pratt [Thu, 2 Sep 2021 05:28:47 +0000 (01:28 -0400)]
Implement #88581

2 years agoremove redundant / misplaced sentence from docs
ast-ral [Thu, 2 Sep 2021 03:52:30 +0000 (20:52 -0700)]
remove redundant / misplaced sentence from docs

2 years agoAuto merge of #83342 - Count-Count:win-console-incomplete-utf8, r=m-ou-se
bors [Thu, 2 Sep 2021 03:31:17 +0000 (03:31 +0000)]
Auto merge of #83342 - Count-Count:win-console-incomplete-utf8, r=m-ou-se

Allow writing of incomplete UTF-8 sequences to the Windows console via stdout/stderr

# Problem
Writes of just an incomplete UTF-8 byte sequence (e.g. `b"\xC3"` or `b"\xF0\x9F"`)  to stdout/stderr with a Windows console attached error with `io::ErrorKind::InvalidData, "Windows stdio in console mode does not support writing non-UTF-8 byte sequences"` even though further writes could complete the codepoint. This is currently a rare occurence since the [linewritershim](https://github.com/rust-lang/rust/blob/2c56ea38b045624dc8b42ec948fc169eaff1206a/library/std/src/io/buffered/linewritershim.rs) implementation flushes complete lines immediately and buffers up to 1024 bytes for incomplete lines. It can still happen as described in #83258.

The problem will become more pronounced once the developer can switch stdout/stderr from line-buffered to block-buffered or immediate when the changes in the "Switchable buffering for Stdout" pull request (#78515) get merged.

# Patch description
If there is at least one valid UTF-8 codepoint all valid UTF-8 is passed through to the extracted `write_valid_utf8_to_console()` fn. The new code only comes into play if `write()` is being passed a short byte slice comprising an incomplete UTF-8 codepoint. In this case up to three bytes are buffered in the `IncompleteUtf8` struct associated with `Stdout` / `Stderr`. The bytes are accepted one at a time. As soon as an error can be detected `io::ErrorKind::InvalidData, "Windows stdio in console mode does not support writing non-UTF-8 byte sequences"` is returned. Once a complete UTF-8 codepoint is received it is passed to the `write_valid_utf8_to_console()` and the buffer length is set to zero.

Calling `flush()` will neither error nor write anything if an incomplete codepoint is present in the buffer.

# Tests
Currently there are no Windows-specific tests for console writing code at all. Writing (regression) tests for this problem is a bit challenging since unit tests and UI tests don't run in a console and suddenly popping up another console window might be surprising to developers running the testsuite and it might not work at all in CI builds. To just test the new functionality in unit tests the code would need to be refactored. Some guidance on how to proceed would be appreciated.

# Public API changes
* `std::str::verifications::utf8_char_width()` would be exposed as `std::str::utf8_char_width()` behind the "str_internals" feature gate.

# Related issues
* Fixes #83258.
* PR #78515 will exacerbate the problem.

# Open questions
* Add tests?
* Squash into one commit with better commit message?

2 years agoAuto merge of #88522 - camelid:box-paren-output, r=jyn514
bors [Thu, 2 Sep 2021 00:12:21 +0000 (00:12 +0000)]
Auto merge of #88522 - camelid:box-paren-output, r=jyn514

rustdoc: Box `GenericArgs::Parenthesized.output`

Split out from #88379.

This reduces the size of `GenericArgs` from 104 bytes to 56 bytes,
essentially reducing it by half.

`GenericArgs` is one of the fields of `PathSegment`, so this should
reduce the amount of memory allocated for `PathSegment`s in the cases
where the generics are not for a `Fn`, `FnMut`, or `FnOnce` trait.

r? `@jyn514`

2 years agoFix drop handling for `if let` expressions
Matthew Jasper [Wed, 1 Sep 2021 21:52:17 +0000 (22:52 +0100)]
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.

2 years agorustdoc: Don't panic on ambiguous inherent associated types
Noah Lev [Wed, 1 Sep 2021 21:59:07 +0000 (14:59 -0700)]
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.

2 years agoAuto merge of #88490 - GuillaumeGomez:associated-types-implementors-display, r=cameli...
bors [Wed, 1 Sep 2021 21:31:16 +0000 (21:31 +0000)]
Auto merge of #88490 - GuillaumeGomez:associated-types-implementors-display, r=camelid,Manishearth

Display associated types of implementors

Fixes #86631.

Contrary to before, it doesn't display methods. I also had to "resurrect" the `auto-hide-trait-implementations` setting. :3

Only question at this point: should I move the `render_impl` boolean arguments into one struct? We're starting to have quite a lot of them...

cc `@cynecx`
r? `@camelid`

2 years agoRemove implementors setting
Guillaume Gomez [Wed, 1 Sep 2021 18:34:51 +0000 (20:34 +0200)]
Remove implementors setting

2 years agoCompute proc_macros in resolutions.
Camille GILLOT [Fri, 16 Jul 2021 20:22:08 +0000 (22:22 +0200)]
Compute proc_macros in resolutions.

2 years agoCompute all_traits_impls during resolution.
Camille GILLOT [Fri, 16 Jul 2021 19:55:10 +0000 (21:55 +0200)]
Compute all_traits_impls during resolution.

2 years agoCompute item_generics_num_lifetimes during resolution.
Camille GILLOT [Wed, 14 Jul 2021 16:04:56 +0000 (18:04 +0200)]
Compute item_generics_num_lifetimes during resolution.

2 years agoStop sorting bodies by span.
Camille GILLOT [Fri, 16 Jul 2021 14:54:47 +0000 (16:54 +0200)]
Stop sorting bodies by span.

The definition order is already close to the span order, and only differs
in corner cases.

2 years agoRemove redundant `Span` in `QueryJobInfo`
Noah Lev [Wed, 1 Sep 2021 18:07:33 +0000 (11:07 -0700)]
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.

2 years agoAuto merge of #88563 - ehuss:update-cargo-books, r=ehuss
bors [Wed, 1 Sep 2021 17:26:49 +0000 (17:26 +0000)]
Auto merge of #88563 - ehuss:update-cargo-books, r=ehuss

Update cargo, books

## nomicon

2 commits in 0c7e5bd1428e7838252bb57b7f0fbfda4ec82f02..fe6227eb3c8533200c52dffa42ef1b6f2f02c40e
2021-08-04 10:18:22 -0700 to 2021-08-31 05:42:38 +0900
- update lifetime-elision to show what elided code under `rust_2018_idi… (rust-lang/nomicon#306)
- Change code for `into_iter` on the `RawVec` section for consistency/soundness (rust-lang/nomicon#302)

## cargo

8 commits in f559c109cc79fe413a8535fb620a5a58b3823d94..18751dd3f238d94d384a7fe967abfac06cbfe0b9
2021-08-26 22:54:55 +0000 to 2021-09-01 14:26:00 +0000
- print the full destination path when no track duplicates (rust-lang/cargo#9850)
- Stabilize 2021 edition (rust-lang/cargo#9800)
- Stabilize patch-in-config (and prefer config over manifest) (rust-lang/cargo#9839)
- Adding the cargo doc --examples subcommand (rust-lang/cargo#9808)
- Make library created with `cargo new` clippy happy (rust-lang/cargo#9796)
- Swap out some outdated repo urls in documentation (rust-lang/cargo#9862)
- Change `cargo fix --edition` to only fix edition lints. (rust-lang/cargo#9846)
- Show desc of well known subcommands (fmt, clippy) in cargo --list (rust-lang/cargo#9848)

## reference

1 commits in da6ea9b03f74cae0a292f40315723d7a3a973637..0e5ed7a4bec065f0cc18c35d1c904639e095314d
2021-08-19 21:28:10 -0700 to 2021-08-29 17:33:21 +0900
- expressions.md: Attempt fixing broken grammar in Mutability paragraph (rust-lang/reference#1084)

## book

1 commits in 687e21bde2ea10c261f79fa14797c5137425098d..fcb5e0ea68112d85a1d29a7a7335978ef2a02181
2021-08-18 20:48:38 -0400 to 2021-08-31 21:26:19 -0400
- Improve the reading of the code (rust-lang/book#2845)

## rustc-dev-guide

7 commits in cf0e151b7925a40f13fbc6573c6f97d5f94c7c17..95f1acf9a39d6f402f654e917e2c1dfdb779c5fc
2021-08-22 11:47:02 -0300 to 2021-08-31 12:38:30 -0500
- Add link to `Span`
- Add rustc-source to suggested rust-analyzer config (rust-lang/rustc-dev-guide#1189)
- Fix typo, clarify backtick wording, and use inline code
- Trailing date comments in a line inside of a paragraph caused beginning of a new paragraph. (rust-lang/rustc-dev-guide#1196)
- Fix warning "Renderer command uses a path relative to the renderer output directory ..." (rust-lang/rustc-dev-guide#1194)
- Fix a code block containing ```rust
- date-check: Recognize capitalized 'Date' as well

## edition-guide

1 commits in 3710b0cae783d0bcd2b42452a63b081473f5970a..2d9b1b9da706de24650fdc5c3b0182f55c82115d
2021-07-26 11:34:46 -0700 to 2021-08-31 10:44:09 +0200
- Update for 2021 stabilization (rust-lang/edition-guide#266)

## embedded-book

1 commits in 4f9fcaa30d11ba52b641e6fd5206536d65838af9..c3a51e23859554369e6bbb5128dcef0e4f159fb5
2021-08-06 17:43:12 +0000 to 2021-08-26 07:04:58 +0000
- Make glossary more linkable and add more detail  (rust-embedded/book#299)

2 years agoadd regression test for issue 83190
Rémy Rakic [Wed, 1 Sep 2021 16:33:34 +0000 (18:33 +0200)]
add regression test for issue 83190

2 years agoUpdate cargo, books
Eric Huss [Wed, 1 Sep 2021 16:27:57 +0000 (09:27 -0700)]
Update cargo, books

2 years agouse the correct feature gate
lcnr [Wed, 1 Sep 2021 15:43:07 +0000 (17:43 +0200)]
use the correct feature gate

Co-authored-by: Boxy <supbscripter@gmail.com>
2 years agoAuto merge of #88269 - prconrad:doctest-persist-binaries, r=jyn514
bors [Wed, 1 Sep 2021 14:33:37 +0000 (14:33 +0000)]
Auto merge of #88269 - prconrad:doctest-persist-binaries, r=jyn514

Doctest persist full binaries when persisting

Tested by adding an extra debug to echo the whole compiler line. Trimmed significantly:

Persisted but not running -> full compile so we get binaries (new behavior).
```
$ rustdoc -Zunstable-options --test --persist-doctests doctests --no-run --extern t=libt.rlib t.rs

DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "doctests/t_rs_8_0/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--target" "x86_64-unknown-linux-gnu" "--color" "always"
DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "doctests/t_rs_2_0/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--target" "x86_64-unknown-linux-gnu" "--color" "always"
test t.rs - foople (line 2) - compile ... ok
test t.rs - florp (line 8) - compile ... ok
```

Persisted and running -> full compile.
```
$ rustdoc -Zunstable-options --test --persist-doctests doctests --extern t=libt.rlib t.rs

DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "doctests/t_rs_8_0/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--target" "x86_64-unknown-linux-gnu" "--color" "always"
DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "doctests/t_rs_2_0/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--target" "x86_64-unknown-linux-gnu" "--color" "always"

```

Running but not persisted -> full compile only
```
$ rustdoc --test --extern t=libt.rlib t.rs

DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "/tmp/rustdoctestixWAUI/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "--target" "x86_64-unknown-linux-gnu" "--color" "always"
DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "/tmp/rustdoctestKEaJQu/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "--target" "x86_64-unknown-linux-gnu" "--color" "always"

```

Not running and not persisting -> save time and only run metadata.
```
RUSTDOC_LOG=rustdoc=debug,std::test=debug rustdoc -Zunstable-options --no-run --test --extern t=libt.rlib t.rs

DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "/tmp/rustdoctest8twt2c/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--emit=metadata" "--target" "x86_64-unknown-linux-gnu" "--color" "always"
DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "/tmp/rustdoctest3miSqv/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--emit=metadata" "--target" "x86_64-unknown-linux-gnu" "--color" "always"
```

I can't see any infrastructure for automating this sort of test. Am I missing it?

2 years agofix clippy lints
klensy [Wed, 1 Sep 2021 12:52:29 +0000 (15:52 +0300)]
fix clippy lints

2 years agoMove add_rlib and add_native_library to cg_ssa
bjorn3 [Wed, 1 Sep 2021 12:38:37 +0000 (14:38 +0200)]
Move add_rlib and add_native_library to cg_ssa

This deduplicates logic between codegen backends

2 years ago`fmt::Formatter::pad`: don't call chars().count() more than one time
klensy [Wed, 1 Sep 2021 12:35:58 +0000 (15:35 +0300)]
`fmt::Formatter::pad`: don't call chars().count() more than one time

2 years agoAuto merge of #88395 - ricky26:llvm-submodule, r=nikic
bors [Wed, 1 Sep 2021 11:47:18 +0000 (11:47 +0000)]
Auto merge of #88395 - ricky26:llvm-submodule, r=nikic

Update LLVM submodule

This will capture the two M68k bugfixes to help with #88321.

2 years agoupdate FIXME
lcnr [Wed, 1 Sep 2021 09:42:52 +0000 (11:42 +0200)]
update FIXME

2 years agocleanup const generics FIXME
lcnr [Wed, 1 Sep 2021 09:41:06 +0000 (11:41 +0200)]
cleanup const generics FIXME

2 years agoAuto merge of #88556 - m-ou-se:rollup-q636wyd, r=m-ou-se
bors [Wed, 1 Sep 2021 09:06:24 +0000 (09:06 +0000)]
Auto merge of #88556 - m-ou-se:rollup-q636wyd, r=m-ou-se

Rollup of 9 pull requests

Successful merges:

 - #86376 (Emit specific warning to clarify that `#[no_mangle]` should not be applied on foreign statics or functions)
 - #88040 (BTree: remove Ord bound from new)
 - #88053 (Fix the flock fallback implementation)
 - #88350 (add support for clobbering xer, cr, and cr[0-7] for asm! on OpenPower/PowerPC)
 - #88410 (Remove bolding on associated constants)
 - #88525 (fix(rustc_typeck): produce better errors for dyn auto trait)
 - #88542 (Use the return value of readdir_r() instead of errno)
 - #88548 (Stabilize `Iterator::intersperse()`)
 - #88551 (Stabilize `UnsafeCell::raw_get()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoClean render_impl arguments
Guillaume Gomez [Tue, 31 Aug 2021 10:20:02 +0000 (12:20 +0200)]
Clean render_impl arguments