Commit Graph

125776 Commits

Author SHA1 Message Date
Matthias Krüger
c7ada001ec
Rollup merge of #90001 - Fearyncess:master, r=alexcrichton
Make rlib metadata strip works with MIPSr6 architecture

Because MIPSr6 has many differences with previous MIPSr2 arch, the previous rlib metadata stripping code in `rustc_codegen_ssa` is only for MIPSr2/r3/r5 (which share the same elf e_flags).

This commit fixed this problem. It makes `rustc_codegen_ssa` happy when compiling rustc for MIPSr6 target or hosts.

e_flags REF: e356027016/llvm/include/llvm/BinaryFormat/ELF.h (L562)
2022-01-13 08:11:16 +01:00
bors
e916815d21 Auto merge of #92526 - djc:rustdoc-askama, r=jsha
Migrate rustdoc from Tera to Askama

See #84419.

Should probably get a benchmarking run to verify if it has the intended effect on rustdoc performance.

cc `@jsha` `@jyn514.`
2022-01-13 00:29:34 +00:00
Camille GILLOT
441c1a6c50 Bless tests. 2022-01-12 23:41:28 +01:00
Camille GILLOT
2e0a80c8c0 Err about fn traits in a single place. 2022-01-12 23:13:52 +01:00
pierwill
68515cb668 Rename environment variable for overriding rustc version 2022-01-12 15:31:26 -06:00
Tomasz Miąsko
d4fb6ec683 Remove LLVM-style inline assembly from rustfmt 2022-01-12 21:43:35 +01:00
Michael Goulet
8568f44fe1 suggest deref/unboxing before wrapping variant 2022-01-12 12:01:01 -08:00
Richard Cobbe
0cf7fd1208 Call out to binutils' dlltool for raw-dylib on windows-gnu platforms. 2022-01-12 10:25:35 -08:00
Tomasz Miąsko
d60edea2bd Remove LLVM-style inline assembly from clippy 2022-01-12 18:51:32 +01:00
Tomasz Miąsko
064eda47f1 Migrate intrinsic-unreachable test to asm! 2022-01-12 18:51:32 +01:00
Tomasz Miąsko
02e6c64a04 Migrate inline assembly incremental tests to asm! 2022-01-12 18:51:32 +01:00
Tomasz Miąsko
cc20dd49de Migrate abi-sysv64 abi-sysv64-register-usage test to asm! 2022-01-12 18:51:32 +01:00
Tomasz Miąsko
0b315250b8 Use black_box intrinsic in out-of-stack test 2022-01-12 18:51:31 +01:00
Tomasz Miąsko
c7d591dc28 Remove pretty tests for LLVM-style inline assembly 2022-01-12 18:51:31 +01:00
Tomasz Miąsko
11d014d05a Remove codegen tests for LLLVM-style inline assembly 2022-01-12 18:51:31 +01:00
Tomasz Miąsko
47b1c16fcd Remove mir-opt tests for LLVM-style inline assembly 2022-01-12 18:51:31 +01:00
Tomasz Miąsko
61c233bac3 Remove ui tests for LLVM-style inline assembly 2022-01-12 18:51:31 +01:00
Tomasz Miąsko
a76577cb8a Remove LLVM-style inline assembly from unstable book 2022-01-12 18:51:31 +01:00
Michael Goulet
7bf0cb7671 Add new tests, fix up old tests 2022-01-12 08:28:41 -08:00
Matthias Krüger
05dd1e4a2b
Rollup merge of #92764 - GuillaumeGomez:fix-rust-logo-style, r=jsha
Fix rust logo style

The style on the rust logo is currently broken:

![Screenshot from 2022-01-11 13-36-30](https://user-images.githubusercontent.com/3050060/148946754-a1a57253-bed0-44cf-a41c-83e0eecbd6b5.png)

With this fix, we're back to normal:

![Screenshot from 2022-01-11 13-42-07](https://user-images.githubusercontent.com/3050060/148946778-99f44678-aac1-419f-bb8c-ffa837e0c1ee.png)

I also used a GUI test to prevent future silent regressions.

r? ```@jsha```
2022-01-12 07:12:19 +01:00
Matthias Krüger
8f002a0a83
Rollup merge of #92756 - lnicola:rust-analyzer-2022-01-11, r=lnicola
⬆️ rust-analyzer

r? ```@ghost```
2022-01-12 07:12:17 +01:00
Matthias Krüger
bc0a165240
Rollup merge of #92742 - GuillaumeGomez:missing-suffix-sidebar-items, r=notriddle
Add missing suffix for sidebar-items script path

Fixes https://github.com/rust-lang/docs.rs/issues/1590.

r? ```@syphar```
2022-01-12 07:12:15 +01:00
Matthias Krüger
eecdfe526f
Rollup merge of #92732 - wesleywiser:note_musl_patch_info, r=Mark-Simulacrum
Add note about upstream commit musl-patch-configure.diff is derived from

The patch landed in upstream over the weekend so I'm adding a note so we can more easily track when our patch file can be removed.
2022-01-12 07:12:14 +01:00
Matthias Krüger
cfb9306ef9
Rollup merge of #92707 - JohnScience:patch-1, r=GuillaumeGomez
Extended the note on the use of `no_run` attribute
2022-01-12 07:12:11 +01:00
Matthias Krüger
b24b0fdcd0
Rollup merge of #92699 - camelid:private-fields, r=jsha
rustdoc: Display "private fields" instead of "fields omitted"

Also:

  * Always use `/* */` block comments
  * Use the same message everywhere, rather than sometimes prefixing
    with "some"

When I first read rustdoc docs, I was confused why the fields were being
omitted. It was only later that I realized it was because they were
private. It's also always bothered me that rustdoc sometimes uses `//`
and sometimes uses `/*` comments for these messages, so this change
makes them all use `/*`.

Technically, I think fields can be omitted if they are public but
`doc(hidden)` too, but `doc(hidden)` is analogous to privacy. It's
really just used to emulate "doc privacy" when -- because of technical
limitations -- an item has to be public. So I think it's fine to include
this under the category of "private fields".

r? ```@jsha```
2022-01-12 07:12:09 +01:00
Matthias Krüger
6726f1e013
Rollup merge of #92432 - fee1-dead:constck-impl-constness, r=oli-obk
Error when selected impl is not const in constck

Catches bad things when checking a `default_method_body_is_const` body, such as:

```rust
self.map(/* .. */).is_sorted();
```

When `Map` does not yet have a `const` `impl` for `Iterator`.

r? ```@oli-obk```
2022-01-12 07:12:06 +01:00
Michael Goulet
40f33a7a4c Deduplicate box deref and regular deref suggestions 2022-01-11 21:13:45 -08:00
Eric Huss
66f1e322c6 Update cargo 2022-01-11 20:18:29 -08:00
Noah Lev
c84f2b27d3 Remove some unnecessary uses of FieldDef::ident 2022-01-11 17:03:45 -08:00
Andy Russell
4193f2da2d
rustdoc: do not emit tuple variant fields if none are documented 2022-01-11 16:44:03 -05:00
Mahdi Dibaiee
2728af7bc0
rustc_pass_by_value: handle inferred generic types (with _) 2022-01-11 21:28:04 +00:00
bors
72e74d7b9c Auto merge of #92533 - Aaron1011:variant-symbol, r=petrochenkov
Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`

The field is also renamed from `ident` to `name`. In most cases,
we don't actually need the `Span`. A new `ident` method is added
to `VariantDef` and `FieldDef`, which constructs the full `Ident`
using `tcx.def_ident_span()`. This method is used in the cases
where we actually need an `Ident`.

This makes incremental compilation properly track changes
to the `Span`, without all of the invalidations caused by storing
a `Span` directly via an `Ident`.
2022-01-11 21:02:01 +00:00
Fabian Wolff
bd1f09d417 Annotate dead code lint with notes about ignored derived impls 2022-01-11 21:06:18 +01:00
Mahdi Dibaiee
959bf2bc2e
rustc_pass_by_value: handle generic and const type parameters 2022-01-11 19:59:06 +00:00
bors
1409c015b4 Auto merge of #90948 - oli-obk:🧹, r=nikomatsakis
Actually instantiate the opaque type when checking bounds

Before this change, `instantiate_opaque_types` was a no-op, because it only works relative to the defined opaque type inference anchor. If it is a no-op, the for loop will not actually have anything to iterate over, and thus nothing is checked at all.
2022-01-11 17:31:07 +00:00
Deadbeef
bf5130b502
Add test 2022-01-11 23:52:24 +08:00
Arlo Siemsen
b03fc76dcc Use the new language identifier for Rust in the PDB debug format
Rust currently identifies as MASM (Microsoft Assembler) in the PDB
debug info format on Windows because no identifier was available.

This change pulls in a cherry-pick to Rust's LLVM that includes the
change to use the new identifier for Rust.

https://docs.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang
2022-01-11 07:41:27 -08:00
Aaron Hill
450ef8613c
Store a Symbol instead of an Ident in VariantDef/FieldDef
The field is also renamed from `ident` to `name. In most cases,
we don't actually need the `Span`. A new `ident` method is added
to `VariantDef` and `FieldDef`, which constructs the full `Ident`
using `tcx.def_ident_span()`. This method is used in the cases
where we actually need an `Ident`.

This makes incremental compilation properly track changes
to the `Span`, without all of the invalidations caused by storing
a `Span` directly via an `Ident`.
2022-01-11 10:16:22 -05:00
Guillaume Gomez
24c6e963d0 Add GUI test for rust logo style in the sidebars 2022-01-11 13:57:17 +01:00
Guillaume Gomez
9234c0fd52 Fix style for rust logo 2022-01-11 13:42:20 +01:00
Mahdi Dibaiee
a6762e962e
rustc_pass_by_value: allow types with no parameters on self
includes minor refactorings
2022-01-11 09:28:13 +00:00
Laurențiu Nicola
22d4e97d6d ⬆️ rust-analyzer 2022-01-11 07:20:40 +02:00
Noah Lev
28d2353f3b Update some comments post the side channel removal 2022-01-10 19:23:26 -08:00
Noah Lev
895fa9cd5c Extract functions for two closures
These closures were quite complex and part of a quite complex function.
The fact that they are closures makes mistakes likely when refactoring.
For example, earlier, I meant to use `resolved`, an argument of the
closure, but I instead typed `res`, which captured a local variable and
caused a subtle bug that led to a confusing test failure.

Extracting them as functions makes the code easier to understand and
refactor.
2022-01-10 19:23:26 -08:00
Noah Lev
a5f09f74d6 Update comment and make code clearer
I'm still not sure why this hack works so seemingly well.
2022-01-10 19:23:26 -08:00
Noah Lev
591ec49df3 Remove unnecessary conditional for suggesting disambiguator
Now that `res` is used directly, it seems the conditional is
unnecessary.
2022-01-10 19:23:26 -08:00
Noah Lev
9acd813380 Use Res instead of Disambiguator for resolved in report_mismatch
This allows simplifying a lot of code. It also fixes a subtle bug,
exemplified by the test output changes.
2022-01-10 19:23:26 -08:00
Noah Lev
977a7ca2e4 Add test for disambiguator mismatch with crate
This currently calls `std` a "crate" in one part of the message and a
"module" in another part. The next commits fix this so it says "crate"
in both places.
2022-01-10 19:23:26 -08:00
Noah Lev
ca20d64fb7 Enable ignored part of test
Inherent associated types *are* supported, just unstable.
2022-01-10 19:23:26 -08:00
Noah Lev
e18b23b7f4 Move two intra-doc-link tests into the intra-doc folder 2022-01-10 19:23:26 -08:00
Noah Lev
49553bbc98 Remove hack that is no longer necessary
This hack was added in 6ab1f05697.
I don't know what change allowed removing the hack, but that commit
added a test (which I presume covered the hack's behavior), and all
tests are passing with this change. So, I think it should be good.
2022-01-10 19:23:25 -08:00
Maybe Waffle
4ccfa97021 Add a test for ungated #[rustc_must_implement_one_of]
This test checks that `#[rustc_must_implement_one_of]` is gated behind
`#![feature(rustc_attrs)]`.
2022-01-11 03:39:43 +03:00
bors
1f213d983d Auto merge of #92601 - camelid:more-intra-doc-cleanup, r=Manishearth
rustdoc: Remove the intra-doc links side channel

The side channel made the code much more complex and harder to
understand. It was added as a temporary workaround in
0c99d806ea, but it's no longer necessary.

The addition of `UrlFragment` in #92088 was the key to getting rid of
the side channel. The semantic information (rather than the strings that
used to be used for fragments) that is now captured by `UrlFragment` is
enough to obviate the side channel. An additional change had to be made
to `UrlFragment` in this PR to make this possible: it now records
`DefId`s rather than item names.

This PR also consolidates the checks for anchor conflicts into one place.

r? `@Manishearth`
2022-01-11 00:08:23 +00:00
Guillaume Gomez
881b427fa3 Add missing suffix for sidebar-items script path 2022-01-10 21:01:09 +01:00
Josh Stone
f3b8812f24 Update rayon and rustc-rayon 2022-01-10 11:34:07 -08:00
Mahdi Dibaiee
71e3314673
rustc_pass_by_value remove dependency on rustc_diagnostic_item 2022-01-10 18:16:13 +00:00
Mahdi Dibaiee
91ed6892f7
rustc_pass_by_value lint: add test on custom types 2022-01-10 17:42:20 +00:00
Dirkjan Ochtman
ef96d573bf Remove configuration which became unused in 8abb4bb698 2022-01-10 18:40:57 +01:00
Dirkjan Ochtman
b00d6668b7 Address feedback 2022-01-10 18:40:57 +01:00
Dirkjan Ochtman
93a16cb7e2 Migrate rustdoc from Tera to Askama
See #84419.
2022-01-10 18:40:54 +01:00
Wesley Wiser
55abf38bf2 Add note about upstream commit musl-patch-configure.diff is derived from 2022-01-10 10:41:31 -05:00
Wesley Wiser
e9cac4ca62 Ignore unused_mod.rs file in code coverage results
As discussed in
https://github.com/rust-lang/rust/pull/92142#issuecomment-1008239473,
tests that contain multiple files order their results differently on
Windows and Linux which the test runner currently can't handle
correctly. For now, ignore the "bin" part of the test and only include
the unused library dependency which is what the test really cares about
anyway.
2022-01-10 10:31:22 -05:00
bors
89b9f7b284 Auto merge of #92719 - matthiaskrgr:rollup-tc7oqys, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92248 (Normalize struct tail type when checking Pointee trait)
 - #92357 (Fix invalid removal of newlines from doc comments)
 - #92602 (Make source links look cleaner)
 - #92636 (Normalize generator-local types with unevaluated constants)
 - #92693 (Release notes: add `Result::unwrap_{,err_}unchecked`)
 - #92702 (Clean up lang_items::extract)
 - #92717 (update miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-10 11:53:15 +00:00
Vadim Petrochenkov
e87ce7ad74 expand: Pick cfgs and cfg_attrs one by one, like other attributes 2022-01-10 18:11:44 +08:00
Matthias Krüger
3d5db0e6b4
Rollup merge of #92717 - RalfJung:miri, r=RalfJung
update miri

Fixes https://github.com/rust-lang/rust/issues/92691
r? `@ghost`
2022-01-10 11:03:12 +01:00
Matthias Krüger
ca9fc28f0b
Rollup merge of #92636 - compiler-errors:normalize-generator-const-expr, r=oli-obk
Normalize generator-local types with unevaluated constants

Normalize generator-interior types in addition to (i.e. instead of just) erasing regions, since sometimes we collect types with unevaluated const exprs.

Fixes #84737
Fixes #88171
Fixes #92091
Fixes #92634
Probably also fixes #73114, but that one has no code I could test. It looks like it's the same issue, though.
2022-01-10 11:03:07 +01:00
Matthias Krüger
a4ac4fae41
Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomez
Make source links look cleaner

Change from syntaxy-looking [src] to the plain word "source".

Change the syntaxy-looking `[-]` at the top of the page to say "collapse".

Reduce opacity of rightside content.

Part of #59851

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/source-link-2/std/string/struct.String.html

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/display.20of.20source.20link).
2022-01-10 11:03:06 +01:00
Matthias Krüger
d20affbf8d
Rollup merge of #92357 - GuillaumeGomez:fix-doc-comment-backline-removal, r=camelid
Fix invalid removal of newlines from doc comments

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

Before:

![Screenshot from 2021-12-28 17-02-11](https://user-images.githubusercontent.com/3050060/147585187-c8e67531-c1b4-457d-9d30-d5b44bf91fea.png)

After:

![Screenshot from 2021-12-28 17-02-25](https://user-images.githubusercontent.com/3050060/147585190-30aa0398-1fc7-4fe7-9e8b-5c475d4f9613.png)

r? `@camelid`
2022-01-10 11:03:05 +01:00
Matthias Krüger
6466f89fc5
Rollup merge of #92248 - compiler-errors:normalize-type-for-pointee, r=jackh726
Normalize struct tail type when checking Pointee trait

Let's go ahead and implement the FIXMEs by properly normalizing the struct-tail type when satisfying a Pointee obligation. This should fix the ICE when we try to calculate a layout depending on `<Ty as Pointee>::Metadata` later.
Fixes #92128
Fixes #92577

Additionally, mark the obligation as ambiguous if there are any infer types in that struct-tail type. This has the effect of causing `<_ as Pointee>::Metadata` to be properly replaced with an infer variable ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/traits/project.rs#L813)) and registered as an obligation... this turns out to be very important in unifying function parameters with formals that are assoc types.

Fixes #91446
2022-01-10 11:03:03 +01:00
Ralf Jung
c8ff80477e miri 2022-01-10 10:27:34 +01:00
Jack Huey
ad57295fc9 Elaborate param_env predicates when checking if type outlives involving projection holds 2022-01-10 00:29:06 -05:00
Dmitrii - Demenev
8fd8db5c29
Extended the note on the use of no_run attribute 2022-01-09 19:17:15 -05:00
Lamb
3a77bb86ff Compute most of Public/Exported access level in rustc_resolve
Mak DefId to AccessLevel map in resolve for export

hir_id to accesslevel in resolve and applied in privacy
using local def id
removing tracing probes
making function not recursive and adding comments

Move most of Exported/Public res to rustc_resolve

moving public/export res to resolve

fix missing stability attributes in core, std and alloc

move code to access_levels.rs

return for some kinds instead of going through them

Export correctness, macro changes, comments

add comment for import binding

add comment for import binding

renmae to access level visitor, remove comments, move fn as closure, remove new_key

fmt

fix rebase

fix rebase

fmt

fmt

fix: move macro def to rustc_resolve

fix: reachable AccessLevel for enum variants

fmt

fix: missing stability attributes for other architectures

allow unreachable pub in rustfmt

fix: missing impl access level + renaming export to reexport

Missing impl access level was found thanks to a test in clippy
2022-01-09 21:33:14 +00:00
Eric Huss
b59e743666 Mark windows_subsytem and no_builtins as crate-only attributes.
These attributes are only checked at the crate root, so they should
have a warning if they are used anywhere else.
2022-01-09 13:08:30 -08:00
Noah Lev
2b70a3df7a Display "private fields" instead of "fields omitted"
Also:

  * Always use `/* */` block comments
  * Use the same message everywhere, rather than sometimes prefixing
    with "some"

When I first read rustdoc docs, I was confused why the fields were being
omitted. It was only later that I realized it was because they were
private. It's also always bothered me that rustdoc sometimes uses `//`
and sometimes uses `/*` comments for these messages, so this change
makes them all use `/*`.

Technically, I think fields can be omitted if they are public but
`doc(hidden)` too, but `doc(hidden)` is analogous to privacy. It's
really just used to emulate "doc privacy" when -- because of technical
limitations -- an item has to be public. So I think it's fine to include
this under the category of "private fields".
2022-01-09 12:48:28 -08:00
Eric Huss
59d4bae018 Add validation for link attribute position. 2022-01-09 11:28:40 -08:00
bors
092e1c9d23 Auto merge of #92534 - Aaron1011:hash-hir, r=petrochenkov
Hash `Ident` spans in all HIR structures

This PR removes all of the `#[stable_hasher(project(name))]`
attributes used in HIR structs. While these attributes are not known
to be causing any issues in practice, we need to hash these in
order for the incremental system to work correctly -
a query could be otherwise be incorrectly marked green
when a change occures in one of the `Span`s that it uses.
2022-01-09 16:03:41 +00:00
Mahdi Dibaiee
4c3e330a8c
feat: pass_by_value lint attribute
Useful for thin wrapper attributes that are best passed as value instead
of reference.
2022-01-09 13:05:51 +00:00
bors
f7bb8e3677 Auto merge of #92690 - matthiaskrgr:rollup-rw0oz05, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #92055 (Add release notes for 1.58)
 - #92490 (Move crate drop-down to search results page)
 - #92510 (Don't resolve blocks in foreign functions)
 - #92573 (expand: Refactor InvocationCollector visitor for better code reuse)
 - #92608 (rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes)
 - #92657 (Implemented const casts of raw pointers)
 - #92671 (Make `Atomic*::from_mut` return `&mut Atomic*`)
 - #92673 (Remove useless collapse toggle on "all items" page)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-09 12:43:37 +00:00
Matthias Krüger
e6aa48d3a7
Rollup merge of #92673 - GuillaumeGomez:remove-all-items-toggle, r=jsha
Remove useless collapse toggle on "all items" page

When clicking on this toggle, nothing happens because there is nothing to collapse. Instead of keeping it around, let's just remove it.

Before:

![Screenshot from 2022-01-08 16-02-38](https://user-images.githubusercontent.com/3050060/148649149-821a1e77-8c34-4975-b50a-984ca8865518.png)

After:

![Screenshot from 2022-01-08 16-02-32](https://user-images.githubusercontent.com/3050060/148649154-b5912a97-9229-46bd-be3c-df3c3fa3ac8f.png)

r? `@jsha`
2022-01-09 13:38:34 +01:00
Matthias Krüger
51001b35bd
Rollup merge of #92608 - petrochenkov:doctrscope3, r=CraftSpider
rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes

The refactoring parts of https://github.com/rust-lang/rust/pull/88679, shouldn't cause any slowdowns.
r? `@jyn514`
2022-01-09 13:38:32 +01:00
Matthias Krüger
464a0813d1
Rollup merge of #92510 - inquisitivecrystal:foreign-block, r=cjgillot
Don't resolve blocks in foreign functions

Although it is an error for a foreign function to have a block, it is still possible at the level of the AST. #74204 made AST lowering skip over blocks belonging to foreign functions, since they're invalid. However, resolve still treated these blocks normally, resulting in a mismatch between the HIR and resolve, which could cause an ICE under certain circumstances. This PR changes resolve to skip over blocks belonging to foreign functions, as AST lowering does.

Fixes #91370.

r? ``@cjgillot``
2022-01-09 13:38:30 +01:00
Matthias Krüger
598364c995
Rollup merge of #92490 - jsha:crates-in-results, r=GuillaumeGomez
Move crate drop-down to search results page

This reduces clutter on doc pages.

Part of #59840

r? ```@GuillaumeGomez```

Demo: https://rustdoc.crud.net/jsha/crates-in-results/std/index.html?search=str
2022-01-09 13:38:29 +01:00
Waffle Maybe
96b2f8ac32 Apply suggestions from code review
Use "(associated) function" terminology instead of "method".

Co-authored-by: Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>
2022-01-09 12:21:33 +03:00
Maybe Waffle
268ae9a232 Move #[rustc_must_implement_one_of] tests to fix tidy check 2022-01-09 12:21:33 +03:00
Maybe Waffle
e6bc0ac6f3 Add test for misused #[rustc_must_implement_one_of] 2022-01-09 12:21:33 +03:00
Maybe Waffle
5ab40c8f99 Implement #[rustc_must_implement_one_of] attribute 2022-01-09 12:21:23 +03:00
Vadim Petrochenkov
4b03fd910c rustc_middle: Rename Export to ModChild and add some comments
Also rename `module_exports`/`export_map` to `module_reexports`/`reexport_map` for clarity.
2022-01-09 09:22:07 +08:00
Vadim Petrochenkov
3051f6e9c4 rustc_metadata: Rename item_children(_untracked) to module_children(_untracked)
And `each_child_of_item` to `for_each_module_child`
2022-01-09 09:22:06 +08:00
Vadim Petrochenkov
96c6a50e96 rustc_metadata: Optimize and document module children decoding 2022-01-09 09:22:04 +08:00
bors
23ce5fc465 Auto merge of #92068 - fee1-dead:libcore2021, r=m-ou-se
Switch all libraries to the 2021 edition

The fix for https://github.com/rust-lang/rust/issues/88638#issuecomment-996620107 is to simply add const-stability for these functions.

r? `@m-ou-se`

Closes #88638.
2022-01-08 21:41:48 +00:00
Camille GILLOT
1be6e2d6e9 Link impl items to corresponding trait items in late resolver. 2022-01-08 20:45:59 +01:00
bors
488acf86a7 Auto merge of #90639 - matthewjasper:leaf-def-cache, r=cjgillot
Add a query for resolving an impl item from the trait item

This makes finding the item in an impl that implements a given trait item a query. This is for a few reasons:

- To slightly improve performance
- To avoid having to do name resolution during monomorphisation
- To make it easier to implement potential future features that create anonymous associated items
2022-01-08 15:20:33 +00:00
Guillaume Gomez
45a43debb6 Remove useless collapse toggle on "all items" page 2022-01-08 16:03:44 +01:00
Jacob Hoffman-Andrews
962c0a4ee5 Make source links look cleaner
Change from syntaxy-looking [src] to the plain word "source".
2022-01-08 09:49:41 -05:00
bors
66f64a441a Auto merge of #92639 - pietroalbini:bump-version, r=pietroalbini
Bump version to 1.60.0

Part of the release process, cc `@rust-lang/release`

r? `@ghost`
2022-01-08 12:06:40 +00:00
bors
02822334e9 Auto merge of #91305 - camelid:rm-cond, r=GuillaumeGomez
rustdoc: Remove apparently unnecessary conditional in `doc_value`

I need to remove this conditional for #91072, but while it seems
unnecessary, we are not certain. So, the plan is to first remove the
conditional and see if any regressions pop up before doing the refactor.
This way, it will be easier to revert if there are subtle regressions.

r? `@jyn514`
2022-01-08 08:55:46 +00:00
Lain Yang
cf36c21b28 tidy: add ahash to permitted dep list 2022-01-08 16:27:58 +08:00
Eric Huss
759b13eb6c
Rollup merge of #92610 - GuillaumeGomez:css-class-instead-of-inline-style, r=jsha
Create CSS class instead of using inline style for search results

I saw this change in the update you proposed in https://github.com/rust-lang/rust/pull/92404. :)

r? ``@jsha``
2022-01-07 20:21:01 -08:00
Vadim Petrochenkov
333a5cc369 mangling_v0: Skip extern blocks during mangling 2022-01-08 11:53:13 +08:00
Vadim Petrochenkov
1b8daf8c58 mangling_v0: Add a test for mangling of foreign types 2022-01-08 11:39:34 +08:00
Vadim Petrochenkov
6a1f9e6fc7 mangling_v0: Update tests for the rust-demangler tool 2022-01-08 11:39:34 +08:00
Badel2
8ef3ce866e Change panic::update_hook to simplify usage
And to remove possibility of panics while changing the panic handler,
because that resulted in a double panic.
2022-01-08 00:57:59 +01:00
Gary Guo
c84cea9c25 Flatten InferredCaptureInformation
Min capture computation can already handle the same place appearing twice,
and previous commits made CaptureInfo construction very cheap, so just
delegate all work to min capture and let InferBorrowKind and
process_collected_capture_information handle everything linearly.
2022-01-07 22:55:36 +00:00
Gary Guo
48258ffe5a Remove region from UpvarCapture and move it to CapturedPlace
Region info is completely unnecessary for upvar capture kind computation
and is only needed to create the final upvar tuple ty. Doing so makes
creation of UpvarCapture very cheap and expose further cleanup opportunity.
2022-01-07 22:55:34 +00:00
Gary Guo
3698e03fb6 Remove span from UpvarCapture::ByValue
This span is unused and is superseded by capture_kind_expr_id in CaptureInfo
2022-01-07 22:54:28 +00:00
Matthew Jasper
9e5f23e2a6 Update clippy for associated item changes 2022-01-07 13:31:46 -08:00
Badel2
8bdf5c3de6 Implement panic::update_hook 2022-01-07 17:28:20 +01:00
Pietro Albini
18d1551f3b
bump version to 1.60.0 2022-01-07 10:04:15 +01:00
Vadim Petrochenkov
5acd1f91a0 rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes 2022-01-07 16:21:53 +08:00
Michael Goulet
d35b23ecd8 Normalize generator-local types with unevaluated constants 2022-01-06 19:08:04 -08:00
Matthias Krüger
0c9cf9a9ea
Rollup merge of #92589 - ChrisDenton:break-loop, r=Mark-Simulacrum
Break the loop

A missing break statement lead to an infinite loop in bootstrap.py.

I also added a short sleep so it's not constantly running at 100%. But I can remove that if it's not wanted.

Fixes #76661
2022-01-06 23:15:20 +01:00
Matthias Krüger
1a8f69826c
Rollup merge of #92417 - dtolnay:printimpl, r=jackh726
Fix spacing and ordering of words in pretty printed Impl

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{}", repro!(impl<T> Struct<T> {}));
    println!("{}", repro!(impl<T> const Trait for T {}));
}
```

Before:&ensp;`impl <T> Struct<T> {}`
After:&ensp;`impl<T> Struct<T> {}`

Before:&ensp;`impl const <T> Trait for T {}` 😿
After:&ensp;`impl<T> const Trait for T {}`
2022-01-06 23:15:16 +01:00
Matthias Krüger
0604cf5fd8
Rollup merge of #92207 - tmiasko:delay-drop-elaboration-bug, r=jackh726
Delay remaining `span_bug`s in drop elaboration

This follows changes from #67967 and converts remaining `span_bug`s into
delayed bugs, since for const items drop elaboration might be executed
on a MIR which failed borrowck.

Fixes #81708.
Fixes #91816.
2022-01-06 23:15:14 +01:00
Noah Lev
a626da4e78 Split out ItemFragment from UrlFragment
This allows eliminating branches in the code where a user-written
fragment is impossible.
2022-01-06 12:49:53 -08:00
Noah Lev
a69e15c501 Remove the side channel
Hooray! It was no longer used, so it can just be deleted.
2022-01-06 12:49:29 -08:00
Noah Lev
54a14e844c Remove the last use of the side channel 2022-01-06 11:48:47 -08:00
Noah Lev
fde94538bf Use fragment instead of side channel in another place 2022-01-06 11:48:47 -08:00
Noah Lev
1064003f8c Use fragment instead of side channel for prim. assoc. items
I had the epiphany that now that fragments are "semantic" -- rather than
just strings -- they fill the role that used to be handled by the side
channel. I think I may be able to get rid of the other uses of the side
channel using this technique too.
2022-01-06 11:48:47 -08:00
Noah Lev
7e3132adb3 Extract function for reporting feature gate error 2022-01-06 11:48:47 -08:00
Noah Lev
a324fc19d4 Only check for conflicting anchors in one place
This coalesces the checks into one place.
2022-01-06 11:48:47 -08:00
Noah Lev
3b50a4e286 Use DefIds instead of names in UrlFragment
This is the next step in computing more "semantic" information during
intra-doc link collection and then doing rendering all at the end.
2022-01-06 11:48:46 -08:00
Noah Lev
f89e2dd935 Move anchor conflict check to call site
I think it makes the code easier to understand.
2022-01-06 11:40:36 -08:00
bors
cfa4ac66c1 Auto merge of #92609 - matthiaskrgr:rollup-ldp47ot, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92058 (Make Run button visible on hover)
 - #92288 (Fix a pair of mistyped test cases in `std::net::ip`)
 - #92349 (Fix rustdoc::private_doc_tests lint for public re-exported items)
 - #92360 (Some cleanups around check_argument_types)
 - #92389 (Regression test for borrowck ICE #92015)
 - #92404 (Fix font size for [src] links in headers)
 - #92443 (Rustdoc: resolve associated traits for non-generic primitive types)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-06 15:30:46 +00:00
Guillaume Gomez
26edfc9e31 Create CSS class instead of using inline style for search results 2022-01-06 15:12:01 +01:00
Matthias Krüger
26a90e4cd7
Rollup merge of #92443 - mdibaiee:90703/resolve-traits-of-primitive-types, r=Manishearth
Rustdoc: resolve associated traits for non-generic primitive types

Fixes #90703

This seems to work:
<img width="457" alt="image" src="https://user-images.githubusercontent.com/2807772/147774059-9556ff96-4519-409e-8ed0-c33ecc436171.png">

I'm just afraid I might have missed some cases / broken previous functionality.

I also have not written tests yet, I will have to take a look to see where tests are and how they are structured, but any help there is also appreciated.
2022-01-06 12:01:05 +01:00
Matthias Krüger
b510278278
Rollup merge of #92404 - GuillaumeGomez:src-font-size, r=jsha
Fix font size for [src] links in headers

Fixes #90384.

cc `@jsha`
r? `@camelid`
2022-01-06 12:01:04 +01:00
Matthias Krüger
96a267ee1f
Rollup merge of #92389 - chordtoll:test-92015, r=Mark-Simulacrum
Regression test for borrowck ICE #92015

This issue has come up a few times. Creating a regression test.
Closes #92015.
2022-01-06 12:01:03 +01:00
Matthias Krüger
fb87e7ceed
Rollup merge of #92360 - jackh726:param-heuristics-1, r=davidtwco
Some cleanups around check_argument_types

Split out in ways from my rebase/continuation of #71827

Commits are mostly self-explanatory and these changes should be fairly straightforward
2022-01-06 12:01:02 +01:00
Matthias Krüger
4d0b567efb
Rollup merge of #92349 - avitex:fix-rustdoc-private-doc-tests, r=GuillaumeGomez
Fix rustdoc::private_doc_tests lint for public re-exported items

Closes #72081

This involves changing the lint to check the access level is exported, rather than public.
The [exported access level](e91ad5fc62/compiler/rustc_middle/src/middle/privacy.rs (L24)) accounts for public items and items accessible to other crates with the help of `pub use` re-exports.
The pattern of re-exporting public items from a private module is usage seen in a number of popular crates.
2022-01-06 12:01:01 +01:00
Matthias Krüger
50d5e38800
Rollup merge of #92058 - jsha:run-on-hover, r=GuillaumeGomez
Make Run button visible on hover

This slightly reduces the noisiness of doc pages, making them easier to read.

Demo: https://rustdoc.crud.net/jsha/run-on-hover/std/string/struct.String.html

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.22Run.22.20button.20visible.20on.20hover).

Part of #59845
2022-01-06 12:00:59 +01:00
David Wood
7ecdc89436 Revert "bootstrap: copy llvm-dwp to sysroot"
This reverts commit 241160de72.
2022-01-06 09:32:42 +00:00
David Wood
2dc1a8a779 cg: use thorin instead of llvm-dwp
`thorin` is a Rust implementation of a DWARF packaging utility that
supports reading DWARF objects from archive files (i.e. rlibs) and
therefore is better suited for integration into rustc.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-01-06 09:32:42 +00:00
David Wood
08ed338f56 sess/cg: re-introduce split dwarf kind
In #79570, `-Z split-dwarf-kind={none,single,split}` was replaced by `-C
split-debuginfo={off,packed,unpacked}`. `-C split-debuginfo`'s packed
and unpacked aren't exact parallels to single and split, respectively.

On Unix, `-C split-debuginfo=packed` will put debuginfo into object
files and package debuginfo into a DWARF package file (`.dwp`) and
`-C split-debuginfo=unpacked` will put debuginfo into dwarf object files
and won't package it.

In the initial implementation of Split DWARF, split mode wrote sections
which did not require relocation into a DWARF object (`.dwo`) file which
was ignored by the linker and then packaged those DWARF objects into
DWARF packages (`.dwp`). In single mode, sections which did not require
relocation were written into object files but ignored by the linker and
were not packaged. However, both split and single modes could be
packaged or not, the primary difference in behaviour was where the
debuginfo sections that did not require link-time relocation were
written (in a DWARF object or the object file).

This commit re-introduces a `-Z split-dwarf-kind` flag, which can be
used to pick between split and single modes when `-C split-debuginfo` is
used to enable Split DWARF (either packed or unpacked).

Signed-off-by: David Wood <david.wood@huawei.com>
2022-01-06 09:32:42 +00:00
inquisitivecrystal
42de973099 Add regression test 2022-01-05 15:22:22 -08:00
Guillaume Gomez
3b70c6e4bd Simplify :target CSS selector 2022-01-05 21:28:19 +01:00
Chris Denton
014f22abaf
Break the loop
A missing break statement lead to an infinite loop in bootstrap.py.
2022-01-05 17:59:13 +00:00
Jacob Hoffman-Andrews
8abb4bb698 Move crate drop-down to search results page
This reduces clutter on doc pages.
2022-01-05 12:57:25 -05:00
Jacob Hoffman-Andrews
f3fe91278c Switch to es6 for eslint
Also update Node to v16.9.0, es-check to 6.1.1, and eslint to 8.6.0.
2022-01-05 11:44:29 -05:00
Guillaume Gomez
a0085f249a Add test for [src] font-size in headers 2022-01-05 17:35:06 +01:00
Guillaume Gomez
270d09dca9 Fix font size for [src] links in headers 2022-01-05 17:35:04 +01:00
bors
f1ce0e6a00 Auto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92092 (Drop guards in slice sorting derive src pointers from &mut T, which is invalidated by interior mutation in comparison)
 - #92388 (Fix a minor mistake in `String::try_reserve_exact` examples)
 - #92442 (Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`)
 - #92483 (Stabilize `result_cloned` and `result_copied`)
 - #92574 (Add RISC-V detection macro and more architecture instructions)
 - #92575 (ast: Always keep a `NodeId` in `ast::Crate`)
 - #92583 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-05 15:28:36 +00:00
Jacob Hoffman-Andrews
6409f0d558 Make Run button visible on hover
This slightly reduces the noisiness of doc pages, making them easier to
read.
2022-01-05 10:07:22 -05:00
Matthias Krüger
439a1254b9
Rollup merge of #92583 - lnicola:rust-analyzer-2022-01-05, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2022-01-05 15:05:50 +01:00
Matthias Krüger
5f03ae3507
Rollup merge of #92575 - petrochenkov:cratenodeid, r=Aaron1011
ast: Always keep a `NodeId` in `ast::Crate`

This makes it more uniform with other expanded nodes.
It makes generic code in https://github.com/rust-lang/rust/pull/92573 simpler in particular.

This is another follow-up to https://github.com/rust-lang/rust/pull/91313.
r? `@Aaron1011`
2022-01-05 15:05:49 +01:00
bors
181e91567c Auto merge of #92580 - matthiaskrgr:rollup-nzyn65y, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92182 (Label more build steps)
 - #92188 (rustdoc: Clean up NestedAttributesExt trait/implementation)
 - #92322 (Add another implementation example to Debug trait)
 - #92448 (Set font size proportional to user's font size)
 - #92517 (Explicitly pass `PATH` to the Windows exe resolver)
 - #92545 (Extract init_env_logger to crate)
 - #92579 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-05 12:32:28 +00:00
Laurențiu Nicola
2687a93bc8 ⬆️ rust-analyzer 2022-01-05 13:43:32 +02:00
Matthias Krüger
a0673468ae
Rollup merge of #92579 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/92527
2022-01-05 11:26:09 +01:00
Matthias Krüger
5bf321f9a4
Rollup merge of #92448 - jsha:font-size-access, r=GuillaumeGomez
Set font size proportional to user's font size

According to MDN (https://developer.mozilla.org/en-US/docs/Web/CSS/font-size),

> To maximize accessibility, it is generally best to use values that are relative to the user's default font size.

> Defining font sizes in px is not accessible, because the user cannot change the font size in some browsers.

Note that changing font size (in browser or OS settings) is distinct from the zoom functionality triggered with Ctrl/Cmd-+. Zoom
functionality increases the size of everything on the page, effectively applying a multiplier to all pixel sizes. Font size changes apply to just text.

For relative font sizes, we could use `em`, as we do in several places already. However that has a problem of "compounding" (see MDN article for details). The compounding problem is nicely solved by `rem`, which make font sizes relative to the root element, not the parent element.

Since we were using a hodge-podge of pixel sizes, em, rem, and percentage sizes before, this change switches everything to rem, while keeping the same size relative to our old default of 16px.

16px is still the default on most browsers, for users that haven't set a larger or smaller font size.

Part of #59845. Note: this will conflict with #92404. We should merge that first (once it's done) and I'll resolve the merge conflicts.

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/font-size-access/std/string/struct.String.html
2022-01-05 11:26:06 +01:00
Matthias Krüger
cc01433d56
Rollup merge of #92188 - vacuus:nested-attributes-ext, r=jyn514
rustdoc: Clean up NestedAttributesExt trait/implementation
2022-01-05 11:26:04 +01:00
Matthias Krüger
e35a4bd8d0
Rollup merge of #92182 - nnethercote:label-more-build-steps, r=Mark-Simulacrum
Label more build steps

Some small improvements.

r? ```@Mark-Simulacrum```
2022-01-05 11:26:03 +01:00
Ralf Jung
e568423815 update Miri 2022-01-05 10:41:22 +01:00
bors
936ce3dab7 Auto merge of #92103 - Kobzol:stable-hash-skip-zero-bytes, r=the8472
Do not hash leading zero bytes of i64 numbers in Sip128 hasher

I was poking into the stable hasher, trying to improve its performance by compressing the number of hashed bytes. First I was experimenting with LEB128, but it was painful to implement because of the many assumptions that the SipHasher makes, so I tried something simpler - just ignoring leading zero bytes. For example, if an 8-byte integer can fit into a 4-byte integer, I will just hash the four bytes.

I wonder if this could produce any hashing ambiguity. Originally I thought so, but then I struggled to find any counter-example where this could cause different values to have the same hash. I'd be glad for any examples that could be broken by this (there are some ways of mitigating it if that would be the case). It could happen if you had e.g. 2x `u8` vs 1x `u16` hashed after one another in two different runs, but that can also happen now, without this "trick". And with collections, it should be fine, because the length is included in their hash.

I gathered some statistics for common values used in the `clap` benchmark. I observed that especially `i64` often had very low values, so I started with that type, let's see what perf does on CI.

There are some tradeoffs that we can try:
1) What types to use this optimization for? `u64`, `u32`, `u16`? Locally it was a slight loss for `u64`, I noticed that its values are often quite large.
2) What byte sizes to check? E.g. we can only distinguish between `u64`/`u32` or `u64`/`u8` instead of `u64`/`u32`/`u16`/`u8` to reduce branching (with `i64` it seemed to be better to go all the way down to `u8` locally though).

(The macro was introduced because I expect that I will be trying out this "trick" for different types).

Can you please schedule a perf. run? Thanks.

r? `@the8472`
2022-01-05 09:27:18 +00:00
Vadim Petrochenkov
55595c5616 ast: Always keep a NodeId in ast::Crate
This makes it more uniform with other expanded nodes
2022-01-05 17:09:37 +08:00
Mahdi Dibaiee
973cf632d3
Remove unsupported types in primitive_to_ty conversion, add FIXME note 2022-01-05 08:04:42 +00:00
Mahdi Dibaiee
19419f3771
add a test case for each supported primitive type 2022-01-05 08:04:40 +00:00
Mahdi Dibaiee
83487b8f27
Rustdoc: resolve associated traits for primitive types
Fixes #90703
2022-01-05 08:03:55 +00:00
bors
b03c504742 Auto merge of #92498 - camelid:ignore-flaky-test, r=Mark-Simulacrum
Ignore flaky `panic-short-backtrace-windows-x86_64.rs` test for now

Mitigates (but does not fix) #92000.

It has been causing a lot of spurious test failures recently that slow
down the bors queue.
2022-01-05 06:18:57 +00:00
Noah Lev
0286ae400e Ignore flaky panic-short-backtrace-windows-x86_64.rs test for now
It has been causing a lot of spurious test failures recently that slow
down the bors queue.
2022-01-04 19:52:43 -08:00
bors
26c9b0046f Auto merge of #92567 - ehuss:update-cargo, r=ehuss
Update cargo

10 commits in fcef61230c3b6213b6b0d233a36ba4ebd1649ec3..358e79fe56fe374649275ca7aebaafd57ade0e8d
2021-12-17 02:30:38 +0000 to 2022-01-04 18:39:45 +0000
- Make rmeta_required no longer depend on whether timing is enabled (rust-lang/cargo#10254)
- The first version of pull request template (rust-lang/cargo#10218)
- Stabilize the `strip` profile option, now that rustc has stable `-C strip` (rust-lang/cargo#10088)
- Update docs for windows ssh-agent. (rust-lang/cargo#10248)
- Fix typo: substract -&gt; subtract (rust-lang/cargo#10244)
- timings: Fix tick mark alignment (rust-lang/cargo#10239)
- Remove unused lifetimes (rust-lang/cargo#10238)
- Make levenshtein distance case insensitive. (rust-lang/cargo#10224)
- [docs] Adds basic CI yaml for GitHub Actions (rust-lang/cargo#10212)
- Add function for parsing already-read manifest (rust-lang/cargo#10209)
2022-01-05 03:03:17 +00:00
Eric Huss
455caef624 Update cargo 2022-01-04 18:41:07 -08:00
bors
5883b87563 Auto merge of #92560 - matthiaskrgr:rollup-jeli7ip, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91587 (core::ops::unsize: improve docs for DispatchFromDyn)
 - #91907 (Allow `_` as the length of array types and repeat expressions)
 - #92515 (RustWrapper: adapt for an LLVM API change)
 - #92516 (Do not use deprecated -Zsymbol-mangling-version in bootstrap)
 - #92530 (Move `contains` method of Option and Result lower in docs)
 - #92546 (Update books)
 - #92551 (rename StackPopClean::None to Root)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-04 23:01:49 +00:00
Matthias Krüger
4b743f882f
Rollup merge of #92546 - ehuss:update-books, r=ehuss
Update books

## reference

3 commits in 06f9e61931bcf58b91dfe6c924057e42ce273ee1..f8ba2f12df60ee19b96de24ae5b73af3de8a446b
2021-12-17 07:31:40 -0800 to 2022-01-03 11:02:08 -0800
- Switch the default edition for examples to 2021 (rust-lang/reference#1125)
- Clarify behavior of x87 FP registers in inline assembly (rust-lang/reference#1126)
- Add inline assembly to the reference (rust-lang/reference#1105)

## book

36 commits in 8a0bb3c96e71927b80fa2286d7a5a5f2547c6aa4..d3740fb7aad0ea4a80ae20f64dee3a8cfc0c5c3c
2021-12-22 20:54:27 -0500 to 2022-01-03 21:46:04 -0500
- Add a concrete example of an optional value. Fixes rust-lang/book#2848.
- match isn't really an operator. Fixes rust-lang/book#2859
- Edits to edits of chapter 6
- Make fixes recommended by shellcheck
- Use shellcheck
- SIGH fix all the typos that were missed while spellcheck was broken
- SIGH add all the words to the dictionary that were missed while spellcheck was broken
- Remove test_harness from the dictionary
- sigh, the xkcd sandwich one
- Install aspell in CI
- set -eu in all bash scripts
- typo: assignement -&gt; assignment
- Fix quotes
- Snapshot of ch12 for nostarch
- Use 'static lifetime earlier because that's more correct. Fixes rust-lang/book#2864.
- Add does_not_compile annotation to intermediate steps that don't compile
- Sidestep who provides output streams. Fixes rust-lang/book#2933.
- Remove note about primitive obsession. Fixes rust-lang/book#2863.
- Remove sentence encouraging writing tests on your own. Fixes rust-lang/book#2223.
- Bump mdBook version to 0.4.14 in workflow main.yml
- Past tense make better sense
- Past tense makes better sense
- Update the edition in all the listings' Cargo.toml
- Update the book to either say 2021 edition or not talk about editions
- Remove most of the 2018 edition text from the title page. Fixes rust-lang/book#2852.
- Fix word wrapping
- Emphasize return type is mandatory
- fix title capitalization
- Further edits to mention of --include-ignored, propagate to src
- feat: mention `cargo test -- --include-ignored`
- wording: get rid of "to from"
- interchanged position of `binary` and `library`
- Fix wrong word typo
- Further edits in rust-analyzer text
- appendix-04 IDE integration: Replaced rls by rust-analyzer
- Update link to Italian translation. Connects to rust-lang/book#2484.

## rustc-dev-guide

3 commits in 9bf0028b557798ddd07a6f652e4d0c635d3d6620..875464457c4104686faf667f47848aa7b0f0a744
2021-12-20 21:53:57 +0900 to 2021-12-28 22:17:49 -0600
- Update link to moved section (rust-lang/rustc-dev-guide#1282)
- Fix link in contributing.md (rust-lang/rustc-dev-guide#1280)
- Streamline "Getting Started" (rust-lang/rustc-dev-guide#1279)
2022-01-04 21:23:11 +01:00
Matthias Krüger
e1a7743971
Rollup merge of #92516 - Kobzol:bootstrap-symbol-mangling, r=Mark-Simulacrum
Do not use deprecated -Zsymbol-mangling-version in bootstrap

`-Zsymbol-mangling-version` now produces warnings unconditionally. So if you want to use legacy mangling for the compiler (`new-symbol-mangling = false` in `config.toml`), the build is now littered with warnings.

However, with this change, stage 1 `std` doesn't compile:
```
error: `-C symbol-mangling-version=legacy` requires `-Z unstable-options`
```
Even after the bootstrap compiler is updated and it will support `-Csymbol-mangling-version`, the bootstrap code would either need to use `-Z` for the legacy mangling or use `-C` in combination with `-Z unstable-options` (because `-C` + legacy is not allowed without the unstable options). Should we just add `-Z unstable-options` to `std` compilation to resolve this?

Btw I use legacy mangling because the new mangling is not supported by [Hotspot](https://github.com/KDAB/hotspot).
2022-01-04 21:23:09 +01:00
Matthias Krüger
ac7a867715
Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU
Allow `_` as the length of array types and repeat expressions

r? `@BoxyUwU` cc `@varkor`
2022-01-04 21:23:06 +01:00
Jakub Beránek
65a3279f4a
Do not hash zero bytes of i64 and u32 in Sip128 hasher 2022-01-04 19:12:10 +01:00
Jakub Beránek
e266cb90de Do not use deprecated -Zsymbol-mangling-version in bootstrap 2022-01-04 12:06:46 -05:00
Matthias Krüger
25fcc0ef8c
Rollup merge of #92507 - chordtoll:suggest-single-quotes, r=petrochenkov
Suggest single quotes when char expected, str provided

If a type mismatch occurs where a char is expected and a string literal is provided, suggest changing the double quotes to single quotes.

We already provide this suggestion in the other direction ( ' -> " ).

Especially useful for new rust devs used to a language in which single/double quotes are interchangeable.

Fixes #92479.
2022-01-04 16:34:17 +01:00
chordtoll
3087c4dfb7
Suggest changing quotes when str/char type mismatch 2022-01-03 22:08:08 -08:00
Eric Huss
ec10c4f7f2 Update books 2022-01-03 19:45:10 -08:00
Caleb Zulawski
3cd49767cf Add pointer-sized integer tests 2022-01-04 01:45:42 +00:00
Caleb Zulawski
8fae33d9b2 Add simd_as intrinsic 2022-01-04 01:45:41 +00:00
Caleb Zulawski
d32ca64692 Allow isize/usize in simd_cast 2022-01-04 01:44:26 +00:00
bors
2b681ac06b Auto merge of #92259 - Aaron1011:normal-mod-hashing, r=michaelwoerister
Remove special-cased stable hashing for HIR module

All other 'containers' (e.g. `impl` blocks) hashed their contents
in the normal, order-dependent way. However, `Mod` was hashing
its contents in a (sort-of) order-independent way. However, the
exact order is exposed to consumers through `Mod.item_ids`,
and through query results like `hir_module_items`. Therefore,
stable hashing needs to take the order of items into account,
to avoid fingerprint ICEs.

Unforuntately, I was unable to directly build a reproducer
for the ICE, due to the behavior of `Fingerprint::combine_commutative`.
This operation swaps the upper and lower `u64` when constructing the
result, which makes the function non-associative. Since we start
the hashing of module items by combining `Fingerprint::ZERO` with
the first item, it's difficult to actually build an example where
changing the order of module items leaves the final hash unchanged.

However, this appears to have been hit in practice in #92218
While we're not able to reproduce it, the fact that proc-macros
are involved (which can give an entire module the same span, preventing
any span-related invalidations) makes me confident that the root
cause of that issue is our method of hashing module items.

This PR removes all of the special handling for `Mod`, instead deriving
a `HashStable` implementation. This makes `Mod` consistent with other
'contains' like `Impl`, which hash their contents through the typical
derive of `HashStable`.
2022-01-04 00:25:23 +00:00
Nicholas Nethercote
2e74ca18e4 Tweak the usage messages for x.py build and x.py check.
They're a bit out of date, and overly complicated.
2022-01-04 09:24:10 +11:00
Nicholas Nethercote
10e3d92306 Label more build steps.
Currently the output of a command like `./x.py build --stage 0 library/std` is this:
```
Updating only changed submodules
Submodules updated in 0.02 seconds
extracting [...]
   Compiling [...]
    Finished dev [unoptimized] target(s) in 17.53s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compling [...]
    Finished release [optimized + debuginfo] target(s) in 21.99s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Build completed successfully in 0:00:51
```
I find the part before the "Building stage0 std artifacts" a bit confusing.

After this commit, it looks like this:
```
Updating only changed submodules
  Submodules updated in 0.02 seconds
extracting [...]
Building rustbuild
   Compiling [...]
    Finished dev [unoptimized] target(s) in 17.53s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compling [...]
    Finished release [optimized + debuginfo] target(s) in 21.99s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Build completed successfully in 0:00:51
```
The "Building rustbuild" label makes it clear what the first cargo build
invocation is for. The indentation of the "Submodules updated" line
indicates it is a sub-step of a parent task.
2022-01-04 09:24:10 +11:00
Aaron Hill
467b72607d
Hash Ident spans in all HIR structures
This PR removes all of the `#[stable_hasher(project(name))]`
attributes used in HIR structs. While these attributes are not known
to be causing any issues in practice, we need to hash these in
order for the incremental system to work correctly -
a query could be otherwise be incorrectly marked green
when a change occures in one of the `Span`s that it uses.
2022-01-03 15:52:38 -05:00
bors
ddabe0775c Auto merge of #92518 - matthiaskrgr:rollup-fl8z4e7, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #90102 (Remove `NullOp::Box`)
 - #92011 (Use field span in `rustc_macros` when emitting decode call)
 - #92402 (Suggest while let x = y when encountering while x = y)
 - #92409 (Couple of libtest cleanups)
 - #92418 (Fix spacing in pretty printed PatKind::Struct with no fields)
 - #92444 (Consolidate Result's and Option's methods into fewer impl blocks)

Failed merges:

 - #92483 (Stabilize `result_cloned` and `result_copied`)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-03 14:30:36 +00:00
Piotr Mikulski
19cfcd5c5a Fix clippy warnings 2022-01-03 06:11:11 -08:00
Matthias Krüger
13e284033e
Rollup merge of #92444 - dtolnay:coremethods, r=joshtriplett
Consolidate Result's and Option's methods into fewer impl blocks

`Result`'s and `Option`'s methods have historically been separated up into `impl` blocks based on their trait bounds, with the bounds specified on type parameters of the impl block. I find this unhelpful because closely related methods, like `unwrap_or` and `unwrap_or_default`, end up disproportionately far apart in source code and rustdocs:

<pre>
impl&lt;T&gt; Option&lt;T&gt; {
    pub fn unwrap_or(self, default: T) -&gt; T {
        ...
    }

    <img alt="one eternity later" src="https://user-images.githubusercontent.com/1940490/147780325-ad4e01a4-c971-436e-bdf4-e755f2d35f15.jpg" width="750">
}

impl&lt;T: Default&gt; Option&lt;T&gt; {
    pub fn unwrap_or_default(self) -&gt; T {
        ...
    }
}
</pre>

I'd prefer for method to be in as few impl blocks as possible, with the most logical grouping within each impl block. Any bounds needed can be written as `where` clauses on the method instead:

```rust
impl<T> Option<T> {
    pub fn unwrap_or(self, default: T) -> T {
        ...
    }

    pub fn unwrap_or_default(self) -> T
    where
        T: Default,
    {
        ...
    }
}
```

*Warning: the end-to-end diff of this PR is computed confusingly by git / rendered confusingly by GitHub; it's practically impossible to review that way. I've broken the PR into commits that move small groups of methods for which git behaves better &mdash; these each should be easily individually reviewable.*
2022-01-03 14:44:21 +01:00
Matthias Krüger
df921190f3
Rollup merge of #92418 - dtolnay:emptystructpat, r=michaelwoerister
Fix spacing in pretty printed PatKind::Struct with no fields

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($pat:pat) => {
        stringify!($pat)
    };
}

fn main() {
    println!("{}", repro!(Struct {}));
}
```

Before:&ensp;<code>Struct&nbsp;{&nbsp;&nbsp;}</code>
After:&ensp;<code>Struct&nbsp;{}</code>
2022-01-03 14:44:20 +01:00
Matthias Krüger
0335b7bca9
Rollup merge of #92402 - pr2502:while-let-typo, r=oli-obk
Suggest while let x = y when encountering while x = y

Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2022-01-03 14:44:18 +01:00
Matthias Krüger
57a4f4a634
Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink
Remove `NullOp::Box`

Follow up of #89030 and MCP rust-lang/compiler-team#460.

~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely.

r? `@jonas-schievink`
`@rustbot` label T-compiler
2022-01-03 14:44:15 +01:00
bors
b5efe5727f Auto merge of #92179 - Aaron1011:incr-loaded-from-disk, r=michaelwoerister
Add `#[rustc_clean(loaded_from_disk)]` to assert loading of query result

Currently, you can use `#[rustc_clean]` to assert to that a particular
query (technically, a `DepNode`) is green or red. However, a green
`DepNode` does not mean that the query result was actually deserialized
from disk - we might have never re-run a query that needed the result.

Some incremental tests are written as regression tests for ICEs that
occured during query result decoding. Using
`#[rustc_clean(loaded_from_disk="typeck")]`, you can now assert
that the result of a particular query (e.g. `typeck`) was actually
loaded from disk, in addition to being green.
2022-01-03 11:20:08 +00:00
bors
d367c349ef Auto merge of #92080 - Aaron1011:pattern-ice, r=cjgillot
Move `PatKind::Lit` checking from ast_validation to ast lowering

Fixes #92074

This allows us to insert an `ExprKind::Err` when an invalid expression
is used in a literal pattern, preventing later stages of compilation
from seeing an unexpected literal pattern.
2022-01-03 06:59:52 +00:00
bors
b5da80871d Auto merge of #92395 - Kobzol:rustdoc-bindings-thin-vec, r=camelid
Rustdoc: use ThinVec for GenericArgs bindings

The bindings are almost always empty. This reduces the size of `PathSegment` and `GenericArgs` by about one fourth.
2022-01-03 03:49:01 +00:00
Jacob Hoffman-Andrews
cc18120425 Set font size proportional to user's font size
According to MDN
(https://developer.mozilla.org/en-US/docs/Web/CSS/font-size),

> To maximize accessibility, it is generally best to use values that
> are relative to the user's default font size.

> Defining font sizes in px is not accessible, because the user cannot
> change the font size in some browsers.

Note that changing font size (in browser or OS settings) is distinct
from the zoom functionality triggered with Ctrl/Cmd-+. Zoom
functionality increases the size of everything on the page, effectively
applying a multiplier to all pixel sizes. Font size changes apply to
just text.

For relative font sizes, we could use `em`, as we do in several places
already. However that has a problem of "compounding" (see MDN article
for details). The compounding problem is nicely solved by `rem`, which
make font sizes relative to the root element, not the parent element.

Since we were using a hodge-podge of pixel sizes, em, rem, and
percentage sizes before, this change switching everything to rem, while
keeping the same size relative to our old default of 16px.

16px is still the default on most browsers, for users that haven't set a
larger or smaller font size.
2022-01-02 11:23:26 -05:00
bors
8f3238f898 Auto merge of #90128 - joshtriplett:stabilize-symbol-mangling-version, r=wesleywiser
Stabilize -Z symbol-mangling-version=v0 as -C symbol-mangling-version=v0

This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options.

This does not change the default symbol-mangling-version. See https://github.com/rust-lang/rust/pull/89917 for a pull request changing the default. Rationale, from #89917:

Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain . characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters A-Z, a-z, 0-9, and _.

Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers).

This pull request allows enabling the new v0 symbol-mangling-version.

See #89917 for references to the implementation of v0, and for references to the tool changes to decode Rust symbols.
2022-01-02 15:49:23 +00:00
bors
03360be6b7 Auto merge of #92066 - Smittyvb:concat_bytes-repeat, r=nagisa
Support [x; n] expressions in concat_bytes!

Currently trying to use `concat_bytes!` with a repeating array value like `[42; 5]` results in an error:
```
error: expected a byte literal
 --> src/main.rs:3:27
  |
3 |     let x = concat_bytes!([3; 4]);
  |                           ^^^^^^
  |
  = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()`
```

This makes it so repeating array syntax can be used the same way normal arrays can be. The RFC doesn't explicitly mention repeat expressions, but it seems reasonable to allow them as well, since normal arrays are allowed.

It is possible to make the compiler get stuck compiling forever with `concat_bytes!([3; 999999999])`, but I don't think that's much of an issue since you can do that already with `const X: [u8; 999999999] = [3; 999999999];`.

Contributes to #87555.
2022-01-02 12:38:41 +00:00
bors
f7934f693b Auto merge of #92034 - petrochenkov:nolinknores, r=joshtriplett
Remove effect of `#[no_link]` attribute on name resolution

Previously it hid all non-macro names from other crates.
This has no relation to linking and can change name resolution behavior in some cases (e.g. glob conflicts), in addition to just producing the "unresolved name" errors.

I can kind of understand the possible reasoning behind the current behavior - if you can use names from a `no_link` crates then you can use, for example, functions too, but whether it will actually work or produce link-time errors will depend on random factors like inliner behavior.
(^^^ This is not the actual reason why the current behavior exist, I've looked through git history and it's mostly accidental.)

I think this risk is ok for such an obscure attribute, and we don't need to specifically prevent use of non-macro items from such crates.
(I'm not actually sure why would anyone use `#[no_link]` on a crate, even if it's macro only, if you aware of any use cases, please share. IIRC, at some point it was used for crates implementing custom derives - the now removed legacy ones, not the current proc macros.)

Extracted from https://github.com/rust-lang/rust/pull/91795.
2022-01-02 06:28:34 +00:00
David Tolnay
a18f43f25d
Fix unclosed boxes in pretty printing of TraitAlias 2022-01-01 18:02:00 -08:00
Josh Triplett
ff94b3b12b Update references to -Z symbol-mangling-version to use -C
Replace `-Z symbol-mangling-version=v0` with `-C symbol-mangling-version=v0`.

Replace `-Z symbol-mangling-version=legacy` with
`-Z unstable-options -C symbol-mangling-version=legacy`.
2022-01-01 15:53:11 -08:00
Matthias Krüger
2004a51fa4
Rollup merge of #92468 - NieDzejkob:silent-cfg, r=petrochenkov
Emit an error for `--cfg=)`

Fixes #73026

See also: #64467, #89468

The issue stems from a `FatalError` being silently raised in
`panictry_buffer`. Normally this is not a problem, because
`panictry_buffer` emits the causes of the error, but they are not
themselves fatal, so they get filtered out by the silent emitter.

To fix this, we use a parser entrypoint which doesn't use
`panictry_buffer`, and we handle the error ourselves.
2022-01-01 22:49:53 +01:00
Matthias Krüger
a015c86a1d
Rollup merge of #92332 - GuillaumeGomez:where-clause-order, r=jsha
Add test for where clause order

I didn't use ``@snapshot`` because of the `&nbsp;` characters, it's much simpler doing it through rustdoc-gui testsuite.

r? `@camelid`
2022-01-01 22:49:50 +01:00
Matthias Krüger
ab7a356b5d
Rollup merge of #92297 - bjorn3:smaller_bootstrap, r=Mark-Simulacrum
Reduce compile time of rustbuild

Best reviewed commit by commit. The `ignore` crate and it's dependencies are probably responsible for the majority of the compile time after this PR.

cc `@jyn514` as you got a couple of open rustbuild PR.
2022-01-01 22:49:49 +01:00
Aaron Hill
137c374c41
Move PatKind::Lit checking from ast_validation to ast lowering
Fixes #92074

This allows us to insert an `ExprKind::Err` when an invalid expression
is used in a literal pattern, preventing later stages of compilation
from seeing an unexpected literal pattern.
2022-01-01 15:10:43 -05:00
bjorn3
7ea6e713c2 Remove some dead code 2022-01-01 18:50:56 +01:00
bjorn3
ad6f98cd28 Remove the merge dependency 2022-01-01 17:03:24 +01:00
bjorn3
947e9483e9 Make the rustc and rustdoc wrapper not depend on libbootstrap
This slightly improves compilation time by reducing linking time
(saving about a 1/10 of the the total compilation time after
changing rustbuild) and slightly reduces disk usage (from 16MB for
the rustc wrapper to 4MB).
2022-01-01 16:56:05 +01:00
bjorn3
043745cb96 Avoid the merge derive macro in rustbuild
The task of the macro is simple enough that a decl macro is almost ten
times shorter than the original proc macro. The proc macro is 159 lines
while the decl macro is just 18 lines.

This reduces the amount of dependencies of rustbuild from 45 to 37. It
also slight reduces compilation time from 47s to 44s for debug builds.
2022-01-01 16:56:03 +01:00
bjorn3
2fe2728fa9 Remove the lazy_static dependency from rustbuild
Rustbuild already depends on once_cell which in the future can be
replaced with std::lazy::Lazy.
2022-01-01 16:53:47 +01:00
bors
4f49627c6f Auto merge of #92419 - erikdesjardins:coldland, r=nagisa
Mark drop calls in landing pads `cold` instead of `noinline`

Now that deferred inlining has been disabled in LLVM (#92110), this shouldn't cause catastrophic size blowup.

I confirmed that the test cases from https://github.com/rust-lang/rust/issues/41696#issuecomment-298696944 still compile quickly (<1s) after this change. ~Although note that I wasn't able to reproduce the original issue using a recent rustc/llvm with deferred inlining enabled, so those tests may no longer be representative. I was also unable to create a modified test case that reproduced the original issue.~ (edit: I reproduced it on CI by accident--the first commit timed out on the LLVM 12 builder, because I forgot to make it conditional on LLVM version)

r? `@nagisa`
cc `@arielb1` (this effectively reverts #42771 "mark calls in the unwind path as !noinline")
cc `@RalfJung` (fixes #46515)

edit: also fixes #87055
2022-01-01 13:28:13 +00:00
Jakub Beránek
3d8d3f1435
Rustdoc: use ThinVec for GenericArgs bindings 2022-01-01 11:29:14 +01:00
Guillaume Gomez
c6ee7bbe51 Update mixed doc comments test 2022-01-01 11:04:44 +01:00
Guillaume Gomez
ec0c83821e Add test for where clause order 2022-01-01 10:50:55 +01:00
Matthias Krüger
4bd4e271e4
Rollup merge of #92469 - joshtriplett:test-number-fix, r=Mark-Simulacrum
Make tidy check for magic numbers that spell things

Remove existing problematic cases.

r? `@Mark-Simulacrum`
2022-01-01 10:48:58 +01:00
Matthias Krüger
913bc8644a
Rollup merge of #92460 - dwrensha:fix-92267, r=petrochenkov
[rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape

Fixes #92267.

The problem was that the escape string "%%" does not need to appear at the very beginning of the format string, but
the iterator implementation assumed that it did.

The solution follows the pattern used by `format_foregin:🐚:Subtitution::Escape`: 8ed935e92d/compiler/rustc_builtin_macros/src/format_foreign.rs (L629)
2022-01-01 10:48:57 +01:00
Matthias Krüger
efe415878b
Rollup merge of #92420 - dtolnay:patrange, r=Mark-Simulacrum
Fix whitespace in pretty printed PatKind::Range

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($pat:pat) => {
        stringify!($pat)
    };
}

fn main() {
    println!("{}", repro!(0..=1));
}
```

Before:&ensp;`0 ..=1`
After:&ensp;`0..=1`

The canonical spacing applied by rustfmt has no space after the lower expr. Rustc's parser diagnostics also do not put a space there:

df96fb166f/compiler/rustc_parse/src/parser/pat.rs (L754)
2022-01-01 10:48:56 +01:00
Matthias Krüger
682b4cbc4e
Rollup merge of #92412 - dtolnay:tryspace, r=Mark-Simulacrum
Fix double space in pretty printed TryBlock

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($expr:expr) => {
        stringify!($expr)
    };
}

fn main() {
    println!("{}", repro!(try {}));
}
```

Before:&ensp;<code>try&nbsp;&nbsp;{}</code>
After:&ensp;<code>try&nbsp;{}</code>

The `head` helper already appends a space:

2b67c30bfe/compiler/rustc_ast_pretty/src/pprust/state.rs (L654-L664)

so doing `head` followed by `space` resulted in a double space:

2b67c30bfe/compiler/rustc_ast_pretty/src/pprust/state.rs (L2241-L2242)
2022-01-01 10:48:55 +01:00
Matthias Krüger
5a5c9282e0
Rollup merge of #88310 - worldeva:bootstrap-locking, r=Mark-Simulacrum
Lock bootstrap (x.py) build directory

Closes #76661,  closes #80849,
`x.py` creates a lock file at `project_root/lock.db`

r? `@jyn514` , because he was one that told me about this~
2022-01-01 10:48:53 +01:00
Josh Triplett
0d55bd1100 Make tidy check for magic numbers that spell things
Remove existing problematic cases.
2021-12-31 21:13:07 -08:00
Jakub Kądziołka
193342eb8d
Emit an error for --cfg=)
Fixes #73026

See also: #64467, #89468

The issue stems from a `FatalError` being silently raised in
`panictry_buffer`. Normally this is not a problem, because
`panictry_buffer` emits the causes of the error, but they are not
themselves fatal, so they get filtered out by the silent emitter.

To fix this, we use a parser entrypoint which doesn't use
`panictry_buffer`, and we handle the error ourselves.
2022-01-01 05:21:36 +01:00
Matthias Krüger
2da54c729e
Rollup merge of #92440 - GuillaumeGomez:fix-mobile-toggles, r=jsha
Fix mobile toggles position

Before:

![Screenshot from 2021-12-29 18-53-33](https://user-images.githubusercontent.com/3050060/147764842-082f6fa2-b631-4c47-ba34-ced76fe8494f.png)

After:

![Screenshot from 2021-12-29 18-52-48](https://user-images.githubusercontent.com/3050060/147764853-13046330-2442-4fad-b26a-84c167711b54.png)

r? `@jsha`
2021-12-31 23:14:49 +01:00
Matthias Krüger
81f5dbdbd1
Rollup merge of #92405 - bjorn3:more_needs_inline_asm, r=lqd
Add a couple needs-asm-support headers to tests

This will allow them to be ignored by codegen backends that don't support inline asm.
2021-12-31 23:14:47 +01:00
Matthias Krüger
72e36d47e8
Rollup merge of #91480 - jsha:fewer-colors, r=GuillaumeGomez
rustdoc: use smaller number of colors to distinguish items

This reduces visual distractions when reading method signatures.

As discussed in https://github.com/rust-lang/rust/issues/59845#issuecomment-974757191, this categorizes items into one of six colors (down from thirteen):

 - method, function (ochre `#AD7C37`)
 - trait, trait alias (dark slate blue `#6E4FC9`)
 - enum, struct, type alias, union, primitive (maroon `#AD378A`)
 - static, module, keyword, associated type, foreign type (steel blue `#3873AD`)
 - macro (green `#068000`)
 - generic params, self, Self (unmarked black `#000000`)

I slightly tweaked the actual color values so they'd have the same lightness (previously the trait color stood out much more than the others). And I made the color for links in general consistently use steel blue (previously there was a slightly different color for "search-failed").

The ayu and dark themes have been updated according to the same logic. I haven't changed any of the color values in those themes, just their assignment to types.

Demo:

https://rustdoc.crud.net/jsha/fewer-colors/std/string/struct.String.html
https://rustdoc.crud.net/jsha/fewer-colors/std/vec/struct.Vec.html
https://rustdoc.crud.net/jsha/fewer-colors/std/io/trait.Read.html
https://rustdoc.crud.net/jsha/fewer-colors/std/iter/trait.Iterator.html
2021-12-31 23:14:45 +01:00
Matthias Krüger
198fca8601
Rollup merge of #91375 - Apteryks:per-target-default-linker, r=Mark-Simulacrum
config.rs: Add support for a per-target default_linker option.

* src/bootstrap/config.rs (Target) <default_linker>: New field.
(TomlTarget): Likewise.
* src/bootstrap/compile.rs (rustc_cargo_env): Prefer a
target-specified default_linker over a global one if available.
* config.toml.example: Adjust doc.
2021-12-31 23:14:44 +01:00
Matthias Krüger
ac1060e188
Rollup merge of #90383 - tmiasko:union-validity, r=RalfJung
Extend check for UnsafeCell in consts to cover unions

A validity companion to changes from #90373.

`@rust-lang/wg-const-eval`
2021-12-31 23:14:44 +01:00
Maxim Cournoyer
b1fbafddbb rustbuild: Add support for a per-target default-linker option. 2021-12-31 13:13:24 -05:00
David Renshaw
a661671ae3 [rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape 2021-12-31 12:42:15 -05:00
bors
984a6bf9c1 Auto merge of #92175 - Aaron1011:fix-missing-source-file, r=cjgillot
Import `SourceFile`s from crate before decoding foreign `Span`

Fixes #92163
Fixes #92014

When writing to the incremental cache, we encode all `Span`s
we encounter, regardless of whether or not their `SourceFile`
comes from the local crate, or from a foreign crate.

When we decode a `Span`, we use the `StableSourceFileId` we encoded
to locate the matching `SourceFile` in the current session. If this
id corresponds to a `SourceFile` from another crate, then we need to
have already imported that `SourceFile` into our current session.

This usually happens automatically during resolution / macro expansion,
when we try to resolve definitions from other crates. In certain cases,
however, we may try to load a `Span` from a transitive dependency
without having ever imported the `SourceFile`s from that crate, leading
to an ICE.

This PR fixes the issue by enconding the `SourceFile`'s `CrateNum`
when we encode a `Span`. During decoding, we call `imported_source_files()`
when we encounter a foreign `CrateNum`, which ensure that all
`SourceFile`s from that crate are imported into the current session.
2021-12-31 16:38:23 +00:00
worldeva
1326bd6484 Lock x.py build state
Prevent spurious build failures and other bugs caused by parallel runs of
x.py. We back the lock with sqlite, so that we have a cross-platform locking
strategy, and which can be done nearly first in the build process (from Python),
which helps move the lock as early as possible.
2021-12-31 10:31:13 -05:00
bors
8ed935e92d Auto merge of #92252 - GuillaumeGomez:update-pulldown, r=camelid,xFrednet
Update pulldown-cmark version to 0.9

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

r? `@camelid`
2021-12-31 12:46:38 +00:00
Tomasz Miąsko
2eb637a9f2 Extend check for UnsafeCell in consts to cover unions
A validity companion to changes from #90373.
2021-12-31 08:53:12 +01:00
bors
8baeddfe8f Auto merge of #92437 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2021-12-31 00:07:29 +00:00
bors
a09f775e5a Auto merge of #92426 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright
Sync rustfmt subtree

r? `@ghost`

Mostly refactoring and a few minor lint fixes, along with a couple small bug fixes
2021-12-30 20:53:39 +00:00
David Tolnay
5960f7a617
UI test updates for Result and Option method moves 2021-12-30 11:15:50 -08:00
Guillaume Gomez
7c78ea5b53 Fix display of toggles on mobile 2021-12-30 16:21:50 +01:00
Guillaume Gomez
b77830d6d9 Update browser-ui-test version to have assert-position command 2021-12-30 16:21:50 +01:00
bors
b60e32c828 Auto merge of #92434 - matthiaskrgr:rollup-m8wuq0v, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #91519 (ast: Avoid aborts on fatal errors thrown from mutable AST visitor)
 - #92414 (Fix spacing of pretty printed const item without body)
 - #92423 (Add UI test for #92292)
 - #92427 (Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-30 14:52:50 +00:00
flip1995
4bb6fde5f9
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup 2021-12-30 15:10:43 +01:00
Matthias Krüger
a23ef617b3
Rollup merge of #92423 - weirane:ui-92292, r=fee1-dead
Add UI test for #92292

Closes #92292
2021-12-30 13:12:35 +01:00
Matthias Krüger
e810487b4d
Rollup merge of #92414 - dtolnay:constnoexpr, r=oli-obk
Fix spacing of pretty printed const item without body

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{}", repro!(extern "C" { static S: i32; }));
}
```

Before:&ensp;`extern "C" { static S: i32 ; }`
After:&ensp;`extern "C" { static S: i32; }`
2021-12-30 13:12:34 +01:00
bors
f8d4ee7c7a Auto merge of #89336 - Aaron1011:variance-struct-diag, r=cjgillot
Refactor variance diagnostics to work with more types

Instead of special-casing mutable pointers/references, we
now support general generic types (currently, we handle
`ty::Ref`, `ty::RawPtr`, and `ty::Adt`)

When a `ty::Adt` is involved, we show an additional note
explaining which of the type's generic parameters is
invariant (e.g. the `T` in `Cell<T>`). Currently, we don't
explain *why* a particular generic parameter ends up becoming
invariant. In the general case, this could require printing
a long 'backtrace' of types, so doing this would be
more suitable for a follow-up PR.

We still only handle the case where our variance switches
to `ty::Invariant`.
2021-12-30 11:34:24 +00:00
bors
65d8785f0a Auto merge of #92377 - compiler-errors:rustdoc-lifetimes, r=camelid,jyn514
remove in_band_lifetimes from librustdoc

r? `@camelid`

closes #92368
2021-12-30 08:26:07 +00:00
Erik Desjardins
64da730a41 add test for noop drop in landing pad 2021-12-30 01:03:17 -05:00
Erik Desjardins
e4463b2453 keep noinline for system llvm < 14 2021-12-30 00:15:51 -05:00
Caleb Cartwright
521fdcbe4d Merge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree 2021-12-29 20:49:39 -06:00
Wang Ruochen
12b59b4027
Add UI test for #92292
Closes #92292
2021-12-29 16:06:26 -08:00
Aaron Hill
b15cb29a4a
Refactor variance diagnostics to work with more types
Instead of special-casing mutable pointers/references, we
now support general generic types (currently, we handle
`ty::Ref`, `ty::RawPtr`, and `ty::Adt`)

When a `ty::Adt` is involved, we show an additional note
explaining which of the type's generic parameters is
invariant (e.g. the `T` in `Cell<T>`). Currently, we don't
explain *why* a particular generic parameter ends up becoming
invariant. In the general case, this could require printing
a long 'backtrace' of types, so doing this would be
more suitable for a follow-up PR.

We still only handle the case where our variance switches
to `ty::Invariant`.
2021-12-29 18:53:40 -05:00
David Lattimore
4a053f206f Do not flatten match arm block with leading attributes
This is a backport of #4124.

Fixes #4109
2021-12-29 17:43:58 -06:00
bors
d331cb710f Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisa
Add codegen option for branch protection and pointer authentication on AArch64

The branch-protection codegen option enables the use of hint-space pointer
authentication code for AArch64 targets.
2021-12-29 22:35:11 +00:00
David Tolnay
bc1a1ff3c8
Fix whitespace in pretty printed PatKind::Range 2021-12-29 13:02:14 -08:00
Erik Desjardins
2b662217e7 Mark drop calls in landing pads cold instead of noinline
Now that deferred inlining has been disabled in LLVM,
this shouldn't cause catastrophic size blowup.
2021-12-29 15:47:49 -05:00
David Tolnay
8d7cf1a4ca
Fix spacing in pretty printed PatKind::Struct with no fields 2021-12-29 12:45:23 -08:00
David Tolnay
b62163515a
Move equal sign back into head ibox 2021-12-29 12:26:50 -08:00
David Tolnay
b7df49895c
Fix spacing of pretty printed const item without body 2021-12-29 12:26:50 -08:00
David Tolnay
a24e238bdf
Fix spacing and ordering of words in pretty printed Impl 2021-12-29 12:10:24 -08:00
David Tolnay
f3df63f8ee
Add a pretty printer test of impl<T> const Trait 2021-12-29 12:05:51 -08:00
bors
78fd0f633f Auto merge of #92244 - petrochenkov:alltraits, r=cjgillot
rustc_metadata: Encode list of all crate's traits into metadata

While working on https://github.com/rust-lang/rust/pull/88679 I noticed that rustdoc is casually doing something quite expensive, something that is used only for error reporting in rustc - collecting all traits from all crates in the dependency tree.

This PR trades some minor extra time spent by metadata encoder in rustc for major gains for rustdoc (and for rustc runs with errors, which execute the `all_traits` query for better diagnostics).
2021-12-29 19:22:33 +00:00
David Tolnay
2f25a4ab30
Fix double space in pretty printed TryBlock 2021-12-29 11:13:33 -08:00