Commit Graph

246645 Commits

Author SHA1 Message Date
Ralf Jung
0702701297 allow mutable references in const values when they point to no memory 2024-02-16 10:09:12 +01:00
bors
8a0a09a368 Auto merge of #16577 - DropDemBits:structured-snippet-migrate-7, r=Veykril
internal: Migrate assists to the structured snippet API, part 7/7

Continuing from #16467

Migrates the following assists:

- `generate_trait_from_impl`

This adds `add_placeholder_snippet_group`, which adds a group of placeholder snippets which are linked together and allows for renaming generated items without going through a separate rename step.

This also removes the last usages of `SourceChangeBuilder::{insert,replace}_snippet`, as all assists have finally been migrated to the structured snippet versions of those methods.
2024-02-16 08:49:43 +00:00
bors
1be468815c Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnay
Use generic `NonZero` internally.

Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-16 07:46:31 +00:00
DropDemBits
e8457bb78b
Escape { and } as well
These are used in placeholder snippets, which may occur elsewhere in the insert text.
2024-02-16 00:28:02 -05:00
DropDemBits
1d8ed3408e
Escape snippet bits in-between placing snippets
Done so that we don't shift the range that we insert the snippet at.
2024-02-16 00:28:02 -05:00
DropDemBits
1aeec93412
Only use snippet_text_edit to make snippet SnippetTextEdits
The eventual LSP representation looks like it will diverge from RA's representation of `SnippetTextEdit`s, so this'll make it easier to transition to the LSP representation later.
2024-02-16 00:28:02 -05:00
DropDemBits
e4a3cc34d5
Add better snippet bits test 2024-02-16 00:28:01 -05:00
DropDemBits
e9efb568f6
Add dos line ending test 2024-02-16 00:28:01 -05:00
bors
c335b4e4a0 Auto merge of #3301 - rust-lang:rustup-2024-02-16, r=saethlin
Automatic Rustup
2024-02-16 05:08:03 +00:00
The Miri Conjob Bot
840ca093e6 fmt 2024-02-16 05:03:16 +00:00
The Miri Conjob Bot
f1abde7e5d Merge from rustc 2024-02-16 05:02:04 +00:00
The Miri Conjob Bot
089eb6b11f Preparing for merge from rustc 2024-02-16 04:54:51 +00:00
Esteban Küber
9b3fcf9ad4 Detect when method call on argument could be removed to fulfill failed trait bound
When encountering

```rust
struct Foo;
struct Bar;
impl From<Bar> for Foo {
    fn from(_: Bar) -> Self { Foo }
}
fn qux(_: impl From<Bar>) {}
fn main() {
    qux(Bar.into());
}
```

Suggest removing `.into()`:

```
error[E0283]: type annotations needed
 --> f100.rs:8:13
  |
8 |     qux(Bar.into());
  |     ---     ^^^^
  |     |
  |     required by a bound introduced by this call
  |
  = note: cannot satisfy `_: From<Bar>`
note: required by a bound in `qux`
 --> f100.rs:6:16
  |
6 | fn qux(_: impl From<Bar>) {}
  |                ^^^^^^^^^ required by this bound in `qux`
help: try using a fully qualified path to specify the expected types
  |
8 |     qux(<Bar as Into<T>>::into(Bar));
  |         +++++++++++++++++++++++   ~
help: consider removing this method call, as the receiver has type `Bar` and `Bar: From<Bar>` can be fulfilled
  |
8 -     qux(Bar.into());
8 +     qux(Bar);
  |
```

Fix #71252
2024-02-16 04:28:05 +00:00
DropDemBits
4af075dcda
Remove SourceChangeBuilder::{insert,remove}_snippet
All assists have been migrated to use the structured snippet versions of these methods.
2024-02-15 21:34:29 -05:00
DropDemBits
eb6d6ba17c
Migrate generate_trait_from_impl to mutable ast 2024-02-15 21:34:29 -05:00
bors
0f806a9812 Auto merge of #120889 - Ayush1325:uefi-instant, r=joshtriplett
Implement Instant for UEFI

- Uses Timestamp Protocol if present. Else use rdtsc for x86 and x86-64
2024-02-16 02:24:44 +00:00
DropDemBits
115646d7d5
Align set_visibility with the rest of the set_ edit-in-place methods 2024-02-15 20:40:14 -05:00
DropDemBits
581d457e13
Add add_placeholder_snippet_group
Used for allowing newly generated syntax constructs to be renamed without having to go through a separate rename step.
2024-02-15 20:24:31 -05:00
bors
cefa14bf2f Auto merge of #121169 - GuillaumeGomez:rollup-oxk5d5j, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - #120777 (Bump Unicode to version 15.1.0, regenerate tables)
 - #120971 (Fix comment in core/src/str/validations.rs)
 - #121095 (Add extra indent spaces for rust-playground link)
 - #121109 (Add an ErrorGuaranteed to ast::TyKind::Err (attempt 2))
 - #121119 (Make `async Fn` trait kind errors better)
 - #121141 (Fix closure kind docs)
 - #121145 (Update aarch64 target feature docs to match LLVM)
 - #121146 (Only point out non-diverging arms for match suggestions)
 - #121147 (Avoid debug logging entire MIR body)
 - #121155 (doc: add note about panicking examples for strict_overflow_ops)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-16 00:03:46 +00:00
Michel Lind
fafb16b052
lsp-server: add license files
The `lsp-server` crate is currently published without license files, which is
needed when packaging in Linux distributions.

Symlink the files from the repository root so they are kept in sync.

Test showing the files get picked up by `cargo package`:
```
michel in rust-analyzer/lib/lsp-server on  add-lsp-server-license [+] is 📦 v0.7.6 via 🐍 v3.12.1 (.venv311) via 🦀 v1.76.0
⬢ [fedora:39] ❯ cargo package --allow-dirty --no-verify
    Updating crates.io index
   Packaging lsp-server v0.7.6 (/home/michel/src/github/rust-lang/rust-analyzer/lib/lsp-server)
    Updating crates.io index
    Packaged 12 files, 59.6KiB (16.3KiB compressed)

michel in rust-analyzer/lib/lsp-server on  add-lsp-server-license [+] is 📦 v0.7.6 via 🐍 v3.12.1 (.venv311) via 🦀 v1.76.0
⬢ [fedora:39] ❯ tar tf ../../target/package/lsp-server-0.7.6.crate | grep LICENSE
lsp-server-0.7.6/LICENSE-APACHE
lsp-server-0.7.6/LICENSE-MIT
```

Signed-off-by: Michel Lind <salimma@fedoraproject.org>
2024-02-15 18:01:36 -06:00
Zalathar
cd9021e8cb coverage: Discard spans that fill the entire function body
When we try to extract coverage-relevant spans from MIR, sometimes we see MIR
statements/terminators whose spans cover the entire function body. Those spans
tend to be unhelpful for coverage purposes, because they often represent
compiler-inserted code, e.g. the implicit return value of `()`.
2024-02-16 10:57:03 +11:00
Zalathar
75af3c58f9 coverage: Regression test for a span extraction inconsistency 2024-02-16 10:57:03 +11:00
Guillaume Gomez
2a216bb53b
Rollup merge of #121155 - tspiteri:strict-doc-overflow, r=Nilstrieb
doc: add note about panicking examples for strict_overflow_ops

The first commit adds a note before the panicking examples for strict_overflow_ops to make it clearer that the following examples should panic and why, without needing the reader to hover the mouse over the information icon.

The second commit adds panicking examples for division by zero operations for strict division operations on unsigned numbers. The signed numbers already have two panicking examples each: one for division by zero and one for overflowing division (`MIN/-1`); this commit includes the division by zero examples for the unsigned numbers.
2024-02-16 00:27:35 +01:00
Guillaume Gomez
e84a1dd87f
Rollup merge of #121147 - tmiasko:no-debug-body, r=compiler-errors
Avoid debug logging entire MIR body

If there is a need to examine the MIR body there is -Zmir-dump.
2024-02-16 00:27:35 +01:00
Guillaume Gomez
77eaa80d5c
Rollup merge of #121146 - compiler-errors:ignore-diverging-arms, r=estebank
Only point out non-diverging arms for match suggestions

Fixes #121144

There is no reason to point at diverging arms, which will always coerce to whatever is the match block's evaluated type.

This also removes the suggestion from #106601, since as I pointed out in https://github.com/rust-lang/rust/issues/72634#issuecomment-1946210898 the added suggestion is not firing in the right cases, but instead only when one of the match arms already *actually* evaluates to `()`.

r? estebank
2024-02-16 00:27:34 +01:00
Guillaume Gomez
d6e2fc5589
Rollup merge of #121145 - adamgemmell:dev/adagem01/combined-target-features, r=Amanieu
Update aarch64 target feature docs to match LLVM

https://github.com/rust-lang/stdarch/issues/1432 https://github.com/rust-lang/stdarch/pull/1527

r? ```@Amanieu```
2024-02-16 00:27:34 +01:00
Guillaume Gomez
12a73a6bbe
Rollup merge of #121141 - compiler-errors:closure-kind-docs, r=nnethercote
Fix closure kind docs

I didn't review this close enough lol -- the old code snippet didn't use substs correctly, and had a malformed `if let`
2024-02-16 00:27:34 +01:00
Guillaume Gomez
ddad818b7a
Rollup merge of #121119 - compiler-errors:async-fn-kind-errs, r=oli-obk
Make `async Fn` trait kind errors better

1. Make it so that async closures with the wrong closurekind actually report a useful error
2. Explain why async closures can sometimes not implement `Fn`/`FnMut` (because they capture things)

r? oli-obk
2024-02-16 00:27:33 +01:00
Guillaume Gomez
c73aa787f6
Rollup merge of #121109 - nnethercote:TyKind-Err-guar-2, r=oli-obk
Add an ErrorGuaranteed to ast::TyKind::Err (attempt 2)

This makes it more like `hir::TyKind::Err`, and avoids a `has_errors` assertion in `LoweringContext::lower_ty_direct`.

r? ```@oli-obk```
2024-02-16 00:27:32 +01:00
Guillaume Gomez
a7e486a76e
Rollup merge of #121095 - chenyukang:yukang-fix-120998-rust-playground-link, r=GuillaumeGomez
Add extra indent spaces for rust-playground link

Fixes #120998

Seems add `rustfmt` for this is somehow too heavy,
only adding indent spaces at the starting of each line of code seems good enough.
2024-02-16 00:27:32 +01:00
Guillaume Gomez
1630e04509
Rollup merge of #120971 - PizzasBear:patch-1, r=Nilstrieb
Fix comment in core/src/str/validations.rs

Fix minor issue in the comment
2024-02-16 00:27:31 +01:00
Guillaume Gomez
3803469473
Rollup merge of #120777 - Marcondiro:unicode15-1, r=Manishearth
Bump Unicode to version 15.1.0, regenerate tables

r? ```@Manishearth```
2024-02-16 00:27:31 +01:00
bors
a4472498d7 Auto merge of #121133 - tmiasko:skip-coroutines, r=cjgillot
Skip coroutines in jump threading to avoid query cycles

Fixes #121094
2024-02-15 21:30:25 +00:00
bors
b656f5171b Auto merge of #119338 - compiler-errors:upcast-plus-autos, r=lcnr
Consider principal trait ref's auto-trait super-traits in dyn upcasting

Given traits like:

```rust
trait Subtrait: Supertrait + Send {}
trait Supertrait {}
```

We should be able to upcast `dyn Subtrait` to `dyn Supertrait + Send`. This is not currently possible, because when upcasting, we look at the list of auto traits in the object type (`dyn Subtrait`, which has no auto traits in its bounds) and compare them to the target's auto traits (`dyn Supertrait + Send`, which has `Send` in its bound).

Since the target has auto traits that are not present in the source, the upcasting fails. This is overly restrictive, since `dyn Subtrait` will always implement `Send` via its built-in object impl. I propose to loosen this restriction here.

r? types

---

### ~~Aside: Fix this in astconv instead?~~

### edit: This causes too many failures. See https://github.com/rust-lang/rust/pull/119825#issuecomment-1890847150

We may also fix this by by automatically elaborating all auto-trait supertraits during `AstConv::conv_object_ty_poly_trait_ref`. That is, we can make it so that `dyn Subtrait` is elaborated into the same type of `dyn Subtrait + Send`.

I'm open to considering this solution instead, but it would break coherence in the following example:

```rust
trait Foo: Send {}

trait Bar {}
impl Bar for dyn Foo {}
impl Bar for dyn Foo + Send {}
//~^ This would begin to be an overlapping impl.
```
2024-02-15 19:16:06 +00:00
Michael Goulet
954d56591c Fix closure kind docs 2024-02-15 18:44:49 +00:00
Trevor Spiteri
675d092e3e doc: panicking division by zero examples for unsigned strict div ops 2024-02-15 18:41:30 +01:00
Trevor Spiteri
fdc56b6886 doc: add note before panicking examples for strict_overflow_ops 2024-02-15 18:38:36 +01:00
bors
b9b0d29b8e Auto merge of #16574 - davidsemakula:needless-return-fix, r=Veykril
fix: Fix "needless return" diagnostic for trailing item declarations

Fixes #16566
2024-02-15 17:36:17 +00:00
Michael Goulet
6018e21d8a Remove a suggestion that is redundant 2024-02-15 17:20:44 +00:00
davidsemakula
9ae0f924dd fix "needless return" for trailing item declarations 2024-02-15 20:07:58 +03:00
bors
cbddf31863 Auto merge of #121142 - GuillaumeGomez:rollup-5qmksjw, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #120449 (Document requirements for unsized {Rc,Arc}::from_raw)
 - #120505 (Fix BTreeMap's Cursor::remove_{next,prev})
 - #120672 (std::thread update freebsd stack guard handling.)
 - #121088 (Implicitly enable evex512 if avx512 is enabled)
 - #121104 (Ignore unsized types when trying to determine the size of the original type)
 - #121107 (Fix msg for verbose suggestions with confusable capitalization)
 - #121113 (Continue compilation even if inherent impl checks fail)
 - #121120 (Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-15 17:00:55 +00:00
Johannes Lade
17066870cd
Fix typo in VecDeque::handle_capacity_increase() doc comment.
Strategies B and C both show a full buffer before the capacity increase, while strategy A had one empty element left. Filled the last element in.
2024-02-15 17:33:37 +01:00
bors
b30b77d373 Auto merge of #16573 - Veykril:salsa-doc-tests, r=Veykril
internal: Remove salsa doc compile tests

These don't play well with the github CI error annotations
2024-02-15 16:29:39 +00:00
Lukas Wirth
1443d49b72 Remove salsa doc compile tests 2024-02-15 17:28:24 +01:00
Michael Goulet
acb201af54 make better async fn kind errors 2024-02-15 15:59:35 +00:00
bors
db277c7bb3 Auto merge of #16569 - DropDemBits:structured-snippet-fix-adjust-snippet-ranges, r=Veykril
fix: Place snippets correctly in multi-edit assists

Fixes #16539
2024-02-15 15:54:23 +00:00
Michael Goulet
c763f833d1 Only point out non-diverging arms for match suggestions 2024-02-15 15:44:46 +00:00
Michael Goulet
ec8e898193 Consider principal trait ref's auto-trait super-traits in dyn upcasting 2024-02-15 15:38:11 +00:00
Tomasz Miąsko
5d65b1954e Avoid debug logging entire MIR body
If there is a need to examine the MIR body there is -Zmir-dump.
2024-02-15 15:54:28 +01:00
bors
62fb0db9a5 Auto merge of #119863 - tmiasko:will-wake, r=m-ou-se
Waker::will_wake: Compare vtable address instead of its content

Optimize will_wake implementation by comparing vtable address instead of its content.

The existing best practice to avoid false negatives from will_wake is to define a waker vtable as a static item. That approach continues to works with the new implementation.

While this potentially changes the observable behaviour, the function is documented to work on a best-effort basis. The PartialEq impl for RawWaker remains as it was.
2024-02-15 14:43:29 +00:00