Commit Graph

3140 Commits

Author SHA1 Message Date
Yuki Okushi
d682a6834d
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
2021-01-12 16:13:28 +09:00
Yuki Okushi
86b900a3ea
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`
2021-01-12 16:13:15 +09:00
bors
8234db5bc7 Auto merge of #80463 - tgnottingham:incr_comp_serial_mem_usage, r=oli-obk
Serialize incr comp structures to file via fixed-size buffer

Reduce a large memory spike that happens during serialization by writing
the incr comp structures to file by way of a fixed-size buffer, rather
than an unbounded vector.

Effort was made to keep the instruction count close to that of the
previous implementation. However, buffered writing to a file inherently
has more overhead than writing to a vector, because each write may
result in a handleable error. To reduce this overhead, arrangements are
made so that each LEB128-encoded integer can be written to the buffer
with only one capacity and error check. Higher-level optimizations in
which entire composite structures can be written with one capacity and
error check are possible, but would require much more work.

The performance is mostly on par with the previous implementation, with
small to moderate instruction count regressions. The memory reduction is
significant, however, so it seems like a worth-while trade-off.
2021-01-12 05:51:40 +00:00
Camelid
8c43160744 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
2021-01-11 19:59:25 -08:00
bors
467f5e99a5 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.
2021-01-12 02:56:51 +00:00
pierwill
2e3ab43f5c Rename rustc_middle::lint::LevelSource to LevelAndSource 2021-01-11 18:02:09 -08:00
LingMan
6bd661ef17 Replace a simple if let with the matches macro 2021-01-12 01:49:36 +01:00
Andy Russell
b6dc03b93d
fix typo in trait method mutability mismatch help 2021-01-11 19:28:25 -05:00
bors
0406441664 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
2021-01-12 00:14:46 +00:00
Yuki Okushi
4e69c5d0fa
Rollup merge of #80923 - LingMan:exits, r=varkor
Merge different function exits

`@rustbot` modify labels +C-cleanup +T-compiler
2021-01-12 07:59:18 +09:00
Yuki Okushi
f553a0fe59
Rollup merge of #80904 - camelid:fix-small-typo, r=jonas-schievink
Fix small typo

transmutting -> transmuting
2021-01-12 07:59:16 +09:00
Yuki Okushi
fd02c83bfe
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.
2021-01-12 07:59:13 +09:00
Yuki Okushi
8e6472fe32
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.
2021-01-12 07:59:10 +09:00
Yuki Okushi
56504a00f2
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.
2021-01-12 07:59:08 +09:00
Yuki Okushi
edcfe7b629
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
2021-01-12 07:59:06 +09:00
Yuki Okushi
1d83f9828f
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.
2021-01-12 07:58:59 +09:00
bors
fe531d5a5f 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
2021-01-11 21:32:50 +00:00
Gus Caplan
5ba3be1d60
squash! fix wasi 2021-01-11 15:31:52 -06:00
Vadim Petrochenkov
b7071b2353 resolve: Simplify collection of traits in scope 2021-01-11 23:49:47 +03:00
Gus Caplan
8f64cec022
new target 2021-01-11 14:22:41 -06:00
Gus Caplan
94bf59ea34
Use correct ABI for wasm32 by default
Introduces `RUSTC_USE_WASM32_BINDGEN_COMPAT_ABI` env var to use the
compat ABI if need.
2021-01-11 14:22:38 -06:00
Tyson Nottingham
f15fae822e rustc_serialize: fix incorrect signed LEB128 decoding
The signed LEB128 decoding function used a hardcoded constant of 64
instead of the number of bits in the type of integer being decoded,
which resulted in incorrect results for some inputs. Fix this, make the
decoding more consistent with the unsigned version, and increase the
LEB128 encoding and decoding test coverage.
2021-01-11 12:13:26 -08:00
Tyson Nottingham
52f21791fb Serialize incr comp structures to file via fixed-size buffer
Reduce a large memory spike that happens during serialization by writing
the incr comp structures to file by way of a fixed-size buffer, rather
than an unbounded vector.

Effort was made to keep the instruction count close to that of the
previous implementation. However, buffered writing to a file inherently
has more overhead than writing to a vector, because each write may
result in a handleable error. To reduce this overhead, arrangements are
made so that each LEB128-encoded integer can be written to the buffer
with only one capacity and error check. Higher-level optimizations in
which entire composite structures can be written with one capacity and
error check are possible, but would require much more work.

The performance is mostly on par with the previous implementation, with
small to moderate instruction count regressions. The memory reduction is
significant, however, so it seems like a worth-while trade-off.
2021-01-11 12:13:22 -08:00
Santiago Pastorino
82d0c597bf
Revert "Auto merge of #76896 - spastorino:codegen-inline-fns2, r=davidtwco,wesleywiser"
This reverts commit ddf2cc7f8e, reversing
changes made to 937f629535.
2021-01-11 16:27:59 -03:00
jumbatm
4b740acea2 Add FIXME note about storing &'tcx str 2021-01-12 03:31:01 +10:00
jumbatm
7a46a4f219 Remove unnecessary allocation. 2021-01-12 03:31:01 +10:00
jumbatm
15c64a181b Use tcx.symbol_name to check for clashes. 2021-01-12 03:31:00 +10:00
oli
e90b521a15 --emit=mir now emits both mir_for_ctfe and optimized_mir for const fn 2021-01-11 17:24:41 +00:00
bors
6526e5c772 Auto merge of #80889 - cjgillot:asa, r=oli-obk
Do not query the HIR directly in `opt_associated_item`.

Papercut found by `@Aaron1011.`
2021-01-11 14:54:52 +00:00
Yuki Okushi
293a491935
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`
2021-01-11 14:34:52 +09:00
Yuki Okushi
95a6279de7
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`
2021-01-11 14:34:49 +09:00
Yuki Okushi
dcd46bfd31
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.
2021-01-11 14:34:40 +09:00
Camelid
e2d3a25161 Fix small typo
transmutting -> transmuting
2021-01-10 21:24:32 -08:00
William Bain
d46c3e3411 Tweak ? inference error messages 2021-01-10 19:48:11 -05:00
William Bain
62a39ed526 Extract parent def handling for infer failure err 2021-01-10 19:48:11 -05:00
William Bain
b9d9776fea Refactor cannot infer ... message rendering 2021-01-10 19:48:10 -05:00
William Bain
0496fdee4f Note inference failures using ? conversion 2021-01-10 19:47:57 -05:00
bors
26d451f4b3 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`
2021-01-10 23:36:33 +00:00
Camille GILLOT
21e1963e9c Do not query the HIR in opt_associated_item. 2021-01-10 22:41:50 +01:00
Camelid
7af29abbc1 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!
2021-01-10 13:22:15 -08:00
bors
c97f11af7b 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
2021-01-10 20:48:27 +00:00
Camelid
6488aecb74 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.
2021-01-10 12:17:24 -08:00
bors
080ee6f5d7 Auto merge of #80789 - Aaron1011:fix/stmt-empty, r=petrochenkov
Synthesize a `TokenStream` for `StmtKind::Empty`

Fixes #80760
2021-01-10 17:58:38 +00:00
Nym Seddon
06fd212d6a
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)
2021-01-10 15:12:50 +00:00
LingMan
578da998af Merge different function exits 2021-01-10 14:38:14 +01:00
Patryk Wychowaniec
d2f8e398f1
Rework diagnostics for wrong number of generic args 2021-01-10 13:07:40 +01:00
Vadim Petrochenkov
f9b5859173 resolve: Simplify built-in macro table 2021-01-10 14:48:47 +03:00
bors
34628e5b53 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
2021-01-10 08:01:12 +00:00
Yuki Okushi
3e735c6e93
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``
2021-01-10 16:56:05 +09:00
Yuki Okushi
700f3f23d8
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.
2021-01-10 16:55:59 +09:00
Yuki Okushi
f90c7f0f42
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)
2021-01-10 16:55:55 +09:00
1000teslas
757bd23503 Remove trailing whitespace 2021-01-10 16:47:41 +11:00
1000teslas
9e345a5893 Revise async block error message 2021-01-10 16:47:41 +11:00
1000teslas
12f1795743 Fix location of error message explanation 2021-01-10 16:47:40 +11:00
1000teslas
5ccef56456 Explain why borrows can't be held across yield point in async blocks 2021-01-10 16:47:40 +11:00
bors
7a193921a0 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`
2021-01-10 05:15:01 +00:00
Jeremy Fitzhardinge
67978d56c1 Fix --pretty=expanded with --remap-path-prefix
Per https://github.com/rust-lang/rust/issues/80832, using
--pretty=expanded and --remap-path-prefix results in an ICE.

This is becasue the session source files table is stored in remapped
form, whereas --pretty-expanded looks up unremapped files. This remaps
the path prefixes before lookup.
2021-01-09 18:55:50 -08:00
bors
7cf205610e 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`
2021-01-10 01:08:41 +00:00
bors
f30733adb9 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.
2021-01-09 22:19:46 +00:00
Aaron Hill
3ed6caae60
Synthesize a TokenStream for StmtKind::Empty
Fixes #80760
2021-01-09 14:54:14 -05:00
bors
6184f23950 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.
2021-01-09 19:33:23 +00:00
Mara Bos
b293bbaba0 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>
2021-01-09 20:26:57 +01:00
Vadim Petrochenkov
71cd6f42a6 ast: Remove some indirection layers from values in key-value attributes 2021-01-09 21:50:39 +03:00
Mara Bos
0aad91b990 Formatting. 2021-01-09 19:50:12 +01:00
Mara Bos
d651fa78ce 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.
2021-01-09 19:50:06 +01:00
Vadim Petrochenkov
d81c1946c6 resolve/expand: Improve attribute expansion on macro definitions and calls 2021-01-09 18:43:01 +03:00
bors
c87ef0a2fc 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
2021-01-09 04:36:24 +00:00
Joshua Nelson
0215b3a456 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.
2021-01-08 18:38:33 -05:00
Aaron Hill
7b36408b5f
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.
2021-01-08 18:16:20 -05:00
Joshua Nelson
f7d261c3b1 Get rid of DepConstructor
This removes fully 235 unused functions.
2021-01-08 18:12:42 -05:00
Aaron Hill
20979aad77
Change wording of note 2021-01-08 14:57:35 -05:00
Aaron Hill
de90afc72e
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.
2021-01-08 14:37:07 -05:00
Noah
92d3537abb
Add wasi-exec-model cg option for emitting wasi reactors 2021-01-08 13:09:40 -06:00
bors
26438b4738 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).
2021-01-08 18:16:00 +00:00
Camille GILLOT
0f334c3642 Check is_anon outside of can_reconstruct_query_key. 2021-01-08 18:03:27 +01:00
Camille GILLOT
5fcc537d18 Make DepConstructor a module. 2021-01-08 18:02:04 +01:00
Camille GILLOT
921b284167 Make force_from_dep_node a function pointer. 2021-01-08 18:01:50 +01:00
Camille GILLOT
bee1fbb67e Make try_load_from_on_disk_cache a function pointer. 2021-01-08 17:59:27 +01:00
Camille GILLOT
438c430c76 Make can_reconstruct_query_key a function pointer. 2021-01-08 17:57:25 +01:00
Camille GILLOT
5027f1c6ea Use a field for has_params. 2021-01-08 17:55:46 +01:00
Camille GILLOT
d8c87ac080 Use a field for is_eval_always. 2021-01-08 17:53:38 +01:00
Camille GILLOT
24f0b957e7 Use a field for is_anon. 2021-01-08 17:51:53 +01:00
Andrew Sun
80ca198212 Check if the pointer is null/string is not utf8 2021-01-08 11:50:21 -05:00
Camille GILLOT
016ea6b319 Use a side-table of consts instead of matching on the DepKind enum. 2021-01-08 17:48:02 +01:00
Camille GILLOT
d1220fdedf Simplify DepNodeParams. 2021-01-08 17:29:49 +01:00
Camille GILLOT
79a57625f5 Move DepNodeExt outside of the macro. 2021-01-08 17:29:48 +01:00
bors
ddf2cc7f8e Auto merge of #76896 - spastorino:codegen-inline-fns2, r=davidtwco,wesleywiser
Do not make local copies of inline fns in debug mode

r? `@wesleywiser`

cc `@rust-lang/wg-incr-comp`

If this is correct it supersedes https://github.com/rust-lang/rust/pull/76889

Related to #54089
2021-01-08 15:21:45 +00:00
bors
3d8608a863 Auto merge of #80535 - JohnTitor:improve-use-diag, r=estebank
Add a note for `*` and `{}` usage on `use`

Closes #80333
2021-01-08 09:51:26 +00:00
Yuki Okushi
d063745023 Add a note for * and {} usage on use 2021-01-08 17:36:14 +09:00
bors
569e542f9f Auto merge of #80756 - sunfishcode:path-cleanup/rustc-incremental, r=nagisa
Optimize away some `fs::metadata` calls.

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.
2021-01-08 07:01:30 +00:00
Andrew Sun
bc4c5bac40 Use LLVMGetHostCPUFeatures instead of stdsimd 2021-01-07 23:25:19 -05:00
Yuki Okushi
f6c58afe15
Rollup merge of #80785 - petrochenkov:prettyparen, r=Aaron1011
rustc_ast_pretty: Remove `PrintState::insert_extra_parens`

It's no longer necessary after #79472.

r? `@Aaron1011`
2021-01-08 11:11:45 +09:00
Yuki Okushi
0afd72e313
Rollup merge of #79675 - CraftSpider:79669, r=estebank
Make sure rust-call errors occur correctly for traits

Fixes #79669

Adds trait method resolution to the error, and adds UI tests to ensure it doesn't happen again. Opening as draft because I'm getting weird link errors from unrelated code on my machine, and want to see what CI thinks.
2021-01-08 11:11:34 +09:00
Esteban Küber
9a5dcaab67 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.
2021-01-07 16:52:44 -08:00
Caio
f85fc264fe Reintroduce hir::ExprKind::If 2021-01-07 18:54:12 -03:00
Vadim Petrochenkov
f915e3e5cf rustc_ast_pretty: Remove PrintState::insert_extra_parens
It's no longer necessary after #79472
2021-01-08 00:43:38 +03:00
bors
e02b0f4a55 Auto merge of #80709 - lzutao:target-enumerate, r=petrochenkov
Limit target endian to an enum instead of free string

This is #77604 revived.
2021-01-07 21:33:57 +00:00
Yuki Okushi
695f878332
Rollup merge of #80784 - petrochenkov:nontspan, r=Aaron1011
rustc_parse: Better spans for synthesized token streams

I think using the nonterminal span for synthesizing its tokens is a better approximation than using `DUMMY_SP` or the attribute span like #79472 did in `expand.rs`.

r? `@Aaron1011`
2021-01-08 02:06:20 +09:00
Yuki Okushi
695f18ebab
Rollup merge of #80780 - lianghanzhen:master, r=petrochenkov
Return EOF_CHAR constant instead of magic char.
2021-01-08 02:06:18 +09:00
Yuki Okushi
fd7f2443f1
Rollup merge of #80750 - GuillaumeGomez:cleanup-to_string, r=lzutao
Don't use to_string on Symbol in rustc_passes/check_attr.rs

Improve code from #80686.

r? ``@lzutao``
2021-01-08 02:06:14 +09:00
Yuki Okushi
d02b31ca3c
Rollup merge of #80659 - pierwill:edit-tokenstream, r=davidtwco
Edit rustc_ast::tokenstream docs

Fix some punctuation and wording, and add intra-documentation links.
2021-01-08 02:06:07 +09:00
Yuki Okushi
3acd75dd25
Rollup merge of #80521 - richkadel:llvm-coverage-counters-2.4.0, r=wesleywiser
MIR Inline is incompatible with coverage

Fixes: #80060

Fixed by disabling inlining if `-Zinstrument-coverage` is set.

The PR also adds additional use cases to the coverage test for doctests.

r? `@wesleywiser`
cc: `@tmandry`
2021-01-08 02:06:03 +09:00
Yuki Okushi
bb229b8f6c
Rollup merge of #80012 - sasurau4:feature/point-constant-identifier-E0435, r=petrochenkov
Add pointing const identifier when emitting E0435

Fix #79919
2021-01-08 02:05:58 +09:00
Vadim Petrochenkov
0dab076358 rustc_parse: Better spans for synthesized token streams 2021-01-07 17:48:13 +03:00
Vadim Petrochenkov
3ff866ed7c resolve: Scope visiting doesn't need an Ident 2021-01-07 16:09:47 +03:00
Hanzhen Liang
f942c3cbf4 Return EOF_CHAR constant instead of magic char. 2021-01-07 13:20:04 +01:00
Daiki Ihara
c71348a9c6 Refine E0435 description 2021-01-07 20:20:58 +09:00
Daiki Ihara
f03907b33f Add pointing const identifier when emitting E0435 2021-01-07 20:20:58 +09:00
bors
bf5f30684a Auto merge of #80648 - Aaron1011:expn-data-private, r=petrochenkov
Make `ExpnData` fields `krate` and `orig_id` private

These fields are only used by hygiene serialized, and should not be
accessed by anything outside of `rustc_span`.
2021-01-07 08:25:39 +00:00
bors
dfdfaa1f04 Auto merge of #80200 - mahkoh:dst-offset, r=nagisa
Optimize DST field access

For

    struct X<T: ?Sized>(T)
    struct Y<T: ?Sized>(u8, T)

the offset of the unsized field is

    0
    mem::align_of_val(&self.1)

respectively. This patch changes the expression used to compute these
offsets so that the optimizer can perform this optimization.

Consider

```rust
fn f(x: &X<dyn Any>) -> &dyn Any {
    &x.0
}
```

Before:

```asm
test:
	movq	%rsi, %rdx
	movq	16(%rsi), %rax
	leaq	-1(%rax), %rcx
	negq	%rax
	andq	%rcx, %rax
	addq	%rdi, %rax
	retq
```

After:

```asm
test:
	movq	%rsi, %rdx
	movq	%rdi, %rax
	retq
```
2021-01-07 03:13:21 +00:00
bors
5b3d52414e Auto merge of #80425 - camelid:resolve-moduledata-docs, r=petrochenkov
Document `ModuleData` and improve names

- Document `ModuleData`
- Rename `ModuleData.normal_ancestor_id` to `nearest_parent_mod`
- Rename `Resolver::nearest_mod_parent` to `nearest_parent_mod`

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/mentoring/near/221029702

r? `@petrochenkov`
2021-01-07 00:31:09 +00:00
bors
d7769b9bea Auto merge of #80754 - sunfishcode:path-cleanup/rustc-fs-util, r=davidtwco
Optimize away a `fs::metadata` call.

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.
2021-01-06 21:48:06 +00:00
Camelid
ff75da89b1 Rename to nearest_parent_mod
* Rename `ModuleData.normal_ancestor_id` to `nearest_parent_mod`

`normal_ancestor_id` is a very confusing name if you don't already
understand what it means. Adding docs helps, but using a clearer and
more obvious name is also important.

* Rename `Resolver::nearest_mod_parent` to `nearest_parent_mod`

* Add more docs
2021-01-06 12:55:44 -08:00
Camelid
06931988c0 Document ModuleData
* Convert comments on fields to doc comments so they're visible in API
  docs
* Add new documentation
* Get rid of "normal module" terminology
2021-01-06 12:51:36 -08:00
Dan Gohman
68338bc2b0 Optimize away a fs::metadata call.
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.
2021-01-06 08:33:15 -08:00
Dan Gohman
304643c00d Optimize away some fs::metadata calls.
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.
2021-01-06 08:31:25 -08:00
Daniel Henry-Mantilla
a4de27aeec Fixed non-declarative-nor-opaque macros effective privacy.
cc @petrochenkov
2021-01-06 15:13:39 +01:00
Daniel Henry-Mantilla
dd15f410df WIP: attempt to fix the undocument re-export issue 2021-01-06 15:13:39 +01:00
Lzu Tao
8ee804dc2b Change related spec files to use the new enum 2021-01-06 13:34:20 +00:00
Lzu Tao
fa4d8bc878 Prefer enum Endian in rustc_target::Target 2021-01-06 13:34:19 +00:00
bors
8fec6c7bb9 Auto merge of #80714 - jakevossen5:master, r=lcnr
fixed const_generics error help

Closes https://github.com/rust-lang/rust/issues/80702
2021-01-06 10:25:18 +00:00
Guillaume Gomez
7bc22e96d3 Don't use to_string on Symbol 2021-01-06 10:59:50 +01:00
Andrew Sun
bf80159050 Make target-cpu=native detect individual features 2021-01-06 03:23:54 -05:00
bors
41601ef394 Auto merge of #80415 - cjgillot:issue-77828, r=petrochenkov
Compute parent module when collecting hir::MacroDef.

Fixes #77828.

r? `@jyn514`
2021-01-06 00:36:14 +00:00
Arlie Davis
4721b6518c 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. By itself, that's not a substantial
reduction. However, 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. It also removes all conditionals from Size::bits(),
which is called in many places.
2021-01-05 12:52:34 -08:00
Camille GILLOT
4fb12369b3 Do not swallow parent for MacroDef. 2021-01-05 21:10:35 +01:00
Camille GILLOT
59f1ccd35c Compute parent module when collecting hir::MacroDef. 2021-01-05 21:10:34 +01:00
bors
da305a2b00 Auto merge of #80711 - camelid:intrinsic-of-val-safety, r=oli-obk
Make `size_of_val` and `min_align_of_val` intrinsics unsafe

Fixes #80668.

r? `@oli-obk`
2021-01-05 17:07:25 +00:00
oli
41a732dfd4 Remove a FIXME and explain the decision 2021-01-05 12:10:56 +00:00
René Rebe
a0b0aecda3 Added support for i386-unknown-linux-gnu and i486-unknown-linux-gnu
Support for both can be useful when creating new firmware, boot loaders,
or embedded operating systems.
2021-01-05 12:05:36 +01:00
bors
f4b9d32ef5 Auto merge of #80686 - GuillaumeGomez:error-doc-alias-same-name, r=jyn514
Error when #[doc(alias)] has same name as the item

Something I came across when reviewing some doc alias PRs.

r? `@jyn514`
2021-01-05 08:47:46 +00:00
Jake Vossen
f37e737535 fixed const_generics error help 2021-01-05 00:01:48 -07:00
Camelid
bbf175df3c Make size_of_val and min_align_of_val intrinsics unsafe 2021-01-04 19:23:55 -08:00
Yuki Okushi
598d189e9b
Rollup merge of #80643 - LingMan:unwrap, r=oli-obk
Move variable into the only branch where it is relevant

At the `if` branch `filter` (the `let` binding) is `None` iff `filter` (the parameter) was `None`.
We can branch on the parameter, move the binding into the `if`, and the complexity of handling
`Option<Option<_>` largely dissolves.

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

Note: I have no idea how hot this code is. If this method frequently gets called with a `None` filter, there might be a small perf improvement.
2021-01-05 09:52:44 +09:00
Yuki Okushi
faf8beddef
Rollup merge of #80637 - LingMan:filter, r=oli-obk
Use Option::filter instead of open-coding it

`@rustbot` modify labels +C-cleanup +T-compiler
2021-01-05 09:52:42 +09:00
Yuki Okushi
be2a3f8642
Rollup merge of #80538 - JulianKnodt:err_usize, r=lcnr
Add check for `[T;N]`/`usize` mismatch in astconv

Helps clarify the issue in #80506
by adding a specific check for mismatches between [T;N] and usize.

r? `@lcnr`
2021-01-05 09:52:37 +09:00
oli
65ee418e5c Do not run const prop on the mir_for_ctfe of const fn 2021-01-04 22:29:45 +00:00
oli
3af7989a7c No doc comments on expressions 2021-01-04 21:40:38 +00:00
oli
a76dae4946 Fix wording of query description 2021-01-04 21:40:38 +00:00
oli
9eaec139d0 Small comment adjustments 2021-01-04 21:40:38 +00:00
oli
caeb3d525d Move MIR body loading to a machine function 2021-01-04 21:40:38 +00:00
oli
f6d54aa0c1 Adjust imports 2021-01-04 21:40:38 +00:00
oli
7202054800 Document all the things 2021-01-04 21:40:38 +00:00
oli
680c4022ae Comment nit 2021-01-04 21:40:38 +00:00
oli
db90150b91 Polymorphization should look at the runtime MIR of const fn 2021-01-04 21:40:38 +00:00
oli
eb4e94b2e5 Simplify the optimize_mir query 2021-01-04 21:40:38 +00:00
oli
1f5fb3e056 Differentiate between the availability of ctfe MIR and runtime MIR 2021-01-04 21:40:38 +00:00
oli
cccd40f9b5 Keep an unoptimized duplicate of const fn around
This allows CTFE to reliably detect UB, as otherwise
optimizations may hide UB.
2021-01-04 21:40:38 +00:00
oli
8e4fe6647f Require the encode_promoted_mir caller to know whether MIR for this item actually exists 2021-01-04 21:40:38 +00:00
oli
248b4dbc4f Limit trait item mir encoding to items with default bodies 2021-01-04 21:40:38 +00:00