Commit Graph

228678 Commits

Author SHA1 Message Date
Matthias Krüger
5d74664a7e
Rollup merge of #113144 - compiler-errors:elaborate-clauses, r=oli-obk
Make the `Elaboratable` trait take clauses

We only ever elaborate clauses, so make this explicit in the trait's definition rather than having a bunch of `.expect_clause()` calls everywhere.
2023-06-29 16:36:32 +02:00
Matthias Krüger
f135815f9b
Rollup merge of #112795 - He1pa:translation_builtin_macros, r=davidtwco
Migrate some rustc_builtin_macros to SessionDiagnostic

Part of https://github.com/rust-lang/rust/issues/100717.

``@rustbot`` label +A-translation
2023-06-29 16:36:32 +02:00
Matthias Krüger
f00db43e97
Rollup merge of #112300 - Zalathar:run-coverage, r=wesleywiser
Convert `run-make/coverage-reports` tests to use a custom compiletest mode

I was frustrated by the fact that most of the coverage tests are glued together with makefiles and shell scripts, so I tried my hand at converting most of them over to a newly-implemented `run-coverage` mode/suite in compiletest.

This ~~*mostly*~~ resolves #85009, ~~though I've left a small number of the existing tests as-is because they would require more work to fix/support~~.

---

I had time to go back and add support for the more troublesome tests that I had initially skipped over, so this PR now manages to completely get rid of `run-make/coverage-reports`.

---

The patches are arranged as follows:

- Declare the new mode/suite in bootstrap
- Small changes to compiletest that will be used by the new mode
- Implement the new mode in compiletest
- Migrate most of the tests over
- Add more code to bootstrap and compiletest to support the remaining tests
- Migrate the remaining tests (with some temporary hacks to avoid re-blessing them)
- Remove the temporary hacks and re-bless the migrated tests
- Remove the unused remnants of `run-make/coverage-reports`
2023-06-29 16:36:31 +02:00
Matthias Krüger
93a97c7a2a
Rollup merge of #112234 - ozkanonur:hotfix, r=jyn514
refactor `tool_doc!`

resolves https://github.com/rust-lang/rust/pull/112211#discussion_r1215190510
2023-06-29 16:36:30 +02:00
Matthias Krüger
be0a96fc7d
Rollup merge of #112086 - petrochenkov:impambig, r=oli-obk
resolve: Remove artificial import ambiguity errors

Fixes https://github.com/rust-lang/rust/issues/56414.

FCP report: https://github.com/rust-lang/rust/pull/112086#issuecomment-1568713662
2023-06-29 16:36:30 +02:00
Matthias Krüger
4696a92183
Rollup merge of #111322 - mirkootter:master, r=davidtwco
Support for native WASM exceptions

### Motivation
Currently, rustc does not support native WASM exceptions. It does support JavaScript based exceptions for the wasm32-emscripten-target, but this requires back&forth with javascript for many calls, which is very slow.

Native wasm support for exceptions is quite common: Clang+LLVM implemented them years ago, and all major browsers support them by now. They enable zero-cost exceptions, at least with regard to runtime-performance-cost. They may increase startup-time and code size, though.

### Important: This PR does not change default behaviour
Exceptions usually add a lot of code in form of unwinding blocks, increasing the binary size. Most users probably do not want that, especially which regard to web development.

Therefore, wasm exceptions play a similar role as WASM-threads: rustc should support them, like clang does, but users who want to use it have to use some command-line magic like rustflags to opt in.

### What does this PR do?
As stated above, the default behaviour is not changed. It is already possible to opt-in into wasm exceptions using the command line. Unfortunately, the LLVM IR is invalid and the LLVM backend crashes.
```
rustc <sourcefile>
  --target wasm32-unknown-unknown
  -C panic=unwind
  -C llvm-args=-wasm-enable-eh
  -C target-feature=+exception-handling
```
As it turns out, LLVM is quite picky when it comes to IR for exception handling. If the IR does not look exactly like it should, some LLVM-assertions fail and the code generation crashes.

This PR adds the necessary modifications to the code generator to make it work. It also adds `exception-handling` as a wasm target feature.

### What this PR does not / what is missing
This PR is not a full fledges solution. It is the first step. A few parts are still missing; however, it is already useable (see next section).

Currently missing:
* The std library has to be adapted. Currently, only [no_std] crates work
* Usually, nested exceptions abort the program (i.e. a panic during the cleanup of another panic). This is currently not done yet.
  - Currently, code inside cleanup handlers does not unwind
  - To fix this requires a little more work: The code generator currently maintains a single terminate block per function for this. Unfortunately, WASM requires funclet based exception handling. Therefore, we need to create a terminate block per funclet. This is probably not a big problem, but I want to keep this PR simple.

### How to use the compiler given this PR?
This PR does not add any command line flags or features. It uses those which are already there. To compile with exceptions enabled, you need
* to set the panic strategy to unwind, i.e. `-C panic=unwind`
* to enable the exception-handling target feature, i.e. `-C target-feature=+exception-handling`
* to tell LLVM about the exception handling, i.e. `-C llvm-args=-wasm-enable-eh`

Since the standard library has not been adapted, you can only use it in [no_std] crates as of now. The intrinsic `core::intrinsics::r#try` works. To throw exceptions, you need the ```@llvm.wasm.throw``` intrinsic.

I created a sample application which works for me: https://github.com/mirkootter/rust-wasm-demos
This example can be run at https://webassembly.sh
2023-06-29 16:36:30 +02:00
Bryanskiy
35c6a1d0f3 Fix type privacy lints error message 2023-06-29 16:24:07 +03:00
Jakub Beránek
32428ab5f3
CI: do not cancel concurrent builds on the same branch
Add an exception for try and try-perf branches to enable concurrent try builds and unrolled rollup builds.
2023-06-29 14:52:52 +02:00
Caio
fc832f0eb7 Dogfood 2023-06-29 09:30:04 -03:00
Caio
f0619024b8 Fix #10413 2023-06-29 09:27:49 -03:00
Catherine
826edd75ef heavily refactor 2023-06-29 06:46:28 -05:00
Catherine
95b24d44a6 Fix FP 2023-06-29 06:46:28 -05:00
Catherine
b1acbde618 Add msrv check and make test pass 2023-06-29 06:46:28 -05:00
Catherine
bfcc8ba444 New lint tuple_array_conversions 2023-06-29 06:46:00 -05:00
bors
e69c7306e2 Auto merge of #113151 - RalfJung:miri, r=RalfJung,oli-obk
update Miri

r? `@ghost`
2023-06-29 10:55:40 +00:00
Oli Scherer
78f58f96aa Use a valid target directory in miri ui tests 2023-06-29 10:43:49 +00:00
Vadim Petrochenkov
4dcce38cda resolve: Remove artificial import ambiguity errors 2023-06-29 13:42:58 +03:00
bors
9020937bbe Auto merge of #11030 - darklyspaced:master, r=Centri3,xFrednet
suggests `is_some_and` over `map().unwrap`

changelog: Enhancement: [`option_map_unwrap_or`] now considers the [`msrv`] config when creating the suggestion.

 * modified option_map_unwrap_or lint to recognise when an `Option<T>` is mapped to an `Option<bool>` with false being used when `None` is detected; suggests the use of `is_some_and` instead
 * msrv is set to 1.70.0 for this lint; when `is_some_and` was stabilised

fixes #9125
2023-06-29 09:54:51 +00:00
ozkanonur
cde54ffc99 refactor tool_doc! so that it can accept additional arguments.
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-06-29 12:37:48 +03:00
darklyspaced
bb42b18081
ran cargo collect-metadata 2023-06-29 17:30:39 +08:00
lcnr
d04775d739 change snapshot tracking in fulfillment contexts 2023-06-29 10:02:26 +02:00
Tshepang Mbambo
5b46aa1122
make HashMap::or_insert_with example more simple 2023-06-29 09:33:15 +02:00
Ralf Jung
a3cea7f179 update lockfile 2023-06-29 09:31:47 +02:00
bors
de22388873 Auto merge of #113134 - TaKO8Ki:rollup-4hvqzf6, r=TaKO8Ki
Rollup of 5 pull requests

Successful merges:

 - #112946 (Improve cgu naming and ordering)
 - #113048 (Fix build on Solaris where fd-lock cannot be used.)
 - #113100 (Fix display of long items in search results)
 - #113107 (add check for ConstKind::Value(_) to in_operand())
 - #113119 (rustdoc: Reduce internal function visibility.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-29 07:07:37 +00:00
bors
feed376e15 Auto merge of #2946 - RalfJung:rustup, r=RalfJung
Rustup
2023-06-29 06:45:06 +00:00
Ralf Jung
cca0c81027 Merge from rustc 2023-06-29 08:43:01 +02:00
Ralf Jung
8d4b2bdf7b Preparing for merge from rustc 2023-06-29 08:42:56 +02:00
bors
0a32ca9831 Auto merge of #113146 - matthiaskrgr:rollup-bxtr51e, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #112670 (privacy: Type privacy lints fixes and cleanups)
 - #112929 (Test that we require implementing trait items whose bounds don't hold in the current impl)
 - #113054 (Make `rustc_on_unimplemented` std-agnostic)
 - #113137 (don't suggest `move` for borrows that aren't closures)
 - #113139 (style-guide: Clarify let-else further)
 - #113140 (style-guide: Add an example of formatting a multi-line attribute)
 - #113143 (style-guide: Narrow guidance about references and dereferencing)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-29 04:34:46 +00:00
Li Zhanhui
9a67df290c
Fix document examples of Vec::from_raw_parts and Vec::from_raw_parts_in
Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>
2023-06-29 04:21:00 +00:00
Matthias Krüger
7a7ffced6a
Rollup merge of #113143 - joshtriplett:style-guide-narrow-dereference-guidance, r=calebcartwright
style-guide: Narrow guidance about references and dereferencing

The style guide advises "prefer dereferencing to taking references", but
doesn't give guidance on when that "preference" should get overridden by
other considerations. Give an example of when it's fine to ignore
that advice.
2023-06-29 05:48:41 +02:00
Matthias Krüger
c0e37ad127
Rollup merge of #113140 - joshtriplett:style-guide-example-multi-line-attribute, r=calebcartwright
style-guide: Add an example of formatting a multi-line attribute

We already say to format attributes like functions, but we didn't have
an example of formatting a multi-line attribute.
2023-06-29 05:48:41 +02:00
Matthias Krüger
c4dc70eb31
Rollup merge of #113139 - joshtriplett:style-clarify-let-else, r=calebcartwright
style-guide: Clarify let-else further

Give some additional examples with multi-line patterns.

Make it clearer to go on to the next case if the conditions aren't met.
2023-06-29 05:48:41 +02:00
Matthias Krüger
7e1869f9b4
Rollup merge of #113137 - lukas-code:no-moving-references, r=compiler-errors
don't suggest `move` for borrows that aren't closures

fixes https://github.com/rust-lang/rust/issues/113087
2023-06-29 05:48:40 +02:00
Matthias Krüger
f35f213d27
Rollup merge of #113054 - Rageking8:make-rustc_on_unimplemented-std-agnostic, r=WaffleLapkin
Make `rustc_on_unimplemented` std-agnostic

See #112923

r? `@WaffleLapkin`
2023-06-29 05:48:40 +02:00
Matthias Krüger
1963688f93
Rollup merge of #112929 - oli-obk:what_if_an_impl_item_just_doesnt_wanna_be_impld, r=compiler-errors
Test that we require implementing trait items whose bounds don't hold in the current impl

I initially tried to make most of these pass, but that's a big can of worms, so I'm just adding them as tests, considering we have no tests for these things.
2023-06-29 05:48:39 +02:00
Matthias Krüger
42a495da7e
Rollup merge of #112670 - petrochenkov:typriv, r=eholk
privacy: Type privacy lints fixes and cleanups

See individual commits.
Follow up to https://github.com/rust-lang/rust/pull/111801.
2023-06-29 05:48:39 +02:00
darklyspaced
211278bc86
updated list of lints that use msrv 2023-06-29 10:18:38 +08:00
Nicholas Nethercote
7e786e81b0 Avoid cloning LocalDecls.
`DerefChecker` can just hold a reference instead. This avoids quite a
lot of allocations for some benchmarks.
2023-06-29 11:53:41 +10:00
Nicholas Nethercote
8d7084d65f Simplify the bundles vectors.
After the last commit, they contain `Option<&OperandBundleDef<'a>>` but
the values are always `Some(_)`. This commit removes the needless
`Option` wrapper. This also simplifies the type signatures of
`LLVMRustBuild{Invoke,Call}`, which were relying on the fact that the
represention of `Option<&T>` is the same as `&T` for non-`None` values.
2023-06-29 11:51:00 +10:00
Nicholas Nethercote
81436ebd55 Use SmallVec for the bundles vectors.
They never have a length of more than two. So this commit changes them
to `SmallVec<[_; 2]>`.

Also, we possibly push `None` values and then filter those `None` values
out again with `retain`. So this commit removes the `retain` and instead
only pushes the values if they are `Some(_)`.
2023-06-29 11:47:39 +10:00
Nicholas Nethercote
d20b1a8f6b Set capacity of the string passed to push_item_name.
Other callsites already do this, but these two were missed. This avoids
some allocations.
2023-06-29 11:46:25 +10:00
Nicholas Nethercote
f2d863fa75 Remove SmallStr.
It no longer has any uses. If it's needed in the future, it can be
easily reinstated. Or a crate such as `smallstr` can be used, much like
we use `smallvec`.
2023-06-29 11:45:52 +10:00
Nicholas Nethercote
de1914af34 Avoid an unnecessary use of SmallStr.
I don't know why `SmallStr` was used here; some ad hoc profiling showed
this code is not that hot, the string is usually empty, and when it's
not empty it's usually very short. However, the use of a
`SmallStr<1024>` does result in 1024 byte `memcpy` call on each
execution, which shows up when I do `memcpy` profiling. So using a
normal string makes the code both simpler and very slightly faster.
2023-06-29 11:37:12 +10:00
Nicholas Nethercote
45fcd1d0c5 Use partition_point in SourceMap::lookup_source_file_idx.
This makes it (a) a little simpler, and (b) more similar to
`SourceFile::lookup_line`.
2023-06-29 11:36:09 +10:00
Nicholas Nethercote
b4c6e19ade Replace a lookup_debug_loc call.
`lookup_debug_loc` finds a file, line, and column, which requires two
binary searches. But this call site only needs the file.

This commit replaces the call with `lookup_source_file`, which does a
single binary search.
2023-06-29 11:31:43 +10:00
Nicholas Nethercote
a13be655a5 Avoid unnecessary line lookup.
`lookup_debug_loc` calls `SourceMap::lookup_line`, which does a binary
search over the files, and then a binary search over the lines within
the found file. It then calls `SourceFile::line_begin_pos`, which redoes
the binary search over the lines within the found file.

This commit removes the second binary search over the lines, instead
getting the line starting pos directly using the result of the first
binary search over the lines.

(And likewise for `get_span_loc`, in the cranelift backend.)
2023-06-29 11:26:39 +10:00
Michael Goulet
aafc801d69 Make the Elaboratable trait take clauses 2023-06-29 00:46:41 +00:00
Josh Triplett
025dd3aef0 style-guide: Narrow guidance about references and dereferencing
The style guide advises "prefer dereferencing to taking references", but
doesn't give guidance on when that "preference" should get overridden by
other considerations. Give an example of when it's fine to ignore
that advice.
2023-06-28 17:10:03 -07:00
bors
75726cae37 Auto merge of #112629 - compiler-errors:atb-imply, r=jackh726
Make associated type bounds in supertrait position implied

`trait A: B<Assoc: C> {}` should be able to imply both `Self: B` and `<Self as B>::Assoc: C`. Adjust the way that we collect implied predicates to do so.

Fixes #112573
Fixes #112568
2023-06-28 23:58:28 +00:00
Josh Triplett
4cc80651b8 style-guide: Add an example of formatting a multi-line attribute
We already say to format attributes like functions, but we didn't have
an example of formatting a multi-line attribute.
2023-06-28 15:35:05 -07:00