Commit Graph

165387 Commits

Author SHA1 Message Date
Dylan DPC
1f33cd1827
Rollup merge of #95407 - xfix:inline-u8-is_utf8_char_boundary, r=scottmcm
Inline u8::is_utf8_char_boundary

Since Rust beta, Rust is incapable of inlining this function in the following example function.

```rust
pub fn safe_substr_to(s: &str, mut length: usize) -> &str {
    loop {
        if let Some(s) = s.get(..length) {
            return s;
        }
        length -= 1;
    }
}
```

When compiled with beta or nightly compiler on Godbolt with `-C opt-level=3` flag it prints the following assembly.

```asm
example::safe_substr_to:
        push    r15
        push    r14
        push    r12
        push    rbx
        push    rax
        mov     r14, rdi
        test    rdx, rdx
        je      .LBB0_8
        mov     rbx, rdx
        mov     r15, rsi
        mov     r12, qword ptr [rip + core::num::<impl u8>::is_utf8_char_boundary@GOTPCREL]
        jmp     .LBB0_4
.LBB0_2:
        je      .LBB0_9
.LBB0_3:
        add     rbx, -1
        je      .LBB0_8
.LBB0_4:
        cmp     rbx, r15
        jae     .LBB0_2
        movzx   edi, byte ptr [r14 + rbx]
        call    r12
        test    al, al
        je      .LBB0_3
        mov     r15, rbx
        jmp     .LBB0_9
.LBB0_8:
        xor     r15d, r15d
.LBB0_9:
        mov     rax, r14
        mov     rdx, r15
        add     rsp, 8
        pop     rbx
        pop     r12
        pop     r14
        pop     r15
        ret
```

`qword ptr [rip + core::num::<impl u8>::is_utf8_char_boundary@GOTPCREL]` is not inlined. `-C remark=all` outputs the following message:

```
note: /rustc/7bccde19767082c7865a12902fa614ed4f8fed73/library/core/src/str/mod.rs:214:25: inline: _ZN4core3num20_$LT$impl$u20$u8$GT$21is_utf8_char_boundary17hace9f12f5ba07a7fE will not be inlined into _ZN4core3str21_$LT$impl$u20$str$GT$16is_char_boundary17hf2587e9a6b8c5e43E because its definition is unavailable
```

Stable compiler outputs more reasonable code:

```asm
example::safe_substr_to:
        mov     rcx, rdx
        mov     rax, rdi
        test    rdx, rdx
        je      .LBB0_9
        mov     rdx, rsi
        jmp     .LBB0_4
.LBB0_2:
        cmp     rdx, rcx
        je      .LBB0_7
.LBB0_3:
        add     rcx, -1
        je      .LBB0_9
.LBB0_4:
        cmp     rcx, rdx
        jae     .LBB0_2
        cmp     byte ptr [rax + rcx], -64
        jl      .LBB0_3
        mov     rdx, rcx
.LBB0_7:
        ret
.LBB0_9:
        xor     edx, edx
        ret
```
2022-03-28 20:41:53 +02:00
Dylan DPC
4c8bc046b9
Rollup merge of #95397 - dtolnay:disclaimer, r=m-ou-se
Link to std::io's platform-specific behavior disclaimer

This PR adds some links in standard library documentation to point to https://doc.rust-lang.org/std/io/index.html#platform-specific-behavior.

> ### Platform-specific behavior
>
> Many I/O functions throughout the standard library are documented to indicate what various library or syscalls they are delegated to. This is done to help applications both understand what’s happening under the hood as well as investigate any possibly unclear semantics. Note, however, that this is informative, not a binding contract. The implementation of many of these functions are subject to change over time and may call fewer or more syscalls/library functions.

Many of the `std::fs` APIs already link to this disclaimer when discussing system calls.
2022-03-28 20:41:52 +02:00
Dylan DPC
ce319ac1a2
Rollup merge of #95328 - DrMeepster:box_gep_err, r=oli-obk
Fix yet another Box<T, A> ICE

Fixes #95036.

This widens the special case from #94414 to make sure that boxes with a custom allocator are never directly dereferenced.
2022-03-28 20:41:51 +02:00
Dylan DPC
e10d5039bc
Rollup merge of #95318 - rust-lang:notriddle/issue-95208, r=wesleywiser
diagnostics: correct generic bounds with doubled colon

Fixes #95208
2022-03-28 20:41:50 +02:00
Dylan DPC
72770efcb0
Rollup merge of #93787 - klensy:really-not-a-features, r=wesleywiser
parallel_compiler: hide dependencies behind feature

Separate dependencies for `parallel_compiler` feature, so they will not be compiled if feature not selected, reducing number of compiled crates from 238 to 224.
2022-03-28 20:41:49 +02:00
Oli Scherer
638f84d782 rebase fallout 2022-03-28 17:22:42 +00:00
Oli Scherer
b262c7c2da Add test for revealing auto traits in the defining scope 2022-03-28 17:09:50 +00:00
Oli Scherer
5d3941878e Add some tests showcasing further differences between TAIT and RPIT 2022-03-28 17:09:40 +00:00
Oli Scherer
88296432d3 Bless ui tests 2022-03-28 17:09:29 +00:00
Oli Scherer
360edd611d Also use the RPIT back compat hack in trait projection 2022-03-28 17:09:00 +00:00
Oli Scherer
dc35d584a9 Show that the behaviour is the same for RPIT and TAIT 2022-03-28 17:08:50 +00:00
Oli Scherer
e82b0cde4e Add a test showing that a similar example compiles 2022-03-28 17:08:40 +00:00
Oli Scherer
7b4f715979 Added another folder to the ui dir 2022-03-28 17:08:28 +00:00
Oli Scherer
2aa49d4005 Fix mixing lazy TAIT and RPIT in their defining scopes 2022-03-28 17:02:21 +00:00
Oli Scherer
4f6e27d4cf Add regression test 2022-03-28 17:02:08 +00:00
Oli Scherer
3cce66c544 Add another regression test 2022-03-28 17:01:57 +00:00
Oli Scherer
6596e9dfcf Test that TAIT and RPIT are in sync 2022-03-28 17:01:23 +00:00
Oli Scherer
53c96ed528 Add some tests around recursion and "revealing" 2022-03-28 17:01:09 +00:00
Oli Scherer
1f46f771a6 Remove some special code handling TAIT being passed through if and match
This is not necessary for RPIT anymore, since we reverted that to using inference vars.
2022-03-28 17:00:29 +00:00
Oli Scherer
02536fe18b The hack isn't necessary for back compat anymore 2022-03-28 16:59:56 +00:00
Oli Scherer
7f933de194 Merge two duplicates of the same logic into a common function 2022-03-28 16:59:11 +00:00
Oli Scherer
2bf63a5011 Add regression tests 2022-03-28 16:58:59 +00:00
Oli Scherer
1163aa7e72 Remove opaque type obligation and just register opaque types as they are encountered.
This also registers obligations for the hidden type immediately.
2022-03-28 16:57:45 +00:00
Noa
97c58e8a87 Touch up ExitCode docs 2022-03-28 09:54:57 -07:00
Oli Scherer
86e1860495 Revert to inference variable based hidden type computation for RPIT 2022-03-28 16:53:47 +00:00
Konrad Borowski
12c085a057 Inline u8::is_utf8_char_boundary 2022-03-28 18:37:11 +02:00
Oli Scherer
3136bfef93 Special case the situation where the previous span is the same as the new one 2022-03-28 16:31:52 +00:00
Oli Scherer
d5b6510bfb Have the spans of TAIT type conflict errors point to the actual site instead of the owning function 2022-03-28 16:30:59 +00:00
Oli Scherer
4b249b062b Remove some dead code 2022-03-28 16:30:34 +00:00
Oli Scherer
4cfaf9a931 Normalize all projections in mir validation again 2022-03-28 16:30:16 +00:00
Oli Scherer
1c5bfb1770 Don't bind hidden types when searching for matching impls 2022-03-28 16:29:54 +00:00
Oli Scherer
f42a6793ce Fail more aggressively 2022-03-28 16:29:31 +00:00
Oli Scherer
264cd05b16 Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
This reverts commit 6499c5e7fc, reversing
changes made to 78450d2d60.
2022-03-28 16:27:14 +00:00
bors
600ec28483 Auto merge of #95403 - Dylan-DPC:rollup-9on30mg, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #95301 (Remove `Nonterminal::NtTT`.)
 - #95314 (Tell users that `||` operators are not currently supported in let chain expressions)
 - #95350 (resolve: Simplify some diagnostic code to avoid an ICE)
 - #95370 ([bootstrap] Don't print `Suite not skipped` unless `--verbose` is set)
 - #95390 (Ignore doc comments in a declarative macro matcher.)
 - #95401 (Remove duplicated and unused test files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-28 16:15:17 +00:00
Dylan DPC
e5afe2b107
Rollup merge of #95401 - c410-f3r:moar-tests, r=petrochenkov
Remove duplicated and unused test files

cc https://github.com/rust-lang/rust/issues/73494
r? `@petrochenkov`
2022-03-28 16:08:12 +02:00
Dylan DPC
1c8b7412d4
Rollup merge of #95390 - nnethercote:allow-doc-comments-in-macros, r=petrochenkov
Ignore doc comments in a declarative macro matcher.

Fixes #95267. Reverts to the old behaviour before #95159 introduced a
regression.

r? `@petrochenkov`
2022-03-28 16:08:11 +02:00
Dylan DPC
2f5e944322
Rollup merge of #95370 - jyn514:less-verbose-skips, r=Dylan-DPC
[bootstrap] Don't print `Suite not skipped` unless `--verbose` is set

This was so verbose before that it made it hard to see what effect the flag actually had.

Before:
```
Set({test::src/tools/tidy}) not skipped for "bootstrap::test::Tidy" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Skipping Suite(test::src/test/ui) because it is excluded
Suite(test::src/test/run-pass-valgrind) not skipped for "bootstrap::test::RunPassValgrind" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Skipping Suite(test::src/test/mir-opt) because it is excluded
Suite(test::src/test/codegen) not skipped for "bootstrap::test::Codegen" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Suite(test::src/test/codegen-units) not skipped for "bootstrap::test::CodegenUnits" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Suite(test::src/test/assembly) not skipped for "bootstrap::test::Assembly" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Suite(test::src/test/incremental) not skipped for "bootstrap::test::Incremental" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Skipping Suite(test::src/test/debuginfo) because it is excluded
Skipping Suite(test::src/test/ui-fulldeps) because it is excluded
... about 100 more lines ...
```

After:
```
Skipping Suite(test::src/test/ui) because it is excluded
Skipping Suite(test::src/test/mir-opt) because it is excluded
Skipping Suite(test::src/test/debuginfo) because it is excluded
Skipping Suite(test::src/test/ui-fulldeps) because it is excluded
```
2022-03-28 16:08:10 +02:00
Dylan DPC
4dd9567cf6
Rollup merge of #95350 - petrochenkov:qpathregr, r=cjgillot
resolve: Simplify some diagnostic code to avoid an ICE

No need to resolve those paths, they are already resolved, we just need to take the results from `partial_res_map`.

Fixes https://github.com/rust-lang/rust/issues/95327
2022-03-28 16:08:09 +02:00
Dylan DPC
4651c8df02
Rollup merge of #95314 - c410-f3r:aqui-vamos-nos, r=lcnr
Tell users that `||` operators are not currently supported in let chain expressions

Tells that `||` operators are not currently supported instead of not allowed. See https://github.com/rust-lang/rust/issues/53667#issuecomment-1066075876

In other words, this PR is pretty much trivial.
2022-03-28 16:08:08 +02:00
Dylan DPC
ae037a86f9
Rollup merge of #95301 - nnethercote:rm-NtTT, r=petrochenkov
Remove `Nonterminal::NtTT`.

It's only needed for macro expansion, not as a general element in the
AST. This commit removes it, adds `NtOrTt` for the parser and macro
expansion cases, and renames the variants in `NamedMatch` to better
match the new type.

r? `@petrochenkov`
2022-03-28 16:08:07 +02:00
bors
2d37f38f87 Auto merge of #95024 - koehlma:rustdoc-private-items, r=GuillaumeGomez,camelid,jsha
rustdoc: add 🔒 to items with restricted visibility

This change marks items with restricted visibility with 🔒 when building with `--document-private-items`:

<img width="278" alt="Screen Shot 2022-03-20 at 23 50 24" src="https://user-images.githubusercontent.com/509209/159189513-9e4b09bb-6785-41a5-bfe2-df02f83f8641.png">

There also appears a “Restricted Visibility” tooltip when hovering over the emoji.

---

The original PR for reference:

This change makes private items slightly transparent (similar to `unstable` items in rustc):

<img width="272" alt="Screen Shot 2022-03-16 at 22 17 43" src="https://user-images.githubusercontent.com/509209/158692627-a1f6f5ec-e043-4aa2-9352-8d2b15c31c08.png">

I found myself using `--document-private-items` a lot recently because I find the documentation of private internals quite helpful when working on a larger project. However, not being able to distinguish private from public items (see #87785) when looking at the documentation makes this somewhat cumbersome.

This PR addresses the third suggestion of issue #87785 by marking private items typographically. It seems to me that the other suggestions are more involved but this is at least a first step.

A private item is also made slightly transparent in the path displayed in the header of a page:

<img width="467" alt="Screen Shot 2022-03-16 at 22 19 51" src="https://user-images.githubusercontent.com/509209/158692885-0bbd3417-3c0b-486f-b8ab-99c05c6fa7ca.png">

I am looking forward to feedback and suggestions.
2022-03-28 13:49:22 +00:00
Caio
6947a772dd Remove duplicated and unused test files 2022-03-28 10:16:32 -03:00
bors
0e4524e5b4 Auto merge of #94789 - compiler-errors:fatal-never, r=eddyb
Make fatal DiagnosticBuilder yield `!`

Fatal errors should really be fatal, so emitting them should cause us to exit at the same time.

Fine with just throwing away these changes if they're not worthwhile. Also, maybe we want to use an uninhabited enum instead of `!`.

r? `@eddyb` who has been working on `DiagnosticBuilder` stuff, feel free to reassign.
2022-03-28 11:08:23 +00:00
bors
b3e46a9763 Auto merge of #95396 - TaKO8Ki:suggest-replacing-field-when-using-the-same-type, r=compiler-errors
Suggest replacing a field when using the same type

closes #89166
2022-03-28 08:40:25 +00:00
bors
13c9fc38c9 Auto merge of #95300 - workingjubilee:less-bitsets, r=eddyb
Skip needless bitset for debuginfo

Found this while digging around looking at the inlining logic.
Seemed obvious enough so I decided to try to take care of it.
Is this what you had in mind, `@eddyb?`
2022-03-28 05:48:25 +00:00
klensy
008fc79dcd Propagate parallel_compiler feature through rustc crates. Turned off feature gives change of builded crates: 238 -> 224. 2022-03-28 08:41:12 +03:00
klensy
78fbcca3e1 use cfg attribute instead of macro 2022-03-28 08:37:32 +03:00
Michael Goulet
928388bad2 Make fatal DiagnosticBuilder yield never 2022-03-27 22:25:32 -07:00
Takayuki Maeda
c26cfd1c53 use can_coerce instead of same_type_modulo_infer 2022-03-28 13:43:33 +09:00
David Tolnay
d55854d484
Link to std::io's platform-specific behavior disclaimer 2022-03-27 21:01:28 -07:00