]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #84640 - ids1024:u8_from_char, r=m-ou-se
Eric Huss [Sat, 8 Jan 2022 04:20:55 +0000 (20:20 -0800)]
Rollup merge of #84640 - ids1024:u8_from_char, r=m-ou-se

Implement `TryFrom<char>` for `u8`

Previously suggested in https://github.com/rust-lang/rfcs/issues/2854.

It makes sense to have this since `char` implements `From<u8>`. Likewise `u32`, `u64`, and `u128` (since #79502) implement `From<char>`.

2 years agoImplement `TryFrom<char>` for `u8`
Ian Douglas Scott [Wed, 28 Apr 2021 04:05:26 +0000 (21:05 -0700)]
Implement `TryFrom<char>` for `u8`

Previously suggested in https://github.com/rust-lang/rfcs/issues/2854.

It makes sense to have this since `char` implements `From<u8>`. Likewise
`u32`, `u64`, and `u128` (since #79502) implement `From<char>`.

2 years agoAuto merge of #92627 - matthiaskrgr:rollup-xmz0rib, r=matthiaskrgr
bors [Thu, 6 Jan 2022 22:56:13 +0000 (22:56 +0000)]
Auto merge of #92627 - matthiaskrgr:rollup-xmz0rib, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #91055 (return the correct type for closures in `type_of`)
 - #92207 (Delay remaining `span_bug`s in drop elaboration)
 - #92417 (Fix spacing and ordering of words in pretty printed Impl)
 - #92504 (Exit nonzero on rustc -Wall)
 - #92559 (RustWrapper: adapt to new AttributeMask API)
 - #92589 (Break the loop)
 - #92607 (rustc_metadata: Some minor cleanups and optimizations)
 - #92620 (Remove unused `ExtendDefault` struct)

Failed merges:

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

2 years agoRollup merge of #92620 - steffahn:remove_unused_ExtendDefault_struct, r=Mark-Simulacrum
Matthias Krüger [Thu, 6 Jan 2022 22:15:23 +0000 (23:15 +0100)]
Rollup merge of #92620 - steffahn:remove_unused_ExtendDefault_struct, r=Mark-Simulacrum

Remove unused `ExtendDefault` struct

As noted in https://github.com/rust-lang/rust/pull/77850#issuecomment-1002272054, this struct is no longer used.

2 years agoRollup merge of #92607 - petrochenkov:doctrscope2, r=cjgillot
Matthias Krüger [Thu, 6 Jan 2022 22:15:21 +0000 (23:15 +0100)]
Rollup merge of #92607 - petrochenkov:doctrscope2, r=cjgillot

rustc_metadata: Some minor cleanups and optimizations

Mostly extracted from https://github.com/rust-lang/rust/pull/88679 (which is otherwise a rustdoc PR).
r? ``@cjgillot``

2 years agoRollup merge of #92589 - ChrisDenton:break-loop, r=Mark-Simulacrum
Matthias Krüger [Thu, 6 Jan 2022 22:15:20 +0000 (23:15 +0100)]
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

2 years agoRollup merge of #92559 - durin42:llvm-14-attributemask, r=nikic
Matthias Krüger [Thu, 6 Jan 2022 22:15:18 +0000 (23:15 +0100)]
Rollup merge of #92559 - durin42:llvm-14-attributemask, r=nikic

RustWrapper: adapt to new AttributeMask API

Upstream LLVM change 9290ccc3c1a1 migrated attribute removal to use
AttributeMask instead of AttrBuilder, so we need to follow suit here.

r? ``@nagisa`` cc ``@nikic``

2 years agoRollup merge of #92504 - dtolnay:wall, r=jackh726
Matthias Krüger [Thu, 6 Jan 2022 22:15:17 +0000 (23:15 +0100)]
Rollup merge of #92504 - dtolnay:wall, r=jackh726

Exit nonzero on rustc -Wall

Previously `rustc -Wall /dev/null` would print a paragraph explaining that `-Wall` is not a thing in Rust, but would then exit 0. I believe exiting 0 is not the right behavior. For something like `rustc --version` or `rustc --help` or `rustc -C help` the user is requesting rustc to print some information; rustc prints that information and exits 0 because what the user requested has been accomplished. In the case of `rustc -Wall path/to/main.rs`, I don't find it correct to conceptualize this as "the user requested rustc to print information about the fact that Wall doesn't exist". The user requested a particular thing, and despite rustc knowing what they probably meant and informing them about that, the thing they requested has *not* been accomplished. Thus a nonzero exit code is needed.

2 years agoRollup merge of #92417 - dtolnay:printimpl, r=jackh726
Matthias Krüger [Thu, 6 Jan 2022 22:15:16 +0000 (23:15 +0100)]
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 {}` :crying_cat_face:
After:&ensp;`impl<T> const Trait for T {}`

2 years agoRollup merge of #92207 - tmiasko:delay-drop-elaboration-bug, r=jackh726
Matthias Krüger [Thu, 6 Jan 2022 22:15:14 +0000 (23:15 +0100)]
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.

2 years agoRollup merge of #91055 - lcnr:type_of-closures, r=nikomatsakis
Matthias Krüger [Thu, 6 Jan 2022 22:15:13 +0000 (23:15 +0100)]
Rollup merge of #91055 - lcnr:type_of-closures, r=nikomatsakis

return the correct type for closures in `type_of`

A bit unhappy about the way `typeck::check_crate` works rn. Would have preferred to not change `CollectItemTypesVisitor` in this way.

r? ``@nikomatsakis``

2 years agoExit nonzero on rustc -Wall
David Tolnay [Sun, 2 Jan 2022 22:24:11 +0000 (14:24 -0800)]
Exit nonzero on rustc -Wall

2 years agoremove unused ExtendDefault struct
Frank Steffahn [Thu, 6 Jan 2022 17:48:10 +0000 (18:48 +0100)]
remove unused ExtendDefault struct

2 years agoAuto merge of #92609 - matthiaskrgr:rollup-ldp47ot, r=matthiaskrgr
bors [Thu, 6 Jan 2022 15:30:46 +0000 (15:30 +0000)]
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

2 years agoAuto merge of #89819 - davidtwco:issue-81024-multiple-crates-multiple-dwarves, r...
bors [Thu, 6 Jan 2022 12:21:10 +0000 (12:21 +0000)]
Auto merge of #89819 - davidtwco:issue-81024-multiple-crates-multiple-dwarves, r=nagisa

cg: split dwarf for crate dependencies

Fixes #81024.

- 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 in object files and package debuginfo into a DWARF package file (`.dwp`) and `-C split-debuginfo=unpacked` will put debuginfo in 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).

  In the first commit of this PR, I re-introduce 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).
- Split DWARF packaging requires all of the object files to exist, including those in dependencies. ~~Therefore, the second commit of this PR makes rustc keep all objects or dwarf objects for unpacked mode and if the crate is a dependency in packed mode (determined by heuristic: if no linking is taking place), then objects or dwarf objects are kept. Objects are kept if `-Z split-dwarf-kind` is `SplitDwarfKind::Single`, and dwarf objects if `SplitDwarfKind::Split`.~~

  ~~There are other approaches that could be taken to supporting packed Split DWARF with crate dependencies but this seemed like the least complicated and was contained to only rustc. Other potential approaches are described in https://github.com/rust-lang/rust/issues/81024#issuecomment-760478223, I'm happy to change the approach I've taken here if it isn't what we're looking for.~~ See https://github.com/rust-lang/rust/pull/89819#issuecomment-985671867 for the current approach.
- ~~There's still a dependency on `llvm-dwp` after this change, which [we probably want to move away from](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/llvm-dwp.20is.20not.20recommended) but that seems out-of-scope for this PR. Ideally, Split DWARF (in packed or unpacked modes) will be usable on nightly after this lands. If there aren't any bugs reported then it's possible we could allow Split DWARF to be used on stable after this change, it depends whether or not switching away from `llvm-dwp` later would break any guarantees, or whether we'd want to change how we handle this cross-crate case in future.~~ See https://github.com/rust-lang/rust/pull/89819#issuecomment-985671867.

r? `@nagisa`
cc `@alexcrichton`

2 years agoRollup merge of #92443 - mdibaiee:90703/resolve-traits-of-primitive-types, r=Manishearth
Matthias Krüger [Thu, 6 Jan 2022 11:01:05 +0000 (12:01 +0100)]
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.

2 years agoRollup merge of #92404 - GuillaumeGomez:src-font-size, r=jsha
Matthias Krüger [Thu, 6 Jan 2022 11:01:04 +0000 (12:01 +0100)]
Rollup merge of #92404 - GuillaumeGomez:src-font-size, r=jsha

Fix font size for [src] links in headers

Fixes #90384.

cc `@jsha`
r? `@camelid`

2 years agoRollup merge of #92389 - chordtoll:test-92015, r=Mark-Simulacrum
Matthias Krüger [Thu, 6 Jan 2022 11:01:03 +0000 (12:01 +0100)]
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.

2 years agoRollup merge of #92360 - jackh726:param-heuristics-1, r=davidtwco
Matthias Krüger [Thu, 6 Jan 2022 11:01:02 +0000 (12:01 +0100)]
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

2 years agoRollup merge of #92349 - avitex:fix-rustdoc-private-doc-tests, r=GuillaumeGomez
Matthias Krüger [Thu, 6 Jan 2022 11:01:01 +0000 (12:01 +0100)]
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](https://github.com/rust-lang/rust/blob/e91ad5fc62bdee4a29c18baa5fad2ca42fc91bf4/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.

2 years agoRollup merge of #92288 - yescallop:patch-1, r=m-ou-se
Matthias Krüger [Thu, 6 Jan 2022 11:01:00 +0000 (12:01 +0100)]
Rollup merge of #92288 - yescallop:patch-1, r=m-ou-se

Fix a pair of mistyped test cases in `std::net::ip`

These two test cases are not consistent with their comments, which I believe is unintended.

2 years agoRollup merge of #92058 - jsha:run-on-hover, r=GuillaumeGomez
Matthias Krüger [Thu, 6 Jan 2022 11:00:59 +0000 (12:00 +0100)]
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

2 years agoRevert "bootstrap: copy `llvm-dwp` to sysroot"
David Wood [Fri, 3 Dec 2021 14:34:35 +0000 (14:34 +0000)]
Revert "bootstrap: copy `llvm-dwp` to sysroot"

This reverts commit 241160de72b5b55187ca54243e2a6e82e336d07c.

2 years agocg: use thorin instead of llvm-dwp
David Wood [Fri, 3 Dec 2021 14:24:05 +0000 (14:24 +0000)]
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>
2 years agosess/cg: re-introduce split dwarf kind
David Wood [Fri, 8 Oct 2021 16:10:17 +0000 (16:10 +0000)]
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>
2 years agorustc_metadata: Split `fn get_implementations_for_trait` into two functions
Vadim Petrochenkov [Thu, 6 Jan 2022 07:13:22 +0000 (15:13 +0800)]
rustc_metadata: Split `fn get_implementations_for_trait` into two functions

2 years agorustc_metadata: Make `opt_item_ident` in decoder faster and stricter
Vadim Petrochenkov [Thu, 6 Jan 2022 04:23:01 +0000 (12:23 +0800)]
rustc_metadata: Make `opt_item_ident` in decoder faster and stricter

By avoiding formatting and allocations in the no-ident case, and by making the span mandatory if the ident exists.

Use the optimized `opt_item_ident` to cleanup `fn each_child_of_item`

2 years agorustc_metadata: Make attribute decoding slightly faster and stricter
Vadim Petrochenkov [Thu, 6 Jan 2022 04:13:41 +0000 (12:13 +0800)]
rustc_metadata: Make attribute decoding slightly faster and stricter

Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions

2 years agorustc_middle: Add a method for getting a `SimplifiedType` definition/ID
Vadim Petrochenkov [Thu, 6 Jan 2022 04:02:00 +0000 (12:02 +0800)]
rustc_middle: Add a method for getting a `SimplifiedType` definition/ID

Import `SimplifiedType` more

2 years agoSimplify :target CSS selector
Guillaume Gomez [Wed, 5 Jan 2022 20:28:19 +0000 (21:28 +0100)]
Simplify :target CSS selector

2 years agoRustWrapper: simplify removing attributes
Augie Fackler [Wed, 5 Jan 2022 18:51:59 +0000 (13:51 -0500)]
RustWrapper: simplify removing attributes

Avoids some extra conversions. Spotted by nikic during review.

2 years agoBreak the loop
Chris Denton [Wed, 5 Jan 2022 17:55:52 +0000 (17:55 +0000)]
Break the loop

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

2 years agoAdd test for [src] font-size in headers
Guillaume Gomez [Wed, 29 Dec 2021 13:56:07 +0000 (14:56 +0100)]
Add test for [src] font-size in headers

2 years agoFix font size for [src] links in headers
Guillaume Gomez [Wed, 29 Dec 2021 13:55:49 +0000 (14:55 +0100)]
Fix font size for [src] links in headers

2 years agoAuto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgr
bors [Wed, 5 Jan 2022 15:28:36 +0000 (15:28 +0000)]
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 (:arrow_up: rust-analyzer)

Failed merges:

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

2 years agoMake Run button visible on hover
Jacob Hoffman-Andrews [Sat, 18 Dec 2021 06:38:18 +0000 (22:38 -0800)]
Make Run button visible on hover

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

2 years agoRollup merge of #92583 - lnicola:rust-analyzer-2022-01-05, r=lnicola
Matthias Krüger [Wed, 5 Jan 2022 14:05:50 +0000 (15:05 +0100)]
Rollup merge of #92583 - lnicola:rust-analyzer-2022-01-05, r=lnicola

:arrow_up: rust-analyzer

r? `@ghost`

2 years agoRollup merge of #92575 - petrochenkov:cratenodeid, r=Aaron1011
Matthias Krüger [Wed, 5 Jan 2022 14:05:49 +0000 (15:05 +0100)]
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`

2 years agoRollup merge of #92574 - luojia65:riscv-kernel-dev-rust, r=Amanieu
Matthias Krüger [Wed, 5 Jan 2022 14:05:48 +0000 (15:05 +0100)]
Rollup merge of #92574 - luojia65:riscv-kernel-dev-rust, r=Amanieu

Add RISC-V detection macro and more architecture instructions

This pull request includes:

- Update `stdarch` dependency to include ratified RISC-V supervisor and hypervisor instruction intrinsics which is useful in Rust kernel development
- Add macro `is_riscv_feature_detected!`
- Modify impl of `core::hint::spin_loop` to comply with latest version of `core::arch`

After this update, users may now develop RISC-V kernels and user applications more freely.

r? `@Amanieu`

2 years agoRollup merge of #92483 - ksqsf:master, r=dtolnay
Matthias Krüger [Wed, 5 Jan 2022 14:05:47 +0000 (15:05 +0100)]
Rollup merge of #92483 - ksqsf:master, r=dtolnay

Stabilize `result_cloned` and `result_copied`

Tracking issue: #63168

The FCP is now completed.

2 years agoRollup merge of #92442 - pierwill:localdefid-doc-ord, r=Aaron1011
Matthias Krüger [Wed, 5 Jan 2022 14:05:46 +0000 (15:05 +0100)]
Rollup merge of #92442 - pierwill:localdefid-doc-ord, r=Aaron1011

Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`

Suggested in https://github.com/rust-lang/rust/pull/92233#discussion_r776123222.

This also fixes some formatting in the doc comment.

r? `@cjgillot`

2 years agoRollup merge of #92388 - SpriteOvO:master, r=Mark-Simulacrum
Matthias Krüger [Wed, 5 Jan 2022 14:05:45 +0000 (15:05 +0100)]
Rollup merge of #92388 - SpriteOvO:master, r=Mark-Simulacrum

Fix a minor mistake in `String::try_reserve_exact` examples

The examples of `String::try_reserve_exact` didn't actually use `try_reserve_exact`, which was probably a minor mistake, and this PR fixed it.

2 years agoRollup merge of #92092 - saethlin:fix-sort-guards-sb, r=danielhenrymantilla
Matthias Krüger [Wed, 5 Jan 2022 14:05:44 +0000 (15:05 +0100)]
Rollup merge of #92092 - saethlin:fix-sort-guards-sb, r=danielhenrymantilla

Drop guards in slice sorting derive src pointers from &mut T, which is invalidated by interior mutation in comparison

I tried to run https://github.com/rust-lang/miri-test-libstd on `alloc` with `-Zmiri-track-raw-pointers`, and got a failure on the test `slice::panic_safe`. The test failure has nothing to do with panic safety, it's from how the test tests for panic safety.

I minimized the test failure into this very silly program:
```rust
use std::cell::Cell;
use std::cmp::Ordering;

#[derive(Clone)]
struct Evil(Cell<usize>);

fn main() {
    let mut input = vec![Evil(Cell::new(0)); 3];

    // Hits the bug pattern via CopyOnDrop in core
    input.sort_unstable_by(|a, _b| {
        a.0.set(0);
        Ordering::Less
    });

    // Hits the bug pattern via InsertionHole in alloc
    input.sort_by(|_a, b| {
        b.0.set(0);
        Ordering::Less
    });
}
```

To fix this, I'm just removing the mutability/uniqueness where it wasn't required.

2 years agoAuto merge of #92580 - matthiaskrgr:rollup-nzyn65y, r=matthiaskrgr
bors [Wed, 5 Jan 2022 12:32:28 +0000 (12:32 +0000)]
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

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Wed, 5 Jan 2022 11:43:32 +0000 (13:43 +0200)]
:arrow_up: rust-analyzer

2 years agoRollup merge of #92579 - RalfJung:miri, r=RalfJung
Matthias Krüger [Wed, 5 Jan 2022 10:26:09 +0000 (11:26 +0100)]
Rollup merge of #92579 - RalfJung:miri, r=RalfJung

update Miri

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

2 years agoRollup merge of #92545 - dtolnay:rustlog, r=petrochenkov
Matthias Krüger [Wed, 5 Jan 2022 10:26:08 +0000 (11:26 +0100)]
Rollup merge of #92545 - dtolnay:rustlog, r=petrochenkov

Extract init_env_logger to crate

I've been doing some work on rustc_ast_pretty using an out-of-tree main.rs and Cargo.toml with the following:

```toml
[dependencies]
rustc_ast = { path = "../rust/compiler/rustc_ast" }
rustc_ast_pretty = { path = "../rust/compiler/rustc_ast_pretty" }
rustc_span = { path = "../rust/compiler/rustc_span" }
```

Rustc_ast_pretty helpfully uses `tracing::debug!` but I found that in order to enable the debug output, my test crate must depend on rustc_driver which is an enormously bigger dependency than what I have been using so far, and slows down iteration time because an enormous dependency tree between rustc_ast and rustc_driver must now be rebuilt after every ast change.

I pulled out the tracing initialization to a new minimal rustc_log crate so that projects depending on the other rustc crates, like rustc_ast_pretty, can access the `debug!` messages in them without building all the rest of rustc.

2 years agoRollup merge of #92517 - ChrisDenton:explicit-path, r=dtolnay
Matthias Krüger [Wed, 5 Jan 2022 10:26:07 +0000 (11:26 +0100)]
Rollup merge of #92517 - ChrisDenton:explicit-path, r=dtolnay

Explicitly pass `PATH` to the Windows exe resolver

This allows for testing different `PATH`s without using the actual environment.

2 years agoRollup merge of #92448 - jsha:font-size-access, r=GuillaumeGomez
Matthias Krüger [Wed, 5 Jan 2022 10:26:06 +0000 (11:26 +0100)]
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

2 years agoRollup merge of #92322 - alper:add_debug_trait_documentation, r=dtolnay
Matthias Krüger [Wed, 5 Jan 2022 10:26:05 +0000 (11:26 +0100)]
Rollup merge of #92322 - alper:add_debug_trait_documentation, r=dtolnay

Add another implementation example to Debug trait

As per the discussion in: #92276

2 years agoRollup merge of #92188 - vacuus:nested-attributes-ext, r=jyn514
Matthias Krüger [Wed, 5 Jan 2022 10:26:04 +0000 (11:26 +0100)]
Rollup merge of #92188 - vacuus:nested-attributes-ext, r=jyn514

rustdoc: Clean up NestedAttributesExt trait/implementation

2 years agoRollup merge of #92182 - nnethercote:label-more-build-steps, r=Mark-Simulacrum
Matthias Krüger [Wed, 5 Jan 2022 10:26:03 +0000 (11:26 +0100)]
Rollup merge of #92182 - nnethercote:label-more-build-steps, r=Mark-Simulacrum

Label more build steps

Some small improvements.

r? ```@Mark-Simulacrum```

2 years agoupdate Miri
Ralf Jung [Wed, 5 Jan 2022 09:41:22 +0000 (10:41 +0100)]
update Miri

2 years agoAuto merge of #92103 - Kobzol:stable-hash-skip-zero-bytes, r=the8472
bors [Wed, 5 Jan 2022 09:27:18 +0000 (09:27 +0000)]
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`

2 years agoast: Always keep a `NodeId` in `ast::Crate`
Vadim Petrochenkov [Wed, 5 Jan 2022 08:09:55 +0000 (16:09 +0800)]
ast: Always keep a `NodeId` in `ast::Crate`

This makes it more uniform with other expanded nodes

2 years agoRemove unsupported types in primitive_to_ty conversion, add FIXME note
Mahdi Dibaiee [Mon, 3 Jan 2022 18:08:19 +0000 (18:08 +0000)]
Remove unsupported types in primitive_to_ty conversion, add FIXME note

2 years agoadd a test case for each supported primitive type
Mahdi Dibaiee [Mon, 3 Jan 2022 10:28:01 +0000 (10:28 +0000)]
add a test case for each supported primitive type

2 years agoRustdoc: resolve associated traits for primitive types
Mahdi Dibaiee [Thu, 30 Dec 2021 17:07:05 +0000 (17:07 +0000)]
Rustdoc: resolve associated traits for primitive types

Fixes #90703

2 years agoAdd is_riscv_feature_detected!; modify impl of hint::spin_loop
luojia65 [Wed, 5 Jan 2022 07:28:03 +0000 (15:28 +0800)]
Add is_riscv_feature_detected!; modify impl of hint::spin_loop

Update library/core/src/hint.rs

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
Remove redundant config gate

2 years agoAuto merge of #92498 - camelid:ignore-flaky-test, r=Mark-Simulacrum
bors [Wed, 5 Jan 2022 06:18:57 +0000 (06:18 +0000)]
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.

2 years agoIgnore flaky `panic-short-backtrace-windows-x86_64.rs` test for now
Noah Lev [Sun, 2 Jan 2022 20:13:18 +0000 (12:13 -0800)]
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.

2 years agoAuto merge of #92567 - ehuss:update-cargo, r=ehuss
bors [Wed, 5 Jan 2022 03:03:17 +0000 (03:03 +0000)]
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)

2 years agoUpdate cargo
Eric Huss [Wed, 5 Jan 2022 02:41:07 +0000 (18:41 -0800)]
Update cargo

2 years agoAuto merge of #92560 - matthiaskrgr:rollup-jeli7ip, r=matthiaskrgr
bors [Tue, 4 Jan 2022 23:01:49 +0000 (23:01 +0000)]
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

2 years agoTouch up Debug example from PR 92322
David Tolnay [Tue, 4 Jan 2022 22:25:20 +0000 (14:25 -0800)]
Touch up Debug example from PR 92322

2 years agoRollup merge of #92551 - RalfJung:stack-pop-cleanup, r=oli-obk
Matthias Krüger [Tue, 4 Jan 2022 20:23:12 +0000 (21:23 +0100)]
Rollup merge of #92551 - RalfJung:stack-pop-cleanup, r=oli-obk

rename StackPopClean::None to Root

With https://github.com/rust-lang/rust/pull/90102, `StackPopClean::None` is now only used for the "root" frame of the stack, so adjust its name accordingly and add an assertion.

r? `@oli-obk`

2 years agoRollup merge of #92546 - ehuss:update-books, r=ehuss
Matthias Krüger [Tue, 4 Jan 2022 20:23:11 +0000 (21:23 +0100)]
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)

2 years agoRollup merge of #92530 - dtolnay:contains, r=yaahc
Matthias Krüger [Tue, 4 Jan 2022 20:23:10 +0000 (21:23 +0100)]
Rollup merge of #92530 - dtolnay:contains, r=yaahc

Move `contains` method of Option and Result lower in docs

Follow-up to #92444 trying to get the `Option` and `Result` rustdocs in better shape.

This addresses the request in https://github.com/rust-lang/rust/issues/62358#issuecomment-645676285. The `contains` methods are previously too high up in the docs on both `Option` and `Result` &mdash; stuff like `ok` and `map` and `and_then` should all be featured higher than `contains`. All of those are more ubiquitously useful than `contains`.

2 years agoRollup merge of #92516 - Kobzol:bootstrap-symbol-mangling, r=Mark-Simulacrum
Matthias Krüger [Tue, 4 Jan 2022 20:23:09 +0000 (21:23 +0100)]
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).

2 years agoRollup merge of #92515 - krasimirgg:rust-head-llvm-0301, r=nagisa
Matthias Krüger [Tue, 4 Jan 2022 20:23:08 +0000 (21:23 +0100)]
Rollup merge of #92515 - krasimirgg:rust-head-llvm-0301, r=nagisa

RustWrapper: adapt for an LLVM API change

No functional changes intended.

The LLVM commit https://github.com/llvm/llvm-project/commit/ec501f15a8b8ace2b283732740d6d65d40d82e09 removed the signed version of `createExpression`.
This adapts the Rust LLVM wrappers accordingly.

2 years agoRollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU
Matthias Krüger [Tue, 4 Jan 2022 20:23:06 +0000 (21:23 +0100)]
Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU

Allow `_` as the length of array types and repeat expressions

r? `@BoxyUwU` cc `@varkor`

2 years agoRollup merge of #91587 - nrc:dispatchfromdyn-docs, r=yaahc
Matthias Krüger [Tue, 4 Jan 2022 20:23:05 +0000 (21:23 +0100)]
Rollup merge of #91587 - nrc:dispatchfromdyn-docs, r=yaahc

core::ops::unsize: improve docs for DispatchFromDyn

Docs-only PR, improves documentation for DispatchFromDyn.

2 years agoAuto merge of #92556 - matthiaskrgr:rollup-s9vopuj, r=matthiaskrgr
bors [Tue, 4 Jan 2022 19:56:13 +0000 (19:56 +0000)]
Auto merge of #92556 - matthiaskrgr:rollup-s9vopuj, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #91754 (Modifications to `std::io::Stdin` on Windows so that there is no longer a 4-byte buffer minimum in read().)
 - #91884 (Constify `Box<T, A>` methods)
 - #92107 (Actually set IMAGE_SCN_LNK_REMOVE for .rmeta)
 - #92456 (Make the documentation of builtin macro attributes accessible)
 - #92507 (Suggest single quotes when char expected, str provided)
 - #92525 (intra-doc: Make `Receiver::into_iter` into a clickable link)
 - #92532 (revert #92254 "Bump gsgdt to 0.1.3")

Failed merges:

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

2 years agoRustWrapper: adapt to new AttributeMask API
Augie Fackler [Tue, 4 Jan 2022 18:41:36 +0000 (13:41 -0500)]
RustWrapper: adapt to new AttributeMask API

Upstream LLVM change 9290ccc3c1a1 migrated attribute removal to use
AttributeMask instead of AttrBuilder, so we need to follow suit here.

2 years agoDo not hash zero bytes of i64 and u32 in Sip128 hasher
Jakub Beránek [Sat, 18 Dec 2021 19:41:58 +0000 (20:41 +0100)]
Do not hash zero bytes of i64 and u32 in Sip128 hasher

2 years agoDo not use deprecated -Zsymbol-mangling-version in bootstrap
Jakub Beránek [Mon, 3 Jan 2022 11:33:26 +0000 (12:33 +0100)]
Do not use deprecated -Zsymbol-mangling-version in bootstrap

2 years agoRollup merge of #92532 - krasimirgg:gsgdt-down, r=Mark-Simulacrum
Matthias Krüger [Tue, 4 Jan 2022 15:34:20 +0000 (16:34 +0100)]
Rollup merge of #92532 - krasimirgg:gsgdt-down, r=Mark-Simulacrum

revert #92254 "Bump gsgdt to 0.1.3"

This reverts https://github.com/rust-lang/rust/pull/92254 since gsgdt 0.1.3 was yanked: https://github.com/rust-lang/rust/pull/92254#issuecomment-1004269481

2 years agoRollup merge of #92525 - zohnannor:patch-1, r=camelid
Matthias Krüger [Tue, 4 Jan 2022 15:34:19 +0000 (16:34 +0100)]
Rollup merge of #92525 - zohnannor:patch-1, r=camelid

intra-doc: Make `Receiver::into_iter` into a clickable link

The documentation on `std::sync::mpsc::Iter` and `std::sync::mpsc::TryIter` provides links to the corresponding `Receiver` methods, unlike `std::sync::mpsc::IntoIter` does.

This was left out in c59b188aaeadea32625534250d1f5120420be000
Related to #29377

2 years agoRollup merge of #92507 - chordtoll:suggest-single-quotes, r=petrochenkov
Matthias Krüger [Tue, 4 Jan 2022 15:34:17 +0000 (16:34 +0100)]
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.

2 years agoRollup merge of #92456 - danielhenrymantilla:patch-1, r=petrochenkov
Matthias Krüger [Tue, 4 Jan 2022 15:34:16 +0000 (16:34 +0100)]
Rollup merge of #92456 - danielhenrymantilla:patch-1, r=petrochenkov

Make the documentation of builtin macro attributes accessible

`use ::std::prelude::v1::derive;` compiles on stable, so, AFAIK, there is no reason to have it be `#[doc(hidden)]`.

  - What it currently looks like for things such as `#[test]`, `#[derive]`, `#[global_allocator]`: https://doc.rust-lang.org/1.57.0/core/prelude/v1/index.html#:~:text=Experimental-,pub,-use%20crate%3A%3Amacros%3A%3Abuiltin%3A%3Aglobal_allocator

    <img width="767" alt="Screen Shot 2021-12-31 at 17 49 46" src="https://user-images.githubusercontent.com/9920355/147832999-cbd747a6-4607-4df6-8e57-c1675dcbc1c3.png">

    and in `::std` they're just straight `hidden`.

    <img width="452" alt="Screen Shot 2021-12-31 at 17 53 18" src="https://user-images.githubusercontent.com/9920355/147833105-c5ff8cd1-9e4d-4d2b-9621-b36aa3cfcb28.png">

  - Here is how it looks like with this PR (assuming the `Rustc{De,En}codable` ones are not reverted):

    <img width="778" alt="Screen Shot 2021-12-31 at 17 50 55" src="https://user-images.githubusercontent.com/9920355/147833034-84286342-dbf7-4e6e-9062-f39cd6c286a4.png">

    <img width="291" alt="Screen Shot 2021-12-31 at 17 52 54" src="https://user-images.githubusercontent.com/9920355/147833109-c92ed55c-51c6-40a2-9205-f834d1e349c0.png">

 Since this involves doc people to chime in, and since `jyn` is on vacation, I'll cc `@GuillaumeGomez` and tag the `rustdoc` team as well

2 years agoRollup merge of #92107 - nikic:rmeta-lnk-remove, r=nagisa
Matthias Krüger [Tue, 4 Jan 2022 15:34:15 +0000 (16:34 +0100)]
Rollup merge of #92107 - nikic:rmeta-lnk-remove, r=nagisa

Actually set IMAGE_SCN_LNK_REMOVE for .rmeta

The code intended to set the IMAGE_SCN_LNK_REMOVE flag for the
.rmeta section, however the value of this flag was set to zero.
Instead use the actual value provided by the object crate.

This dates back to the original introduction of this code in
PR #84449, so we were never setting this flag. As I'm not on
Windows, I'm not sure whether that means we were embedding .rmeta
into executables, or whether the section ended up getting stripped
for some other reason.

2 years agoRollup merge of #91884 - woppopo:const_box, r=oli-obk
Matthias Krüger [Tue, 4 Jan 2022 15:34:14 +0000 (16:34 +0100)]
Rollup merge of #91884 - woppopo:const_box, r=oli-obk

Constify `Box<T, A>` methods

Tracking issue: none yet

Most of the methods bounded on `~const`. `intrinsics::const_eval_select` is used for handling an allocation error.

<details><summary>Constified API</summary>

```rust
impl<T, A: Allocator> Box<T, A> {
    pub const fn new_in(x: T, alloc: A) -> Self
    where
        A: ~const Allocator + ~const Drop;
    pub const fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
    where
        T: ~const Drop,
        A: ~const Allocator + ~const Drop;
    pub const fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
    where
        A: ~const Allocator + ~const Drop;
    pub const fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
    where
        A: ~const Allocator + ~const Drop;
    pub const fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
    where
        A: ~const Allocator + ~const Drop;
    pub const fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
    where
        A: ~const Allocator + ~const Drop;
    pub const fn pin_in(x: T, alloc: A) -> Pin<Self>
    where
        A: 'static,
        A: 'static + ~const Allocator + ~const Drop,
    pub const fn into_boxed_slice(boxed: Self) -> Box<[T], A>;
    pub const fn into_inner(boxed: Self) -> T
    where
        Self: ~const Drop,
}

impl<T, A: Allocator> Box<MaybeUninit<T>, A> {
    pub const unsafe fn assume_init(self) -> Box<T, A>;
    pub const fn write(mut boxed: Self, value: T) -> Box<T, A>;
    pub const unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self;
    pub const fn into_raw_with_allocator(b: Self) -> (*mut T, A);
    pub const fn into_unique(b: Self) -> (Unique<T>, A);
    pub const fn allocator(b: &Self) -> &A;
    pub const fn leak<'a>(b: Self) -> &'a mut T
    where
        A: 'a;
    pub const fn into_pin(boxed: Self) -> Pin<Self>
    where
        A: 'static;
}

unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> const Drop for Box<T, A>;
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
where
    A: 'static;
impl<T: ?Sized, A: Allocator> const Deref for Box<T, A>;
impl<T: ?Sized, A: Allocator> const DerefMut for Box<T, A>;
impl<T: ?Sized, A: Allocator> const Unpin for Box<T, A> where A: 'static;
```

</details>

<details><summary>Example</summary>

```rust
pub struct ConstAllocator;

unsafe impl const Allocator for ConstAllocator {
    fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
        unsafe {
            let ptr = core::intrinsics::const_allocate(layout.size(), layout.align());
            Ok(NonNull::new_unchecked(ptr as *mut [u8; 0] as *mut [u8]))
        }
    }

    unsafe fn deallocate(&self, _ptr: NonNull<u8>, _layout: Layout) {
        /* do nothing */
    }

    fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
        self.allocate(layout)
    }

    unsafe fn grow(
        &self,
        _ptr: NonNull<u8>,
        _old_layout: Layout,
        _new_layout: Layout,
    ) -> Result<NonNull<[u8]>, AllocError> {
        unimplemented!()
    }

    unsafe fn grow_zeroed(
        &self,
        _ptr: NonNull<u8>,
        _old_layout: Layout,
        _new_layout: Layout,
    ) -> Result<NonNull<[u8]>, AllocError> {
        unimplemented!()
    }

    unsafe fn shrink(
        &self,
        _ptr: NonNull<u8>,
        _old_layout: Layout,
        _new_layout: Layout,
    ) -> Result<NonNull<[u8]>, AllocError> {
        unimplemented!()
    }

    fn by_ref(&self) -> &Self
    where
        Self: Sized,
    {
        self
    }
}

#[test]
fn const_box() {
    const VALUE: u32 = {
        let mut boxed = Box::new_in(1u32, ConstAllocator);
        assert!(*boxed == 1);

        *boxed = 42;
        assert!(*boxed == 42);

        *boxed
    };

    assert!(VALUE == 42);
}
```

</details>

2 years agoRollup merge of #91754 - Patrick-Poitras:rm-4byte-minimum-stdio-windows, r=Mark-Simul...
Matthias Krüger [Tue, 4 Jan 2022 15:34:14 +0000 (16:34 +0100)]
Rollup merge of #91754 - Patrick-Poitras:rm-4byte-minimum-stdio-windows, r=Mark-Simulacrum

Modifications to `std::io::Stdin` on Windows so that there is no longer a 4-byte buffer minimum in read().

This is an attempted fix of issue #91722, where a too-small buffer was passed to the read function of stdio on Windows. This caused an error to be returned when `read_to_end` or `read_to_string` were called. Both delegate to `std::io::default_read_to_end`, which creates a buffer that is of length >0, and forwards it to `std::io::Stdin::read()`. The latter method returns an error if the length of the buffer is less than 4, as there might not be enough space to allocate a UTF-16 character. This creates a problem when the buffer length is in `0 < N < 4`, causing the bug.

The current modification creates an internal buffer, much like the one used for the write functions

I'd also like to acknowledge the help of ``@agausmann`` and ``@hkratz`` in detecting and isolating the bug, and for suggestions that made the fix possible.

Couple disclaimers:

- Firstly, I didn't know where to put code to replicate the bug found in the issue. It would probably be wise to add that case to the testing suite, but I'm afraid that I don't know _where_ that test should be added.
- Secondly, the code is fairly fundamental to IO operations, so my fears are that this may cause some undesired side effects ~or performance loss in benchmarks.~ The testing suite runs on my computer, and it does fix the issue noted in #91722.
- Thirdly, I left the "surrogate" field in the Stdin struct, but from a cursory glance, it seems to be serving the same purpose for other functions. Perhaps merging the two would be appropriate.

Finally, this is my first pull request to the rust language, and as such some things may be weird/unidiomatic/plain out bad. If there are any obvious improvements I could do to the code, or any other suggestions, I would appreciate them.

Edit: Closes #91722

2 years agorename StackPopClean::None to Root
Ralf Jung [Mon, 3 Jan 2022 22:07:07 +0000 (23:07 +0100)]
rename StackPopClean::None to Root

2 years agoMake rustc_log doc test runnable
David Tolnay [Tue, 4 Jan 2022 06:01:35 +0000 (22:01 -0800)]
Make rustc_log doc test runnable

2 years agoSuggest changing quotes when str/char type mismatch
chordtoll [Sat, 1 Jan 2022 21:32:04 +0000 (13:32 -0800)]
Suggest changing quotes when str/char type mismatch

2 years agoStabilize `result_cloned` and `result_copied`
ksqsf [Sun, 19 Dec 2021 08:59:39 +0000 (16:59 +0800)]
Stabilize `result_cloned` and `result_copied`

2 years agoJustify why rustc_log exists
David Tolnay [Tue, 4 Jan 2022 04:23:59 +0000 (20:23 -0800)]
Justify why rustc_log exists

2 years agoUpdate books
Eric Huss [Tue, 4 Jan 2022 03:45:10 +0000 (19:45 -0800)]
Update books

2 years agoExtract init_env_logger to crate
David Tolnay [Tue, 4 Jan 2022 00:32:52 +0000 (16:32 -0800)]
Extract init_env_logger to crate

2 years agoAuto merge of #92259 - Aaron1011:normal-mod-hashing, r=michaelwoerister
bors [Tue, 4 Jan 2022 00:25:23 +0000 (00:25 +0000)]
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`.

2 years agoTweak the usage messages for `x.py build` and `x.py check`.
Nicholas Nethercote [Tue, 21 Dec 2021 23:29:49 +0000 (10:29 +1100)]
Tweak the usage messages for `x.py build` and `x.py check`.

They're a bit out of date, and overly complicated.

2 years agoLabel more build steps.
Nicholas Nethercote [Tue, 21 Dec 2021 19:41:26 +0000 (06:41 +1100)]
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.

2 years agoAuto merge of #92314 - Kobzol:encoding-u16-leb128, r=michaelwoerister
bors [Mon, 3 Jan 2022 20:30:23 +0000 (20:30 +0000)]
Auto merge of #92314 - Kobzol:encoding-u16-leb128, r=michaelwoerister

Do not use LEB128 for encoding u16 and i16

An experiment to try out the suggestion from https://github.com/rust-lang/rust/issues/68779.

Closes: https://github.com/rust-lang/rust/issues/68779
2 years agoMake the documentation of builtin macro attributes accessible
Daniel Henry-Mantilla [Fri, 31 Dec 2021 12:32:03 +0000 (13:32 +0100)]
Make the documentation of builtin macro attributes accessible

  - Do not `#[doc(hidden)]` the `#[derive]` macro attribute

  - Add a link to the reference section to `derive`'s inherent docs

  - Do the same for `#[test]` and `#[global_allocator]`

  - Fix `GlobalAlloc` link (why is it on `core` and not `alloc`?)

  - Try `no_inline`-ing the `std` reexports from `core`

  - Revert "Try `no_inline`-ing the `std` reexports from `core`"

  - Address PR review

  - Also document the unstable macros

2 years agorevert #92254 "Bump gsgdt to 0.1.3"
Krasimir Georgiev [Mon, 3 Jan 2022 19:25:46 +0000 (20:25 +0100)]
revert #92254 "Bump gsgdt to 0.1.3"

gsgdt 0.1.3 was yanked:
https://github.com/rust-lang/rust/pull/92254#issuecomment-1004269481

2 years agoMove `contains` method of Option and Result lower in docs
David Tolnay [Mon, 3 Jan 2022 18:46:15 +0000 (10:46 -0800)]
Move `contains` method of Option and Result lower in docs

2 years agoMake `Receiver::into_iter` into a clickable link
zohnannor [Mon, 3 Jan 2022 17:17:57 +0000 (20:17 +0300)]
Make `Receiver::into_iter` into a clickable link

The documentation on `std::sync::mpsc::Iter` and `std::sync::mpsc::TryIter` provides links to the corresponding `Receiver` methods, unlike `std::sync::mpsc::IntoIter` does.

This was left out in c59b188aaeadea32625534250d1f5120420be000
Related to #29377

2 years agoFix a compile error when no_global_oom_handling
woppopo [Mon, 3 Jan 2022 16:37:53 +0000 (01:37 +0900)]
Fix a compile error when no_global_oom_handling

2 years agoAdd tracking issues (`const_box`, `const_alloc_error`)
woppopo [Mon, 3 Jan 2022 15:35:53 +0000 (00:35 +0900)]
Add tracking issues (`const_box`, `const_alloc_error`)