]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #80930 - euclio:trait-method-mutability-help, r=estebank
Yuki Okushi [Tue, 12 Jan 2021 07:13:35 +0000 (16:13 +0900)]
Rollup merge of #80930 - euclio:trait-method-mutability-help, r=estebank

fix typo in trait method mutability mismatch help

3 years agoRollup merge of #80927 - LingMan:matches, r=estebank
Yuki Okushi [Tue, 12 Jan 2021 07:13:33 +0000 (16:13 +0900)]
Rollup merge of #80927 - LingMan:matches, r=estebank

Replace a simple `if let` with the `matches` macro

`@rustbot` modify labels +C-cleanup +T-compiler

3 years agoRollup merge of #80917 - epilys:patch-1, r=jyn514
Yuki Okushi [Tue, 12 Jan 2021 07:13:31 +0000 (16:13 +0900)]
Rollup merge of #80917 - epilys:patch-1, r=jyn514

core/slice: remove doc comment about scoped borrow

There's no need to scope the borrow in the doc example due to NLL.

[Playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20mut%20v%20%3D%20%5B1%2C%200%2C%203%2C%200%2C%205%2C%206%5D%3B%0A%0A%20%20%20%20let%20(left%2C%20right)%20%3D%20v.split_at_mut(2)%3B%0A%20%20%20%20assert_eq!(left%2C%20%5B1%2C%200%5D)%3B%0A%20%20%20%20assert_eq!(right%2C%20%5B3%2C%200%2C%205%2C%206%5D)%3B%0A%20%20%20%20left%5B1%5D%20%3D%202%3B%0A%20%20%20%20right%5B1%5D%20%3D%204%3B%0A%0A%20%20%20%20assert_eq!(v%2C%20%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%5D)%3B%0A%7D%0A) where changed code compiles

3 years agoRollup merge of #80898 - JohnTitor:vecdeque-another-case, r=lcnr
Yuki Okushi [Tue, 12 Jan 2021 07:13:29 +0000 (16:13 +0900)]
Rollup merge of #80898 - JohnTitor:vecdeque-another-case, r=lcnr

Add another test case for #79808

Taken from #80293.
Closes #80293

r? `@lcnr`

3 years agoRollup merge of #80897 - camelid:atty, r=jyn514
Yuki Okushi [Tue, 12 Jan 2021 07:13:28 +0000 (16:13 +0900)]
Rollup merge of #80897 - camelid:atty, r=jyn514

driver: Use `atty` instead of rolling our own

Fixes #80888.

Rationale:

- `atty` is widely used in the Rust ecosystem
- We already use it (in `rustc_errors` and other places)
- We shouldn't be rolling our own TTY detector when there's a
  widely-used, well-tested package that we can use

3 years agoRollup merge of #80880 - c410-f3r:tests-tests-tests, r=petrochenkov
Yuki Okushi [Tue, 12 Jan 2021 07:13:26 +0000 (16:13 +0900)]
Rollup merge of #80880 - c410-f3r:tests-tests-tests, r=petrochenkov

Move some tests to more reasonable directories

The idea is to move `issues`/`ui` tests in small batches

r? `@petrochenkov`

3 years agoRollup merge of #80600 - CoffeeBlend:maybe_uninit_array_assume_init, r=dtolnay
Yuki Okushi [Tue, 12 Jan 2021 07:13:24 +0000 (16:13 +0900)]
Rollup merge of #80600 - CoffeeBlend:maybe_uninit_array_assume_init, r=dtolnay

Add `MaybeUninit` method `array_assume_init`

When initialising an array element-by-element, the conversion to the initialised array is done through `mem::transmute`, which is both ugly and does not work with const generics (see #61956). This PR proposes the associated method `array_assume_init`, matching the style of `slice_assume_init_*`:

```rust
unsafe fn array_assume_init<T, const N: usize>(array: [MaybeUninit<T>; N]) -> [T; N];
```

Example:
```rust
let mut array: [MaybeUninit<i32>; 3] = MaybeUninit::uninit_array();
array[0].write(0);
array[1].write(1);
array[2].write(2);

// SAFETY: Now safe as we initialised all elements
let array: [i32; 3] = unsafe {
     MaybeUninit::array_assume_init(array)
};
```

Things I'm unsure about:
* Should this be a method of array instead?
* Should the function be const?

3 years agoRollup merge of #79757 - jryans:long-line-tab-handling-early-expand, r=estebank
Yuki Okushi [Tue, 12 Jan 2021 07:13:15 +0000 (16:13 +0900)]
Rollup merge of #79757 - jryans:long-line-tab-handling-early-expand, r=estebank

Replace tabs earlier in diagnostics

This replaces tabs earlier in the diagnostics emitting process, which allows various margin calculations to ignore the existence of tabs. It does add a string copy for the source lines that are emitted.

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

r? `@estebank`

3 years agodriver: Use `atty` instead of rolling our own
Camelid [Mon, 11 Jan 2021 02:07:05 +0000 (18:07 -0800)]
driver: Use `atty` instead of rolling our own

Rationale:

- `atty` is widely used in the Rust ecosystem
- We already use it (in `rustc_errors` and other places)
- We shouldn't be rolling our own TTY detector when there's a
  widely-used, well-tested package that we can use

3 years agoAuto merge of #76580 - rokob:iss76011, r=estebank
bors [Tue, 12 Jan 2021 02:56:51 +0000 (02:56 +0000)]
Auto merge of #76580 - rokob:iss76011, r=estebank

Suggest async {} for async || {}

Fixes #76011

This adds support for adding help diagnostics to the feature gating checks and
then uses it for the async_closure gate to add the extra bit of help
information as described in the issue.

3 years agoReplace a simple `if let` with the `matches` macro
LingMan [Mon, 11 Jan 2021 21:22:04 +0000 (22:22 +0100)]
Replace a simple `if let` with the `matches` macro

3 years agoFix implementation
CoffeeBlend [Tue, 12 Jan 2021 00:39:10 +0000 (01:39 +0100)]
Fix implementation

3 years agofix typo in trait method mutability mismatch help
Andy Russell [Tue, 12 Jan 2021 00:27:38 +0000 (19:27 -0500)]
fix typo in trait method mutability mismatch help

3 years agoAuto merge of #80928 - JohnTitor:rollup-sgerm3j, r=JohnTitor
bors [Tue, 12 Jan 2021 00:14:46 +0000 (00:14 +0000)]
Auto merge of #80928 - JohnTitor:rollup-sgerm3j, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #79997 (Emit a reactor for cdylib target on wasi)
 - #79998 (Use correct ABI for wasm32 by default)
 - #80042 (Split a func into cold/hot parts, reducing binary size)
 - #80324 (Explain method-call move errors in loops)
 - #80864 (std/core docs: fix wrong link in PartialEq)
 - #80870 (resolve: Simplify built-in macro table)
 - #80885 (rustdoc: Resolve `&str` as `str`)
 - #80904 (Fix small typo)
 - #80923 (Merge different function exits)

Failed merges:

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

3 years agoRollup merge of #80923 - LingMan:exits, r=varkor
Yuki Okushi [Mon, 11 Jan 2021 22:59:18 +0000 (07:59 +0900)]
Rollup merge of #80923 - LingMan:exits, r=varkor

Merge different function exits

`@rustbot` modify labels +C-cleanup +T-compiler

3 years agoRollup merge of #80904 - camelid:fix-small-typo, r=jonas-schievink
Yuki Okushi [Mon, 11 Jan 2021 22:59:16 +0000 (07:59 +0900)]
Rollup merge of #80904 - camelid:fix-small-typo, r=jonas-schievink

Fix small typo

transmutting -> transmuting

3 years agoRollup merge of #80885 - camelid:intra-doc-str-ref, r=jyn514
Yuki Okushi [Mon, 11 Jan 2021 22:59:15 +0000 (07:59 +0900)]
Rollup merge of #80885 - camelid:intra-doc-str-ref, r=jyn514

rustdoc: Resolve `&str` as `str`

People almost always are referring to `&str`, not `str`, so this will
save a manual link resolve in many cases.

Note that we already accept `&` (resolves to `reference`) in intra-doc
links, so this shouldn't cause breakage.

r? `@jyn514`

3 years agoRollup merge of #80870 - petrochenkov:bmactable, r=oli-obk
Yuki Okushi [Mon, 11 Jan 2021 22:59:13 +0000 (07:59 +0900)]
Rollup merge of #80870 - petrochenkov:bmactable, r=oli-obk

resolve: Simplify built-in macro table

We don't use full `SyntaxExtension`s from the table, only `SyntaxExtensionKind`s, and `Ident` in `register_builtin_macro` always had dummy span. This PR removes unnecessary data from the table and related function signatures.

Noticed when reviewing #80850.

3 years agoRollup merge of #80864 - ericseppanen:master, r=jyn514
Yuki Okushi [Mon, 11 Jan 2021 22:59:11 +0000 (07:59 +0900)]
Rollup merge of #80864 - ericseppanen:master, r=jyn514

std/core docs: fix wrong link in PartialEq

PartialEq doc was attempting to link to ``[`Eq`]`` but instead we got a link to `` `eq` ``. Disambiguate with `trait@Eq`.

You can see the bad link [here](https://doc.rust-lang.org/std/cmp/trait.PartialEq.html) (Second sentence, "floating point types implement PartialEq but not Eq").

3 years agoRollup merge of #80324 - Aaron1011:loop-move-fn-self, r=oli-obk
Yuki Okushi [Mon, 11 Jan 2021 22:59:10 +0000 (07:59 +0900)]
Rollup merge of #80324 - Aaron1011:loop-move-fn-self, r=oli-obk

Explain method-call move errors in loops

PR #73708 added a more detailed explanation of move errors that occur
due to a call to a method that takes `self`. This PR extends that logic
to work when a move error occurs due to a method call in the previous
iteration of a loop.

3 years agoRollup merge of #80042 - sivadeilra:cold_bits, r=oli-obk
Yuki Okushi [Mon, 11 Jan 2021 22:59:08 +0000 (07:59 +0900)]
Rollup merge of #80042 - sivadeilra:cold_bits, r=oli-obk

Split a func into cold/hot parts, reducing binary size

I noticed that the Size::bits function is called in many places,
and is inlined into them. On x86_64-pc-windows-msvc, this function
is inlined 527 times, and compiled separately (non-inlined) 3 times.

Each of those inlined calls contains code that panics. This commit
moves the `panic!` call into a separate function and marks that
function with `#[cold]`.

This reduces binary size by 24 KB. Not much, but it's something.
Changes like this often reduce pressure on instruction-caches,
since it reduces the amount of code that is inlined into hot code
paths. Or more precisely, it removes cold code from hot cache lines.

3 years agoRollup merge of #79998 - devsnek:wasm32-bindgen-compat, r=alexcrichton
Yuki Okushi [Mon, 11 Jan 2021 22:59:06 +0000 (07:59 +0900)]
Rollup merge of #79998 - devsnek:wasm32-bindgen-compat, r=alexcrichton

Use correct ABI for wasm32 by default

Introduces `wasm32-unknown-bindgen` for those wishing to use the bindgen compat abi. `wasm32-*` now uses the correct abi by default.

Fixes https://github.com/rustwasm/team/issues/291

3 years agoRollup merge of #79997 - coolreader18:wasm-reactor, r=alexcrichton
Yuki Okushi [Mon, 11 Jan 2021 22:58:59 +0000 (07:58 +0900)]
Rollup merge of #79997 - coolreader18:wasm-reactor, r=alexcrichton

Emit a reactor for cdylib target on wasi

Fixes #79199, and relevant to #73432

Implements wasi reactors, as described in WebAssembly/WASI#13 and [`design/application-abi.md`](https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md)

Empty `lib.rs`, `lib.crate-type = ["cdylib"]`:

```shell
$ cargo +reactor build --release --target wasm32-wasi
   Compiling wasm-reactor v0.1.0 (/home/coolreader18/wasm-reactor)
    Finished release [optimized] target(s) in 0.08s
$ wasm-dis target/wasm32-wasi/release/wasm_reactor.wasm >reactor.wat
```
`reactor.wat`:
```wat
(module
 (type $none_=>_none (func))
 (type $i32_=>_none (func (param i32)))
 (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
 (type $i32_=>_i32 (func (param i32) (result i32)))
 (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_prestat_get" (func $__wasi_fd_prestat_get (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "fd_prestat_dir_name" (func $__wasi_fd_prestat_dir_name (param i32 i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "proc_exit" (func $__wasi_proc_exit (param i32)))
 (import "wasi_snapshot_preview1" "environ_sizes_get" (func $__wasi_environ_sizes_get (param i32 i32) (result i32)))
 (import "wasi_snapshot_preview1" "environ_get" (func $__wasi_environ_get (param i32 i32) (result i32)))
 (memory $0 17)
 (table $0 1 1 funcref)
 (global $global$0 (mut i32) (i32.const 1048576))
 (global $global$1 i32 (i32.const 1049096))
 (global $global$2 i32 (i32.const 1049096))
 (export "memory" (memory $0))
 (export "_initialize" (func $_initialize))
 (export "__data_end" (global $global$1))
 (export "__heap_base" (global $global$2))
 (func $__wasm_call_ctors
  (call $__wasilibc_initialize_environ_eagerly)
  (call $__wasilibc_populate_preopens)
 )
 (func $_initialize
  (call $__wasm_call_ctors)
 )
 (func $malloc (param $0 i32) (result i32)
  (call $dlmalloc
   (local.get $0)
  )
 )
 ;; lots of dlmalloc, memset/memcpy, & libpreopen code
)
```

I went with repurposing cdylib because I figured that it doesn't make much sense to have a wasi shared library that can't be initialized, and even if someone was using it adding an `_initialize` export is a very small change.

3 years agoMove some tests to more reasonable directories
Caio [Mon, 11 Jan 2021 22:49:51 +0000 (19:49 -0300)]
Move some tests to more reasonable directories

3 years agoSimplify array_assume_init
CoffeeBlend [Mon, 11 Jan 2021 22:32:03 +0000 (23:32 +0100)]
Simplify array_assume_init

3 years agoAuto merge of #79012 - tgnottingham:span_data_to_lines_and_cols, r=estebank
bors [Mon, 11 Jan 2021 21:32:50 +0000 (21:32 +0000)]
Auto merge of #79012 - tgnottingham:span_data_to_lines_and_cols, r=estebank

rustc_span: add span_data_to_lines_and_cols to caching source map view

3 years agosquash! fix wasi
Gus Caplan [Mon, 11 Jan 2021 21:31:52 +0000 (15:31 -0600)]
squash! fix wasi

3 years agonew target
Gus Caplan [Mon, 14 Dec 2020 16:33:35 +0000 (10:33 -0600)]
new target

3 years agoUse correct ABI for wasm32 by default
Gus Caplan [Sun, 13 Dec 2020 04:31:35 +0000 (22:31 -0600)]
Use correct ABI for wasm32 by default

Introduces `RUSTC_USE_WASM32_BINDGEN_COMPAT_ABI` env var to use the
compat ABI if need.

3 years agoAuto merge of #75490 - LukasKalbertodt:add-basic-array-methods, r=dtolnay
bors [Mon, 11 Jan 2021 18:50:53 +0000 (18:50 +0000)]
Auto merge of #75490 - LukasKalbertodt:add-basic-array-methods, r=dtolnay

Add `[T; N]::each_ref` and `[T; N]::each_mut`

This PR adds the methods `each_ref` and `each_mut` to `[T; N]`. The ability to add methods to arrays was added in #75212. These two methods are particularly useful with `map` which was also added in that PR. Tracking issue: #76118

```rust
impl<T, const N: usize> [T; N] {
    pub fn each_ref(&self) -> [&T; N];
    pub fn each_mut(&mut self) -> [&mut T; N];
}
```

3 years agocore/slice: remove doc comment about scoped borrow
Manos Pitsidianakis [Mon, 11 Jan 2021 16:55:35 +0000 (18:55 +0200)]
core/slice: remove doc comment about scoped borrow

There's no need to scope the borrow in the doc example due to NLL.

Playground link where changed code compiles
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20mut%20v%20%3D%20%5B1%2C%200%2C%203%2C%200%2C%205%2C%206%5D%3B%0A%0A%20%20%20%20let%20(left%2C%20right)%20%3D%20v.split_at_mut(2)%3B%0A%20%20%20%20assert_eq!(left%2C%20%5B1%2C%200%5D)%3B%0A%20%20%20%20assert_eq!(right%2C%20%5B3%2C%200%2C%205%2C%206%5D)%3B%0A%20%20%20%20left%5B1%5D%20%3D%202%3B%0A%20%20%20%20right%5B1%5D%20%3D%204%3B%0A%0A%20%20%20%20assert_eq!(v%2C%20%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%5D)%3B%0A%7D%0A

3 years agoAuto merge of #80889 - cjgillot:asa, r=oli-obk
bors [Mon, 11 Jan 2021 14:54:52 +0000 (14:54 +0000)]
Auto merge of #80889 - cjgillot:asa, r=oli-obk

Do not query the HIR directly in `opt_associated_item`.

Papercut found by `@Aaron1011.`

3 years agoAdd `[T; N]::each_ref` and `[T; N]::each_mut`
Lukas Kalbertodt [Wed, 12 Aug 2020 22:19:53 +0000 (00:19 +0200)]
Add `[T; N]::each_ref` and `[T; N]::each_mut`

These methods work very similarly to `Option`'s methods `as_ref` and
`as_mut`. They are useful in several situation, particularly when
calling other array methods (like `map`) on the result. Unfortunately,
we can't easily call them `as_ref` and `as_mut` as that would shadow
those methods on slices, thus being a breaking change (that is likely
to affect a lot of code).

3 years agoAdd tracking issue for array_assume_init
CoffeeBlend [Mon, 11 Jan 2021 09:07:29 +0000 (10:07 +0100)]
Add tracking issue for array_assume_init

3 years agoAuto merge of #80905 - JohnTitor:rollup-tmmwmnb, r=JohnTitor
bors [Mon, 11 Jan 2021 06:09:50 +0000 (06:09 +0000)]
Auto merge of #80905 - JohnTitor:rollup-tmmwmnb, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #80809 (Use standard formatting for "rust-call" ABI message)
 - #80872 (Fix typo in source-based-code-coverage.md)
 - #80878 (Add ABI argument to `find_mir_or_eval_fn`)
 - #80881 ( Fix intra-doc links to `Self` and `crate` )
 - #80887 (log-color: Detect TTY based on stderr, not stdout)
 - #80892 (rustdoc: Remove `*` intra-doc alias for `pointer`)

Failed merges:

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

3 years agoRollup merge of #80892 - camelid:intra-doc-remove-star, r=jyn514
Yuki Okushi [Mon, 11 Jan 2021 05:34:54 +0000 (14:34 +0900)]
Rollup merge of #80892 - camelid:intra-doc-remove-star, r=jyn514

rustdoc: Remove `*` intra-doc alias for `pointer`

It's not valid Rust code and it can easily be confused with a wildcard
glob pattern or something else. People can always use `pointer` instead,
so it's just removing an alias.

It hasn't hit stable yet (I think it's still on nightly), so it's okay
to remove it. (We can always add it back later if we change our mind
too.)

r? `@jyn514`
cc https://github.com/rust-lang/rust/pull/80885#discussion_r554622737

3 years agoRollup merge of #80887 - camelid:fix-log-color-auto, r=RalfJung
Yuki Okushi [Mon, 11 Jan 2021 05:34:52 +0000 (14:34 +0900)]
Rollup merge of #80887 - camelid:fix-log-color-auto, r=RalfJung

log-color: Detect TTY based on stderr, not stdout

Fixes #78435 (again).

Logging goes to stderr, not stdout, so we should base our automated
detection on stderr instead of stdout.

Thanks to Ralf Jung for noticing and reporting the bug!

r? `@oli-obk`
cc `@RalfJung`

3 years agoRollup merge of #80881 - jyn514:intra-doc-self, r=GuillaumeGomez
Yuki Okushi [Mon, 11 Jan 2021 05:34:51 +0000 (14:34 +0900)]
Rollup merge of #80881 - jyn514:intra-doc-self, r=GuillaumeGomez

 Fix intra-doc links to `Self` and `crate`

Closes https://github.com/rust-lang/rust/issues/77732.

3 years agoRollup merge of #80878 - unseddd:abi, r=RalfJung
Yuki Okushi [Mon, 11 Jan 2021 05:34:49 +0000 (14:34 +0900)]
Rollup merge of #80878 - unseddd:abi, r=RalfJung

Add ABI argument to `find_mir_or_eval_fn`

Add ABI argument for called function in `find_mir_or_eval_fn` and
`call_extra_fn`. Useful for comparing with expected ABI in interpreters.

Related to [miri/1631](https://github.com/rust-lang/miri/issues/1631)

r? `@RalfJung`

3 years agoRollup merge of #80872 - eltociear:patch-4, r=jonas-schievink
Yuki Okushi [Mon, 11 Jan 2021 05:34:47 +0000 (14:34 +0900)]
Rollup merge of #80872 - eltociear:patch-4, r=jonas-schievink

Fix typo in source-based-code-coverage.md

preceeding -> preceding

3 years agoRollup merge of #80809 - camelid:rust-call-abi-msg, r=lcnr
Yuki Okushi [Mon, 11 Jan 2021 05:34:40 +0000 (14:34 +0900)]
Rollup merge of #80809 - camelid:rust-call-abi-msg, r=lcnr

Use standard formatting for "rust-call" ABI message

Nearly all error messages start with a lowercase letter and don't use
articles - instead they refer to the plural case.

3 years agoFix small typo
Camelid [Mon, 11 Jan 2021 05:24:15 +0000 (21:24 -0800)]
Fix small typo

transmutting -> transmuting

3 years agoAuto merge of #80818 - 12101111:system-libunwind, r=Mark-Simulacrum
bors [Mon, 11 Jan 2021 03:24:14 +0000 (03:24 +0000)]
Auto merge of #80818 - 12101111:system-libunwind, r=Mark-Simulacrum

Don't build in-tree llvm-libunwind if system-llvm-libunwind is enable

When "system-llvm-libunwind" is enabled, some target eg. musl still build in-tree llvm-libunwind which is useless.

3 years agoAdd another test case for #79808
Yuki Okushi [Mon, 11 Jan 2021 03:10:16 +0000 (12:10 +0900)]
Add another test case for #79808

Taken from #80293.

3 years agorustdoc: Remove `*` intra-doc alias for `pointer`
Camelid [Sun, 10 Jan 2021 23:40:20 +0000 (15:40 -0800)]
rustdoc: Remove `*` intra-doc alias for `pointer`

It's not valid Rust code and it can easily be confused with a wildcard
glob pattern or something else. People can always use `pointer` instead,
so it's just removing an alias.

It hasn't hit stable yet (I think it's still on nightly), so it's okay
to remove it. (We can always add it back later if we change our mind
too.)

3 years agoAuto merge of #80782 - petrochenkov:viscopes, r=matthewjasper
bors [Sun, 10 Jan 2021 23:36:33 +0000 (23:36 +0000)]
Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasper

resolve: Scope visiting doesn't need an `Ident`

Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part.
The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow.

I think it's clearer to pass only the necessary part.
Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case.

r? `@matthewjasper`

3 years agoDo not query the HIR in `opt_associated_item`.
Camille GILLOT [Sun, 10 Jan 2021 21:41:50 +0000 (22:41 +0100)]
Do not query the HIR in `opt_associated_item`.

3 years agolog-color: Detect TTY based on stderr, not stdout
Camelid [Sun, 10 Jan 2021 21:16:06 +0000 (13:16 -0800)]
log-color: Detect TTY based on stderr, not stdout

Logging goes to stderr, not stdout, so we should base our automated
detection on stderr instead of stdout.

Thanks to Ralf Jung for noticing and reporting the bug!

3 years agorustdoc: Resolve `&str` as `str`
Camelid [Sun, 10 Jan 2021 20:45:58 +0000 (12:45 -0800)]
rustdoc: Resolve `&str` as `str`

People almost always are referring to `&str`, not `str`, so this will
save a manual link resolve in many cases.

Note that we already accept `&` (resolves to `reference`) in intra-doc
links, so this shouldn't cause breakage.

3 years agoAuto merge of #79414 - sasurau4:feature/add-suggestion-for-pattern-in-fns-without...
bors [Sun, 10 Jan 2021 20:48:27 +0000 (20:48 +0000)]
Auto merge of #79414 - sasurau4:feature/add-suggestion-for-pattern-in-fns-without-body, r=matthewjasper

Add suggestion for PATTERNS_IN_FNS_WITHOUT_BODY

## Overview

Fix #78927

3 years agoUse standard formatting for "rust-call" ABI message
Camelid [Fri, 8 Jan 2021 05:21:21 +0000 (21:21 -0800)]
Use standard formatting for "rust-call" ABI message

Nearly all error messages start with a lowercase letter and don't use
articles - instead they refer to the plural case.

3 years agoAuto merge of #80789 - Aaron1011:fix/stmt-empty, r=petrochenkov
bors [Sun, 10 Jan 2021 17:58:38 +0000 (17:58 +0000)]
Auto merge of #80789 - Aaron1011:fix/stmt-empty, r=petrochenkov

Synthesize a `TokenStream` for `StmtKind::Empty`

Fixes #80760

3 years agoAdd ABI argument to `find_mir_or_eval_fn`
Nym Seddon [Sun, 10 Jan 2021 14:31:02 +0000 (14:31 +0000)]
Add ABI argument to `find_mir_or_eval_fn`

Add ABI argument for called function in `find_mir_or_eval_fn` and
`call_extra_fn`. Useful for comparing with expected ABI in interpreters.

Related to [miri/1631](https://github.com/rust-lang/miri/issues/1631)

3 years agoSmall cleanups
Joshua Nelson [Sun, 10 Jan 2021 15:00:41 +0000 (10:00 -0500)]
Small cleanups

3 years agoFix intra-doc links to `Self` and `crate`
Joshua Nelson [Sun, 10 Jan 2021 15:00:17 +0000 (10:00 -0500)]
Fix intra-doc links to `Self` and `crate`

3 years agoMerge different function exits
LingMan [Sun, 10 Jan 2021 13:38:14 +0000 (14:38 +0100)]
Merge different function exits

3 years agoFix typo in source-based-code-coverage.md
Ikko Ashimine [Sun, 10 Jan 2021 13:17:51 +0000 (22:17 +0900)]
Fix typo in source-based-code-coverage.md

preceeding -> preceding

3 years agoresolve: Simplify built-in macro table
Vadim Petrochenkov [Sun, 10 Jan 2021 11:36:30 +0000 (14:36 +0300)]
resolve: Simplify built-in macro table

3 years agoAuto merge of #80391 - ssomers:btree_cleanup_slices_3, r=Mark-Simulacrum
bors [Sun, 10 Jan 2021 10:48:55 +0000 (10:48 +0000)]
Auto merge of #80391 - ssomers:btree_cleanup_slices_3, r=Mark-Simulacrum

BTreeMap: tougher checking on most uses of copy_nonoverlapping

Miri checks pointer provenance and destination, but we can check it in debug builds already.
Also, we can let Miri confirm we don't mistake imprints of moved keys and values as genuine.
r? `@Mark-Simulacrum`

3 years agoAuto merge of #80867 - JohnTitor:rollup-tvqw555, r=JohnTitor
bors [Sun, 10 Jan 2021 08:01:12 +0000 (08:01 +0000)]
Auto merge of #80867 - JohnTitor:rollup-tvqw555, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #79502 (Implement From<char> for u64 and u128.)
 - #79968 (Improve core::ptr::drop_in_place debuginfo)
 - #80774 (Fix safety comment)
 - #80801 (Use correct span for structured suggestion)
 - #80803 (Remove useless `fill_in` function)
 - #80820 (Support `download-ci-llvm` on NixOS)
 - #80825 (Remove under-used ImplPolarity enum)
 - #80850 (Allow #[rustc_builtin_macro = "name"])
 - #80857 (Add comment to `Vec::truncate` explaining `>` vs `>=`)

Failed merges:

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

3 years agoRollup merge of #80857 - camelid:vec-truncate-comment, r=scottmcm
Yuki Okushi [Sun, 10 Jan 2021 07:56:07 +0000 (16:56 +0900)]
Rollup merge of #80857 - camelid:vec-truncate-comment, r=scottmcm

Add comment to `Vec::truncate` explaining `>` vs `>=`

Hopefully this will prevent people from continuing to ask about this
over and over again :)

See [this Zulip discussion][1] for more.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Vec.3A.3Atruncate.20implementation

r? ``@scottmcm``

3 years agoRollup merge of #80850 - m-ou-se:rustc-builtin-macro-name, r=petrochenkov
Yuki Okushi [Sun, 10 Jan 2021 07:56:05 +0000 (16:56 +0900)]
Rollup merge of #80850 - m-ou-se:rustc-builtin-macro-name, r=petrochenkov

Allow #[rustc_builtin_macro = "name"]

This adds the option of specifying the name of a builtin macro in the `#[rustc_builtin_macro]` attribute: `#[rustc_builtin_macro = "name"]`.

This makes it possible to have both `std::panic!` and `core::panic!` as a builtin macro, by using different builtin macro names for each. This is needed to implement the edition-specific behaviour of the panic macros of RFC 3007.

Also removes `SyntaxExtension::is_derive_copy`, as the macro name (e.g. `sym::Copy`) is now tracked and provides that information directly.

r? ``@petrochenkov``

3 years agoRollup merge of #80825 - GuillaumeGomez:rustdoc-cleanup-bis-repetita, r=jyn514
Yuki Okushi [Sun, 10 Jan 2021 07:56:03 +0000 (16:56 +0900)]
Rollup merge of #80825 - GuillaumeGomez:rustdoc-cleanup-bis-repetita, r=jyn514

Remove under-used ImplPolarity enum

It doesn't make much sense to have an enum with only two possible values and to store it inside an `Option` in my opinion when you can do all the same with a simple boolean. I don't expect any chances, performance or RSS usage wise.

r? ``@jyn514``

3 years agoRollup merge of #80820 - nagisa:nagisa/dcl-nixos, r=Mark-Simulacrum
Yuki Okushi [Sun, 10 Jan 2021 07:56:02 +0000 (16:56 +0900)]
Rollup merge of #80820 - nagisa:nagisa/dcl-nixos, r=Mark-Simulacrum

Support `download-ci-llvm` on NixOS

In particular, the CI built `libLLVM-*.so` needs to have `libz.so`
RPATHed so that binaries like `llvm-config` work at all.

3 years agoRollup merge of #80803 - jyn514:cleanup-fill-in, r=GuillaumeGomez
Yuki Okushi [Sun, 10 Jan 2021 07:56:00 +0000 (16:56 +0900)]
Rollup merge of #80803 - jyn514:cleanup-fill-in, r=GuillaumeGomez

Remove useless `fill_in` function

It was only used once, in a function that was otherwise trivial.

3 years agoRollup merge of #80801 - estebank:correct-binding-sugg-span, r=petrochenkov
Yuki Okushi [Sun, 10 Jan 2021 07:55:59 +0000 (16:55 +0900)]
Rollup merge of #80801 - estebank:correct-binding-sugg-span, r=petrochenkov

Use correct span for structured suggestion

On structured suggestion for `let` -> `const`  and `const` -> `let`, use
a proper `Span` and update tests to check the correct application.

Follow up to #80012.

3 years agoRollup merge of #80774 - LingMan:patch-1, r=nagisa
Yuki Okushi [Sun, 10 Jan 2021 07:55:57 +0000 (16:55 +0900)]
Rollup merge of #80774 - LingMan:patch-1, r=nagisa

Fix safety comment

The size assertion in the comment was inverted compared to the code. After fixing that the implication that `(new_size >= old_size) => new_size != 0` still doesn't hold so explain why `old_size != 0` at this point.

3 years agoRollup merge of #79968 - bjorn3:better_drop_glue_debuginfo, r=matthewjasper
Yuki Okushi [Sun, 10 Jan 2021 07:55:55 +0000 (16:55 +0900)]
Rollup merge of #79968 - bjorn3:better_drop_glue_debuginfo, r=matthewjasper

Improve core::ptr::drop_in_place debuginfo

* Use span of the dropped type as function span when possible.
* Rename symbol from `core::ptr::drop_in_place::$hash` to `{{drop}}::<$TYPE>::$hash`.

Fixes #77465

(I haven't yet updated the tests)

3 years agoRollup merge of #79502 - Julian-Wollersberger:from_char_for_u64, r=withoutboats
Yuki Okushi [Sun, 10 Jan 2021 07:55:53 +0000 (16:55 +0900)]
Rollup merge of #79502 - Julian-Wollersberger:from_char_for_u64, r=withoutboats

Implement From<char> for u64 and u128.

With this PR you can write
```
let u = u64::from('👤');
let u = u128::from('👤');
```

Previously, you could already write `as` conversions ([Playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cee18febe28e69024357d099f07ca081)):
```
// Lossless conversions
dbg!('👤' as u32);    // Prints 128100
dbg!('👤' as u64);    // Prints 128100
dbg!('👤' as u128);   // Prints 128100

// truncates, thus no `From` impls.
dbg!('👤' as u8);     // Prints 100
dbg!('👤' as u16);    // Prints 62564

// These `From` impls already exist.
dbg!(u32::from('👤'));               // Prints 128100
dbg!(u64::from(u32::from('👤')));    // Prints 128100
```

The idea is from ``@gendx`` who opened [this Internals thread](https://internals.rust-lang.org/t/implement-from-char-for-u64/13454), and ``@withoutboats`` responded that someone should open a PR for it.
Some people mentioned `From<char>` impls for `f32` and `f64`, but that doesn't seem correct to me, so I didn't include them here.

I don't know what the feature should be named. Must it be registered somewhere, like unstable features?

r? ``@withoutboats``

3 years agofix broken link in PartialEq doc
Eric Seppanen [Sun, 10 Jan 2021 06:40:48 +0000 (22:40 -0800)]
fix broken link in PartialEq doc

PartialEq doc was attempting to link to [`Eq`] but instead we got a link
to `eq`. Disambiguate with "trait@Eq".

3 years agoAuto merge of #77862 - danielhenrymantilla:rustdoc/fix-macros_2_0-paths, r=jyn514...
bors [Sun, 10 Jan 2021 05:15:01 +0000 (05:15 +0000)]
Auto merge of #77862 - danielhenrymantilla:rustdoc/fix-macros_2_0-paths, r=jyn514,petrochenkov

Rustdoc: Fix macros 2.0 and built-in derives being shown at the wrong path

Fixes #74355

  - ~~waiting on author + draft PR since my code ought to be cleaned up _w.r.t._ the way I avoid the `.unwrap()`s:~~

      - ~~dummy items may avoid the first `?`,~~

      - ~~but within the module traversal some tests did fail (hence the second `?`), meaning the crate did not possess the exact path of the containing module (`extern` / `impl` blocks maybe? I'll look into that).~~

r? `@jyn514`

3 years agoAuto merge of #80831 - jyn514:no-inline, r=Mark-Simulacrum
bors [Sun, 10 Jan 2021 01:08:41 +0000 (01:08 +0000)]
Auto merge of #80831 - jyn514:no-inline, r=Mark-Simulacrum

Don't mark `force_query_with_job` as `inline(always)`

It's rather large, and using `inline(always)` forces it to be recompiled
in each calling crate. Hopefully this change will help with #65031. I intentionally only removed inline from `force_query_with_job` because the other functions are tiny and I wanted to measure this change on its own.

This may conflict with https://github.com/rust-lang/rust/issues/78780. I am not sure if it will hurt or help.

cc `@cjgillot`

3 years agoAuto merge of #80441 - petrochenkov:kwtok, r=Aaron1011
bors [Sat, 9 Jan 2021 22:19:46 +0000 (22:19 +0000)]
Auto merge of #80441 - petrochenkov:kwtok, r=Aaron1011

ast: Remove some indirection layers from values in key-value attributes

Trying to address some perf regressions from https://github.com/rust-lang/rust/pull/78837#issuecomment-745380762.

3 years agoAdd comment to `Vec::truncate` explaining `>` vs `>=`
Camelid [Sat, 9 Jan 2021 20:35:47 +0000 (12:35 -0800)]
Add comment to `Vec::truncate` explaining `>` vs `>=`

Hopefully this will prevent people from continuing to ask about this
over and over again :)

See [this Zulip discussion][1] for more.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Vec.3A.3Atruncate.20implementation

3 years agoSynthesize a `TokenStream` for `StmtKind::Empty`
Aaron Hill [Thu, 7 Jan 2021 16:43:21 +0000 (11:43 -0500)]
Synthesize a `TokenStream` for `StmtKind::Empty`

Fixes #80760

3 years agoAuto merge of #80830 - Aaron1011:capture-token-empty-stack, r=petrochenkov
bors [Sat, 9 Jan 2021 19:33:23 +0000 (19:33 +0000)]
Auto merge of #80830 - Aaron1011:capture-token-empty-stack, r=petrochenkov

Use an empty `TokenCursorFrame` stack when capturing tokens

We will never need to pop  past our starting frame during token
capturing. Using an empty stack allows us to avoid pointless heap
allocations/deallocations.

3 years agoDon't set builtin_name for builtin macro implementations.
Mara Bos [Sat, 9 Jan 2021 19:24:23 +0000 (19:24 +0000)]
Don't set builtin_name for builtin macro implementations.

This used to be necessary for `is_builtin` in the past, but is no longer required.

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
3 years agoast: Remove some indirection layers from values in key-value attributes
Vadim Petrochenkov [Sat, 19 Dec 2020 20:38:22 +0000 (23:38 +0300)]
ast: Remove some indirection layers from values in key-value attributes

3 years agoFormatting.
Mara Bos [Sat, 9 Jan 2021 15:54:12 +0000 (16:54 +0100)]
Formatting.

3 years agoAllow #[rustc_builtin_macro = "name"].
Mara Bos [Sat, 9 Jan 2021 15:48:58 +0000 (16:48 +0100)]
Allow #[rustc_builtin_macro = "name"].

This makes it possible to have both std::panic and core::panic as a
builtin macro, by using different builtin macro names for each.

Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g.
sym::Copy) is now tracked and provides that information directly.

3 years agoAuto merge of #80563 - petrochenkov:expattronmac, r=Aaron1011
bors [Sat, 9 Jan 2021 16:46:54 +0000 (16:46 +0000)]
Auto merge of #80563 - petrochenkov:expattronmac, r=Aaron1011

resolve/expand: Improve attribute expansion on macro definitions and calls

- Do not forget to visit attributes on macro definitions and calls in couple of places.
- Remove some weird special treatment of macro definition items, which is probably left from old times when macro definitions were treated more like macro calls.

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

3 years agoSupport `download-ci-llvm` on NixOS
Simonas Kazlauskas [Fri, 8 Jan 2021 19:21:30 +0000 (21:21 +0200)]
Support `download-ci-llvm` on NixOS

In particular, the CI built `libLLVM-*.so` needs to have `libz.so`
RPATHed so that binaries like `llvm-config` work at all.

3 years agoresolve/expand: Improve attribute expansion on macro definitions and calls
Vadim Petrochenkov [Thu, 31 Dec 2020 14:59:09 +0000 (17:59 +0300)]
resolve/expand: Improve attribute expansion on macro definitions and calls

3 years agoReplace under-used ImplPolarity enum with a boolean
Guillaume Gomez [Fri, 8 Jan 2021 21:54:35 +0000 (22:54 +0100)]
Replace under-used ImplPolarity enum with a boolean

3 years agoAuto merge of #80808 - CAD97:patch-3, r=nagisa
bors [Sat, 9 Jan 2021 13:56:15 +0000 (13:56 +0000)]
Auto merge of #80808 - CAD97:patch-3, r=nagisa

Fix typo in Step trait

... I don't know how this major typo happened, whoops ðŸ™ƒ

`@bors` rollup=always
(comment only change)

3 years agoUpdate the stabilisation version.
Julian Wollersberger [Sat, 9 Jan 2021 11:31:30 +0000 (12:31 +0100)]
Update the stabilisation version.

3 years agoAuto merge of #80797 - pietroalbini:fix-relative-install, r=Mark-Simulacrum
bors [Sat, 9 Jan 2021 11:06:46 +0000 (11:06 +0000)]
Auto merge of #80797 - pietroalbini:fix-relative-install, r=Mark-Simulacrum

Fix x.py install not working with relative prefix

The code powering `./x.py install` did not handle relative paths well: the installation script is executed inside a temporary directory, so all the relative paths specified in `config.toml` and in the `DESTDIR` environment variable were relative to that temporary directory. The original code fixed the problem for `config.toml` paths by canonicalizing the prefix, but breaking `DESTDIR`. https://github.com/rust-lang/rust/pull/80240 fixed the `DESTDIR` problem, but also regressed `config.toml` paths (#80683).

This PR refactors the installation code to generate paths that *in my understanding* are correct, adding comments in the meantime to explain what each step does. There was no documentation on why choices were made before, so my understanding could actually be wrong.

Regardless, executed `./x.py install` with various combinations of `config.toml` and `DESTDIR` paths, and everything seems to work according to my understanding. Still, I'd love if `@vext01` and `@yshui` could test these changes.

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

3 years agoAuto merge of #80755 - sunfishcode:path-cleanup/copy, r=nagisa
bors [Sat, 9 Jan 2021 07:48:53 +0000 (07:48 +0000)]
Auto merge of #80755 - sunfishcode:path-cleanup/copy, r=nagisa

Optimize away some path lookups in the generic `fs::copy` implementation

This also eliminates a use of a `Path` convenience function, in support
of #80741, refactoring `std::path` to focus on pure data structures and
algorithms.

3 years agoDon't build in-tree llvm-libunwind if system-llvm-libunwind is enable
12101111 [Fri, 8 Jan 2021 18:23:02 +0000 (02:23 +0800)]
Don't build in-tree llvm-libunwind if system-llvm-libunwind is enable

3 years agoAuto merge of #80749 - as-com:target-cpu-actually-native, r=nagisa
bors [Sat, 9 Jan 2021 04:36:24 +0000 (04:36 +0000)]
Auto merge of #80749 - as-com:target-cpu-actually-native, r=nagisa

Make target-cpu=native detect individual features

This PR makes target-cpu=native check for and enable/disable individual features instead of detecting and targeting a CPU by name. This brings the flag's behavior more in line with clang and gcc and ensures that the host actually supports each feature that we are compiling for.

This should resolve issues with miscompilations on e.g. "Haswell" Pentiums and Celerons that lack support for AVX, and also enable support for `aes` on Broadwell processors that support it. It should also resolve issues with failing to detect feature support in newer CPUs that aren't yet known by LLVM (see: #80633).

Fixes #54688
Fixes #48464
Fixes #38218

3 years agoDon't mark `force_query_with_job` as `inline(always)`
Joshua Nelson [Fri, 8 Jan 2021 23:38:33 +0000 (18:38 -0500)]
Don't mark `force_query_with_job` as `inline(always)`

It's rather large, and using `inline(always)` forces it to be recompiled
in each calling crate.

3 years agoUse an empty `TokenCursorFrame` stack when capturing tokens
Aaron Hill [Fri, 8 Jan 2021 23:16:20 +0000 (18:16 -0500)]
Use an empty `TokenCursorFrame` stack when capturing tokens

We will never need to pop  past our starting frame during token
capturing. Using an empty stack allows us to avoid pointless heap
allocations/deallocations.

3 years agoAdd doc comment explaining what the second Array's field is about
Guillaume Gomez [Fri, 8 Jan 2021 21:43:53 +0000 (22:43 +0100)]
Add doc comment explaining what the second Array's field is about

3 years agoChange wording of note
Aaron Hill [Fri, 8 Jan 2021 19:57:28 +0000 (14:57 -0500)]
Change wording of note

3 years agoExplain method-call move errors in loops
Aaron Hill [Wed, 23 Dec 2020 03:15:40 +0000 (22:15 -0500)]
Explain method-call move errors in loops

PR #73708 added a more detailed explanation of move errors that occur
due to a call to a method that takes `self`. This PR extends that logic
to work when a move error occurs due to a method call in the previous
iteration of a loop.

3 years agoAdd wasi-exec-model cg option for emitting wasi reactors
Noah [Sun, 13 Dec 2020 03:38:23 +0000 (21:38 -0600)]
Add wasi-exec-model cg option for emitting wasi reactors

3 years agoBTreeMap: tougher checks on most uses of copy_nonoverlapping
Stein Somers [Mon, 23 Nov 2020 13:41:53 +0000 (14:41 +0100)]
BTreeMap: tougher checks on most uses of copy_nonoverlapping

3 years agoAuto merge of #78452 - cjgillot:ddk-struct, r=Mark-Simulacrum
bors [Fri, 8 Jan 2021 18:16:00 +0000 (18:16 +0000)]
Auto merge of #78452 - cjgillot:ddk-struct, r=Mark-Simulacrum

Access query (DepKind) metadata through fields

This refactors the access to query definition metadata (attributes such as eval always, anon, has_params) and loading/forcing functions to generate a number of structs, instead of matching on the DepKind enum. This makes access to the fields cheaper to compile. Using a struct means that finding the metadata for a given query is just an offset away; previously the match may have been compiled to a jump table but likely not completely inlined as we expect here.

A previous attempt explored a similar strategy, but using trait objects in #78314 that proved less effective, likely due to higher overheads due to forcing dynamic calls and poorer cache utilization (all metadata is fairly densely packed with this PR).

3 years agoCheck is_anon outside of can_reconstruct_query_key.
Camille GILLOT [Wed, 6 Jan 2021 17:54:27 +0000 (18:54 +0100)]
Check is_anon outside of can_reconstruct_query_key.

3 years agoMake DepConstructor a module.
Camille GILLOT [Fri, 25 Dec 2020 18:07:28 +0000 (19:07 +0100)]
Make DepConstructor a module.