Commit graph

9023 commits

Author SHA1 Message Date
Ben Boeckel
863e5226d3 error_codes: uniformly comment error codes 2021-11-05 11:57:17 -04:00
bors
489ec310d2 Auto merge of #90577 - matthiaskrgr:clippy_perf_nov, r=petrochenkov
clippy::perf fixes
2021-11-05 09:17:39 +00:00
Yuki Okushi
6964ec2f72
Rollup merge of #90544 - ehuss:demote-locator-warn, r=petrochenkov
Demote metadata load warning to "info".

There is a warn log message for whenever the crate loader fails to load metadata from a candidate file. I think this warning is too aggressive, as there are several situations where metadata information might not be found in a candidate file, which is normal. Also, this warning is somewhat confusing, and non-actionable in most cases for a user (most users will not know what it means).

If the crate loader ultimately does not find a valid crate, then an error will be reported (and hopefully #88368 will improve that error message).

If a rustc developer wants to debug a loader problem, they can still use `RUSTC_LOG=rustc_metadata=debug` and get the details.

There is more discussion of this particular warning at https://github.com/rust-lang/rust/issues/89795#issuecomment-940798190.

Fixes #90525
2021-11-05 10:32:44 +09:00
Yuki Okushi
a5802d0731
Rollup merge of #90537 - adamgemmell:dev/aarch64-target-feature, r=Amanieu
Update aarch64 `target_feature` list for LLVM 12.

Many of these feature are now available on all valid LLVM versions.

I've also added a few new ones to the list.

r? `@Amanieu`
2021-11-05 10:32:42 +09:00
Yuki Okushi
987797bfe1
Rollup merge of #90507 - TaKO8Ki:suggest-extern-crate-alloc, r=jackh726
Suggest `extern crate alloc` when using undeclared module `alloc`

closes #90136
2021-11-05 10:32:39 +09:00
bors
2cff30b17a Auto merge of #90536 - crlf0710:fix_vtable_hrtb, r=jackh726
Erase regions within `vtable_trait_first_method_offset`

Fixes #90177 .

r? `@jackh726`
2021-11-04 21:52:21 +00:00
Matthias Krüger
28ef4169cc clippy::perf fixes 2021-11-04 21:07:56 +01:00
bors
27143a9094 Auto merge of #90518 - calebcartwright:rustc-ast-docs, r=wesleywiser
update rustc_ast crate descriptions in documentation

I noticed this the other day and figured I'd suggest a refresh. It seems like a relic from the days of `libsyntax` that got missed as things were split out into separate crates, since the current documentation text references elements that were moved into their own respective crates (e.g. `rustc_parse`)
2021-11-04 09:40:25 +00:00
bors
e60e19bc65 Auto merge of #90179 - Nilstrieb:lifetime-elision-mismatch-hint, r=estebank
Add beginner friendly lifetime elision hint to E0623

Address #90170

Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't.

Example:

```
error[E0623]: lifetime mismatch
  --> $DIR/issue-90170-elision-mismatch.rs:2:35
   |
LL | fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
   |                 ---------           --------- these two types are declared with different lifetimes...
LL |     core::mem::swap(&mut slice_a, &mut slice_b);
   |                                   ^^^^^^^^^^^^ ...but data from `slice_b` flows into `slice_a` here
   |
   = note: each elided lifetime in input position becomes a distinct lifetime
help: explicitly declare a lifetime and assign it to both
   |
LL | fn foo<'a>(slice_a: &'a mut [u8], slice_b: &'a mut [u8]) {
   |       ++++           ++                     ++

```

for

```rust
fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
    core::mem::swap(&mut slice_a, &mut slice_b);
}
```
2021-11-04 00:39:21 +00:00
Eric Huss
9057936a9a Demote metadata load warning to "info". 2021-11-03 13:39:37 -07:00
Nilstrieb
4b9e4606cb Add beginner friendly lifetime elision hint to E0623
Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't

Issue #90170

This also changes the tests introduced by the previous commits because of another rustc issue (#90258)
2021-11-03 20:10:44 +01:00
Adam Gemmell
cdd98bbdfe Update aarch64 target_feature list for LLVM 12. 2021-11-03 18:04:09 +00:00
Charles Lew
8841204cc6 Erase regions within vtable_trait_first_method_offset. 2021-11-04 00:53:54 +08:00
Tomasz Miąsko
bc4931ed7e addr_of! grants mutable access, maybe?
The exact set of permissions granted when forming a raw reference is
currently undecided https://github.com/rust-lang/rust/issues/56604.

To avoid presupposing any particular outcome, adjust the const
qualification to be compatible with decision where raw reference
constructed from `addr_of!` grants mutable access.
2021-11-03 16:43:12 +01:00
Tomasz Miąsko
b285e0c5d8 Remove MaybeMutBorrowedLocals 2021-11-03 16:43:12 +01:00
bors
3831aaa13c Auto merge of #90478 - rusticstuff:apple-a14, r=wesleywiser
Use apple-a14 as target CPU for aarch64-apple-darwin

After updating the minimum required LLVM version to 12 (#90175) we can use `apple-a14` as target CPU, because that CPU is similar in features to the Apple M1 (see [LLVM 13 source](b8016b626e/llvm/lib/Target/AArch64/AArch64.td (L1127))). Once the minimum required LLVM version is updated to 13 we can use `apple-m1` here.
2021-11-03 08:44:38 +00:00
Takayuki Maeda
6c1e194534 fix message 2021-11-03 13:53:57 +09:00
Caleb Cartwright
9e31fab58c docs(rustc_ast): update crate descriptions 2021-11-02 21:11:17 -05: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
bc26dbba11
Rollup merge of #90472 - joshtriplett:clarify-feature-acceptance, r=jyn514
Clarify what to do with accepted feature gates

The documentation only referenced `removed.rs`, but feature gates for
accepted features move to `accepted.rs`.
2021-11-02 23:48:48 +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
Takayuki Maeda
acb9f9ba38 add a suggestion about undeclared alloc module 2021-11-03 01:44:01 +09:00
Guillaume Gomez
d50a4753b8 Split doc_cfg and doc_auto_cfg features 2021-11-02 16:55:50 +01:00
Josh Triplett
eb23a7333f Add link to documentation about feature gates 2021-11-02 15:30:28 +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
Hans Kratz
37476287bf Use apple-a14 as target CPU for aarch64-apple-darwin.
After updating the minimum required LLVM version to 12 we can use
apple-a14 as that is closer in features to the Apple M1 than the A12.
Once the minimum required LLVM version is updated to 13 we can use
apple-m1.
2021-11-01 17:03:07 +01:00
Josh Triplett
597f889e45 Clarify what to do with accepted feature gates
The documentation only referenced `removed.rs`, but feature gates for
accepted features move to `accepted.rs`.
2021-11-01 15:34:19 +01: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
Pietro Albini
cdd3b8624f
fix formatting 2021-11-01 10:39:43 +01:00
Matthias Krüger
6ce0ef5e89
Rollup merge of #90452 - tmiasko:promote-candidate, r=cjgillot
Remove unnecessary `Option` from `promote_candidate` return type
2021-11-01 03:33:11 +01:00
Matthias Krüger
86f5b8a52d
Rollup merge of #90450 - pierwill:rm-hiridvec, r=cjgillot
Remove `rustc_hir::hir_id::HirIdVec`

See https://github.com/rust-lang/rust/pull/90408#discussion_r739627519:

> IIRC, `HirIdVec` is never used, you can delete it. PR #72015 has been abandoned.

r? `@cjgillot`
2021-11-01 03:33:10 +01: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
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
pierwill
9137960c89 Remove rustc_hir::hir_id::HirIdVec 2021-10-31 13:34:19 -05:00
Gary Guo
4d619d92ae Require panic and panic_bounds_check to be non-generic 2021-10-31 17:57:32 +00: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
Tomasz Miąsko
3a95338f31 Remove unnecessary Option from promote_candidate return type 2021-10-31 00:00:00 +00:00
bors
46ce6a77c2 Auto merge of #90424 - matthiaskrgr:rollup-jezzu4f, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #89789 (Add #[must_use] to thread::Builder)
 - #89899 (Add #[must_use] to remaining alloc functions)
 - #90401 (hermit: Implement Condvar::wait_timeout)
 - #90404 (hermitkernel-target: Set OS to "none")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-30 22:39:24 +00:00
Matthias Krüger
ce48803bfe
Rollup merge of #90404 - mkroening:hermit-kernel-no-os, r=joshtriplett
hermitkernel-target: Set OS to "none"

For our kernel targets, we should not set OS, as the kernel runs bare
metal without a circular dependency on std.

This also prepares us for unifying with
https://github.com/rust-lang/rust/pull/89062. This patch requires
libhermit-rs to change a `cfg`s from `target_os = "hermit"` to `target_os
= "none"`.

I tested this patch locally.

CC: `@stlankes`
2021-10-31 00:33:26 +02: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
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
lcnr
b40aa64e48 stabilize relaxed_struct_unsize 2021-10-30 15:56:02 +02:00
Matthias Krüger
f9111e0336
Rollup merge of #90402 - wesleywiser:query_descriptions, r=oli-obk
Add a few query descriptions
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