]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoupdate miri
Ralf Jung [Thu, 20 May 2021 20:05:08 +0000 (22:05 +0200)]
update miri

3 years agoAuto merge of #85493 - Amanieu:fix_85446, r=dtolnay
bors [Thu, 20 May 2021 15:49:31 +0000 (15:49 +0000)]
Auto merge of #85493 - Amanieu:fix_85446, r=dtolnay

Update stdarch to fix x86 byte shift intrinsics

Fixes #85446

3 years agoAuto merge of #84665 - adamgemmell:aarch64-features, r=Amanieu
bors [Thu, 20 May 2021 13:07:35 +0000 (13:07 +0000)]
Auto merge of #84665 - adamgemmell:aarch64-features, r=Amanieu

Update list of allowed aarch64 features

I recently added these features to std_detect for aarch64 linux, pending [review](https://github.com/rust-lang/stdarch/pull/1146).

I have commented any features not supported by LLVM 9, the current minimum version for Rust. Some (PAuth at least) were renamed between 9 & 12 and I've left them disabled. TME, however, is not in LLVM 9 but I've left it enabled.

See https://github.com/rust-lang/stdarch/issues/993

3 years agoAuto merge of #85486 - RalfJung:rollup-4ibcxuu, r=RalfJung
bors [Thu, 20 May 2021 07:39:24 +0000 (07:39 +0000)]
Auto merge of #85486 - RalfJung:rollup-4ibcxuu, r=RalfJung

Rollup of 8 pull requests

Successful merges:

 - #84717 (impl FromStr for proc_macro::Literal)
 - #85169 (Add method-toggle to <details> for methods)
 - #85287 (Expose `Concurrent` (private type in public i'face))
 - #85315 (adding time complexity for partition_in_place iter method)
 - #85439 (Add diagnostic item to `CStr`)
 - #85464 (Fix UB in documented example for `ptr::swap`)
 - #85470 (Fix invalid CSS rules for a:hover)
 - #85472 (CTFE Machine: do not expose Allocation)

Failed merges:

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

3 years agoAuto merge of #84697 - CDirkx:util, r=m-ou-se
bors [Thu, 20 May 2021 04:58:13 +0000 (04:58 +0000)]
Auto merge of #84697 - CDirkx:util, r=m-ou-se

Introduce `sys_common::rt::rtprintpanic!` to replace `sys_common::util` functionality

This PR introduces a new macro `rtprintpanic!`, similar to `sys_common::util::dumb_print` and uses that macro to replace all `sys_common::util` functionality.

3 years agoAuto merge of #85391 - Mark-Simulacrum:opt-tostring, r=scottmcm
bors [Thu, 20 May 2021 00:55:27 +0000 (00:55 +0000)]
Auto merge of #85391 - Mark-Simulacrum:opt-tostring, r=scottmcm

Avoid zero-length memcpy in formatting

This has two separate and somewhat orthogonal commits. The first change adjusts the ToString general impl for all types that implement Display; it no longer uses the full format machinery, rather directly falling onto a `std::fmt::Display::fmt` call. The second change directly adjusts the general core::fmt::write function which handles the production of format_args! to avoid zero-length push_str calls.

Both changes target the fact that push_str will still call memmove internally (or a similar function), as it doesn't know the length of the passed string. For zero-length strings in particular, this is quite expensive, and even for very short (several bytes long) strings, this is also expensive. Future work in this area may wish to have us fallback to write_char or similar, which may be cheaper on the (typically) short strings between the interpolated pieces in format_args!.

3 years agoUpdate stdarch to fix x86 byte shift intrinsics
Amanieu d'Antras [Thu, 20 May 2021 00:51:05 +0000 (01:51 +0100)]
Update stdarch to fix x86 byte shift intrinsics

Fixes #85446

3 years agoRollup merge of #85472 - RalfJung:allocation, r=oli-obk
Ralf Jung [Wed, 19 May 2021 22:19:09 +0000 (00:19 +0200)]
Rollup merge of #85472 - RalfJung:allocation, r=oli-obk

CTFE Machine: do not expose Allocation

`Memory` is careful now to not expose direct access to `Allocation`, but this one slipped through.
r? ``@oli-obk``

3 years agoRollup merge of #85470 - GuillaumeGomez:fix-css-rules, r=jsha
Ralf Jung [Wed, 19 May 2021 22:19:08 +0000 (00:19 +0200)]
Rollup merge of #85470 - GuillaumeGomez:fix-css-rules, r=jsha

Fix invalid CSS rules for a:hover

When hovering some links:

![Screenshot from 2021-05-19 15-00-31](https://user-images.githubusercontent.com/3050060/118823585-5f2a4b80-b8b9-11eb-8043-bb7759a178c7.png)
![Screenshot from 2021-05-19 15-00-29](https://user-images.githubusercontent.com/3050060/118823566-5b96c480-b8b9-11eb-8c4e-08e490752fbf.png)

It is a side-effect from #84462.

r? ```@jsha```

3 years agoRollup merge of #85464 - steffahn:fix_ub_in_ptr_swap_docs, r=dtolnay
Ralf Jung [Wed, 19 May 2021 22:19:08 +0000 (00:19 +0200)]
Rollup merge of #85464 - steffahn:fix_ub_in_ptr_swap_docs, r=dtolnay

Fix UB in documented example for `ptr::swap`

Compare [this (short) discussion on zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Pointers.20to.20overlapping.20arrays) (or [in the archive](https://zulip-archive.rust-lang.org/122651general/92017Pointerstooverlappingarrays.html), if you don’t have an account).

``@rustbot`` label T-doc T-libs

3 years agoRollup merge of #85439 - mgacek8:add_diagnostic_item_to_CStr_type, r=davidtwco
Ralf Jung [Wed, 19 May 2021 22:19:07 +0000 (00:19 +0200)]
Rollup merge of #85439 - mgacek8:add_diagnostic_item_to_CStr_type, r=davidtwco

Add diagnostic item to `CStr`

Required for clippy issue: https://github.com/rust-lang/rust-clippy/issues/7145

3 years agoRollup merge of #85315 - satylogin:master, r=yaahc
Ralf Jung [Wed, 19 May 2021 22:19:02 +0000 (00:19 +0200)]
Rollup merge of #85315 - satylogin:master, r=yaahc

adding time complexity for partition_in_place iter method

I feel that one thing missing from rust docs compared to cpp references is existence of time complexity for all methods and functions. While it would be humongous task to include it for everything in single go, it is still doable if we as community keep on adding it in relevant places as and when we find them.

This PR adds the time complexity for partition_in_place method in iter.

3 years agoRollup merge of #85287 - eggyal:expose-test-concurrent, r=m-ou-se
Ralf Jung [Wed, 19 May 2021 22:18:58 +0000 (00:18 +0200)]
Rollup merge of #85287 - eggyal:expose-test-concurrent, r=m-ou-se

Expose `Concurrent` (private type in public i'face)

#53410 introduced experimental support for custom test frameworks.

Such frameworks may wish to build upon `library/test` by calling into its publicly exposed API (which I entirely understand is wholly unstable).  However, any that wish to call `test::run_test` cannot currently do so because `test::options::Concurrent` (the type of its `concurrent` parameter) is not publicly exposed.

3 years agoRollup merge of #85169 - jsha:hoist-classes, r=GuillaumeGomez
Ralf Jung [Wed, 19 May 2021 22:18:57 +0000 (00:18 +0200)]
Rollup merge of #85169 - jsha:hoist-classes, r=GuillaumeGomez

Add method-toggle to <details> for methods

The makes the code for handling "auto-hide" settings more consistent.

Demo at https://hoffman-andrews.com/rust/hoist-classes/std/string/struct.String.html

Fixes #84829

3 years agoRollup merge of #84717 - dtolnay:literalfromstr, r=petrochenkov
Ralf Jung [Wed, 19 May 2021 22:18:56 +0000 (00:18 +0200)]
Rollup merge of #84717 - dtolnay:literalfromstr, r=petrochenkov

impl FromStr for proc_macro::Literal

Note that unlike `impl FromStr for proc_macro::TokenStream`, this impl does not permit whitespace or comments. The input string must consist of nothing but your literal.

- `"1".parse::<Literal>()` ⟶ ok

- `"1.0".parse::<Literal>()` ⟶ ok

- `"'a'".parse::<Literal>()` ⟶ ok

- `"\"\n\"".parse::<Literal>()` ⟶ ok

- `"0 1".parse::<Literal>()` ⟶ LexError

- `" 0".parse::<Literal>()` ⟶ LexError

- `"0 ".parse::<Literal>()` ⟶ LexError

- `"/* comment */0".parse::<Literal>()` ⟶ LexError

- `"0/* comment */".parse::<Literal>()` ⟶ LexError

- `"0// comment".parse::<Literal>()` ⟶ LexError

---

## Use case

```rust
let hex_int: Literal = format!("0x{:x}", int).parse().unwrap();
```

The only way this is expressible in the current API is significantly worse.

```rust
let hex_int = match format!("0x{:x}", int)
    .parse::<TokenStream>()
    .unwrap()
    .into_iter()
    .next()
    .unwrap()
{
    TokenTree::Literal(literal) => literal,
    _ => unreachable!(),
};
```

3 years agoAuto merge of #85340 - the8472:no-inplaceiterable-on-peekable, r=yaahc
bors [Wed, 19 May 2021 21:50:45 +0000 (21:50 +0000)]
Auto merge of #85340 - the8472:no-inplaceiterable-on-peekable, r=yaahc

remove InPlaceIterable marker from Peekable due to unsoundness

The unsoundness is not in Peekable per se, it rather is due to the
interaction between Peekable being able to hold an extra item
and vec::IntoIter's clone implementation shortening the allocation.

An alternative solution would be to change IntoIter's clone implementation
to keep enough spare capacity available.

fixes #85322

3 years agoAuto merge of #83842 - LeSeulArtichaut:thir-vec, r=nikomatsakis
bors [Wed, 19 May 2021 18:41:23 +0000 (18:41 +0000)]
Auto merge of #83842 - LeSeulArtichaut:thir-vec, r=nikomatsakis

Store THIR in `IndexVec`s instead of an `Arena`

This is a necessary step to store the THIR in a query: #85273. See [relevant discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/278509-project-thir-unsafeck/topic/THIR-dependent.20queries.20design).

r? `@ghost` cc `@cjgillot` `@nikomatsakis`

3 years agoimpl FromStr for proc_macro::Literal
David Tolnay [Thu, 29 Apr 2021 19:08:35 +0000 (12:08 -0700)]
impl FromStr for proc_macro::Literal

3 years agoAdd proc macro Literal parse test
David Tolnay [Thu, 29 Apr 2021 19:03:35 +0000 (12:03 -0700)]
Add proc macro Literal parse test

3 years agoMake a more meaningful test for Punct eq
David Tolnay [Thu, 29 Apr 2021 18:20:27 +0000 (11:20 -0700)]
Make a more meaningful test for Punct eq

3 years agoMove proc_macro tests to ui test
David Tolnay [Thu, 29 Apr 2021 18:17:44 +0000 (11:17 -0700)]
Move proc_macro tests to ui test

3 years agoMake a ui test to take the role of libproc_macro #[test] tests
David Tolnay [Thu, 29 Apr 2021 18:10:14 +0000 (11:10 -0700)]
Make a ui test to take the role of libproc_macro #[test] tests

3 years agoAuto merge of #84876 - alexcrichton:inline-thread-locals-cross-crate, r=Mark-Simulacrum
bors [Wed, 19 May 2021 15:59:46 +0000 (15:59 +0000)]
Auto merge of #84876 - alexcrichton:inline-thread-locals-cross-crate, r=Mark-Simulacrum

std: Attempt again to inline thread-local-init across crates

Issue #25088 has been part of `thread_local!` for quite some time now.
Historical attempts have been made to add `#[inline]` to `__getit`
in #43931, #50252, and #59720, but these attempts ended up not landing
at the time due to segfaults on Windows.

In the interim though with `const`-initialized thread locals AFAIK this
is the only remaining bug which is why you might want to use
`#[thread_local]` over `thread_local!`. As a result I figured it was
time to resubmit this and see how it fares on CI and if I can help
debugging any issues that crop up.

Closes #25088

3 years agoRemove test for crypto feature ahead of its removal
Adam Gemmell [Wed, 19 May 2021 15:13:52 +0000 (16:13 +0100)]
Remove test for crypto feature ahead of its removal

3 years agoEnsure all crypto components (AES, PMULL, SHA1/2) are available on arm/aarch64
Adam Gemmell [Wed, 19 May 2021 15:13:23 +0000 (16:13 +0100)]
Ensure all crypto components (AES, PMULL, SHA1/2) are available on arm/aarch64

3 years agoRename fptoint to frintts
Adam Gemmell [Wed, 19 May 2021 15:12:30 +0000 (16:12 +0100)]
Rename fptoint to frintts

3 years agoRemove LSE2
Adam Gemmell [Wed, 19 May 2021 15:11:11 +0000 (16:11 +0100)]
Remove LSE2

3 years agoCTFE Machine: do not expose Allocation
Ralf Jung [Wed, 19 May 2021 14:37:17 +0000 (16:37 +0200)]
CTFE Machine: do not expose Allocation

3 years agoAdapt the THIR visitor to the vec-stored THIR
LeSeulArtichaut [Thu, 13 May 2021 20:01:25 +0000 (22:01 +0200)]
Adapt the THIR visitor to the vec-stored THIR

3 years agoStore THIR in `IndexVec`s instead of an `Arena`
LeSeulArtichaut [Sat, 3 Apr 2021 17:58:46 +0000 (19:58 +0200)]
Store THIR in `IndexVec`s instead of an `Arena`

3 years agoRename `rterr` to `rtprintpanic`
Christiaan Dirkx [Thu, 6 May 2021 12:03:50 +0000 (14:03 +0200)]
Rename `rterr` to `rtprintpanic`

3 years agoFix invalid CSS rules for a:hover
Guillaume Gomez [Wed, 19 May 2021 13:37:10 +0000 (15:37 +0200)]
Fix invalid CSS rules for a:hover

3 years agoReplace `sys_common::util::dumb_print` with `rterr!`
Christiaan Dirkx [Thu, 29 Apr 2021 14:10:32 +0000 (16:10 +0200)]
Replace `sys_common::util::dumb_print` with `rterr!`

3 years agoReplace `sys_common::util::report_overflow` with `rterr!`
Christiaan Dirkx [Thu, 29 Apr 2021 14:05:10 +0000 (16:05 +0200)]
Replace `sys_common::util::report_overflow` with `rterr!`

3 years agoRemove `sys_common::util::abort`
Christiaan Dirkx [Thu, 29 Apr 2021 13:59:05 +0000 (15:59 +0200)]
Remove `sys_common::util::abort`

3 years agoIntroduce `sys_common::rt::rterr!`
Christiaan Dirkx [Thu, 29 Apr 2021 13:57:05 +0000 (15:57 +0200)]
Introduce `sys_common::rt::rterr!`

3 years agoFix UB in documented example for `ptr::swap`
Frank Steffahn [Wed, 19 May 2021 10:33:10 +0000 (12:33 +0200)]
Fix UB in documented example for `ptr::swap`

3 years agoAuto merge of #85376 - RalfJung:ptrless-allocs, r=oli-obk
bors [Wed, 19 May 2021 10:11:28 +0000 (10:11 +0000)]
Auto merge of #85376 - RalfJung:ptrless-allocs, r=oli-obk

CTFE core engine allocation & memory API improvemenets

This is a first step towards https://github.com/rust-lang/miri/issues/841.
- make `Allocation` API offset-based (no more making up `Pointer`s just to access an `Allocation`)
- make `Memory` API higher-level (combine checking for access and getting access into one operation)

The Miri-side PR is at https://github.com/rust-lang/miri/pull/1804.
r? `@oli-obk`

3 years agoAuto merge of #85276 - Bobo1239:more_dso_local, r=nagisa
bors [Wed, 19 May 2021 07:25:17 +0000 (07:25 +0000)]
Auto merge of #85276 - Bobo1239:more_dso_local, r=nagisa

Set dso_local for more items

Related to https://github.com/rust-lang/rust/pull/83592. (cc `@nagisa)`

Noticed that on x86_64 with `relocation-model: static` `R_X86_64_GOTPCREL` relocations were still generated in some cases. (related: https://github.com/Rust-for-Linux/linux/issues/135; Rust-for-Linux needs these fixes to successfully build)

First time doing anything with LLVM so not sure whether this is correct but the following are some of the things I've tried to convince myself.

## C equivalent

Example from clang which also sets `dso_local` in these cases:
`clang-12 -fno-PIC -S -emit-llvm test.c`
```C
extern int A;

int* a() {
    return &A;
}

int B;

int* b() {
    return &B;
}
```
```
; ModuleID = 'test.c'
source_filename = "test.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

`@A` = external dso_local global i32, align 4
`@B` = dso_local global i32 0, align 4

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32* `@a()` #0 {
  ret i32* `@A`
}

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32* `@b()` #0 {
  ret i32* `@B`
}

attributes #0 = { noinline nounwind optnone uwtable "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project/ b978a93635b584db380274d7c8963c73989944a1)"}
```
`clang-12 -fno-PIC -c test.c`
`objdump test.o -r`:
```
test.o:     file format elf64-x86-64

RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE
0000000000000006 R_X86_64_64       A
0000000000000016 R_X86_64_64       B

RELOCATION RECORDS FOR [.eh_frame]:
OFFSET           TYPE              VALUE
0000000000000020 R_X86_64_PC32     .text
0000000000000040 R_X86_64_PC32     .text+0x0000000000000010
```

## Comparison to pre-LLVM 12 output

`rustc --emit=obj,llvm-ir --target=x86_64-unknown-none-linuxkernel --crate-type rlib test.rs`
```Rust
#![feature(no_core, lang_items)]
#![no_core]

#[lang="sized"]
trait Sized {}

#[lang="sync"]
trait Sync {}

#[lang = "drop_in_place"]
pub unsafe fn drop_in_place<T: ?Sized>(_: *mut T) {}

impl Sync for i32 {}

pub static STATIC: i32 = 32;

extern {
    pub static EXT_STATIC: i32;
}

pub fn a() -> &'static i32 {
    &STATIC
}
pub fn b() -> &'static i32 {
    unsafe {&EXT_STATIC}
}
```
`objdump test.o -r`
nightly-2021-02-20 (rustc target is `x86_64-linux-kernel`):
```
RELOCATION RECORDS FOR [.text._ZN4test1a17h1024ba65f3424175E]:
OFFSET           TYPE              VALUE
0000000000000007 R_X86_64_32S      _ZN4test6STATIC17h3adc41a83746c9ffE

RELOCATION RECORDS FOR [.text._ZN4test1b17h86a6a80c1190ac8dE]:
OFFSET           TYPE              VALUE
0000000000000007 R_X86_64_32S      EXT_STATIC
```
nightly-2021-05-10:
```
RELOCATION RECORDS FOR [.text._ZN4test1a17he846f03bf37b2d20E]:
OFFSET           TYPE              VALUE
0000000000000007 R_X86_64_GOTPCREL  _ZN4test6STATIC17h5a059515bf3d4968E-0x0000000000000004

RELOCATION RECORDS FOR [.text._ZN4test1b17h7e0f7f80fbd91125E]:
OFFSET           TYPE              VALUE
0000000000000007 R_X86_64_GOTPCREL  EXT_STATIC-0x0000000000000004
```
This PR:
```
RELOCATION RECORDS FOR [.text._ZN4test1a17he846f03bf37b2d20E]:
OFFSET           TYPE              VALUE
0000000000000007 R_X86_64_32S      _ZN4test6STATIC17h5a059515bf3d4968E

RELOCATION RECORDS FOR [.text._ZN4test1b17h7e0f7f80fbd91125E]:
OFFSET           TYPE              VALUE
0000000000000007 R_X86_64_32S      EXT_STATIC
```

3 years agoAuto merge of #85458 - jackh726:rollup-zvvybmt, r=jackh726
bors [Wed, 19 May 2021 04:44:09 +0000 (04:44 +0000)]
Auto merge of #85458 - jackh726:rollup-zvvybmt, r=jackh726

Rollup of 8 pull requests

Successful merges:

 - #83366 (Stabilize extended_key_value_attributes)
 - #83767 (Fix v0 symbol mangling bug)
 - #84883 (compiletest: "fix" FileCheck with --allow-unused-prefixes)
 - #85274 (Only pass --[no-]gc-sections if linker is GNU ld.)
 - #85297 (bootstrap: build cargo only if requested in tools)
 - #85396 (rustdoc: restore header sizes)
 - #85425 (Fix must_use on `Option::is_none`)
 - #85438 (Fix escape handling)

Failed merges:

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

3 years agoRollup merge of #85438 - GuillaumeGomez:fix-escape-handling, r=jsha
Jack Huey [Wed, 19 May 2021 02:36:19 +0000 (22:36 -0400)]
Rollup merge of #85438 - GuillaumeGomez:fix-escape-handling, r=jsha

Fix escape handling

Currently, when we press Escape while on the search results, nothing is happening, this PR fixes it.

More information: it's because in case the element doesn't exist, `hasClass` will return `null`, which coerces into `false` with the `!` comparison operator. But even if it returned `false`, it would still be an issue because if the element doesn't exist, it means it's hidden so in this case it's just as good, hence the additional check I added.

r? ``@jsha``

3 years agoRollup merge of #85425 - mbartlett21:patch-1, r=scottmcm
Jack Huey [Wed, 19 May 2021 02:36:18 +0000 (22:36 -0400)]
Rollup merge of #85425 - mbartlett21:patch-1, r=scottmcm

Fix must_use on `Option::is_none`

This fixes the `#[must_use = ...]` on `Option::is_none` to have a working suggestion.

3 years agoRollup merge of #85396 - jsha:top-doc-font-sizes, r=GuillaumeGomez
Jack Huey [Wed, 19 May 2021 02:36:13 +0000 (22:36 -0400)]
Rollup merge of #85396 - jsha:top-doc-font-sizes, r=GuillaumeGomez

rustdoc: restore header sizes

The `<details>` toggle work changed the relationship from #main to the top-doc docblock so it was no longer a parent relationship but a great-grandparent relationship. This updates the CSS rules that set the heading sizes so they still apply.

Fixes #85389

r? ``@camelid``

3 years agoRollup merge of #85297 - infinity0:master, r=Mark-Simulacrum
Jack Huey [Wed, 19 May 2021 02:36:08 +0000 (22:36 -0400)]
Rollup merge of #85297 - infinity0:master, r=Mark-Simulacrum

bootstrap: build cargo only if requested in tools

In Debian we'd like to build rustfmt and clippy alongside rustc, but we're still excluding cargo from the rustc build and doing that separately. This patch makes that possible.

3 years agoRollup merge of #85274 - luqmana:linker-is-gnu-gc-sections, r=petrochenkov
Jack Huey [Wed, 19 May 2021 02:36:04 +0000 (22:36 -0400)]
Rollup merge of #85274 - luqmana:linker-is-gnu-gc-sections, r=petrochenkov

Only pass --[no-]gc-sections if linker is GNU ld.

Fixes a regression from #84468 where linking now fails with solaris linkers. LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the case of at least the solaris ld in illumos, that flag is unrecognized and will cause the linking step to fail.

Even though removing the `is_like_solaris` branch from `gc_sections` in #84468 made sense as `-z ignore/record` are more analogous to the `--[no-]-as-needed` flags, it inadvertently caused solaris linkers to be passed the `--gc-sections` flag. So let's just change it to be more explicit about when we pass those flags.

3 years agoRollup merge of #84883 - durin42:allow-unused-prefixes, r=nikic
Jack Huey [Wed, 19 May 2021 02:35:59 +0000 (22:35 -0400)]
Rollup merge of #84883 - durin42:allow-unused-prefixes, r=nikic

compiletest: "fix" FileCheck with --allow-unused-prefixes

The default of --allow-unused-prefixes used to be false, but in LLVM
change 87dbdd2e3b (https://reviews.llvm.org/D95849) the default became
true. I'm not quite sure how we could do better here (specifically not
providing the CHECK prefix when it's not needed), but this seems to work
for now.

This reduces codegen test failures against LLVM HEAD from 31 cases to 5.

3 years agoRollup merge of #83767 - camelid:mangle-v0-fix, r=nikomatsakis
Jack Huey [Wed, 19 May 2021 02:35:55 +0000 (22:35 -0400)]
Rollup merge of #83767 - camelid:mangle-v0-fix, r=nikomatsakis

Fix v0 symbol mangling bug

Fixes #83611.

r? ``@jackh726``

3 years agoRollup merge of #83366 - jyn514:stabilize-key-value-attrs, r=petrochenkov
Jack Huey [Wed, 19 May 2021 02:35:54 +0000 (22:35 -0400)]
Rollup merge of #83366 - jyn514:stabilize-key-value-attrs, r=petrochenkov

Stabilize extended_key_value_attributes

Closes https://github.com/rust-lang/rust/issues/44732. Closes https://github.com/rust-lang/rust/issues/78835. Closes https://github.com/rust-lang/rust/issues/82768 (by making it irrelevant).

 # Stabilization report

 ## Summary

This stabilizes using macro expansion in key-value attributes, like so:

 ```rust
 #[doc = include_str!("my_doc.md")]
 struct S;

 #[path = concat!(env!("OUT_DIR"), "/generated.rs")]
 mod m;
 ```

See Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455)
for alternatives that were considered and rejected ("why accept no more and no less?")

This has been available on nightly since 1.50 with no major issues.

## Notes

### Accepted syntax

The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`).  Note that decorators and the like may be able to observe other expression forms.

### Expansion ordering

Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input.

There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work).

## Test cases

 - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs
 - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs

The feature has also been dogfooded extensively in the compiler and
standard library:

- https://github.com/rust-lang/rust/pull/83329
- https://github.com/rust-lang/rust/pull/83230
- https://github.com/rust-lang/rust/pull/82641
- https://github.com/rust-lang/rust/pull/80534

## Implementation history

- Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412
- Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121
- Preliminary work to restrict expansion that would conflict with this
feature: https://github.com/rust-lang/rust/pull/77271
- Initial implementation: https://github.com/rust-lang/rust/pull/78837
- Fix for an ICE: https://github.com/rust-lang/rust/pull/80563

## Unresolved Questions

~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~

 ## Additional Information

 There are two workarounds that have a similar effect for `#[doc]`
attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons:

```rust
macro_rules! forward_inner_docs {
    ($e:expr => $i:item) => {
        #[doc = $e]
        $i
    };
}

forward_inner_docs!(include_str!("lib.rs") => struct S {});
```

This also works for other attributes (like `#[path = concat!(...)]`).
The other is to use `doc(include)`:

```rust
 #![feature(external_doc)]
 #[doc(include = "lib.rs")]
 struct S {}
```

The first works, but is non-trivial for people to discover, and
difficult to read and maintain. The second is a strange special-case for
a particular use of the macro. This generalizes it to work for any use
case, not just including files.

I plan to remove `doc(include)` when this is stabilized
(https://github.com/rust-lang/rust/pull/82539). The `forward_inner_docs`
workaround will still compile without warnings, but I expect it to be
used less once it's no longer necessary.

3 years agoAdd method-toggle to <details> for methods.
Jacob Hoffman-Andrews [Mon, 10 May 2021 23:41:41 +0000 (16:41 -0700)]
Add method-toggle to <details> for methods.

The makes the code for handling "auto-hide" settings more consistent.

3 years agoAuto merge of #85176 - a1phyr:impl_clone_from, r=yaahc
bors [Wed, 19 May 2021 02:17:41 +0000 (02:17 +0000)]
Auto merge of #85176 - a1phyr:impl_clone_from, r=yaahc

Override `clone_from` for some types

Override `clone_from` method of the `Clone` trait for:
- `cell::RefCell`
- `cmp::Reverse`
- `io::Cursor`
- `mem::ManuallyDrop`

This can bring performance improvements.

3 years agofrom review: more robust test
the8472 [Sun, 16 May 2021 13:35:05 +0000 (15:35 +0200)]
from review: more robust test

This also checks the contents and not only the capacity in case IntoIter's clone implementation is changed to add capacity at the end. Extra capacity at the beginning would be needed to make InPlaceIterable work.

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
3 years agoadd regression test
The8472 [Sat, 15 May 2021 18:41:15 +0000 (20:41 +0200)]
add regression test

3 years agoremove InPlaceIterable marker from Peekable due to unsoundness
The8472 [Sat, 15 May 2021 18:08:09 +0000 (20:08 +0200)]
remove InPlaceIterable marker from Peekable due to unsoundness

The unsoundness is not in Peekable per se, it rather is due to the
interaction between Peekable being able to hold an extra item
and vec::IntoIter's clone implementation shortening the allocation.

An alternative solution would be to change IntoIter's clone implementation
to keep enough spare capacity available.

3 years agoAuto merge of #84767 - scottmcm:try_trait_actual, r=lcnr
bors [Tue, 18 May 2021 20:50:01 +0000 (20:50 +0000)]
Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnr

Implement the new desugaring from `try_trait_v2`

~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix.

`try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277

Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them.  (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits.

r? `@ghost`

~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.

3 years agoNo matter how trivial the change, tidy always finds a way to complain...
Scott McMurray [Tue, 18 May 2021 18:48:00 +0000 (11:48 -0700)]
No matter how trivial the change, tidy always finds a way to complain...

3 years agoMention the issue number for the new mir-opt in the FIXMEs
scottmcm [Tue, 18 May 2021 18:29:34 +0000 (18:29 +0000)]
Mention the issue number for the new mir-opt in the FIXMEs

Thanks for the suggestions, lcnr!

Co-authored-by: lcnr <rust@lcnr.de>
3 years agostd: Attempt again to inline thread-local-init across crates
Alex Crichton [Mon, 3 May 2021 18:39:10 +0000 (11:39 -0700)]
std: Attempt again to inline thread-local-init across crates

Issue #25088 has been part of `thread_local!` for quite some time now.
Historical attempts have been made to add `#[inline]` to `__getit`
in #43931, #50252, and #59720, but these attempts ended up not landing
at the time due to segfaults on Windows.

In the interim though with `const`-initialized thread locals AFAIK this
is the only remaining bug which is why you might want to use
`#[thread_local]` over `thread_local!`. As a result I figured it was
time to resubmit this and see how it fares on CI and if I can help
debugging any issues that crop up.

Closes #25088

3 years agoSet dso_local for more items
Boris-Chengbiao Zhou [Fri, 14 May 2021 01:47:41 +0000 (03:47 +0200)]
Set dso_local for more items

3 years agoFix assembly test from #83592
Boris-Chengbiao Zhou [Thu, 13 May 2021 23:56:00 +0000 (01:56 +0200)]
Fix assembly test from #83592

The test case wasn't actually checked for x64 due to a small difference in the name.

3 years agoAuto merge of #85443 - RalfJung:rollup-d9gd64t, r=RalfJung
bors [Tue, 18 May 2021 18:04:47 +0000 (18:04 +0000)]
Auto merge of #85443 - RalfJung:rollup-d9gd64t, r=RalfJung

Rollup of 7 pull requests

Successful merges:

 - #84462 (rustdoc: use focus for search navigation)
 - #85251 (Make `const_generics_defaults` not an incomplete feature)
 - #85404 (Backport 1.52.1 release notes)
 - #85407 (Improve display for "copy-path" button, making it more discreet)
 - #85423 (Don't require cmake on Windows when LLVM isn't being built)
 - #85428 (Add x.py pre-setup instructions)
 - #85442 (fix typo)

Failed merges:

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

3 years agoRollup merge of #85442 - imjorge:patch-1, r=jonas-schievink
Ralf Jung [Tue, 18 May 2021 17:35:48 +0000 (19:35 +0200)]
Rollup merge of #85442 - imjorge:patch-1, r=jonas-schievink

fix typo

3 years agoRollup merge of #85428 - leebradley:add-xpy-presetup-instructions, r=Mark-Simulacrum
Ralf Jung [Tue, 18 May 2021 17:35:47 +0000 (19:35 +0200)]
Rollup merge of #85428 - leebradley:add-xpy-presetup-instructions, r=Mark-Simulacrum

Add x.py pre-setup instructions

This change adds pre-setup instructions that outline how x.py requires
python to be setup and how to work around the problem of x.py failing to
locate python, especially now that Ubuntu 20.04's dropped default python
command is causing people to encounter this issue regularly.

See also: #71818

3 years agoRollup merge of #85423 - jyn514:cmake, r=Mark-Simulacrum
Ralf Jung [Tue, 18 May 2021 17:35:46 +0000 (19:35 +0200)]
Rollup merge of #85423 - jyn514:cmake, r=Mark-Simulacrum

Don't require cmake on Windows when LLVM isn't being built

Previously, setting `download-ci-llvm = true` when cmake wasn't
installed would give the following error:

```
failed to execute command: "cmake" "--help"
error: The system cannot find the file specified. (os error 2)
```

3 years agoRollup merge of #85407 - GuillaumeGomez:copy-path-display-improvement, r=jsha
Ralf Jung [Tue, 18 May 2021 17:35:45 +0000 (19:35 +0200)]
Rollup merge of #85407 - GuillaumeGomez:copy-path-display-improvement, r=jsha

Improve display for "copy-path" button, making it more discreet

As suggested by `@Nemo157` [here](https://github.com/rust-lang/rust/pull/85118#issuecomment-838887670):

![Screenshot from 2021-05-18 11-18-49](https://user-images.githubusercontent.com/3050060/118626882-899ddb00-b7cb-11eb-84c5-ef68dee5e351.png)
![Screenshot from 2021-05-18 11-15-06](https://user-images.githubusercontent.com/3050060/118626880-899ddb00-b7cb-11eb-95c1-2f3bacd22374.png)
![Screenshot from 2021-05-18 11-18-54](https://user-images.githubusercontent.com/3050060/118626885-8a367180-b7cb-11eb-870c-7acdf4259bef.png)
![Screenshot from 2021-05-18 11-15-00](https://user-images.githubusercontent.com/3050060/118626877-89054480-b7cb-11eb-9efc-9a0f153964ce.png)
![Screenshot from 2021-05-18 11-18-58](https://user-images.githubusercontent.com/3050060/118626888-8a367180-b7cb-11eb-91bb-47867cd0f2cc.png)
![Screenshot from 2021-05-18 11-19-00](https://user-images.githubusercontent.com/3050060/118626891-8acf0800-b7cb-11eb-9e3d-d2937b361524.png)

r? `@jsha`

3 years agoRollup merge of #85404 - pietroalbini:relnotes-1.52.1, r=Mark-Simulacrum
Ralf Jung [Tue, 18 May 2021 17:35:44 +0000 (19:35 +0200)]
Rollup merge of #85404 - pietroalbini:relnotes-1.52.1, r=Mark-Simulacrum

Backport 1.52.1 release notes

This PR backports the 1.52.1 release notes to master, fixing https://github.com/rust-lang/rust/issues/85235.

r? `@Mark-Simulacrum`
`@rustbot` modify-labels: beta-accepted beta-nominated T-release

3 years agoRollup merge of #85251 - BoxyUwU:constparamdefaultsany%, r=lcnr
Ralf Jung [Tue, 18 May 2021 17:35:40 +0000 (19:35 +0200)]
Rollup merge of #85251 - BoxyUwU:constparamdefaultsany%, r=lcnr

Make `const_generics_defaults` not an incomplete feature

r? `@lcnr`

3 years agoRollup merge of #84462 - jsha:focus-search-results2, r=GuillaumeGomez
Ralf Jung [Tue, 18 May 2021 17:35:35 +0000 (19:35 +0200)]
Rollup merge of #84462 - jsha:focus-search-results2, r=GuillaumeGomez

rustdoc: use focus for search navigation

Rather than keeping track of highlighted element inside the JS, take advantage of `.focus()` and the :focus CSS pseudo-class.

This required wrapping each row of results in one big `<a>` tag (because anchors can be focused, but table rows cannot). That in turn required moving from a table layout to a div layout with float.

This makes it so Ctrl+Enter opens links in new tabs, and using the arrow keys to navigate off the bottom of the page scrolls the rest of the page into view. It also simplifies the keyboard event handling. It eliminates the need for click handlers on the search results, and for tracking mouse movements.

This changes the UI treatment of mouse hovering. A hovered element now gets a light grey background, but does not change the focus. It's possible to have two highlighted search results: one that is focused (via keyboard) and one that is hovered (via mouse). Pressing enter will activate the focused link; clicking will activate the hovered link. This matches up with how Firefox and Chrome handle suggestions in their URL bar, and avoids stray mouse movements changing the focus.

Selecting tabs is now done with left/right arrows while any search result is focused. The visibility of results on each search tab is
controlled with the "active" class, rather than by setting display: none directly. Note that the old code kept track of highlighted search element when tabbing back and forth. The new code doesn't.

Demo at https://hoffman-andrews.com/rust/focus-search-results2/std/?search=fn

Fixes #84384
Fixes #79962
Fixes #79872

3 years agofix mplace_access_checked with forced alignment
Ralf Jung [Mon, 17 May 2021 11:38:15 +0000 (13:38 +0200)]
fix mplace_access_checked with forced alignment

3 years agoadd Align::ONE; add methods to access alloc.extra
Ralf Jung [Mon, 17 May 2021 11:08:12 +0000 (13:08 +0200)]
add Align::ONE; add methods to access alloc.extra

3 years agoreduce number of allocation lookups during copy
Ralf Jung [Mon, 17 May 2021 09:29:49 +0000 (11:29 +0200)]
reduce number of allocation lookups during copy

3 years agoCTFE core engine allocation & memory API improvemenets
Ralf Jung [Sun, 16 May 2021 16:53:20 +0000 (18:53 +0200)]
CTFE core engine allocation & memory API improvemenets

- make Allocation API offset-based (no more Pointer)
- make Memory API higher-level (combine checking for access and getting access into one operation)

3 years agofix typo
Jorge Ferreira [Tue, 18 May 2021 16:05:40 +0000 (17:05 +0100)]
fix typo

3 years agoAuto merge of #85437 - GuillaumeGomez:rollup-3jcirty, r=GuillaumeGomez
bors [Tue, 18 May 2021 14:48:53 +0000 (14:48 +0000)]
Auto merge of #85437 - GuillaumeGomez:rollup-3jcirty, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #84587 (rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`))
 - #85280 (Toggle-wrap items differently than top-doc.)
 - #85338 (Implement more Iterator methods on core::iter::Repeat)
 - #85339 (Report an error if a lang item has the wrong number of generic arguments)
 - #85369 (Suggest borrowing if a trait implementation is found for &/&mut <type>)
 - #85393 (Suppress spurious errors inside `async fn`)
 - #85415 (Clean up remnants of BorrowOfPackedField)

Failed merges:

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

3 years agoAdd diagnostic item to `CStr`
Mateusz Gacek [Tue, 18 May 2021 13:33:38 +0000 (15:33 +0200)]
Add diagnostic item to `CStr`

3 years agoAdd GUI tests for escape handling
Guillaume Gomez [Tue, 18 May 2021 12:51:54 +0000 (14:51 +0200)]
Add GUI tests for escape handling

3 years agoFix escape handling on search results
Guillaume Gomez [Tue, 18 May 2021 12:32:20 +0000 (14:32 +0200)]
Fix escape handling on search results

3 years agoRollup merge of #85415 - LeSeulArtichaut:no-packed-borrow-unsafeck, r=RalfJung
Guillaume Gomez [Tue, 18 May 2021 12:08:57 +0000 (14:08 +0200)]
Rollup merge of #85415 - LeSeulArtichaut:no-packed-borrow-unsafeck, r=RalfJung

Clean up remnants of BorrowOfPackedField

cc #82525 which removed `BorrowOfPackedField` from unsafety-checking
r? `@RalfJung`

3 years agoRollup merge of #85393 - Aaron1011:async-type-err, r=varkor
Guillaume Gomez [Tue, 18 May 2021 12:08:56 +0000 (14:08 +0200)]
Rollup merge of #85393 - Aaron1011:async-type-err, r=varkor

Suppress spurious errors inside `async fn`

Fixes #73741

3 years agoRollup merge of #85369 - FabianWolff:issue-84973, r=jackh726
Guillaume Gomez [Tue, 18 May 2021 12:08:55 +0000 (14:08 +0200)]
Rollup merge of #85369 - FabianWolff:issue-84973, r=jackh726

Suggest borrowing if a trait implementation is found for &/&mut <type>

This pull request fixes #84973 by suggesting to borrow if a trait is not implemented for some type `T`, but it is for `&T` or `&mut T`. For instance:
```rust
trait Ti {}
impl<T> Ti for &T {}
fn foo<T: Ti>(_: T) {}

trait Tm {}
impl<T> Tm for &mut T {}
fn bar<T: Tm>(_: T) {}

fn main() {
    let a: i32 = 5;
    foo(a);

    let b: Box<i32> = Box::new(42);
    bar(b);
}
```
gives, on current nightly:
```
error[E0277]: the trait bound `i32: Ti` is not satisfied
  --> t2.rs:11:9
   |
3  | fn foo<T: Ti>(_: T) {}
   |           -- required by this bound in `foo`
...
11 |     foo(a);
   |         ^ the trait `Ti` is not implemented for `i32`

error[E0277]: the trait bound `Box<i32>: Tm` is not satisfied
  --> t2.rs:14:9
   |
7  | fn bar<T: Tm>(_: T) {}
   |           -- required by this bound in `bar`
...
14 |     bar(b);
   |         ^ the trait `Tm` is not implemented for `Box<i32>`

error: aborting due to 2 previous errors
```
whereas with my changes, I get:
```
error[E0277]: the trait bound `i32: Ti` is not satisfied
  --> t2.rs:11:9
   |
3  | fn foo<T: Ti>(_: T) {}
   |           -- required by this bound in `foo`
...
11 |     foo(a);
   |         ^
   |         |
   |         expected an implementor of trait `Ti`
   |         help: consider borrowing here: `&a`

error[E0277]: the trait bound `Box<i32>: Tm` is not satisfied
  --> t2.rs:14:9
   |
7  | fn bar<T: Tm>(_: T) {}
   |           -- required by this bound in `bar`
...
14 |     bar(b);
   |         ^
   |         |
   |         expected an implementor of trait `Tm`
   |         help: consider borrowing mutably here: `&mut b`

error: aborting due to 2 previous errors
```
In my implementation, I have added a "blacklist" to make these suggestions flexible. In particular, suggesting to borrow can interfere with other suggestions, such as to add another trait bound to a generic argument. I have tried to configure this blacklist to cause the least amount of test case failures, i.e. to model the current behavior as closely as possible (I only had to change one existing test case, and this change was quite clearly an improvement).

3 years agoRollup merge of #85339 - FabianWolff:issue-83893, r=varkor
Guillaume Gomez [Tue, 18 May 2021 12:08:51 +0000 (14:08 +0200)]
Rollup merge of #85339 - FabianWolff:issue-83893, r=varkor

Report an error if a lang item has the wrong number of generic arguments

This pull request fixes #83893. The issue is that the lang item code currently checks whether the lang item has the correct item kind (e.g. a `#[lang="add"]` has to be a trait), but not whether the item has the correct number of generic arguments.

This can lead to an "index out of bounds" ICE when the compiler tries to create more substitutions than there are suitable types available (if the lang item was declared with too many generic arguments).

For instance, here is a reduced ("reduced" in the sense that it does not trigger additional errors) version of the example given in #83893:
```rust
#![feature(lang_items,no_core)]
#![no_core]
#![crate_type="lib"]

#[lang = "sized"]
trait MySized {}

#[lang = "add"]
trait MyAdd<'a, T> {}

fn ice() {
    let r = 5;
    let a = 6;
    r + a
}
```
On current nightly, this immediately causes an ICE without any warnings or errors emitted. With the changes in this PR, however, I get no ICE and two errors:
```
error[E0718]: `add` language item must be applied to a trait with 1 generic argument
 --> pr-ex.rs:8:1
  |
8 | #[lang = "add"]
  | ^^^^^^^^^^^^^^^
9 | trait MyAdd<'a, T> {}
  |            ------- this trait has 2 generic arguments, not 1

error[E0369]: cannot add `{integer}` to `{integer}`
  --> pr-ex.rs:14:7
   |
14 |     r + a
   |     - ^ - {integer}
   |     |
   |     {integer}

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0369, E0718.
For more information about an error, try `rustc --explain E0369`.
```

3 years agoRollup merge of #85338 - lopopolo:core-iter-repeat-gh-81292, r=joshtriplett
Guillaume Gomez [Tue, 18 May 2021 12:08:46 +0000 (14:08 +0200)]
Rollup merge of #85338 - lopopolo:core-iter-repeat-gh-81292, r=joshtriplett

Implement more Iterator methods on core::iter::Repeat

`core::iter::Repeat` always returns the same element, which means we can
do better than implementing most `Iterator` methods in terms of
`Iterator::next`.

Fixes #81292.

#81292 raises the question of whether these changes violate the contract of `core::iter::Repeat`, but as far as I can tell `core::iter::repeat` doesn't make any guarantees around how it calls `Clone::clone`.

3 years agoRollup merge of #85280 - jsha:move-trait-toggles, r=GuillaumeGomez
Guillaume Gomez [Tue, 18 May 2021 12:08:42 +0000 (14:08 +0200)]
Rollup merge of #85280 - jsha:move-trait-toggles, r=GuillaumeGomez

Toggle-wrap items differently than top-doc.

This makes sure things like trait methods get wrapped at the
`<h3><code>` level rather than at the `.docblock` level. Also it ensures
that only the actual top documentation gets the `.top-doc` class.

Fixes #85167

Before:

![image](https://user-images.githubusercontent.com/220205/117743384-98790200-b1bb-11eb-8804-588530842514.png)

https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read

After:

![image](https://user-images.githubusercontent.com/220205/118410882-98a75080-b646-11eb-949d-ca688bab6923.png)

3 years agoRollup merge of #84587 - jyn514:rustdoc-lint-block, r=CraftSpider
Guillaume Gomez [Tue, 18 May 2021 12:08:41 +0000 (14:08 +0200)]
Rollup merge of #84587 - jyn514:rustdoc-lint-block, r=CraftSpider

rustdoc: Make "rust code block is empty" and "could not parse code block" warnings a lint (`INVALID_RUST_CODEBLOCKS`)

Fixes https://github.com/rust-lang/rust/issues/79792. This already went through FCP in https://github.com/rust-lang/rust/pull/79816, so it only needs final review.

This is mostly a rebase of https://github.com/rust-lang/rust/pull/79816 - thank you ``@poliorcetics`` for doing most of the work!

3 years agoAuto merge of #85313 - jackh726:region_eq, r=nikomatsakis
bors [Tue, 18 May 2021 12:07:56 +0000 (12:07 +0000)]
Auto merge of #85313 - jackh726:region_eq, r=nikomatsakis

Unify Regions with RegionVids in UnificationTable

A few test output changes; might be able to revert those but figured I would open this for perf and comments.

r? `@nikomatsakis`

3 years agoDon't pass -pie to linker on windows targets.
Luqman Aden [Tue, 18 May 2021 10:57:53 +0000 (03:57 -0700)]
Don't pass -pie to linker on windows targets.

3 years agoUndo unnecessary changes.
Luqman Aden [Tue, 18 May 2021 09:42:29 +0000 (02:42 -0700)]
Undo unnecessary changes.

3 years agoImprove display for "copy-path" button, making it more discrete
Guillaume Gomez [Mon, 17 May 2021 11:26:58 +0000 (13:26 +0200)]
Improve display for "copy-path" button, making it more discrete

3 years agoAuto merge of #82973 - ijackson:exitstatuserror, r=yaahc
bors [Tue, 18 May 2021 08:01:32 +0000 (08:01 +0000)]
Auto merge of #82973 - ijackson:exitstatuserror, r=yaahc

Provide ExitStatusError

Closes #73125

In MR #81452 "Add #[must_use] to [...] process::ExitStatus" we concluded that the existing arrangements in are too awkward so adding that `#[must_use]` is blocked on improving the ergonomics.

I wrote a mini-RFC-style discusion of the approach in https://github.com/rust-lang/rust/issues/73125#issuecomment-771092741

3 years agoAdd x.py pre-setup instructions
Lee Bradley [Tue, 18 May 2021 05:33:17 +0000 (00:33 -0500)]
Add x.py pre-setup instructions

This change adds pre-setup instructions that outline how x.py requires
python to be setup and how to work around the problem of x.py failing to
locate python, especially now that Ubuntu 20.04's dropped default python
command is causing people to encounter this issue regularly.

See also: #71818

3 years agoStabilize extended_key_value_attributes
Joshua Nelson [Mon, 22 Mar 2021 05:10:10 +0000 (01:10 -0400)]
Stabilize extended_key_value_attributes

 # Stabilization report

 ## Summary

This stabilizes using macro expansion in key-value attributes, like so:

 ```rust
 #[doc = include_str!("my_doc.md")]
 struct S;

 #[path = concat!(env!("OUT_DIR"), "/generated.rs")]
 mod m;
 ```

See the changes to the reference for details on what macros are allowed;
see Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455)
for alternatives that were considered and rejected ("why accept no more
and no less?")

This has been available on nightly since 1.50 with no major issues.

 ## Notes

 ### Accepted syntax

The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`).  Note that decorators and the like may be able to observe other expression forms.

 ### Expansion ordering

Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input.

There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work).

 ## Test cases

 - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs
 - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs

The feature has also been dogfooded extensively in the compiler and
standard library:

- https://github.com/rust-lang/rust/pull/83329
- https://github.com/rust-lang/rust/pull/83230
- https://github.com/rust-lang/rust/pull/82641
- https://github.com/rust-lang/rust/pull/80534

 ## Implementation history

- Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412
- Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121
- Preliminary work to restrict expansion that would conflict with this
feature: https://github.com/rust-lang/rust/pull/77271
- Initial implementation: https://github.com/rust-lang/rust/pull/78837
- Fix for an ICE: https://github.com/rust-lang/rust/pull/80563

 ## Unresolved Questions

~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~

 ## Additional Information

 There are two workarounds that have a similar effect for `#[doc]`
attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons:

```rust
macro_rules! forward_inner_docs {
    ($e:expr => $i:item) => {
        #[doc = $e]
        $i
    };
}

forward_inner_docs!(include_str!("lib.rs") => struct S {});
```

This also works for other attributes (like `#[path = concat!(...)]`).
The other is to use `doc(include)`:

```rust
 #![feature(external_doc)]
 #[doc(include = "lib.rs")]
 struct S {}
```

The first works, but is non-trivial for people to discover, and
difficult to read and maintain. The second is a strange special-case for
a particular use of the macro. This generalizes it to work for any use
case, not just including files.

I plan to remove `doc(include)` when this is stabilized. The
`forward_inner_docs` workaround will still compile without warnings, but
I expect it to be used less once it's no longer necessary.

3 years agoFix must_use on `Option::is_none`
mbartlett21 [Tue, 18 May 2021 03:40:26 +0000 (13:40 +1000)]
Fix must_use on `Option::is_none`

This fixes the `#[must_use = ...]` on `Option::is_none` to have a working suggestion.

3 years agoFix rebase conflicts
Joshua Nelson [Tue, 18 May 2021 03:31:48 +0000 (23:31 -0400)]
Fix rebase conflicts

3 years agoadding algorithm explanation for partition_in_place iter method and bounding complexi...
Satyarth Agrahari [Tue, 18 May 2021 02:29:16 +0000 (07:59 +0530)]
adding algorithm explanation for partition_in_place iter method and bounding complexity to current implementation

3 years agoDon't require cmake on Windows when LLVM isn't being built
Joshua Nelson [Tue, 18 May 2021 02:07:30 +0000 (22:07 -0400)]
Don't require cmake on Windows when LLVM isn't being built

Previously, setting `download-ci-llvm = true` when cmake wasn't
installed would give the following error:

```
failed to execute command: "cmake" "--help"
error: The system cannot find the file specified. (os error 2)
```

3 years agoAddress review comments
Joshua Nelson [Tue, 4 May 2021 02:19:49 +0000 (22:19 -0400)]
Address review comments

- Simplify boolean expression
- Give an example of invalid syntax
- Remove explanation of why code block is text

3 years agoRename INVALID_RUST_CODEBLOCK{,S}
Joshua Nelson [Sat, 1 May 2021 01:28:32 +0000 (21:28 -0400)]
Rename INVALID_RUST_CODEBLOCK{,S}

3 years agoAdd back missing help for ignore blocks
Joshua Nelson [Mon, 26 Apr 2021 13:11:08 +0000 (09:11 -0400)]
Add back missing help for ignore blocks

This also gives a better error message when a span is missing.

3 years agoNew rustdoc lint to respect -Dwarnings correctly
Alexis Bourget [Mon, 28 Dec 2020 22:07:20 +0000 (23:07 +0100)]
New rustdoc lint to respect -Dwarnings correctly

This adds a new lint to `rustc` that is used in rustdoc when a code
block is empty or cannot be parsed as valid Rust code.

Previously this was unconditionally a warning. As such some
documentation comments were (unknowingly) abusing this to pass despite
the `-Dwarnings` used when compiling `rustc`, this should not be the
case anymore.

3 years agoAuto merge of #85402 - RalfJung:miri, r=RalfJung
bors [Tue, 18 May 2021 00:32:19 +0000 (00:32 +0000)]
Auto merge of #85402 - RalfJung:miri, r=RalfJung

update Miri

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

3 years agoAdjust linker_is_gnu branches for cases that don't work on windows.
Luqman Aden [Mon, 17 May 2021 23:14:13 +0000 (16:14 -0700)]
Adjust linker_is_gnu branches for cases that don't work on windows.