Commit Graph

124138 Commits

Author SHA1 Message Date
Tomasz Miąsko
b285e0c5d8 Remove MaybeMutBorrowedLocals 2021-11-03 16:43:12 +01:00
bors
7734cb8078 Auto merge of #90527 - 12101111:libc_a, r=petrochenkov
Provide standalone libc.a in self-contained for musl and wasi

This is a prerequisites of https://github.com/rust-lang/libc/pull/2272, which in turn fix:

- https://github.com/rust-lang/wg-cargo-std-aware/issues/66
- https://github.com/rust-lang/rust/issues/89626
2021-11-03 15:11:06 +00:00
Smittyvb
fdb6bdacfa
Add note about x86 instruction prefixes in asm!
Since rustc doesn't do the assembly parsing itself, it is unable
to detect when inline assembly ends with an instruction prefix,
which doesn't make sense since it would apply to instructions from
the compiler. This fixes #82314 by mentioning that x86 instruction
prefixes must not be used in inline assembly.
2021-11-03 09:24:50 -04:00
12101111
b23c1c5670
Provide standalone libc.a in self-contained for musl and wasi 2021-11-03 21:12:15 +08:00
bors
473eaa42e9 Auto merge of #90517 - willcrichton:example-analyzer, r=jyn514
Fix URL for scrape-examples.js in rustdoc page template

Also adds line numbers to URLs in the "additional examples" section of rustdoc.

r? `@jyn514`
2021-11-03 11:48:52 +00:00
Takayuki Maeda
6c1e194534 fix message 2021-11-03 13:53:57 +09:00
Will Crichton
ce943d26f8 Add line number to URLs in "additional examples" section of rustdoc 2021-11-02 19:38:55 -07:00
Will Crichton
4b5e08ad79 Fix URL for scrape-examples.js in rustdoc page template 2021-11-02 19:10:50 -07:00
bors
3802025f40 Auto merge of #90516 - matthiaskrgr:rollup-3dmfjkj, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #90084 (Make printed message match the code comment)
 - #90354 (Document clippy on nightly-rustc)
 - #90417 (stabilize `relaxed_struct_unsize`)
 - #90472 (Clarify what to do with accepted feature gates)
 - #90500 (Update Clippy dependencies)
 - #90502 (Split doc_cfg and doc_auto_cfg features)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-03 01:52:17 +00:00
Matthias Krüger
e38844a9d8
Rollup merge of #90502 - GuillaumeGomez:split-doc-cfg-feature, r=jyn514
Split doc_cfg and doc_auto_cfg features

Part of #90497.

With this feature, `doc_cfg` won't pick up items automatically anymore.

cc `@Mark-Simulacrum`
r? `@jyn514`
2021-11-02 23:48:50 +01:00
Matthias Krüger
673aafe70e
Rollup merge of #90500 - xFrednet:00000-update-clippy-deps, r=flip1995
Update Clippy dependencies

Clippy has two outdated dependencies, where one indirect dependency has been flagged by rustsec for dropping a lifetime. See [RUSTSEC-2020-0146](https://rustsec.org/advisories/RUSTSEC-2020-0146). This PR updates these dependencies.

With previous dependency updates, it was tried to prevent duplicates in the `Cargo.lock` file of rust-lang/rust. I've tried to keep this in mind with this update.

* Dependency `semver`
    * Used in `src/tools/cargo/Cargo.toml` as version `1.0.3`
    * Used in `src/tools/rust-analyzer/crates/project_model/Cargo.toml` as version `1`
    * Updated in Clippy from `0.11` to `1.0` (Clippy usually defines the major and minor patch version). The `Cargo.lock` file lists `1.0.3` which is one patch version behind the most recent one but prevents a duplicate with cargo's pinned version.
* Dependency `cargo_metadata`
    * Used in several tools as `0.14`
    * Used in `src/tools/tidy` and `src/tools/rls` as `0.12`
    * Updated in Clippy from `0.12` to `0.14`

All updates to the `Cargo.lock` have been done automatically by `x.py`.

There are still some tools with these outdated dependencies. Clippy didn't require any changes, and it would be likely that the others could also be updated without any problem. Let me know if I should try to update them as well 🙃.

Keep up the good work, whoever is reading this 🦀

---

For Clippy:

changelog: none
2021-11-02 23:48:49 +01:00
Matthias Krüger
bc487f7dd2
Rollup merge of #90417 - lcnr:stabilize-relaxed-struct-unsizing, r=wesleywiser
stabilize `relaxed_struct_unsize`

closes #81793

the fcp is already complete.
2021-11-02 23:48:47 +01:00
Matthias Krüger
40f01aaa56
Rollup merge of #90354 - xFrednet:00000-lets-deploy-clippy-docs, r=Mark-Simulacrum
Document clippy on nightly-rustc

Adding Clippy's docs to nightly-rustc, based on commit 01cf0bde. This PR only adds `clippy_utils` to the documentation. I've decided to only document one crate for now, as `clippy_lints` etc. contain very specific and undocumented functions which aren't really reusable. I'm guessing that they would mostly clutter up the search results with little benefit.

`./x.py --stage 1 doc src/tools/clippy` if working fine now after the help that ```````@jyn514``````` and ```````@ehuss``````` have provided. A big THANK YOU to them!
2021-11-02 23:48:46 +01:00
Matthias Krüger
21d2f29533
Rollup merge of #90084 - noncombatant:patch-2, r=steveklabnik
Make printed message match the code comment

I think this code is getting L0, not L1 cache size, if I'm reading the Intel manual right. (I might not be.) Either way, the code comment and the printed message should match, whichever way is right. :)
2021-11-02 23:48:46 +01:00
bors
6f40fa4353 Auto merge of #90464 - lnicola:rust-analyzer-2021-11-01, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2021-11-02 22:45:27 +00:00
Gary Guo
f556075459 Apply adjustments for field expression even if inaccessible
The adjustments are used later by ExprUseVisitor to build Place projections
and without adjustments it can produce invalid result.
2021-11-02 17:22:12 +00:00
Takayuki Maeda
acb9f9ba38 add a suggestion about undeclared alloc module 2021-11-03 01:44:01 +09:00
Guillaume Gomez
d7afbf61d8 Also check for feature gates in "src/test/rustdoc" 2021-11-02 17:15:11 +01:00
Guillaume Gomez
d50a4753b8 Split doc_cfg and doc_auto_cfg features 2021-11-02 16:55:50 +01:00
xFrednet
fd41336c4c Update clippy dependencies
* semver = "0.11" -> "1.0"
* cargo_metadata = "0.12" -> "0.14"
2021-11-02 14:19:31 +01:00
Laurențiu Nicola
ee3b46689b Pull in libkvm on FreeBSD 2021-11-02 10:44:14 +02:00
bors
dca3f1b786 Auto merge of #90490 - ehuss:update-cargo, r=ehuss
Update cargo

3 commits in 6c1bc24b8b49d4bc965f67d7037906dc199c72b7..94ca096afbf25f670e76e07dca754fcfe27134be
2021-10-24 17:51:41 +0000 to 2021-10-29 14:45:06 +0000
- Chore: prefer `HashMap::from` rather than collecting `Vec` of tuples (rust-lang/cargo#10018)
- Change --scrape-examples flag to -Z rustdoc-scrape-examples (rust-lang/cargo#10017)
- Scrape code examples from examples/ directory for Rustdoc (rust-lang/cargo#9525)
2021-11-02 03:18:41 +00:00
Noah Lev
8e4bcdf84b List all cases explicitly in Doc{Folder,Visitor} 2021-11-01 16:15:46 -07:00
Eric Huss
6404dbaf8d Update cargo 2021-11-01 16:08:25 -07:00
bors
6225262562 Auto merge of #90457 - rusticstuff:use-curl-ca-bundle, r=Mark-Simulacrum
CI: Use ubuntu image to download openssl, curl sources, cacert.pem for x86 dist builds

The dist-x86_64 and dist-i686 docker builds are failing again (see [try build](https://github.com/rust-lang-ci/rust/runs/4060836540?check_suite_focus=true)) because python.org renewed its certificate with a CA cert that is too new for debian:6.

In order to solve this once and for all this PR moves the curl and openssl downloads to a new  ubuntu:20.04 "stage-0" docker build and copies the downloaded tarballs over to build them in the "stage-1" debian:6 context. It also downloads the cacert.pem file from the curl website and uses it by pointing the `CURL_CA_BUNDLE` environment variable to it.
2021-11-01 21:21:53 +00:00
Hans Kratz
aef51a0697 Ignore files copied from previous stage when generating hash. 2021-11-01 19:20:07 +01:00
bors
db062de72b Auto merge of #90406 - nbdd0121:panic, r=cjgillot
Collect `panic/panic_bounds_check` during monomorphization

This would prevent link time errors if these functions are `#[inline]` (e.g. when `panic_immediate_abort` is used).

Fix #90405
Fix rust-lang/cargo#10019

`@rustbot` label: T-compiler A-codegen
2021-11-01 17:18:57 +00:00
bors
e9b0d99259 Auto merge of #90463 - matthiaskrgr:rollup-eljk9vo, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #89826 (Feature gate + make must_not_suspend allow-by-default)
 - #89929 (Handling submodule update failures more gracefully from x.py)
 - #90333 (rustdoc: remove flicker during page load)
 - #90349 (Fix rare ICE during typeck in rustdoc scrape_examples)
 - #90398 (Document `doc(keyword)` unstable attribute)
 - #90441 (Test that promotion follows references when looking for drop)
 - #90450 (Remove `rustc_hir::hir_id::HirIdVec`)
 - #90452 (Remove unnecessary `Option` from `promote_candidate` return type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-01 14:00:08 +00:00
bors
db14a17e69 Auto merge of #90462 - pietroalbini:bidi-master, r=nikomatsakis,pietroalbini
[master] Fix CVE-2021-42574

This PR implements new lints to mitigate the impact of [CVE-2021-42574], caused by the presence of bidirectional-override Unicode codepoints in the compiled source code. [See the advisory][advisory] for more information about the vulnerability.

The changes in this PR will be released in tomorrow's nightly release.

[CVE-2021-42574]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42574
[advisory]: https://blog.rust-lang.org/2021/11/01/cve-2021-42574.html
2021-11-01 10:53:49 +00:00
Laurențiu Nicola
a97bfdc7e7 ⬆️ rust-analyzer 2021-11-01 09:01:20 +02:00
Noah Lev
c03cab3fd0 Fix RefCell BorrowMut error in DocVisitor
Until `external_traits` is cleaned up (i.e., no longer behind a
`RefCell`), `DocVisitor` will have to `take` `external_traits` -- just
like `DocFolder` -- to prevent `RefCell` runtime errors.
2021-10-31 21:53:31 -07:00
Noah Lev
3f0f51017c Convert more impls of DocFolder to DocVisitor
I think these are the last of the impls that can be easily converted to visitors.
2021-10-31 21:34:28 -07:00
Noah Lev
b74287076c Convert many impls of DocFolder to DocVisitor
Many of `DocFolder`'s impls didn't actually transform the syntax tree,
so they can be visitors instead.
2021-10-31 21:24:11 -07:00
Noah Lev
10606c3caf rustdoc: Small micro-optimizations and cleanups
* Flip conjuncts of `&&` in rustdoc

  The `CrateNum` comparison should be very cheap, while
  `span.filename()` fetches and clones a `FileName`.

* Use `into_local_path()` instead of `local_path().clone()`
2021-10-31 21:10:32 -07:00
Noah Lev
4ee2d0351a Fix FIXMEs in rustdoc::html::sources
One of the FIXMEs is irrelevant since that code is only run if
`include_sources` is set. I fixed the other FIXME.
2021-10-31 21:05:09 -07:00
Noah Lev
6215f7c85f Clean up now that visitors only need &clean::Crate 2021-10-31 20:59:22 -07:00
Noah Lev
28bdf892d6 rustdoc: Use DocVisitor for sources collection 2021-10-31 20:54:37 -07:00
Noah Lev
5a9bbba280 rustdoc: Add DocVisitor
`DocFolder` allows transforming the docs, accomplished by making its
methods take and return types by-value. However, several of the rustdoc
`DocFolder` impls only *visit* the docs; they don't change anything.
Passing around types by-value is thus unnecessary, confusing, and
potentially inefficient for those impls.

`DocVisitor` is very similar to `DocFolder`, except that its methods
take shared references and return nothing (i.e., the unit type). This
should both be more efficient and make the code clearer.

There is an additional reason to add `DocVisitor`, too. As part of my
cleanup of `external_traits`, I'm planning to add a `fn cache(&mut self)
-> &mut Cache` method to `DocFolder` so that `external_traits` can be
retrieved explicitly from the `Cache`, rather than implicitly via
`Crate.external_traits` (which is an `Rc<RefCell<...>>`). However, some
of the `DocFolder` impls that could be turned into `DocVisitor` impls
only have a shared reference to the `Cache`, because they are used
during rendering. (They have to access the `Cache` via
`html::render::Context.shared.cache`, which involves an `Rc`.)

Since `DocVisitor` does not mutate any of the types it's visiting, its
equivalent `cache()` method will only need a shared reference to the
`Cache`, avoiding the problem described above.
2021-10-31 20:18:52 -07:00
Noah Lev
705dec1194 rustdoc: Replace wildcard with explicit pattern
This simplifies the code and future-proofs it against changes to
`Variant`.
2021-10-31 20:00:48 -07:00
Noah Lev
537b82cfad rustdoc: Remove unnecessary clone in DocFolder
Also, contrary to the comment, the clone is not that small, since
`Variant` contains `Item`s, which are quite large when you factor in
both stack- and heap-allocated memory.
2021-10-31 19:58:28 -07:00
Matthias Krüger
365483a35b
Rollup merge of #90441 - tmiasko:test-promotion-needs-drop, r=Mark-Simulacrum
Test that promotion follows references when looking for drop

Noticed that this wasn't covered by any of existing tests.

The const checking and const qualification, which currently shares the
implementation with promotion, will likely need a different behaviour
here (see issue #90193).
2021-11-01 03:33:09 +01:00
Matthias Krüger
0b8d3b1854
Rollup merge of #90398 - GuillaumeGomez:doc-keyword-doc, r=camelid
Document `doc(keyword)` unstable attribute

r? `@camelid`
2021-11-01 03:33:08 +01:00
Matthias Krüger
3730485a24
Rollup merge of #90349 - willcrichton:example-analyzer, r=jyn514
Fix rare ICE during typeck in rustdoc scrape_examples

While testing the `--scrape-examples` extension on the [wasmtime](https://github.com/bytecodealliance/wasmtime) repository, I found some additional edge cases. Specifically, when asking to typecheck a body containing a function call, I would sometimes get an ICE if:
* The body doesn't exist
* The function's HIR node didn't have a type

This adds checks for both of those conditions.

(Also this updates a test to check that the sources of a reverse-dependency are correctly generated and linked.)

r? `@jyn514`
2021-11-01 03:33:07 +01:00
Matthias Krüger
bb6901d32b
Rollup merge of #90333 - jsha:flashy-searchbar, r=GuillaumeGomez
rustdoc: remove flicker during page load

The search bar has a `:disabled` style that makes it grey, which creates a distracting flicker from grey to white when the page finishes loading. The search bar should stay the same color throughout page load.

A blank white search bar might create an incorrect impression for users with JS turned off. Since they can't use the search functionality, I've hidden the search bar in noscript.css.

Fixes #90246
r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/flashy-searchbar/std/string/struct.String.html
2021-11-01 03:33:06 +01:00
Matthias Krüger
b7be4fc99f
Rollup merge of #89929 - yuvaldolev:handle-submodule-checkout-more-gracefully, r=Mark-Simulacrum
Handling submodule update failures more gracefully from x.py

Addresses #80498

Handling the case where x.py can't check out the right commit of a submodule, because the submodule has local edits that would be overwritten by the checkout, more gracefully.
The error is printed in detail, with some hints on how to revert the local changes to the submodule.
2021-11-01 03:33:04 +01:00
jackh726
18421b1f08 Add lint for region pairs too 2021-10-31 21:53:26 -04:00
jackh726
b84044acff Review comments and more tests 2021-10-31 21:36:04 -04:00
Gus Wynn
185fa56256 Feature gate and make must_not_suspend allow-by-default
This lint is not yet ready for stable use, primarily due to false positives in edge
cases; we want to test it out more before stabilizing.
2021-10-31 21:22:17 -04:00
Hans Kratz
3a687e7510 Use ubuntu image to download openssl, curl sources, cacert.pem 2021-10-31 23:30:37 +01:00
Jacob Hoffman-Andrews
a4fe76ff7c Hide search bar in noscript.css
Also, remove the highlighting of the search bar in disabled state. This
reduces flicker when loading a page.
2021-10-31 12:41:06 -07:00
bors
ff0e14829e Auto merge of #89062 - mikeleany:new-target, r=cjgillot
Add new tier 3 target: `x86_64-unknown-none`

Adds support for compiling OS kernels or other bare-metal applications for the x86-64 architecture.

Below are details on how this target meets the requirements for tier 3:

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I would be willing to be a target maintainer, though I would appreciate if others volunteered to help with that as well.

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

Uses the same naming as the LLVM target, and the same convention as many other bare-metal targets.

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

I don't believe there is any ambiguity here.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

I don't see any legal issues here.

> The target must not introduce license incompatibilities.
> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).
> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.
>If the target supports building host tools (such as rustc or cargo), those host tools must not depend on proprietary (non-FOSS) libraries, other than ordinary runtime libraries supplied by the platform and commonly used by other binaries built for the target. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.
> Targets should not require proprietary (non-FOSS) components to link a functional binary or library.
> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

I see no issues with any of the above.

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

Only relevant to those making approval decisions.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

`core` and `alloc` can be used. `std` cannot be used as this is a bare-metal target.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running tests (even if they do not pass), the documentation must explain how to run tests for the target, using emulation if possible or dedicated hardware if necessary.

Use `--target=x86_64-unknown-none-elf` option to cross compile, just like any target. The target does not support running tests.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.
> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

I don't foresee this being a problem.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

No other targets should be affected by the pull request.
2021-10-31 18:57:14 +00:00
Tomasz Miąsko
fadb9cc521 Test that promotion follows references when looking for drop
Noticed that this wasn't covered by any of existing tests.

The const checking and const qualification, which currently shares the
implementation with promotion, will likely need a different behaviour
here (see issue #90193).
2021-10-31 18:33:29 +01:00
Guillaume Gomez
7bea8eafde Add doc about doc(keyword) unstable attribute 2021-10-31 13:57:04 +01:00
Matthias Krüger
26f505c433
Rollup merge of #90430 - jkugelman:must-use-std-a-through-n, r=joshtriplett
Add #[must_use] to remaining std functions (A-N)

I've run out of compelling reasons to group functions together across crates so I'm just going to go module-by-module. This is half of the remaining items from the `std` crate, from A-N.

I added these functions myself. Clippy predictably ignored the `mut` ones, but I don't know why the rest weren't flagged. Check them closely, please? Maybe I overlooked good reasons.

```rust
std::backtrace::Backtrace                                   const fn disabled() -> Backtrace;
std::backtrace::Backtrace<'a>                               fn frames(&'a self) -> &'a [BacktraceFrame];
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn key_mut(&mut self) -> &mut K;
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_mut(&mut self) -> &mut V;
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_key_value(&mut self) -> (&K, &V);
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_key_value_mut(&mut self) -> (&mut K, &mut V);
std::env                                                    fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString>;
std::env                                                    fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_>;
std::io::Error                                              fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)>;
```

Parent issue: #89692

r? `@joshtriplett`
2021-10-31 13:20:06 +01:00
Matthias Krüger
88e5ae2dd3
Rollup merge of #89786 - jkugelman:must-use-len-and-is_empty, r=joshtriplett
Add #[must_use] to len and is_empty

Parent issue: #89692

r? `@joshtriplett`
2021-10-31 13:20:05 +01:00
Matthias Krüger
6c5aa765fb
Rollup merge of #89068 - bjorn3:restructure_rt2, r=joshtriplett
Restructure std::rt (part 2)

A couple more cleanups on top of https://github.com/rust-lang/rust/pull/89011

Blocked on #89011
2021-10-31 13:20:04 +01:00
Esteban Küber
c0b134582a
Lint against RTL unicode codepoints in literals and comments
Address CVE-2021-42574.
2021-10-31 13:14:04 +01:00
bors
58899c4d9c Auto merge of #90434 - matthiaskrgr:rollup-xbn393a, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #89446 (Add paragraph to ControlFlow docs to menion it works with the ? operator (#88715))
 - #89677 (Stabilize `is_symlink()` for `Metadata` and `Path`)
 - #89833 (Add #[must_use] to Rc::downgrade)
 - #89835 (Add #[must_use] to expensive computations)
 - #89839 (Add #[must_use] to mem/ptr functions)
 - #89897 (Add #[must_use] to remaining core functions)
 - #89951 (Stabilize `option_result_unwrap_unchecked`)
 - #90427 (Add #[must_use] to alloc functions that would leak memory)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-31 09:07:09 +00:00
Matthias Krüger
e79e9f5e2a
Rollup merge of #89839 - jkugelman:must-use-mem-ptr-functions, r=joshtriplett
Add #[must_use] to mem/ptr functions

There's a lot of low-level / unsafe stuff here. Are there legit use cases for ignoring any of these return values?

* No regressions in `./x.py test --stage 1 library/std src/tools/clippy`.
* One regression in `./x.py test --stage 1 src/test/ui`. Fixed.
* I am unable to run `./x.py doc` on my machine so I'll need to wait for the CI to verify doctests pass. I eyeballed all the adjacent tests and they all look okay.

Parent issue: #89692

r? ```@joshtriplett```
2021-10-31 09:20:25 +01:00
bors
38b01d9065 Auto merge of #90391 - camelid:crate-size, r=jyn514
rustdoc: Compute some fields of `clean::Crate` on-demand to reduce size

`clean::Crate` is frequently moved by-value -- for example, in `DocFolder`
implementations -- so reducing its size should improve performance.

This PR reduces the size of `clean::Crate` from 168 bytes to 104 bytes.

r? `@jyn514`
2021-10-31 05:52:42 +00:00
John Kugelman
e129d49f88 Add #[must_use] to remaining std functions (A-N) 2021-10-30 23:44:02 -04:00
John Kugelman
6745e8da06 Add #[must_use] to len and is_empty 2021-10-30 19:25:12 -04:00
John Kugelman
887503ad14 Add #[must_use] to mem/ptr functions 2021-10-30 18:54:48 -04:00
bors
e249ce6b23 Auto merge of #90422 - GuillaumeGomez:rollup-s1mdag0, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #90156 (Remove underlines from non-top docblocks.)
 - #90183 (Show all Deref implementations recursively)
 - #90202 (Improve and test cross-crate hygiene)
 - #90375 (Use `is_global` in `candidate_should_be_dropped_in_favor_of`)
 - #90399 (Skipping verbose diagnostic suggestions when calling .as_ref() on type not implementing AsRef)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-30 19:31:47 +00:00
Guillaume Gomez
197da45e18
Rollup merge of #90399 - yuvaldolev:as-ref-overly-verbose-diagnostic, r=estebank
Skipping verbose diagnostic suggestions when calling .as_ref() on type not implementing AsRef

Addresses #89806

Skipping suggestions when calling `.as_ref()` for types that do not implement the `AsRef` trait.

r? `@estebank`
2021-10-30 20:30:28 +02:00
Guillaume Gomez
06bb1ff1b5
Rollup merge of #90375 - yanok:master, r=lcnr
Use `is_global` in `candidate_should_be_dropped_in_favor_of`

This manifistated in #90195 with compiler being unable to keep
one candidate for a trait impl, if where is a global impl and more
than one trait bound in the where clause.

Before #87280 `candidate_should_be_dropped_in_favor_of` was using
`TypeFoldable::is_global()` that was enough to discard the two
`ParamCandidate`s. But #87280 changed it to use
`TypeFoldable::is_known_global()` instead, which is pessimistic, so
now the compiler drops the global impl instead (because
`is_known_global` is not sure) and then can't decide between the
two `ParamCandidate`s.

Switching it to use `is_global` again solves the issue.

Fixes #90195.
2021-10-30 20:30:27 +02:00
Guillaume Gomez
1a1f525bb0
Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkov
Improve and test cross-crate hygiene

- Decode the parent expansion for traits and enums in `rustc_resolve`, this was already being used for resolution in typeck
- Avoid suggesting importing names with def-site hygiene, since it's often not useful
- Add more tests

r? `@petrochenkov`
2021-10-30 20:30:27 +02:00
Guillaume Gomez
73494404e9
Rollup merge of #90183 - GuillaumeGomez:recurse-deref, r=jyn514
Show all Deref implementations recursively

Fixes #87783.

This is a re-implementation of #80653, so taking the original PR comment:

This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level.

![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png)

cc `@camelid`
r? `@jyn514`
2021-10-30 20:30:26 +02:00
Guillaume Gomez
ec83b95ab9
Rollup merge of #90156 - jsha:less-border-bottom-2, r=GuillaumeGomez
Remove underlines from non-top docblocks.

We still had a number of places where underlined section headings would
show up, like under Implementations.

Follow-up to #89506 (thanks `@yaymukund!)` and #90036. Related to #59829.

r? `@camelid`

Demo:

[Before](https://doc.rust-lang.org/nightly/std/string/struct.String.html#trait-implementations):

[![image](https://user-images.githubusercontent.com/220205/138402555-b0c0a3ea-ff50-4aad-bb74-6f9e57323807.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations)

[After](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations):

[![image](https://user-images.githubusercontent.com/220205/138402669-d0835bd9-8813-4f0c-8697-f86e9759acec.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations)
2021-10-30 20:30:25 +02:00
Noah Lev
a58e214894 rustdoc: Stop sorting external crates
Now that #73423 is fixed, sorting should no longer be necessary.
See also this discussion [1].

[1]: https://github.com/rust-lang/rust/pull/86889#discussion_r664134963
2021-10-30 11:16:26 -07:00
Noah Lev
ebe9a11f71 rustdoc: Remove Crate.name and instead compute it on-demand
It is not as large as `Crate.src` was, but it's still 8 bytes, and
`clean::Crate` is moved by-value a lot.
2021-10-30 11:16:24 -07:00
Noah Lev
85f8ae8ec4 rustdoc: Remove Crate.src and instead compute it on-demand
It is only used in one place; `src` was about a third of `Crate`'s total
size; `Crate` is frequently moved by-value; and `src` can be easily
computed on-demand.
2021-10-30 11:16:00 -07:00
Noah Lev
47b0059dba rustdoc: Document that Crate is always local 2021-10-30 11:15:21 -07:00
Gary Guo
94e940dd30 Collect panic/panic_bounds_check during monomorphization 2021-10-30 18:21:44 +01:00
bors
2609fab8e4 Auto merge of #90205 - mati865:link-modifiers-in-rustc, r=petrochenkov
Repace use of `static_nobundle` with `native_link_modifiers` within Rust codebase

This fixes warnings when building Rust and running tests:
```
warning: library kind `static-nobundle` has been superseded by specifying `-bundle` on library kind `static`. Try `static:-bundle`
warning: `rustc_llvm` (lib) generated 2 warnings (1 duplicate)
```
2021-10-30 16:22:49 +00:00
Jacob Hoffman-Andrews
a65c98fefb Remove underlines from non-top docblocks.
We still had a number of places where underlined section headings would
show up, like under Implementations.
2021-10-30 09:22:28 -07:00
Guillaume Gomez
78b604569b Document tests a bit more 2021-10-30 16:30:14 +02:00
lcnr
b40aa64e48 stabilize relaxed_struct_unsize 2021-10-30 15:56:02 +02:00
Matthias Krüger
19b5b0f8fb
Rollup merge of #90412 - jyn514:macro-use, r=camelid
Remove unnecessary `macro_use`s in rustdoc
2021-10-30 14:37:04 +02:00
Matthias Krüger
d99dc7abfa
Rollup merge of #90396 - b-naber:type_flags_ices_default_anon_consts, r=lcnr
Prevent type flags assertions being thrown in default_anon_const_substs if errors occurred

Fixes https://github.com/rust-lang/rust/issues/90364
Fixes https://github.com/rust-lang/rust/issues/88997

r? ``@lcnr``
2021-10-30 14:37:03 +02:00
Matthias Krüger
88e0bea7ca
Rollup merge of #90395 - b-naber:const-expr-type-relation, r=oli-obk
Restrict liveness of mutable borrow of inner infcx in ConstInferUnifier::consts

Fixes https://github.com/rust-lang/rust/issues/89304

r? ``@oli-obk``
2021-10-30 14:37:02 +02:00
Matthias Krüger
a213740abe
Rollup merge of #90374 - GuillaumeGomez:unify-rustdoc-book-titles, r=camelid
Unify titles in rustdoc book doc attributes chapter

As discussed in https://github.com/rust-lang/rust/pull/90339.

I wasn't able to find out where the link to the titles was used so let's see if the CI fails. :)

r? ``@camelid``
2021-10-30 14:37:00 +02:00
bors
22f1ad75e9 Auto merge of #88268 - GuillaumeGomez:generics-search-index, r=notriddle,camelid,jyn514
rustdoc: Fix generics generation in search index

The generics were not added to the search index as they should, instead they were added as arguments. I used this opportunity to allow generics to have generics themselves (will come in very handy for my current rewrite of the search engine!).

r? `@jyn514`
2021-10-30 04:12:40 +00:00
Noah Lev
27d47d93be rustdoc: Add static size assertion for clean::Crate 2021-10-29 20:43:27 -07:00
Joshua Nelson
b6851ba3c9 Remove unnecessary macro_uses in rustdoc 2021-10-30 02:22:38 +00:00
Will Crichton
b8ecc9fefa Fix rare ICE during typeck in rustdoc scrape_examples 2021-10-29 13:21:50 -07:00
Guillaume Gomez
0c70831171 Unify titles in rustdoc book doc attributes chapter 2021-10-29 21:27:44 +02:00
Guillaume Gomez
355e6eddfe Fix invalid handling of generics 2021-10-29 20:54:15 +02:00
bors
e99963c554 Auto merge of #90390 - umanwizard:update-miri, r=RalfJung
Update miri

Fixes https://github.com/rust-lang/rust/issues/90298
2021-10-29 18:41:17 +00:00
bors
deb4572923 Auto merge of #90389 - camelid:rustdoc-rayon, r=jyn514
rustdoc: Switch to mainline rayon

The rustc fork of rayon integrates with Cargo's jobserver to limit the
amount of parallelism. However, rustdoc's use case is concurrent I/O,
which is not CPU-heavy, so it should be able to use mainline rayon.

See [this discussion][1] for more details.

[1]: https://github.com/rust-lang/rust/issues/90227#issuecomment-952468618

Note: I chose rayon 1.3.1 so that the rayon version used elsewhere in
the workspace does not change.

r? `@Mark-Simulacrum`
cc `@jyn514`
2021-10-29 15:31:37 +00:00
Yuval Dolev
cad2d21cb6 Explicitly skipping suggestions for 'Pin' as it does not implement the 'AsRef' trait 2021-10-29 15:49:55 +03:00
Yuval Dolev
e2151497bf Skip suggestions for the AsRef trait 2021-10-29 15:49:55 +03:00
Guillaume Gomez
f09b67a696 Fix panic when documenting libproc-macro 2021-10-29 14:37:01 +02:00
Guillaume Gomez
dd68d207a5 Don't display "Methods from Deref<...>" if no method is display (the ones which don't have self argument) 2021-10-29 14:37:01 +02:00
Guillaume Gomez
3398877858 Remove the Rc wrapping of deref_id_map 2021-10-29 14:25:15 +02:00
Guillaume Gomez
0c38f31bf2 Add tests for recursive deref 2021-10-29 14:25:15 +02:00
bors
9ed5b94b28 Auto merge of #90373 - tmiasko:union-qualification, r=oli-obk
Use type based qualification for unions

Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.

Fixes #90268.

`@rust-lang/wg-const-eval`
2021-10-29 12:21:09 +00:00
Guillaume Gomez
8a473ca346 Recursively document Deref 2021-10-29 14:14:46 +02:00
b-naber
87fbf3c5aa ignore type flags insertion in default_anon_const_substs if error occurred 2021-10-29 13:47:53 +02:00
b-naber
a39c50b64c add test 2021-10-29 12:38:28 +02:00