about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2021-03-01Change default Solaris x86 target to x86_64-pc-solarisJakub Kulik-23/+24
2021-03-01Rollup merge of #82630 - JohnTitor:fix-typo-in-find-anon-type-doc, ↵Yuki Okushi-1/+1
r=petrochenkov Fix a typo in the `find_anon_type` doc
2021-03-01Auto merge of #82601 - terhechte:catalyst-support-m1-fix, r=petrochenkovbors-5/+3
Fixed support for macOS Catalyst on ARM64 When I initially added Arm64 Catalyst support in https://github.com/rust-lang/rust/pull/77484 I had access to a DTK. However, while waiting to merge the PR some other changes were merged which caused conflicts in the branch. When fixing those conflicts I had no access to the DTK anymore and didn't try out if the resulting binaries did indeed work on Apple Silicon. I finally have a M1 and I realized that some small changes were necessary to support Apple Silicon. This PR adds the required changes. I've been running binaries generated with this branch for some time now and they work without issues.
2021-02-28Fix a typo in the `find_anon_type` docYuki Okushi-1/+1
2021-02-28Auto merge of #82594 - nagisa:nagisa/remove-rumprun, r=petrochenkovbors-26/+0
Remove the x86_64-rumprun-netbsd target Herein we remove the target from the compiler and the code from libstd intended to support the now-defunct rumprun project. Closes #81514
2021-02-27Rollup merge of #82607 - bjorn3:frame_loc_getter, r=RalfJungDylan DPC-0/+10
Add a getter for Frame.loc This is necessary for Priroda. For context see https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Frame.3A.3Aloc.20no.20longer.20public/near/228070266 and oli-obk/priroda#27. cc `@DJMcNab` r? `@RalfJung`
2021-02-27Rollup merge of #82537 - wesleywiser:update_measureme, r=oli-obkDylan DPC-3/+3
Update measureme dependency to the latest version This version adds the ability to use `rdpmc` hardware-based performance counters instead of wall-clock time for measuring duration. This also introduces a dependency on the `perf-event-open-sys` crate on Linux which is used when using hardware counters. r? ```@oli-obk```
2021-02-27Rollup merge of #82534 - nikic:musl-crtend, r=nagisaDylan DPC-7/+14
Link crtbegin/crtend on musl to terminate .eh_frame For some targets, rustc uses a "CRT fallback", where it links CRT object files it ships instead of letting the host compiler link them. On musl, rustc currently links crt1, crti and crtn (provided by libc), but does not link crtbegin and crtend (provided by libgcc). In particular, crtend is responsible for terminating the .eh_frame section. Lack of terminator may result in segfaults during unwinding, as reported in #47551 and encountered by the LLVM 12 update in #81451. This patch links crtbegin and crtend for musl as well, following the table at the top of crt_objects.rs. r? ``@nagisa``
2021-02-27Rollup merge of #82498 - tmiasko:partitioning-debug, r=matthewjasperDylan DPC-6/+15
Use log level to control partitioning debug output
2021-02-27Rollup merge of #82401 - osa1:remove_redundant_macro, r=matthewjasperDylan DPC-9/+9
Remove a redundant macro Turn the macro into a function. Also remove unused 'span' argument.
2021-02-27Rollup merge of #81856 - Smittyvb:utf16-warn, r=matthewjasperDylan DPC-0/+3
Suggest character encoding is incorrect when encountering random null bytes This adds a note whenever null bytes are seen at the start of a token unexpectedly, since those tend to come from UTF-16 encoded files without a [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) (if a UTF-16 BOM appears it won't be valid UTF-8, but if there is no BOM it be both valid UTF-16 and valid but garbled UTF-8). This approach was suggested in https://github.com/rust-lang/rust/issues/73979#issuecomment-653976451. Closes #73979.
2021-02-27Add a getter for Frame.locbjorn3-0/+10
This is necessary for Priroda.
2021-02-27Auto merge of #80454 - JulianKnodt:ob_forest_op, r=matthewjasperbors-20/+25
Skip Ty w/o infer ty/const in trait select Remove some allocations & also add `skip_current_subtree` to skip subtrees with no inferred items. r? `@eddyb` since marked in the FIXME
2021-02-27Fixed support for macOS Catalyst for Apple SiliconBenedikt Terhechte-5/+3
2021-02-27Remove the x86_64-rumprun-netbsd targetSimonas Kazlauskas-26/+0
Closes #81514
2021-02-27Combine HasAttrs and HasTokens into AstLikeAaron Hill-206/+264
When token-based attribute handling is implemeneted in #80689, we will need to access tokens from `HasAttrs` (to perform cfg-stripping), and we will to access attributes from `HasTokens` (to construct a `PreexpTokenStream`). This PR merges the `HasAttrs` and `HasTokens` traits into a new `AstLike` trait. The previous `HasAttrs` impls from `Vec<Attribute>` and `AttrVec` are removed - they aren't attribute targets, so the impls never really made sense.
2021-02-27Rollup merge of #82494 - estebank:issue-82455, r=petrochenkovDylan DPC-0/+12
Substitute erased lifetimes on bad placeholder type Fix #82455.
2021-02-27Rollup merge of #82482 - tmiasko:small-cycles, r=varkorDylan DPC-7/+4
Use small hash set in `mir_inliner_callees` Use small hash set in `mir_inliner_callees` to avoid temporary allocation when possible and quadratic behaviour for large number of callees.
2021-02-27Rollup merge of #82442 - Aaron1011:fix/closure-mut-crash, r=matthewjasperDylan DPC-25/+26
Skip emitting closure diagnostic when closure_kind_origins has no entry Fixes #82438 This map is not guarnateed to have an entry for a closure.
2021-02-27Rollup merge of #82419 - petrochenkov:inertord, r=Aaron1011Dylan DPC-9/+14
expand: Preserve order of inert attributes during expansion Fixes https://github.com/rust-lang/rust/issues/67839 Fixes https://github.com/rust-lang/rust/issues/81871 r? `````@Aaron1011`````
2021-02-27Rollup merge of #82370 - ↵Dylan DPC-64/+70
0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank Improve anonymous lifetime note to indicate the target span Improvement for #81650 Cc #81995 Message after this improvement: (Improve note in the middle) ``` error[E0311]: the parameter type `T` may not live long enough --> src/main.rs:25:11 | 24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) { | -- help: consider adding an explicit lifetime bound...: `T: 'a +` 25 | scope.spawn(move |_| { | ^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 24:40... --> src/main.rs:24:40 | 24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) { | ^^^^^ note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds --> src/main.rs:25:11 | 25 | scope.spawn(move |_| { | ^^^^^ ``` r? ``````@estebank``````
2021-02-27Rollup merge of #82057 - upsuper-forks:cstr, r=davidtwco,wesleywiserDylan DPC-60/+30
Replace const_cstr with cstr crate This PR replaces the `const_cstr` macro inside `rustc_data_structures` with `cstr` macro from [cstr](https://crates.io/crates/cstr) crate. The two macros basically serve the same purpose, which is to generate `&'static CStr` from a string literal. `cstr` is better because it validates the literal at compile time, while the existing `const_cstr` does it at runtime when `debug_assertions` is enabled. In addition, the value `cstr` generates can be used in constant context (which is seemingly not needed anywhere currently, though).
2021-02-27Rollup merge of #81794 - lcnr:relaxed_adt_unsize-tracking-issue, r=camelidDylan DPC-1/+1
update tracking issue for `relaxed_struct_unsize` forgot to do this before #80726 got merged. The tracking issue is #81793
2021-02-26Auto merge of #82559 - tmiasko:inlined, r=petrochenkovbors-8/+52
Miscellaneous inlining improvements Inline a few small and hot functions.
2021-02-26Auto merge of #82552 - GuillaumeGomez:rollup-8dn1ztn, r=GuillaumeGomezbors-212/+279
Rollup of 8 pull requests Successful merges: - #81940 (Stabilize str_split_once) - #82165 (Reword labels on E0308 involving async fn return type) - #82456 (Replaced some unwrap_or and map_or with lazy variants) - #82491 (Consider inexpensive inlining criteria first) - #82506 (Properly account for non-shorthand pattern field in unused variable lint) - #82535 (Set codegen thread names) - #82545 (rustdoc: add optional woff2 versions of FiraSans.) - #82549 (Revert "Update normalize.css to 8.0.1") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-26Rollup merge of #82535 - wesleywiser:wip_codegen_thread_names, r=nagisaGuillaume Gomez-47/+77
Set codegen thread names Set names on threads spawned during codegen. Various debugging and profiling tools can take advantage of this to show a more useful identifier for threads. For example, gdb will show thread names in `info threads`: ``` (gdb) info threads Id Target Id Frame 1 Thread 0x7fffefa7ec40 (LWP 2905) "rustc" __pthread_clockjoin_ex (threadid=140737214134016, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145 2 Thread 0x7fffefa7b700 (LWP 2957) "rustc" 0x00007ffff125eaa8 in llvm::X86_MC::initLLVMToSEHAndCVRegMapping(llvm::MCRegisterInfo*) () from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so 3 Thread 0x7fffeef0f700 (LWP 3116) "rustc" futex_wait_cancelable (private=0, expected=0, futex_word=0x7fffe8602ac8) at ../sysdeps/nptl/futex-internal.h:183 * 4 Thread 0x7fffeed0e700 (LWP 3123) "rustc" rustc_codegen_ssa::back::write::spawn_work (cgcx=..., work=...) at /home/wesley/code/rust/rust/compiler/rustc_codegen_ssa/src/back/write.rs:1573 6 Thread 0x7fffe113b700 (LWP 3150) "opt foof.7rcbfp" 0x00007ffff2940e62 in llvm::CallGraph::populateCallGraphNode(llvm::CallGraphNode*) () from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so 8 Thread 0x7fffe0d39700 (LWP 3158) "opt foof.7rcbfp" 0x00007fffefe8998e in malloc_consolidate (av=av@entry=0x7ffe2c000020) at malloc.c:4492 9 Thread 0x7fffe0f3a700 (LWP 3162) "opt foof.7rcbfp" 0x00007fffefef27c4 in __libc_open64 (file=0x7fffe0f38608 "foof.foof.7rcbfp3g-cgu.6.rcgu.o", oflag=524865) at ../sysdeps/unix/sysv/linux/open64.c:48 (gdb) ``` and Windows Performance Analyzer will also show this information when profiling: ![image](https://user-images.githubusercontent.com/831192/109231017-d311f780-7793-11eb-8072-ab836a830e90.png)
2021-02-26Rollup merge of #82506 - estebank:unused_variable_lint, r=lcnrGuillaume Gomez-5/+10
Properly account for non-shorthand pattern field in unused variable lint Fix #82488
2021-02-26Rollup merge of #82491 - tmiasko:i, r=lcnrGuillaume Gomez-124/+146
Consider inexpensive inlining criteria first Refactor inlining decisions so that inexpensive criteria are considered first: 1. Based on code generation attributes. 2. Based on MIR availability (examines call graph). 3. Based on MIR body.
2021-02-26Rollup merge of #82456 - klensy:or-else, r=estebankGuillaume Gomez-28/+34
Replaced some unwrap_or and map_or with lazy variants Replaced some `unwrap_or` and `map_or` with `unwrap_or_else` and `map_or_else`.
2021-02-26Rollup merge of #82165 - nellshamrell:nell/fix-80658-B, r=estebankGuillaume Gomez-2/+11
Reword labels on E0308 involving async fn return type Fix for #80658. When someone writes code like this: ```rust fn foo() -> u8 { async fn async_fn() -> () {} async_fn() } ``` And they try to compile it, they will see an error that looks like this: ```bash error[E0308]: mismatched types --> test.rs:4:5 | 1 | fn foo() -> u8 { | -- expected `u8` because of return type 2 | async fn async_fn() -> () {} | -- checked the `Output` of this `async fn`, found opaque type 3 | 4 | async_fn() | ^^^^^^^^^^ expected `u8`, found opaque type | = note: while checking the return type of this `async fn` = note: expected type `u8` found opaque type `impl Future` ```
2021-02-26Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-seGuillaume Gomez-6/+1
Stabilize str_split_once Closes #74773
2021-02-26Auto merge of #81458 - estebank:match-stmt-remove-semi, r=oli-obkbors-10/+80
Detect match statement intended to be tail expression CC #24157
2021-02-26Link crtbegin/crtend on musl to terminate .eh_frameNikita Popov-7/+14
For some targets, rustc uses a "CRT fallback", where it links CRT object files it ships instead of letting the host compiler link them. On musl, rustc currently links crt1, crti and crtn (provided by libc), but does not link crtbegin and crtend (provided by libgcc). In particular, crtend is responsible for terminating the .eh_frame section. Lack of terminator may result in segfaults during unwinding, as reported in #47551 and encountered by the LLVM 12 update in #81451. This patch links crtbegin and crtend for musl as well, following the table at the top of crt_objects.rs.
2021-02-26update tracking issue for `relaxed_struct_unsize`lcnr-1/+1
2021-02-26Auto merge of #78429 - casey:doctest-attribute-splitting, r=jyn514bors-3/+3
[librustdoc] Only split lang string on `,`, ` `, and `\t` Split markdown lang strings into tokens on `,`. The previous behavior was to split lang strings into tokens on any character that wasn't a `_`, `_`, or alphanumeric. This is a potentially breaking change, so please scrutinize! See discussion in #78344. I noticed some test cases that made me wonder if there might have been some reason for the original behavior: ``` t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None); t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None); t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None); t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None); ``` It seemed pretty peculiar to specifically test lang strings in braces, with all the tokens prefixed by `.`. I did some digging, and it looks like the test cases were added way back in [this commit from 2014](https://github.com/rust-lang/rust/commit/3fef7a74ca9a) by `@skade.` It looks like they were added just to make sure that the splitting was permissive, and aren't testing that those strings in particular are accepted. Closes https://github.com/rust-lang/rust/issues/78344.
2021-02-26Miscellaneous inlining improvementsTomasz Miąsko-8/+52
Inline a few small and hot functions.
2021-02-25Set codegen thread namesWesley Wiser-47/+77
For example, gdb: ``` (gdb) info threads Id Target Id Frame 1 Thread 0x7fffefa7ec40 (LWP 2905) "rustc" __pthread_clockjoin_ex (threadid=140737214134016, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145 2 Thread 0x7fffefa7b700 (LWP 2957) "rustc" 0x00007ffff125eaa8 in llvm::X86_MC::initLLVMToSEHAndCVRegMapping(llvm::MCRegisterInfo*) () from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so 3 Thread 0x7fffeef0f700 (LWP 3116) "rustc" futex_wait_cancelable (private=0, expected=0, futex_word=0x7fffe8602ac8) at ../sysdeps/nptl/futex-internal.h:183 * 4 Thread 0x7fffeed0e700 (LWP 3123) "rustc" rustc_codegen_ssa::back::write::spawn_work (cgcx=..., work=...) at /home/wesley/code/rust/rust/compiler/rustc_codegen_ssa/src/back/write.rs:1573 6 Thread 0x7fffe113b700 (LWP 3150) "opt foof.7rcbfp" 0x00007ffff2940e62 in llvm::CallGraph::populateCallGraphNode(llvm::CallGraphNode*) () from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so 8 Thread 0x7fffe0d39700 (LWP 3158) "opt foof.7rcbfp" 0x00007fffefe8998e in malloc_consolidate (av=av@entry=0x7ffe2c000020) at malloc.c:4492 9 Thread 0x7fffe0f3a700 (LWP 3162) "opt foof.7rcbfp" 0x00007fffefef27c4 in __libc_open64 (file=0x7fffe0f38608 "foof.foof.7rcbfp3g-cgu.6.rcgu.o", oflag=524865) at ../sysdeps/unix/sysv/linux/open64.c:48 (gdb) ```
2021-02-25Update measureme dependency to the latest versionWesley Wiser-3/+3
This version adds the ability to use `rdpmc` hardware-based performance counters instead of wall-clock time for measuring duration. This also introduces a dependency on the `perf-event-open-sys` crate on Linux which is used when using hardware counters.
2021-02-25Rollup merge of #82510 - jyn514:fix-typo, r=Dylan-DPCAaron Hill-1/+1
Fix typo in `param_env_reveal_all_normalized` This made the generated docs look strange: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.param_env_reveal_all_normalized
2021-02-25Rollup merge of #82468 - osa1:pick_by_value_method_docs, r=petrochenkovAaron Hill-19/+17
Move pick_by_value_method docs above function header - Currently style triggers #81183 so we can't add `#[instrument]` to this function. - Having docs above the header is more consistent with the rest of the code base.
2021-02-25Rollup merge of #82269 - LeSeulArtichaut:cleanup-ppmode, r=spastorinoAaron Hill-99/+92
Cleanup `PpMode` and friends This PR: - Separates `PpSourceMode` and `PpHirMode` to remove invalid states - Renames the variant to remove the redundant `Ppm` prefix - Adds basic documentation for the different pretty-print modes - Cleanups some code to make it more idiomatic Not sure if this is actually useful, but it looks cleaner to me.
2021-02-25Auto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obkbors-4/+244
Add #[rustc_legacy_const_generics] This is the first step towards removing `#[rustc_args_required_const]`: a new attribute is added which rewrites function calls of the form `func(a, b, c)` to `func::<{b}>(a, c)`. This allows previously stabilized functions in `stdarch` which use `rustc_args_required_const` to use const generics instead. This new attribute is not intended to ever be stabilized, it is only intended for use in `stdarch` as a replacement for `#[rustc_args_required_const]`. ```rust #[rustc_legacy_const_generics(1)] pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] { [x, Y, z] } fn main() { assert_eq!(foo(0 + 0, 1 + 1, 2 + 2), [0, 2, 4]); assert_eq!(foo::<{1 + 1}>(0 + 0, 2 + 2), [0, 2, 4]); } ``` r? `@oli-obk`
2021-02-25Detect match statement intended to be tail expressionEsteban Küber-10/+80
CC #24157
2021-02-25Rollup merge of #82364 - osa1:issue82361, r=estebankDylan DPC-4/+32
Improve error msgs when found type is deref of expected This improves help messages in two cases: - When expected type is `T` and found type is `&T`, we now look through blocks and suggest dereferencing the expression of the block, rather than the whole block. - In the above case, if the expression is an `&`, we not suggest removing the `&` instead of adding `*`. Both of these are demonstrated in the regression test. Before this patch the first error in the test would be: error[E0308]: `if` and `else` have incompatible types --> test.rs:8:9 | 5 | / if true { 6 | | a | | - expected because of this 7 | | } else { 8 | | b | | ^ expected `usize`, found `&usize` 9 | | }; | |_____- `if` and `else` have incompatible types | help: consider dereferencing the borrow | 7 | } else *{ 8 | b 9 | }; | Now: error[E0308]: `if` and `else` have incompatible types --> test.rs:8:9 | 5 | / if true { 6 | | a | | - expected because of this 7 | | } else { 8 | | b | | ^ | | | | | expected `usize`, found `&usize` | | help: consider dereferencing the borrow: `*b` 9 | | }; | |_____- `if` and `else` have incompatible types The second error: error[E0308]: `if` and `else` have incompatible types --> test.rs:14:9 | 11 | / if true { 12 | | 1 | | - expected because of this 13 | | } else { 14 | | &1 | | ^^ expected integer, found `&{integer}` 15 | | }; | |_____- `if` and `else` have incompatible types | help: consider dereferencing the borrow | 13 | } else *{ 14 | &1 15 | }; | now: error[E0308]: `if` and `else` have incompatible types --> test.rs:14:9 | 11 | / if true { 12 | | 1 | | - expected because of this 13 | | } else { 14 | | &1 | | ^- | | || | | |help: consider removing the `&`: `1` | | expected integer, found `&{integer}` 15 | | }; | |_____- `if` and `else` have incompatible types Fixes #82361 --- r? ````@estebank````
2021-02-25Rollup merge of #82321 - bugadani:ast3, r=varkorDylan DPC-7/+6
AST: Remove some unnecessary boxes
2021-02-25Rollup merge of #82220 - henryboisdequin:fixes-80853, r=varkorDylan DPC-2/+21
fix the false 'defined here' messages Closes #80853. Take this code: ```rust struct S; fn repro_ref(thing: S) { thing(); } ``` Previously, the error message would be this: ``` error[E0618]: expected function, found `S` --> src/lib.rs:4:5 | 3 | fn repro_ref(thing: S) { | ----- `S` defined here 4 | thing(); | ^^^^^-- | | | call expression requires function error: aborting due to previous error ``` This is incorrect as `S` is not defined in the function arguments, `thing` is defined there. With this change, the following is emitted: ``` error[E0618]: expected function, found `S` --> $DIR/80853.rs:4:5 | LL | fn repro_ref(thing: S) { | ----- is of type `S` LL | thing(); | ^^^^^-- | | | call expression requires function | = note: local variable `S` is not a function error: aborting due to previous error ``` As you can see, this error message points out that `thing` is of type `S` and later in a note, that `S` is not a function. This change does seem like a downside for some error messages. Take this example: ``` LL | struct Empty2; | -------------- is of type `Empty2` ``` As you can see, the error message shows that the definition of `Empty2` is of type `Empty2`. Although this isn't wrong, it would be more helpful if it would say something like this (which was there previously): ``` LL | struct Empty2; | -------------- `Empty2` defined here ``` If there is a better way of doing this, where the `Empty2` example would stay the same as without this change, please inform me. **Update: This is now fixed** CC `@camelid`
2021-02-25Rollup merge of #82214 - est31:no_to_string, r=oli-obkDylan DPC-6/+6
Remove redundant to_string calls
2021-02-25Rollup merge of #82213 - est31:slices_for_vecs, r=jyn514Dylan DPC-3/+3
Slices for vecs
2021-02-25Rollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebankDylan DPC-2/+12
Do not consider using a semicolon inside of a different-crate macro Fixes #81943
2021-02-25Rollup merge of #82087 - estebank:abolish-ice, r=oli-obkDylan DPC-20/+14
Fix ICE caused by suggestion with no code substitutions Change suggestion logic to filter and checking _before_ creating specific resolution suggestion. Assert earlier that suggestions contain code substitions to make it easier in the future to debug invalid uses. If we find this becomes too noisy in the wild, we can always make the emitter resilient to these cases and remove the assertions. Fix #78651.