Commit graph

148681 commits

Author SHA1 Message Date
Luqman Aden 0188664425 Swap TargetOptions::linker_is_gnu default from false to true and update targets as appropriate. 2021-05-20 16:47:08 -07:00
bors 99e3aef020 Auto merge of #85518 - GuillaumeGomez:rollup-mq4ohfy, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #85275 (Move `std::memchr` to `sys_common`)
 - #85326 (bootstrap: ensure host std when cross-compiling tools, fixes #85320)
 - #85375 (Fix missing lifetimes diagnostics after #83759)
 - #85507 (Extend escape key check)
 - #85509 (Prevent tab title to "null" if the URL is a search one)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-20 18:30:26 +00:00
Guillaume Gomez 247e2e24eb
Rollup merge of #85509 - GuillaumeGomez:search-null-title, r=jsha
Prevent tab title to "null" if the URL is a search one

When we arrive on page with a search parameter in the URL, until the results are displayed, the page title is "null". It's because of this code:

```js
if (params.search !== undefined) {
    var search = searchState.outputElement();
    search.innerHTML = "<h3 style=\"text-align: center;\">" +
       searchState.loadingText + "</h3>";
    searchState.showResults(search);
    loadSearch();
}
```

In `searchState.showResults`, we have this:

```js
document.title = searchState.title;
```

But since it's `null`, we set it as title. This PR fixes it.

r? `@jsha`
2021-05-20 17:56:58 +02:00
Guillaume Gomez 0918348eaf
Rollup merge of #85507 - GuillaumeGomez:extend-escape-key-check, r=jsha
Extend escape key check

Since #84462 has been merged, we can now extend the `escape-key` test.

r? `@jsha`
2021-05-20 17:56:57 +02:00
Guillaume Gomez 67d5435695
Rollup merge of #85375 - SkiFire13:fix-85347, r=jackh726
Fix missing lifetimes diagnostics after #83759

In #83759 while rebasing I didn't realize there was a new function for suggesting to add lifetime arguments. It relied on some invariants, namely that if a generic type/trait has angle brackets then it must have some generic argument, which is now no longer true. This PR updates that function to handle the new invariants.

This also adds a new regression test but I'm not sure if that's the correct place for it.

Fixes #85347
2021-05-20 17:56:56 +02:00
Guillaume Gomez ddc376c03d
Rollup merge of #85326 - infinity0:fix-cross-compile-tools, r=Mark-Simulacrum
bootstrap: ensure host std when cross-compiling tools, fixes #85320
2021-05-20 17:56:51 +02:00
Guillaume Gomez 0d3bee8be0
Rollup merge of #85275 - CDirkx:memchr, r=m-ou-se
Move `std::memchr` to `sys_common`

`std::memchr` is a thin abstraction over the different `memchr` implementations in `sys`, along with documentation and tests. The module is only used internally by `std`, nothing is exported externally. Code like this is exactly what the `sys_common` module is for, so this PR moves it there.
2021-05-20 17:56:46 +02:00
bors 9a3214e9be Auto merge of #85493 - Amanieu:fix_85446, r=dtolnay
Update stdarch to fix x86 byte shift intrinsics

Fixes #85446
2021-05-20 15:49:31 +00:00
Guillaume Gomez 222126adaf Prevent tab title to "null" if the URL is a search one 2021-05-20 16:01:08 +02:00
bors 8a57820bca 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
2021-05-20 13:07:35 +00:00
Guillaume Gomez 792d4cf21f Extend escape key check 2021-05-20 13:37:29 +02:00
bors 35bab923c8 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
2021-05-20 07:39:24 +00:00
bors 5ab0f37087 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.
2021-05-20 04:58:13 +00:00
bors a426fc37f2 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!.
2021-05-20 00:55:27 +00:00
Amanieu d'Antras d4a0bcce0f Update stdarch to fix x86 byte shift intrinsics
Fixes #85446
2021-05-20 01:51:05 +01:00
Ralf Jung 9fa15ff0fc
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``
2021-05-20 00:19:09 +02:00
Ralf Jung b2becf09d3
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```
2021-05-20 00:19:08 +02:00
Ralf Jung 2065c4b096
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
2021-05-20 00:19:08 +02:00
Ralf Jung 1207b7fa0b
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
2021-05-20 00:19:07 +02:00
Ralf Jung c1c4cd57b3
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.
2021-05-20 00:19:02 +02:00
Ralf Jung a552b5b04b
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.
2021-05-20 00:18:58 +02:00
Ralf Jung 42174308a2
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
2021-05-20 00:18:57 +02:00
Ralf Jung a1ac372894
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!(),
};
```
2021-05-20 00:18:56 +02:00
bors df70463ea5 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
2021-05-19 21:50:45 +00:00
bors f94942d842 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`
2021-05-19 18:41:23 +00:00
David Tolnay 34585cb678
impl FromStr for proc_macro::Literal 2021-05-19 11:38:24 -07:00
David Tolnay 965bce4834
Add proc macro Literal parse test 2021-05-19 11:38:23 -07:00
David Tolnay faad7e209d
Make a more meaningful test for Punct eq 2021-05-19 11:38:23 -07:00
David Tolnay 3c16c0e1df
Move proc_macro tests to ui test 2021-05-19 11:38:23 -07:00
David Tolnay 39441bb2c1
Make a ui test to take the role of libproc_macro #[test] tests 2021-05-19 11:38:23 -07:00
bors 3bcaeb0bf9 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
2021-05-19 15:59:46 +00:00
Adam Gemmell d3737a6607 Remove test for crypto feature ahead of its removal 2021-05-19 16:13:52 +01:00
Adam Gemmell 904467a926 Ensure all crypto components (AES, PMULL, SHA1/2) are available on arm/aarch64 2021-05-19 16:13:23 +01:00
Adam Gemmell c71e58d432 Rename fptoint to frintts 2021-05-19 16:12:30 +01:00
Adam Gemmell 523b4d1499 Remove LSE2 2021-05-19 16:11:11 +01:00
Ralf Jung 50a9f008f2 CTFE Machine: do not expose Allocation 2021-05-19 16:37:57 +02:00
LeSeulArtichaut 7093a21e27 Adapt the THIR visitor to the vec-stored THIR 2021-05-19 16:03:41 +02:00
LeSeulArtichaut dc3eabd487 Store THIR in IndexVecs instead of an Arena 2021-05-19 16:03:35 +02:00
Christiaan Dirkx 4ff5ab5296 Rename rterr to rtprintpanic 2021-05-19 15:52:09 +02:00
Guillaume Gomez ec32bcf3fd Fix invalid CSS rules for a:hover 2021-05-19 15:37:19 +02:00
Christiaan Dirkx 6145051eee Replace sys_common::util::dumb_print with rterr! 2021-05-19 15:05:35 +02:00
Christiaan Dirkx 236705f3c3 Replace sys_common::util::report_overflow with rterr! 2021-05-19 15:01:52 +02:00
Christiaan Dirkx b987f74f05 Remove sys_common::util::abort 2021-05-19 15:01:50 +02:00
Christiaan Dirkx 5b0908587e Introduce sys_common::rt::rterr! 2021-05-19 15:01:47 +02:00
Frank Steffahn f9752b4930 Fix UB in documented example for ptr::swap 2021-05-19 14:09:23 +02:00
bors 3e827cc21e 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`
2021-05-19 10:11:28 +00:00
bors be8450eec8 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
```
2021-05-19 07:25:17 +00:00
bors 9f8012e3aa 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
2021-05-19 04:44:09 +00:00
Jack Huey 6cfcbf7d03
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``
2021-05-18 22:36:19 -04:00
Jack Huey e113a4f77b
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.
2021-05-18 22:36:18 -04:00