Commit graph

162867 commits

Author SHA1 Message Date
bors 5d6ee0db96 Auto merge of #93836 - matthiaskrgr:rollup-d1ssiwl, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #91443 (Better suggestions when user tries to collect into an unsized `[_]`)
 - #91504 (`#[used(linker)]` attribute)
 - #93503 (debuginfo: Fix DW_AT_containing_type vtable debuginfo regression)
 - #93753 (Complete removal of #[main] attribute from compiler)
 - #93799 (Fix typo in `std::fmt` docs)
 - #93813 (Make a few cleanup MIR passes public)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-10 02:27:43 +00:00
Tomoaki Kawada bdc9508bb6 kmc-solid: Fix wait queue manipulation errors in the Condvar implementation 2022-02-10 10:21:39 +09:00
Tyler Mandry 69cd826a85 Add llvm.build-config option 2022-02-09 22:41:23 +00:00
Matthias Krüger 323880646d
Rollup merge of #93813 - xldenis:public-mir-passes, r=wesleywiser
Make a few cleanup MIR passes public

Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Making.20passes.20public.20again

This makes a few passes which used to be public, public again. I'd like to use these to clean up MIR code for my external rustc driver. The other option would be to make them all public, but I don't know if that's warranted / useful.

r? `@wesleywiser`
2022-02-09 23:29:59 +01:00
Matthias Krüger 6db0f9ca0d
Rollup merge of #93799 - wooorm:patch-1, r=dtolnay
Fix typo in `std::fmt` docs

Hey!

Reading the docs (https://doc.rust-lang.org/std/fmt/#named-parameters), this seems like a typo?

The docs here also seem to mix “named argument” and “named parameter”? Intentional? Mistake?
2022-02-09 23:29:58 +01:00
Matthias Krüger 84c28041b4
Rollup merge of #93753 - jeremyBanks:main-conflict, r=petrochenkov
Complete removal of #[main] attribute from compiler

resolves #93786

---

The `#[main]` attribute was mostly removed from the language in #84217, but not completely. It is still recognized as a builtin attribute by the compiler, but it has no effect. However, this no-op attribute is no longer gated by `#[feature(main)]` (which no longer exists), so it's possible to include it in code *on stable* without any errors, which seems unintentional. For example, the following code is accepted ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=%23%5Bmain%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22hello%20world%22)%3B%0A%7D%0A)).

```rust
#[main]
fn main() {
    println!("hello world");
}
```

Aside from that oddity, the existence of this attribute causes code like the following to fail ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=use%20tokio%3A%3Amain%3B%0A%0A%23%5Bmain%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22hello%20world%22)%3B%0A%7D%0A)). According https://github.com/rust-lang/rust/pull/84062#issuecomment-825038275, the removal of `#[main]` was expected to eliminate this conflict (previously reported as #62127).

```rust
use tokio::main;

#[main]
fn main() {
    println!("hello world");
}
```

```
error[E0659]: `main` is ambiguous
 --> src/main.rs:3:3
  |
3 | #[main]
  |   ^^^^ ambiguous name
  |
  = note: ambiguous because of a name conflict with a builtin attribute
  = note: `main` could refer to a built-in attribute
```

[This error message can be confusing](https://stackoverflow.com/q/71024443/1114), as the mostly-removed `#[main]` attribute is not mentioned in any documentation.

Since the current availability of `#[main]` on stable seems unintentional, and to needlessly block use of the `main` identifier in the attribute namespace, this PR finishes removing the `#[main]` attribute as described in https://github.com/rust-lang/rust/issues/29634#issuecomment-274951753 by deleting it from `builtin_attrs.rs`, and adds two test cases to ensure that the attribute is no longer accepted and no longer conflicts with other attributes imported as `main`.
2022-02-09 23:29:57 +01:00
Matthias Krüger 6d40850e09
Rollup merge of #93503 - michaelwoerister:fix-vtable-holder-debuginfo-regression, r=wesleywiser
debuginfo: Fix DW_AT_containing_type vtable debuginfo regression

This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in #89597.

It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable.

r? ``@wesleywiser``

This PR should fix issue https://github.com/rust-lang/rust/issues/93164.
~~The PR is blocked on https://github.com/rust-lang/rust/pull/93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~
2022-02-09 23:29:56 +01:00
Matthias Krüger 3f4aaf4f2e
Rollup merge of #91504 - cynecx:used_retain, r=nikic
`#[used(linker)]` attribute

See https://github.com/dtolnay/linkme/issues/41#issuecomment-927255631.
2022-02-09 23:29:56 +01:00
Matthias Krüger 9634559599
Rollup merge of #91443 - compiler-errors:bad_collect_into_slice, r=wesleywiser
Better suggestions when user tries to collect into an unsized `[_]`

1. Extend the predicate on `rustc_on_unimplemented` to support substitutions like note, label, etc (i.e. treat it as a `OnUnimplementedFormatString`) so we can have slightly more general `rustc_on_unimplemented` special-cases.
2. Add a `rustc_on_unimplemented` if we fail on `FromIterator<A> for [A]` which happens when we don't explicitly collect into a `vec<A>`, but then pass the return from a `.collect` call into something that takes a slice.

Fixes #91423
2022-02-09 23:29:55 +01:00
Amanieu d'Antras 7b8f6ac5ab Bump compiler-builtins to 0.1.69 2022-02-09 21:03:13 +00:00
Noah Lev 504f3f037d Title-case trait aliases section for consistency 2022-02-09 11:39:13 -08:00
Noah Lev 163a8004ae Refactor sidebar printing code
The new code is much simpler and easier to understand. In fact, the old
code actually had a subtle bug where it excluded a few item types,
including trait aliases, from the sidebar, even though they are rendered
on the page itself! Now, all sections should show up in the sidebar.
2022-02-09 11:39:13 -08:00
Noah Lev 1115f69bf4 Deduplicate item sections 2022-02-09 11:39:12 -08:00
Noah Lev fa400ace11 rustdoc: Create enum for sections holding items 2022-02-09 11:39:12 -08:00
Camille GILLOT 8edd32c940 Avoid clone. 2022-02-09 20:11:33 +01:00
Camille GILLOT e1a72c29aa Explain &Arc. 2022-02-09 20:11:30 +01:00
Camille GILLOT 4435dfec0f Make FnAbiError Copy. 2022-02-09 20:11:29 +01:00
Camille GILLOT e52131efad Use a slice for object_lifetime_defaults. 2022-02-09 20:11:01 +01:00
Camille GILLOT f72f15ca28 Use a slice in DefIdForest. 2022-02-09 20:11:00 +01:00
Camille GILLOT 6c2ee885e6 Ensure that queries only return Copy types. 2022-02-09 20:07:38 +01:00
bors e7aca89598 Auto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillot
Refactor query system to maintain a global job id counter

This replaces the per-shard counters with a single global counter, simplifying
the JobId struct down to just a u64 and removing the need to pipe a DepKind
generic through a bunch of code. The performance implications on non-parallel
compilers are likely minimal (this switches to `Cell<u64>` as the backing
storage over a `u64`, but the latter was already inside a `RefCell` so it's not
really a significance divergence). On parallel compilers, the cost of a single
global u64 counter may be more significant: it adds a serialization point in
theory. On the other hand, we can imagine changing the counter to have a
thread-local component if it becomes worrisome or some similar structure.

The new design is sufficiently simpler that it warrants the potential for slight
changes down the line if/when we get parallel compilation to be more of a
default.

A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid
possibly overflowing it and causing problems; it is effectively impossible that
we would overflow a u64 counter in this context.
2022-02-09 18:54:30 +00:00
Amanieu d'Antras 49d4823112 Stabilize cfg_target_has_atomic
Closes #32976
2022-02-09 18:45:44 +00:00
Michael Goulet fea0015f93 Suggest collecting into Vec<_> when collecting into [_] 2022-02-09 09:35:46 -08:00
Michael Goulet f43e3a86a7 Allow substitutions in rustc_on_unimplemented predicate 2022-02-09 09:35:42 -08:00
Xavier Denis c97302efad Make a few cleanup MIR passes public 2022-02-09 17:27:58 +01:00
Nixon Enraght-Moony bf0e862903 rustdoc-json: Add some tests for typealias item 2022-02-09 16:10:58 +00:00
Nixon Enraght-Moony 2d0bb0d4b9 jsondocck: Improved error messages for invalid json value and failed @count check 2022-02-09 16:10:58 +00:00
bors 9747ee4755 Auto merge of #93724 - Mark-Simulacrum:drop-query-stats, r=michaelwoerister
Delete -Zquery-stats infrastructure

These statistics are computable from the self-profile data and/or ad-hoc collectable as needed, and in the meantime contribute to rustc bootstrap times -- locally, this PR shaves ~2.5% from rustc_query_impl builds in instruction counts.

If this does lose some functionality we want to keep, I think we should migrate it to self-profile (or a similar interface) rather than this ad-hoc reporting.
2022-02-09 15:53:10 +00:00
Guillaume Gomez e8d5ae41a1 Update rustdoc tests for headings indent 2022-02-09 14:55:26 +01:00
Guillaume Gomez 6aad08f13f Unify headings indent and remove useless anchor 2022-02-09 14:43:44 +01:00
bors b7cd0f7864 Auto merge of #93681 - Mark-Simulacrum:rlink-binary, r=davidtwco,bjorn3
Store rlink data in opaque binary format on disk

This removes one of the only uses of JSON decoding (to Rust structs) from the compiler, and fixes the FIXME comment. It's not clear to me what the reason for using JSON here originally was, and from what I can tell nothing outside of rustc expects to read the emitted information, so it seems like a reasonable step to move it to the metadata-encoding format (rustc_serialize::opaque).

Mostly intended as a FIXME fix, though potentially a stepping stone to dropping the support for Decodable to be used to decode JSON entirely (allowing for better/faster APIs on the Decoder trait).

cc #64191
2022-02-09 12:51:53 +00:00
Titus 3d3318b406
Fix typo in std::fmt docs 2022-02-09 11:26:10 +01:00
Nikita Popov 170593313a Move tests into attributes directory to pacify tidy 2022-02-09 11:21:25 +01:00
Nikita Popov 933963e10a Add tracking issue 2022-02-09 11:21:25 +01:00
bors 1f0a96862a Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk
Improve opaque type higher-ranked region error message under NLL

Currently, any higher-ranked region errors involving opaque types
fall back to a generic "higher-ranked subtype error" message when
run under NLL. This PR adds better error message handling for this
case, giving us the same kinds of error messages that we currently
get without NLL:

```
error: implementation of `MyTrait` is not general enough
  --> $DIR/opaque-hrtb.rs:12:13
   |
LL | fn foo() -> impl for<'a> MyTrait<&'a str> {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough
   |
   = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`...
   = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2`

error: aborting due to previous error
```

To accomplish this, several different refactoring needed to be made:

* We now have a dedicated `InstantiateOpaqueType` struct which
implements `TypeOp`. This is used to invoke `instantiate_opaque_types`
during MIR type checking.
* `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is
needed to report opaque type region errors.
* We no longer assume that all `TypeOp`s correspond to canonicalized
queries. This allows us to properly handle opaque type instantiation
(which does not occur in a query) as a `TypeOp`.
A new `ErrorInfo` associated type is used to determine what
additional information is used during higher-ranked region error
handling.
* The body of `try_extract_error_from_fulfill_cx`
has been moved out to a new function `try_extract_error_from_region_constraints`.
This allows us to re-use the same error reporting code between
canonicalized queries (which can extract region constraints directly
from a fresh `InferCtxt`) and opaque type handling (which needs to take
region constraints from the pre-existing `InferCtxt` that we use
throughout MIR borrow checking).
2022-02-09 09:41:48 +00:00
bors 6966a42c1a Auto merge of #8404 - camsteffen:rm-ui-test, r=flip1995
Factor out ui_test suite

changelog: none
2022-02-09 09:09:58 +00:00
bors bf242bb119 Auto merge of #93795 - JohnTitor:rollup-n0dmsoo, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #93445 (Add From<u8> for ExitCode)
 - #93694 (rustdoc: tweak line spacing and paragraph spacing for accessibility)
 - #93735 (Stabilize int_abs_diff in 1.60.0.)
 - #93746 (Remove defaultness from ImplItem.)
 - #93748 (rustc_query_impl: reduce visibility of some modules/fn's)
 - #93751 (Drop tracking: track borrows of projections)
 - #93781 (update `ty::TyKind` documentation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-09 06:54:16 +00:00
Yuki Okushi 7f4486b255
Rollup merge of #93781 - lcnr:ty-kind-docs, r=jackh726
update `ty::TyKind` documentation

slightly unsure about `ty::Opaque` and `ty::Bound`/`ty::Placeholder`.

r? `@jackh726` `@nikomatsakis` `@oli-obk`
2022-02-09 14:12:25 +09:00
Yuki Okushi a07eed99f6
Rollup merge of #93751 - eholk:issue-93648-drop-tracking-projection, r=tmiasko
Drop tracking: track borrows of projections

Previous efforts to ignore partially consumed values meant we were also not considering borrows of a projection. This led to cases where we'd miss borrowed types which MIR expected to be there, leading to ICEs.

This PR also includes the `-Zdrop-tracking` flag from #93313. If that PR lands first, I'll rebase to drop the commit from this one.

Fixes #93648
2022-02-09 14:12:24 +09:00
Yuki Okushi 68fa9b198a
Rollup merge of #93748 - klensy:vis-r, r=cjgillot
rustc_query_impl: reduce visibility of some modules/fn's

Locally this reduces number of exported functions from 15221 -> 14952 and size a little.

Perf run please?
2022-02-09 14:12:23 +09:00
Yuki Okushi 5044e3769e Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis
Remove defaultness from ImplItem.

This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-09 14:12:22 +09:00
Yuki Okushi e5ac08779b
Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis
Remove defaultness from ImplItem.

This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-09 14:12:22 +09:00
Yuki Okushi 56094651b8
Rollup merge of #93735 - m-ou-se:stabilize-int-abs-diff, r=joshtriplett
Stabilize int_abs_diff in 1.60.0.

FCP finished here: https://github.com/rust-lang/rust/issues/89492#issuecomment-1030694522
2022-02-09 14:12:21 +09:00
Yuki Okushi a5084488f8
Rollup merge of #93694 - jsha:font-sizes-spacing, r=GuillaumeGomez
rustdoc: tweak line spacing and paragraph spacing for accessibility

The [W3C Web Content Accessibility Guidelines](https://www.w3.org/WAI/WCAG21/Understanding/visual-presentation.html) specify a minimum line spacing of 1.5 and a minimum paragraph spacing of 1.5 times the line spacing. Our current line spacing (implemented by line-height) is 1.4, so it's a small bump to go up to 1.5. Similarly, we have a paragraph spacing of 0.6em. Bump that to 0.75em (which is 1.5 times the 0.5em distance between lines).

Also, fix all the font sizes so instead of being round-ish numbers in rem (like 1.1rem, 1.2rem), they are round numbers in pixels: 16px, 18px, 20px, 22px, 24px. Ensure each font size is at least 2 pixels different than the nearest other font size, so distinctions can be clearly seen. Overall the font-sizes are mostly staying the same, being rounded up or down as appropriate. This will make reasoning about consistent layout sizes much easier.

Remove a few unused styles.

Simplify the display of the mobile-topbar location, by setting its margins to auto rather than trying to size it exactly to the topbar.

Part of #59845.

Demo: https://rustdoc.crud.net/jsha/font-sizes-spacing/std/string/struct.String.html

r? `@GuillaumeGomez`
2022-02-09 14:12:18 +09:00
Yuki Okushi ec2fd8a35f
Rollup merge of #93445 - yaahc:exitcode-constructor, r=dtolnay
Add From<u8> for ExitCode

This should cover a mostly cross-platform subset of supported exit codes.

We decided to stick with `u8` initially since its the common subset between all platforms that we support (excluding wasm which I think only works with `true` or `false`). Posix is supposed to take i32s, but in practice many unix platforms mask out all but the low 8 bits or in some cases the 8-15th bits. Windows takes a u32 instead of an i32. Bourne-compatible shells also report signals as exitcode 128 + `signal_no`, so there's some ambiguity there when returning exit codes > 127, but it is possible to disambiguate them on the other side so we decided against restricting the possible codes further than to `u8`.

## Related

- Detailed analysis of exit code support on various platforms: https://internals.rust-lang.org/t/mini-pre-rfc-redesigning-process-exitstatus/5426
- https://github.com/rust-lang/rust/issues/48711
- https://github.com/rust-lang/rust/issues/43301
- https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization
2022-02-09 14:12:17 +09:00
bors e1f586cfa5 Auto merge of #93793 - ehuss:update-cargo, r=ehuss
Update cargo

5 commits in 25fcb135d02ea897ce894b67ae021f48107d522b..c082648646cbb2be266df9ecbcdc253058158d68
2022-02-01 01:32:48 +0000 to 2022-02-08 14:55:05 +0000
- Add rustup link (rust-lang/cargo#10371)
- Improve startup time of bash completion. (rust-lang/cargo#10365)
- Stabilize `-Ztimings` as `--timings` (rust-lang/cargo#10245)
- Remove needless borrow (rust-lang/cargo#10360)
- Compute non custom build and non transitive deps for doc (rust-lang/cargo#10341)
2022-02-09 04:05:55 +00:00
Eric Huss 2a0883695b Update cargo 2022-02-08 18:55:23 -08:00
bors 9a5a961be9 Auto merge of #93778 - matthiaskrgr:rollup-yfngdao, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91950 (Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`)
 - #92715 (Do not suggest char literal for zero-length strings)
 - #92917 (Don't constrain projection predicates with inference vars in GAT substs)
 - #93206 (Use `NtCreateFile` instead of `NtOpenFile` to open a file)
 - #93732 (add fut/back compat tests for implied trait bounds)
 - #93764 (⬆️ rust-analyzer)
 - #93767 (deduplicate `lcnr` in mailmap)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-09 01:18:06 +00:00
Mark Rousskov e240783a4d Switch QueryJobId to a single global counter
This replaces the per-shard counters with a single global counter, simplifying
the JobId struct down to just a u64 and removing the need to pipe a DepKind
generic through a bunch of code. The performance implications on non-parallel
compilers are likely minimal (this switches to `Cell<u64>` as the backing
storage over a `u64`, but the latter was already inside a `RefCell` so it's not
really a significance divergence). On parallel compilers, the cost of a single
global u64 counter may be more significant: it adds a serialization point in
theory. On the other hand, we can imagine changing the counter to have a
thread-local component if it becomes worrisome or some similar structure.

The new design is sufficiently simpler that it warrants the potential for slight
changes down the line if/when we get parallel compilation to be more of a
default.

A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid
possibly overflowing it and causing problems; it is effectively impossible that
we would overflow a u64 counter in this context.
2022-02-08 18:49:55 -05:00
cynecx 438826fd1a add more tests and make used(linker/compiler) mutually exclusive 2022-02-08 23:51:17 +01:00