Commit Graph

1141 Commits

Author SHA1 Message Date
est31 d683e3ac23 Remove rustc_session::config::Config
The wrapper type led to tons of target.target
across the compiler. Its ptr_width field isn't
required any more, as target_pointer_width
is already present in parsed form.
2020-10-15 12:02:24 +02:00
est31 4fa5578774 Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces
rustc_target::config::Config with its wrapped Target.

On its own, this commit breaks the build. I don't like making
build-breaking commits, but in this instance I believe that it
makes review easier, as the "real" changes of this PR can be
seen much more easily.

Result of running:

find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \;
./x.py fmt
2020-10-15 12:02:24 +02:00
est31 0d1aa1e034 Rename target_pointer_width to pointer_width and turn it into an u32
Rename target_pointer_width to pointer_width because it is already
member of the Target struct.

The compiler supports only three valid values for target_pointer_width:
16, 32, 64. Thus it can safely be turned into an int.
This means less allocations and clones as well as easier handling of the type.
2020-10-15 12:02:23 +02:00
est31 64ba25d0f2 Use integer literals for builtin target_pointer_width fields
Also change target_pointer_width to pointer_width.

Preparation for a subsequent type change of
target_pointer_width to an integer together with a rename
to pointer_width.

On its own, this commit breaks the build. I don't like making
build-breaking commits, but in this instance I believe that it
makes review easier, as the "real" changes of this PR can be
seen much more easily.

Result of running:

find compiler/rustc_target/src/spec/ -type f -exec sed -i -e 's/target_pointer_width: "\(.*\)"\..*,/pointer_width: \1,/g' {} \;
2020-10-15 12:01:53 +02:00
bors 93deabce03 Auto merge of #77873 - sexxi-goose:use_tuple_inference_for_closures, r=nikomatsakis
Replace tuple of infer vars for upvar_tys with single infer var

This commit allows us to decide the number of captures required after
completing capture ananysis, which is required as part of implementing
RFC-2229.

closes https://github.com/rust-lang/project-rfc-2229/issues/4
r? `@nikomatsakis`
2020-10-15 04:17:10 +00:00
Yuki Okushi ccc86bbb40
Rollup merge of #77946 - tmiasko:validate-source-scope, r=jonas-schievink
Validate references to source scopes
2020-10-15 07:32:39 +09:00
Yuki Okushi df08fe7214
Rollup merge of #77936 - est31:remove_needless_alloc_slice, r=jonas-schievink
Remove needless alloc_slice

Don't invoke alloc_slice.

Arenas are temporary,
empty slices are eternal!
2020-10-15 07:32:37 +09:00
Yuki Okushi 022d20759b
Rollup merge of #77739 - est31:remove_unused_code, r=petrochenkov,varkor
Remove unused code

Rustc has a builtin lint for detecting unused code inside a crate, but when an item is marked `pub`, the code, even if unused inside the entire workspace, is never marked as such. Therefore, I've built [warnalyzer](https://github.com/est31/warnalyzer) to detect unused items in a cross-crate setting.

Closes https://github.com/est31/warnalyzer/issues/2
2020-10-15 07:32:29 +09:00
Yuki Okushi 35210a66ed
Rollup merge of #77570 - GuillaumeGomez:whitespace-doc-alias, r=jyn514,ollie27
Allow ascii whitespace char for doc aliases

Fixes issue from https://github.com/rust-lang/rust/issues/76705#issuecomment-703123847

cc @lopopolo @ollie27

r? @jyn514
2020-10-15 07:32:27 +09:00
est31 301907497f Remove needless alloc_slice
Don't invoke alloc_slice.

Arenas are temporary,
empty slices are eternal!
2020-10-14 14:23:32 +02:00
bors 5565241f65 Auto merge of #77741 - JohnTitor:add-tests, r=matthewjasper
Add some regression tests

They're fixed since nightly-2020-10-07:
Closes #52843
Closes #53448
Closes #54108
Closes #65581
Closes #65934
Closes #70292
Closes #71443
2020-10-14 06:43:10 +00:00
Roxane a64ad51ff7 Address comments 2020-10-14 00:17:42 -04:00
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
est31 215cd36e1c Remove unused code from remaining compiler crates 2020-10-14 04:14:32 +02:00
est31 58b3923ad3 Remove unused code from rustc_span 2020-10-14 04:14:32 +02:00
est31 338fad2162 Remove unused code from rustc_query_system 2020-10-14 04:14:32 +02:00
est31 9ed2177d86 Remove unused code from rustc_infer 2020-10-14 04:14:32 +02:00
est31 6897619d6d Remove unused code from rustc_hir 2020-10-14 04:14:32 +02:00
est31 feaac592a3 Remove unused code from rustc_codegen_* 2020-10-14 04:14:32 +02:00
est31 49d4a756f1 Remove unused code from rustc_ast 2020-10-14 04:14:32 +02:00
est31 d7791f485b Remove unused code from rustc_middle 2020-10-14 04:14:32 +02: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
Tomasz Miąsko 585e737ec1 Validate references to source scopes 2020-10-14 00:00:00 +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