about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-02-24Remove in-band lifetimesMichael Goulet-1323/+35
2022-02-24Rollup merge of #94315 - lcnr:auto-trait-lint-update, r=oli-obkDylan DPC-7/+32
update auto trait lint for `PhantomData` cc https://github.com/rust-lang/rust/issues/93367#issuecomment-1047898410
2022-02-24Rollup merge of #94242 - compiler-errors:fat-uninhabitable-pointer, ↵Dylan DPC-0/+29
r=michaelwoerister properly handle fat pointers to uninhabitable types Calculate the pointee metadata size by using `tcx.struct_tail_erasing_lifetimes` instead of duplicating the logic in `fat_pointer_kind`. Open to alternatively suggestions on how to fix this. Fixes #94149 r? ````@michaelwoerister```` since you touched this code last, I think!
2022-02-24Rollup merge of #94212 - scottmcm:swapper, r=dtolnayDylan DPC-0/+140
Stop manually SIMDing in `swap_nonoverlapping` Like I previously did for `reverse` (#90821), this leaves it to LLVM to pick how to vectorize it, since it can know better the chunk size to use, compared to the "32 bytes always" approach we currently have. A variety of codegen tests are included to confirm that the various cases are still being vectorized. It does still need logic to type-erase in some cases, though, as while LLVM is now smart enough to vectorize over slices of things like `[u8; 4]`, it fails to do so over slices of `[u8; 3]`. As a bonus, this change also means one no longer gets the spurious `memcpy`(s?) at the end up swapping a slice of `__m256`s: <https://rust.godbolt.org/z/joofr4v8Y> <details> <summary>ASM for this example</summary> ## Before (from godbolt) note the `push`/`pop`s and `memcpy` ```x86 swap_m256_slice: push r15 push r14 push r13 push r12 push rbx sub rsp, 32 cmp rsi, rcx jne .LBB0_6 mov r14, rsi shl r14, 5 je .LBB0_6 mov r15, rdx mov rbx, rdi xor eax, eax .LBB0_3: mov rcx, rax vmovaps ymm0, ymmword ptr [rbx + rax] vmovaps ymm1, ymmword ptr [r15 + rax] vmovaps ymmword ptr [rbx + rax], ymm1 vmovaps ymmword ptr [r15 + rax], ymm0 add rax, 32 add rcx, 64 cmp rcx, r14 jbe .LBB0_3 sub r14, rax jbe .LBB0_6 add rbx, rax add r15, rax mov r12, rsp mov r13, qword ptr [rip + memcpy@GOTPCREL] mov rdi, r12 mov rsi, rbx mov rdx, r14 vzeroupper call r13 mov rdi, rbx mov rsi, r15 mov rdx, r14 call r13 mov rdi, r15 mov rsi, r12 mov rdx, r14 call r13 .LBB0_6: add rsp, 32 pop rbx pop r12 pop r13 pop r14 pop r15 vzeroupper ret ``` ## After (from my machine) Note no `rsp` manipulation, sorry for different ASM syntax ```x86 swap_m256_slice: cmpq %r9, %rdx jne .LBB1_6 testq %rdx, %rdx je .LBB1_6 cmpq $1, %rdx jne .LBB1_7 xorl %r10d, %r10d jmp .LBB1_4 .LBB1_7: movq %rdx, %r9 andq $-2, %r9 movl $32, %eax xorl %r10d, %r10d .p2align 4, 0x90 .LBB1_8: vmovaps -32(%rcx,%rax), %ymm0 vmovaps -32(%r8,%rax), %ymm1 vmovaps %ymm1, -32(%rcx,%rax) vmovaps %ymm0, -32(%r8,%rax) vmovaps (%rcx,%rax), %ymm0 vmovaps (%r8,%rax), %ymm1 vmovaps %ymm1, (%rcx,%rax) vmovaps %ymm0, (%r8,%rax) addq $2, %r10 addq $64, %rax cmpq %r10, %r9 jne .LBB1_8 .LBB1_4: testb $1, %dl je .LBB1_6 shlq $5, %r10 vmovaps (%rcx,%r10), %ymm0 vmovaps (%r8,%r10), %ymm1 vmovaps %ymm1, (%rcx,%r10) vmovaps %ymm0, (%r8,%r10) .LBB1_6: vzeroupper retq ``` </details> This does all its copying operations as either the original type or as `MaybeUninit`s, so as far as I know there should be no potential abstract machine issues with reading padding bytes as integers. <details> <summary>Perf is essentially unchanged</summary> Though perhaps with more target features this would help more, if it could pick bigger chunks ## Before ``` running 10 tests test slice::swap_with_slice_4x_usize_30 ... bench: 894 ns/iter (+/- 11) test slice::swap_with_slice_4x_usize_3000 ... bench: 99,476 ns/iter (+/- 2,784) test slice::swap_with_slice_5x_usize_30 ... bench: 1,257 ns/iter (+/- 7) test slice::swap_with_slice_5x_usize_3000 ... bench: 139,922 ns/iter (+/- 959) test slice::swap_with_slice_rgb_30 ... bench: 328 ns/iter (+/- 27) test slice::swap_with_slice_rgb_3000 ... bench: 16,215 ns/iter (+/- 176) test slice::swap_with_slice_u8_30 ... bench: 312 ns/iter (+/- 9) test slice::swap_with_slice_u8_3000 ... bench: 5,401 ns/iter (+/- 123) test slice::swap_with_slice_usize_30 ... bench: 368 ns/iter (+/- 3) test slice::swap_with_slice_usize_3000 ... bench: 28,472 ns/iter (+/- 3,913) ``` ## After ``` running 10 tests test slice::swap_with_slice_4x_usize_30 ... bench: 868 ns/iter (+/- 36) test slice::swap_with_slice_4x_usize_3000 ... bench: 99,642 ns/iter (+/- 1,507) test slice::swap_with_slice_5x_usize_30 ... bench: 1,194 ns/iter (+/- 11) test slice::swap_with_slice_5x_usize_3000 ... bench: 139,761 ns/iter (+/- 5,018) test slice::swap_with_slice_rgb_30 ... bench: 324 ns/iter (+/- 6) test slice::swap_with_slice_rgb_3000 ... bench: 15,962 ns/iter (+/- 287) test slice::swap_with_slice_u8_30 ... bench: 281 ns/iter (+/- 5) test slice::swap_with_slice_u8_3000 ... bench: 5,324 ns/iter (+/- 40) test slice::swap_with_slice_usize_30 ... bench: 275 ns/iter (+/- 5) test slice::swap_with_slice_usize_3000 ... bench: 28,277 ns/iter (+/- 277) ``` </detail>
2022-02-24Rollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkovDylan DPC-1/+413
Improve `--check-cfg` implementation This pull-request is a mix of improvements regarding the `--check-cfg` implementation: - Simpler internal representation (usage of `Option` instead of separate bool) - Add --check-cfg to the unstable book (based on the RFC) - Improved diagnostics: * List possible values when the value is unexpected * Suggest if possible a name or value that is similar - Add more tests (well known names, mix of combinations, ...) r? ```@petrochenkov```
2022-02-24Rollup merge of #93714 - compiler-errors:can-type-impl-copy-error-span, ↵Dylan DPC-1/+40
r=jackh726 better ObligationCause for normalization errors in `can_type_implement_copy` Some logic is needed so we can point to the field when given totally nonsense types like `struct Foo(<u32 as Iterator>::Item);` Fixes #93687
2022-02-24Update clippy testsVadim Petrochenkov-2/+2
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-4/+4
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-24restore spans for issue-50480Michael Goulet-18/+16
2022-02-24better ObligationCause for normalization errors in can_type_implement_copyMichael Goulet-17/+58
2022-02-24Auto merge of #94129 - cjgillot:rmeta-table, r=petrochenkovbors-2/+2
Back more metadata using per-query tables r? `@ghost`
2022-02-24update auto trait lintlcnr-7/+32
2022-02-24Rollup merge of #94296 - lnicola:rust-analyzer-2022-02-23, r=lnicolaMatthias Krüger-16/+16
:arrow_up: rust-analyzer r? `@ghost`
2022-02-24Rollup merge of #94270 - RalfJung:fn-ptrs, r=oli-obkMatthias Krüger-18/+92
Miri: relax fn ptr check As discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/72#issuecomment-1025407536, the function pointer check done by Miri is currently overeager: contrary to our usual principle of only checking rather uncontroversial validity invariants, we actually check that the pointer points to a real function. So, this relaxes the check to what the validity invariant probably will be (and what the reference already says it is): the function pointer must be non-null, and that's it. The check that CTFE does on the final value of a constant is unchanged -- CTFE recurses through references, so it makes some sense to also recurse through function pointers. We might still want to relax this in the future, but that would be a separate change. r? `@oli-obk`
2022-02-24Rollup merge of #89887 - arlosi:char-debug, r=wesleywiserMatthias Krüger-5/+4
Change `char` type in debuginfo to DW_ATE_UTF Rust previously encoded the `char` type as DW_ATE_unsigned_char. The more appropriate encoding is `DW_ATE_UTF`. Clang also uses the DW_ATE_UTF for `char32_t` in C++. This fixes the display of the `char` type in the Windows debuggers. Without this change, the variable did not show in the locals window. ![image](https://user-images.githubusercontent.com/704597/137368067-9b3e4dc8-a075-44ba-a687-bf3810a44e5a.png) LLDB 13 is also able to display the char value, when before it failed with `need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x8, bit_size = 32` r? `@wesleywiser`
2022-02-23Miri: relax fn ptr checkRalf Jung-18/+92
2022-02-23Change `char` type in debuginfo to DW_ATE_UTFArlo Siemsen-5/+4
Rust previously encoded the `char` type as DW_ATE_unsigned_char. The more appropriate encoding is DW_ATE_UTF. Clang uses this same debug encoding for char32_t. This fixes the display of `char` types in Windows debuggers as well as LLDB.
2022-02-23properly handle fat pointers to uninhabitable typesMichael Goulet-0/+29
2022-02-23:arrow_up: rust-analyzerLaurențiu Nicola-16/+16
2022-02-23Add compiler flag `--check-cfg` to the unstable bookLoïc BRANSTETT-0/+221
2022-02-23Continue improvements on the --check-cfg implementationLoïc BRANSTETT-1/+138
- Test the combinations of --check-cfg with partial values() and --cfg - Test that we detect unexpected value when none are expected
2022-02-23Rollup merge of #94263 - anko:patch-1, r=GuillaumeGomezMatthias Krüger-1/+1
Typo fix: Close inline-code backtick A drop in the ocean.
2022-02-23Rollup merge of #94260 - GuillaumeGomez:infinite-redirection, r=notriddleMatthias Krüger-26/+63
Fix rustdoc infinite redirection generation Someone came to me about a funny bug they had when clicking on any link on [this page](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/builders/index.html): it ended one page redirecting to itself indefinitely. I was able to make a minimum reproducible case to trigger this bug which I now use as a test. r? ``@notriddle``
2022-02-23Rollup merge of #94259 - krasimirgg:bump-llvm-ci, r=Mark-SimulacrumMatthias Krüger-1/+1
Bump download-ci-llvm-stamp for llvm-nm inclusion We started using it in https://github.com/rust-lang/rust/pull/94023.
2022-02-23Rollup merge of #94253 - bjorn3:xpy-fmt-2021, r=Mark-SimulacrumMatthias Krüger-1/+1
Use 2021 edition in ./x.py fmt
2022-02-23Rollup merge of #94240 - compiler-errors:pathbuf-display, r=lcnrMatthias Krüger-2/+16
Suggest calling .display() on `PathBuf` too Fixes #94210
2022-02-23Rollup merge of #94213 - digama0:patch-4, r=Dylan-DPCMatthias Krüger-2/+2
fix names in feature(...) suggestion
2022-02-23Rollup merge of #94137 - aDotInTheVoid:abi-enum, r=CraftSpiderMatthias Krüger-115/+238
rustdoc-json: Better Header Type - Make ABI an enum, instead of being stringly typed - Replace Qualifier HashSet with 3 bools - Merge ABI field into header, as they always occor together r? ``@CraftSpider`` ``@rustbot`` modify labels: +A-rustdoc-json +T-rustdoc
2022-02-23Rollup merge of #94128 - mqy:master, r=Dylan-DPCMatthias Krüger-1/+1
rustdoc: several minor fixes ``@rustbot`` label A-docs
2022-02-22Update cargoEric Huss-0/+0
2022-02-22Improve diagnostic of the unexpected_cfgs lintLoïc BRANSTETT-4/+9
2022-02-22Add test for well known names defined by rustcLoïc BRANSTETT-0/+49
2022-02-22Auto merge of #83706 - a1phyr:fix_vec_layout_calculation, r=JohnTitorbors-0/+3
Fix a layout possible miscalculation in `alloc::RawVec` A layout miscalculation could happen in `RawVec` when used with a type whose size isn't a multiple of its alignment. I don't know if such type can exist in Rust, but the Layout API provides ways to manipulate such types. Anyway, it is better to calculate memory size in a consistent way.
2022-02-22Typo fix: Close inline-code backtickAntti Korpi-1/+1
2022-02-22Add test for infinite redirectionGuillaume Gomez-0/+29
2022-02-22Prevent generation of infinite redirectionsGuillaume Gomez-26/+34
2022-02-22Auto merge of #94254 - matthiaskrgr:rollup-7llbjhd, r=matthiaskrgrbors-66/+240
Rollup of 7 pull requests Successful merges: - #94169 (Fix several asm! related issues) - #94178 (tidy: fire less "ignoring file length unneccessarily" warnings) - #94179 (solarish current_exe using libc call directly) - #94196 (compiletest: Print process output info with less whitespace) - #94208 (Add the let else tests found missing in the stabilization report) - #94237 (Do not suggest wrapping an item if it has ambiguous un-imported methods) - #94246 (ScalarMaybeUninit is explicitly hexadecimal in its formatting) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-22Bump download-ci-llvm-stamp for llvm-nm inclusionKrasimir Georgiev-1/+1
We started using it in https://github.com/rust-lang/rust/pull/94023.
2022-02-22Rollup merge of #94237 - compiler-errors:dont-wrap-ambiguous-receivers, r=lcnrMatthias Krüger-26/+41
Do not suggest wrapping an item if it has ambiguous un-imported methods If the method is defined for the receiver we have, but is ambiguous during probe, then it probably comes from one of several traits that just weren't `use`d. Don't suggest wrapping the receiver in `Box`/etc., even if that makes the method probe unambiguous. Fixes #94218
2022-02-22Rollup merge of #94208 - est31:let_else, r=Mark-SimulacrumMatthias Krüger-4/+100
Add the let else tests found missing in the stabilization report In the stabilization report of `let else`, in #93628, I found various cases which weren't tested. This PR adds them.
2022-02-22Rollup merge of #94196 - aDotInTheVoid:terse-procres-info, r=Mark-SimulacrumMatthias Krüger-15/+19
compiletest: Print process output info with less whitespace Before: ``` error: jsondocck failed! status: exit status: 1 command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--template" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" stdout: ------------------------------------------ ------------------------------------------ stderr: ------------------------------------------ Invalid command: Tried to use the previous path in the first command on line 10 Error: "Jsondocck failed for /data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" ------------------------------------------ Rustdoc Output: status: exit status: 0 command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait/auxiliary" "-o" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--deny" "warnings" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" "--output-format" "json" "-Zunstable-options" stdout: ------------------------------------------ ------------------------------------------ stderr: ------------------------------------------ ------------------------------------------ ``` After: ``` error: jsondocck failed! status: exit status: 1 command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--template" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" stdout: none --- stderr ------------------------------- Invalid command: Tried to use the previous path in the first command on line 10 Error: "Jsondocck failed for /data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" ------------------------------------------ Rustdoc Output: status: exit status: 0 command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait/auxiliary" "-o" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--deny" "warnings" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" "--output-format" "json" "-Zunstable-options" stdout: none stderr: none ```
2022-02-22Rollup merge of #94178 - est31:tolerant_lines_check, r=Mark-SimulacrumMatthias Krüger-0/+3
tidy: fire less "ignoring file length unneccessarily" warnings This avoids a situation where a file is at the border of the limit, and alternates between hitting the limit and not hitting it, causing a back and forth of addition of the ignore-tidy-linelength directive. As an example, consider the ignore-tidy-filelength of compiler/rustc_typeck/src/collect.rs. It was added in 2ca4964db5d263a8f9222846bd70a7f26cf414cf, removed in 37354ebc9794b0eb14b08c02177e3094c8fe91cd (a revert of the earlier commit), added again in 448d07683a6defd567996114793a09c9a8aef5df, removed in 3171bd5bf54fb91f7f7df7c40df5adc7d8bd5dea, added in 438826fd1a9a119d00992ede948cdd479431ecbb, and removed in bb0a2f985cb6e980cc026ea952733d53bb868f87. To avoid this back and forth, we exempt files from the unneccessary ignoring warning that have length of at least 70% of the limit.
2022-02-22Rollup merge of #94169 - Amanieu:asm_stuff, r=nagisaMatthias Krüger-21/+77
Fix several asm! related issues This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other. Fixes #92378 Fixes #85247 r? ``@nagisa``
2022-02-22Auto merge of #94209 - lcnr:print-mir-consts, r=oli-obkbors-317/+84
change `mir::Constant` in mir dumps this removes duplicate information and avoids printing the `stable_crate_id` in mir dumps which broke CI in #94059 r? `@oli-obk` cc `@b-naber`
2022-02-22Use 2021 edition in ./x.py fmtbjorn3-1/+1
2022-02-22change `mir::Constant` in mir dumpslcnr-317/+84
2022-02-22Auto merge of #93839 - Mark-Simulacrum:delete-json-rust-deserialization, ↵bors-89/+16
r=nnethercote Simplify rustc_serialize by dropping support for decoding into JSON This PR currently bundles two (somewhat separate) tasks. First, it removes the JSON Decoder trait impl, which permitted going from JSON to Rust structs. For now, we keep supporting JSON deserialization, but only to `Json` (an equivalent of serde_json::Value). The primary hard to remove user there is for custom targets -- which need some form of JSON deserialization -- but they already have a custom ad-hoc pass for moving from Json to a Rust struct. A [comment](https://github.com/rust-lang/rust/blob/e7aca895980f25f6d2d3c48e10fd04656764d1e4/compiler/rustc_target/src/spec/mod.rs#L1653) there suggests that it would be impractical to move them to a Decodable-based impl, at least without backwards compatibility concerns. I suspect that if we were widely breaking compat there, it would make sense to use serde_json at this point which would produce better error messages; the types in rustc_target are relatively isolated so we would not particularly suffer from using serde_derive. The second part of the PR (all but the first commit) is to simplify the Decoder API by removing the non-primitive `read_*` functions. These primarily add indirection (through a closure), which doesn't directly cause a performance issue (the unique closure types essentially guarantee monomorphization), but does increase the amount of work rustc and LLVM need to do. This could be split out to a separate PR, but is included here in part to help motivate the first part. Future work might consist of: * Specializing enum discriminant encoding to avoid leb128 for small enums (since we know the variant count, we can directly use read/write u8 in almost all cases) * Adding new methods to support faster deserialization (e.g., access to the underlying byte stream) * Currently these are somewhat ad-hoc supported by specializations for e.g. `Vec<u8>`, but other types which could benefit don't today. * Removing the Decoder trait entirely in favor of a concrete type -- today, we only really have one impl of it modulo wrappers used for specialization-based dispatch. Highly recommend review with whitespace changes off, as the removal of closures frequently causes things to be de-indented.
2022-02-21Suggest calling .display() on PathBuf tooMichael Goulet-2/+16
2022-02-21Do not suggest wrapping an item if it has ambiguous un-imported methodsMichael Goulet-26/+41
2022-02-21Auto merge of #94225 - matthiaskrgr:rollup-0728x8n, r=matthiaskrgrbors-56/+85
Rollup of 10 pull requests Successful merges: - #91192 (Some improvements to the async docs) - #94143 (rustc_const_eval: adopt let else in more places) - #94156 (Gracefully handle non-UTF-8 string slices when pretty printing) - #94186 (Update pin_static_ref stabilization version.) - #94189 (Implement LowerHex on Scalar to clean up their display in rustdoc) - #94190 (Use Metadata::modified instead of FileTime::from_last_modification_ti…) - #94203 (CTFE engine: Scalar: expose size-generic to_(u)int methods) - #94211 (Better error if the user tries to do assignment ... else) - #94215 (trait system: comments and small nonfunctional changes) - #94220 (Correctly handle miniz_oxide extern crate declaration) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup