Commit Graph

1114 Commits

Author SHA1 Message Date
bors
31e4087b90 Auto merge of #77926 - Dylan-DPC:rollup-wttr8a1, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #77765 (Add LLVM flags to limit DWARF version to 2 on BSD)
 - #77788 (BTreeMap: fix gdb provider on BTreeMap with ZST keys or values)
 - #77795 (Codegen backend interface refactor)
 - #77808 (Moved the main `impl` for FnCtxt to its own file.)
 - #77817 (Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`)
 - #77829 (bootstrap: only use compiler-builtins-c if they exist)
 - #77870 (Use intra-doc links for links to module-level docs)
 - #77897 (Move `Strip` into a separate rustdoc pass)

Failed merges:

 - #77879 (Provide better documentation and help messages for x.py setup)
 - #77902 (Include aarch64-pc-windows-msvc in the dist manifests)

r? `@ghost`
2020-10-14 02:48:05 +00:00
Dylan DPC
41146c1420
Rollup merge of #77817 - jyn514:const-since, r=petrochenkov
Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`

This gives greater type safety and is less work to maintain on the rustdoc end. It also makes rustdoc more consistent with rustc.
Noticed this while working on https://github.com/rust-lang/rust/issues/76998.

- Remove `clean::Stability` in favor of `rustc_attr::Stability`
- Remove `impl Clean for Stability`; it's no longer necessary

r? @GuillaumeGomez
cc @petrochenkov
2020-10-14 02:30:42 +02:00
Dylan DPC
becd6c61c8
Rollup merge of #77808 - Nicholas-Baron:fn_ctxt_impl, r=matthewjasper
Moved the main `impl` for FnCtxt to its own file.

Resolves #77085 without breaking the API of the `FnCtxt` struct.

This is a solution to the file length being over 3000 (see issue #60302).

The other solution to the file length is
1. to change the API of this struct by
2. encapulating certain fields of the struct into other structs.
2020-10-14 02:30:40 +02:00
Dylan DPC
17ee28b71f
Rollup merge of #77795 - bjorn3:codegen_backend_interface_refactor, r=oli-obk
Codegen backend interface refactor

This moves several things away from the codegen backend to rustc_interface. There are a few behavioral changes where previously the incremental cache (incorrectly) wouldn't get finalized, but now it does. See the individual commit messages.
2020-10-14 02:30:38 +02:00
Dylan DPC
596235281c
Rollup merge of #77765 - amshafer:master, r=petrochenkov
Add LLVM flags to limit DWARF version to 2 on BSD

This has been a thorn in my side for a while, I can finally generate flamegraphs of rust programs on bsd again. This fixes dtrace profiling on freebsd, I think it might help with lldb as well but I can't test that because my current rust-lldb setup is messed up.

I'm limiting the dwarf version to 2 on all bsd's (netbsd/openbsd/freebsd) since it looks like this applies to all of them, but I have only tested on freebsd.

Let me know if there's anything I can improve!

---
Currently on FreeBSD dtrace profiling does not work and shows jumbled/incorrect
symbols in the backtraces. FreeBSD does not support the latest versions of DWARF
in dtrace (and lldb?) yet, and needs to be limited to DWARF2 in the same way as macos.

This adds an is_like_bsd flag since it was missing. NetBSD/OpenBSD/FreeBSD all
match this.

This effectively copies #11864 but targets FreeBSD instead of macos.
2020-10-14 02:30:34 +02:00
bors
4ba5068815 Auto merge of #77135 - Aaron1011:pretty-ignore-paren, r=petrochenkov
Refactor AST pretty-printing to allow skipping insertion of extra parens

Fixes #75734
Makes progress towards #43081
Unblocks PR #76130

When pretty-printing an AST node, we may insert additional parenthesis
to ensure that precedence is properly preserved in code we output.
However, the proc macro implementation relies on comparing a
pretty-printed AST node to the captured `TokenStream`. Inserting extra
parenthesis changes the structure of the reparsed `TokenStream`, making
the comparison fail.

This PR refactors the AST pretty-printing code to allow skipping the
insertion of additional parenthesis. Several freestanding methods are
moved to trait methods on `PrintState`, which keep track of an internal
`insert_extra_parens` flag. This flag is normally `true`, but we expose
a public method which allows pretty-printing a nonterminal with
`insert_extra_parens = false`.

To avoid changing the public interface of `rustc_ast_pretty`, the
freestanding `_to_string` methods are changed to delegate to a
newly-crated `State`. The main pretty-printing code is moved to a new
`state` module to ensure that it does not accidentally call any of these
public helper functions (instead, the internal functions with the same
name should be used).
2020-10-14 00:26:50 +00:00
bors
f243a2ad90 Auto merge of #77917 - JohnTitor:rollup-e47h2qt, r=JohnTitor
Rollup of 14 pull requests

Successful merges:

 - #77239 (Enable building Cargo for aarch64-apple-darwin)
 - #77569 (BTreeMap: type-specific variants of node_as_mut and cast_unchecked)
 - #77719 (Remove unnecessary rustc_const_stable attributes.)
 - #77722 (Remove unsafety from sys/unsupported and add deny(unsafe_op_in_unsafe_fn).)
 - #77725 (Add regression issue template)
 - #77776 ( Give an error when running `x.py test --stage 0 src/test/ui`)
 - #77786 (Mention rustdoc in `x.py setup`)
 - #77825 (`min_const_generics` diagnostics improvements)
 - #77868 (Include `llvm-dis`, `llc` and `opt` in `llvm-tools-preview` component)
 - #77884 (Use Option::unwrap_or instead of open-coding it)
 - #77886 (Replace trivial bool matches with the `matches!` macro)
 - #77892 (Replace absolute paths with relative ones)
 - #77895 (Include aarch64-apple-darwin in the dist manifests)
 - #77909 (bootstrap: set correct path for the build-manifest binary)

Failed merges:

 - #77902 (Include aarch64-pc-windows-msvc in the dist manifests)

r? `@ghost`
2020-10-13 22:13:09 +00:00
Yuki Okushi
70f8e1a56f
Rollup merge of #77892 - est31:remove_redundant_absolute_paths, r=lcnr
Replace absolute paths with relative ones

Modern compilers allow reaching external crates
like std or core via relative paths in modules
outside of lib.rs and main.rs.
2020-10-14 06:02:36 +09:00
Yuki Okushi
083638cfcf
Rollup merge of #77886 - LingMan:ast_pretty_bool_matches, r=petrochenkov
Replace trivial bool matches with the `matches!` macro

This derives `PartialEq` on one enum (and two structs it contains) to enable the `==` operator for it. If there's some downside to this, I could respin with the `matches!` macro instead.
2020-10-14 06:02:35 +09:00
Yuki Okushi
31135e02fa
Rollup merge of #77884 - LingMan:ast_pretty_unwrap_or, r=varkor
Use Option::unwrap_or instead of open-coding it
2020-10-14 06:02:33 +09:00
Yuki Okushi
c44cc7e236
Rollup merge of #77825 - ethanboxx:min_const_generics_diagnostic, r=lcnr
`min_const_generics` diagnostics improvements

As disscussed in [zulip/project-const-generics/non-trivial anonymous constant](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/non-trivial.20anonymous.20constants).

This is my first PR on the compiler.

@lcnr is mentoring me on this PR.

Related to #60551.
2020-10-14 06:02:29 +09:00
Austin Shafer
4511f8b9f3 Add a target option for selecting a DWARF version
Certain platforms need to limit the DWARF version emitted (oxs, *bsd). This
change adds a dwarf_version entry to the options that allows a platform to
specify the dwarf version to use. By default this option is none and the default
DWARF version is selected.

Also adds an option for printing Option<u32> json keys
2020-10-13 15:56:30 -04:00
LingMan
7a23a71e51 Replace trivial bool matches with the matches! macro 2020-10-13 21:29:38 +02:00
Ding Xiang Fei
50627a39c1
explanatory comments and fix guard binding stack 2020-10-14 00:51:00 +08:00
Ding Xiang Fei
4a8ba7b031
dedicated visitor for arm patterns 2020-10-14 00:50:59 +08:00
Ding Xiang Fei
66345d9359
rustfmt 2020-10-14 00:50:57 +08:00
Ding Xiang Fei
7f5721c3f4
also record the types of borrows from the pattern locals in match guards
so that it reflects the fact that borrowing these pattern locals is happening
before any yield points in match guards
2020-10-14 00:50:55 +08:00
Ding Xiang Fei
f9ccd39ae3
documentation fix 2020-10-14 00:50:54 +08:00
bors
d65c08e9cc Auto merge of #75406 - mati865:mingw-aslr, r=Mark-Simulacrum
Enable ASLR for windows-gnu

Fixes https://github.com/rust-lang/rust/issues/16514
Fixes https://github.com/rust-lang/rust/issues/16593
Fixes https://github.com/rust-lang/rust/issues/17684

Passes the tests for me with x86_64 toolchain.
2020-10-13 14:12:08 +00:00
est31
a0fc455d30 Replace absolute paths with relative ones
Modern compilers allow reaching external crates
like std or core via relative paths in modules
outside of lib.rs and main.rs.
2020-10-13 14:16:45 +02:00
bors
2d6eccdb67 Auto merge of #77755 - bugadani:perf-calc-dtor, r=ecstatic-morse
Monomorphize `calculate_dtor` instead of using function pointers

Change `calculate_dtor` to avoid dynamic dispatching. This change allows the empty functions to be optimized away.

Based on the discussion in https://github.com/rust-lang/rust/pull/77754#discussion_r502498970, the performance impact of this change was measured.

Perf run results: https://perf.rust-lang.org/compare.html?start=7bc5839e99411aad9061a632b62075d1346cbb3b&end=ffec759ae9bbc4d6d2235ff40ade6723a85bc7cc
2020-10-13 10:19:30 +00:00
bors
f54072bb81 Auto merge of #76830 - Artoria2e5:tune, r=nagisa
Pass tune-cpu to LLVM

I think this is how it should work...

See https://internals.rust-lang.org/t/expose-tune-cpu-from-llvm/13088 for the background. Or the documentation diff.
2020-10-13 02:49:00 +00:00
LingMan
61e722f331 Use Option::unwrap_or instead of open-coding it 2020-10-13 04:30:17 +02:00
bors
afb4514c09 Auto merge of #77796 - jonas-schievink:switchint-refactor, r=oli-obk
Refactor how SwitchInt stores jump targets

Closes https://github.com/rust-lang/rust/issues/65693
2020-10-13 00:57:03 +00:00
bors
abbdec3be6 Auto merge of #77792 - matthewjasper:instrument-trait-selection, r=oli-obk
Use tracing spans in rustc_trait_selection

Spans are very helpful when debugging this code. It's also hot enough to make a good benchmark.

r? `@oli-obk`
2020-10-12 23:04:55 +00:00
Ethan Brierley
facb38d1dc
A little rewording
Co-authored-by: varkor <github@varkor.com>
2020-10-12 15:58:06 -05:00
Ethan Brierley
e62da8ff0b
Remove a little jargon from error
Co-authored-by: varkor <github@varkor.com>
2020-10-12 15:57:04 -05:00
Nicholas-Baron
ce7c73c5a5 Made a submodule for fn_ctxt 2020-10-12 12:18:24 -07:00
Yuki Okushi
e40ae080ac
Rollup merge of #77831 - LingMan:use_std, r=jonas-schievink
Use std methods on char instead of open coding them
2020-10-13 04:08:03 +09:00
Yuki Okushi
233319fc65
Rollup merge of #77818 - bugadani:range, r=oli-obk
Mono collector: replace pair of ints with Range

I found the initial PR (#33171) that introduced this piece of code but I didn't find any information about why a tuple was preferred over a `Range<usize>`.

I'm hoping there are no technical reasons to not do this.
2020-10-13 04:08:02 +09:00
Yuki Okushi
687d7646de
Rollup merge of #77550 - lcnr:ty-dep-path-ct-cleanup, r=ecstatic-morse
add shims for WithOptConstParam query calls

r? @ecstatic-morse @eddyb
2020-10-13 04:07:50 +09:00
Ethan Brierley
eec443681e
Make error help clearer
Co-authored-by: varkor <github@varkor.com>
2020-10-12 07:18:29 -05:00
bors
d6b5ffb5b4 Auto merge of #77821 - tmiasko:discriminant-value-is-safe, r=jonas-schievink
Remove unnecessary unsafe block around calls to discriminant_value

Since 63793 the discriminant_value intrinsic is safe to call. Remove
unnecessary unsafe block around calls to this intrinsic in built-in
derive macros.
2020-10-12 12:12:54 +00:00
bjorn3
b620e49cca Remove dump_incremental_data 2020-10-12 10:34:30 +02:00
Nicholas-Baron
84878794ed Moved the functions starting with check to a separate file 2020-10-11 17:27:29 -07:00
Jonas Schievink
4f5394199b Fix -Clinker-plugin-lto with opt-levels s and z 2020-10-12 01:45:00 +02:00
Nicholas-Baron
16d0205d5c Moved the functions starting with suggest to a separate file 2020-10-11 16:28:06 -07:00
Nicholas-Baron
48291cf1d7 Moved some short functions back into fn_ctxt.rs 2020-10-11 16:10:42 -07:00
bors
c71248b708 Auto merge of #76859 - Aaron1011:fix/llvm-cgu-reuse, r=davidtwco,nikic
Use llvm::computeLTOCacheKey to determine post-ThinLTO CGU reuse

During incremental ThinLTO compilation, we attempt to re-use the
optimized (post-ThinLTO) bitcode file for a module if it is 'safe' to do
so.

Up until now, 'safe' has meant that the set of modules that our current
modules imports from/exports to is unchanged from the previous
compilation session. See PR #67020 and PR #71131 for more details.

However, this turns out be insufficient to guarantee that it's safe
to reuse the post-LTO module (i.e. that optimizing the pre-LTO module
would produce the same result). When LLVM optimizes a module during
ThinLTO, it may look at other information from the 'module index', such
as whether a (non-imported!) global variable is used. If this
information changes between compilation runs, we may end up re-using an
optimized module that (for example) had dead-code elimination run on a
function that is now used by another module.

Fortunately, LLVM implements its own ThinLTO module cache, which is used
when ThinLTO is performed by a linker plugin (e.g. when clang is used to
compile a C proect). Using this cache directly would require extensive
refactoring of our code - but fortunately for us, LLVM provides a
function that does exactly what we need.

The function `llvm::computeLTOCacheKey` is used to compute a SHA-1 hash
from all data that might influence the result of ThinLTO on a module.
In addition to the module imports/exports that we manually track, it
also hashes information about global variables (e.g. their liveness)
which might be used during optimization. By using this function, we
shouldn't have to worry about new LLVM passes breaking our module re-use
behavior.

In LLVM, the output of this function forms part of the filename used to
store the post-ThinLTO module. To keep our current filename structure
intact, this PR just writes out the mapping 'CGU name -> Hash' to a
file. To determine if a post-LTO module should be reused, we compare
hashes from the previous session.

This should unblock PR #75199 - by sheer chance, it seems to have hit
this issue due to the particular CGU partitioning and optimization
decisions that end up getting made.
2020-10-11 20:50:02 +00:00
LingMan
a56b0e96d0 Simplify using is_ascii_alphabetic and is_ascii_alphanumeric 2020-10-11 22:27:21 +02:00
LingMan
e533bb73bc Don't duplicate char::is_ascii_digit 2020-10-11 22:27:20 +02:00
Ethan Brierley
d7029cbd7e min_const_generics diagnostics improvements
2

3
2020-10-11 19:20:42 +01:00
Aaron Hill
9a6ea38647
Add hack to keep actix-web and actori-web compiling
This extends the existing `ident_name_compatibility_hack` to handle the
`tuple_from_req` macro defined in `actix-web` (and its fork
`actori-web`).
2020-10-11 13:20:26 -04:00
bors
8cc82ee340 Auto merge of #77793 - tmiasko:no-op-discriminant, r=ecstatic-morse
Recognize discriminant reads as no-ops in RemoveNoopLandingPads

The cleanup blocks often contain read of discriminants. Teach
RemoveNoopLandingPads to recognize them as no-ops to remove
additional no-op landing pads.
2020-10-11 16:33:47 +00:00
Aaron Hill
477ce31d37
Remove unused import 2020-10-11 12:09:48 -04:00
Aaron Hill
820953819c
Add relaxed_delim_match parameter 2020-10-11 12:09:48 -04:00
Aaron Hill
ea468f4270
Allow skipping extra paren insertion during AST pretty-printing
Fixes #74616
Makes progress towards #43081
Unblocks PR #76130

When pretty-printing an AST node, we may insert additional parenthesis
to ensure that precedence is properly preserved in code we output.
However, the proc macro implementation relies on comparing a
pretty-printed AST node to the captured `TokenStream`. Inserting extra
parenthesis changes the structure of the reparsed `TokenStream`, making
the comparison fail.

This PR refactors the AST pretty-printing code to allow skipping the
insertion of additional parenthesis. Several freestanding methods are
moved to trait methods on `PrintState`, which keep track of an internal
`insert_extra_parens` flag. This flag is normally `true`, but we expose
a public method which allows pretty-printing a nonterminal with
`insert_extra_parens = false`.

To avoid changing the public interface of `rustc_ast_pretty`, the
freestanding `_to_string` methods are changed to delegate to a
newly-crated `State`. The main pretty-printing code is moved to a new
`state` module to ensure that it does not accidentally call any of these
public helper functions (instead, the internal functions with the same
name should be used).
2020-10-11 12:09:48 -04:00
Aaron Hill
a20ae8901c
Move pprust code to a 'state' submodule 2020-10-11 12:09:48 -04:00
Joshua Nelson
96b0446b53 Move PartialOrd impl out of rustc
Rustdoc's ordering requirements are probably not relevant to the rest of
the compiler.
2020-10-11 11:11:33 -04:00
Matthew Jasper
b8d2560dca Use tracing spans in rustc_trait_selection 2020-10-11 16:08:23 +01:00