Commit Graph

246514 Commits

Author SHA1 Message Date
Nadrieril 4b732c990d Let rustbot ping me on changes to match lowering 2024-02-16 18:26:34 +01:00
bors d2e8ecd8bd Auto merge of #121188 - GuillaumeGomez:rollup-bejz7fq, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #119928 (suggest `into_iter()` when `Iterator` method called on `impl IntoIterator`)
 - #121020 (Avoid an ICE in diagnostics)
 - #121111 (For E0038, suggest associated type if available)
 - #121137 (Add clippy into the known `cfg` list)
 - #121179 (allow mutable references in const values when they point to no memory)
 - #121181 (Fix an ICE in the recursion lint)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-16 16:40:45 +00:00
bors 0932f89586 Auto merge of #16588 - compiler-errors:async-and-const-bounds, r=Veykril
internal: Parse (nightly) `const` and `async` trait bounds

Both of these bound modifiers were added recently:

* `const` trait bounds: https://github.com/rust-lang/rust/pull/119099
* `async` trait bounds: https://github.com/rust-lang/rust/pull/120392

The latter will certainly will not do the right thing; namely, `async Fn` needs to be mapped to the `AsyncFn` trait. IDK how to do that, so advice would be appreciated, though perhaps we could land this first so the parser isn't complaining about these bounds?
2024-02-16 16:25:22 +00:00
Michael Goulet 36020bb512 Update grammar
Bounds are CONSTNESS ASYNCNESS POLARITY
2024-02-16 16:16:37 +00:00
Guillaume Gomez f82875e242
Rollup merge of #121181 - oli-obk:normalize_with_conflicting_impls, r=cjgillot
Fix an ICE in the recursion lint

fixes #121170

I looked into it, and there is no good path towards tainting mir_build (where the ICE happens), but using `try_normalize` in a lint seems generally better anyway
2024-02-16 17:08:14 +01:00
Guillaume Gomez 0c92146034
Rollup merge of #121179 - RalfJung:zst-mutable-refs, r=oli-obk
allow mutable references in const values when they point to no memory

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

The second commit is just some drive-by test suite cleanup.

r? `@oli-obk`
2024-02-16 17:08:13 +01:00
Guillaume Gomez f60576b3df
Rollup merge of #121137 - GuillaumeGomez:add-clippy-cfg, r=Urgau,Nilstrieb
Add clippy into the known `cfg` list

In clippy, we are removing the `feature = "cargo-clippy"` cfg to replace it with `clippy` in https://github.com/rust-lang/rust-clippy/pull/12292. But for it to work, we need to declare `clippy` as cfg. It makes it more coherent with other existing tools like rustdoc.

cc `@flip1995`
2024-02-16 17:08:13 +01:00
Guillaume Gomez 670bdbf808
Rollup merge of #121111 - trevyn:associated-type-suggestion, r=davidtwco
For E0038, suggest associated type if available

Closes #116434
2024-02-16 17:08:12 +01:00
Guillaume Gomez e5a743c4c2
Rollup merge of #121020 - oli-obk:diagnostics_ice, r=davidtwco
Avoid an ICE in diagnostics

fixes #121004

just a slice usage in diagnostics code. Sadly we can't yet bubble the `ErrorGuaranteed` from wf check to borrowck for these cases, as that causes cycle errors iirc
2024-02-16 17:08:12 +01:00
Guillaume Gomez f81fd901db
Rollup merge of #119928 - d-sonuga:into-iter-sugg, r=compiler-errors
suggest `into_iter()` when `Iterator` method called on `impl IntoIterator`

Fix for issue #117711.
2024-02-16 17:08:11 +01:00
bors 25d12673db Auto merge of #16586 - Veykril:crate-graph-side-table, r=Veykril
fix: Remove cargo knowledge from `CrateData`

Fixes https://github.com/rust-lang/rust-analyzer/issues/16170, Fixes https://github.com/rust-lang/rust-analyzer/issues/15656
2024-02-16 16:04:14 +00:00
Michael Goulet 3e4deab3d8 Add support for const and async trait bounds 2024-02-16 16:00:04 +00:00
Ben Kimock 7c2db703b0 Don't use mem::zeroed in vec::IntoIter 2024-02-16 10:44:39 -05:00
Lukas Wirth ead369117a CrateOrigin::Local means local to the project workspace, not cargo workspace 2024-02-16 16:28:17 +01:00
Michael Goulet f624d55ea7 Nits 2024-02-16 15:07:37 +00:00
Michael Goulet a9dbf63087 Move trait into attr so it's greppable 2024-02-16 15:07:37 +00:00
Michael Goulet 9c25823bb4 Use extension trait derive 2024-02-16 15:07:37 +00:00
Michael Goulet 3250e95305 Add a simple extension trait derive 2024-02-16 15:07:37 +00:00
bors bb0f93a260 Auto merge of #16587 - LucasFA:update-actions, r=lnicola
ci: Update GitHub Actions and Node version

Use newer versions of actions; Node 16 -> 18

Fix several warnings in the actions tab regarding usage of the EOL Node 16
2024-02-16 15:03:52 +00:00
LucasFA c8fd8a33d2
Update GitHub actions dependencies
Use newer versions of actions, Node 16 -> 18

Fixes several warnings in the actions tab regarding usage of Node 16
2024-02-16 15:58:10 +01:00
Lukas Wirth 0ccb3b8731 Move dedup-dev-deps tests into rust-analyzer crate 2024-02-16 15:47:40 +01:00
Takashiidobe b49bd0bba0 Add examples to document the return type of `select_nth_unstable`, `select_nth_unstable_by`, and `select_nth_unstable_by_key`. 2024-02-16 09:20:51 -05:00
bors ae9d7b0c64 Auto merge of #116385 - kornelski:maybe-rename, r=Amanieu
Rename MaybeUninit::write_slice

A step to push #79995 forward.

https://github.com/rust-lang/libs-team/issues/122 also suggested to make them inherent methods, but they can't be — they'd conflict with slice's regular methods.
2024-02-16 14:11:10 +00:00
Lukas Wirth b1404d387a fix: Split toolchain and datalayout out of CrateData 2024-02-16 14:48:25 +01:00
bors 890666167b Auto merge of #16585 - lnicola:bump-checkout, r=lnicola
internal: bump `actions/checkout` to v4

Silences more Node version warnings.
2024-02-16 12:31:18 +00:00
Laurențiu Nicola ed425f8700 Bump actions/checkout to v4 2024-02-16 14:23:10 +02:00
Lukas Markeffsky 5d989770f2 address review comments 2024-02-16 13:11:05 +01:00
Lukas Markeffsky 8f259ade66 add codegen test 2024-02-16 13:11:05 +01:00
Lukas Markeffsky b6702939f7 outline large copies 2024-02-16 13:10:52 +01:00
Lukas Markeffsky 1e3849aed0 reduce branchiness 2024-02-16 13:10:52 +01:00
Lukas Markeffsky 500ef67877 reduce amount of math 2024-02-16 13:10:52 +01:00
Lukas Markeffsky ec95d259e4 simplify codegen for trivially droppable types 2024-02-16 13:10:52 +01:00
bors c864953c0f Auto merge of #16583 - Veykril:unknown-mismatch, r=Veykril
fix: Don't show type mismatches for `{unknown}` to non-`{unknown}` mismatches

Fixes https://github.com/rust-lang/rust-analyzer/issues/15704

Basically we zip the two types, inspecting their substitutions if the constructors are the same, if we encounter a zip step with an `{unknown}` on one side and a non-`{unknown}` on the other we error out and discard the diagnostic. Otherwise we keep it.
2024-02-16 12:01:33 +00:00
bors c9a7db6e20 Auto merge of #120538 - kornelski:read-not-exact, r=m-ou-se
Make File::read_to_end less special

Follow-up to #117925
2024-02-16 11:53:05 +00:00
Lukas Wirth fd652ceb73 fix: Don't show type mismatches for `{unknown}` to non-`{unknown}` mismatches 2024-02-16 12:16:43 +01:00
Ralf Jung d3fc69ae45 add test ensuring we detect a static actually having a mutable reference 2024-02-16 11:38:11 +01:00
bors a01655552d Auto merge of #16582 - Veykril:find-path-length, r=Veykril
fix: Respect textual length of paths in find-path

Fixes https://github.com/rust-lang/rust-analyzer/issues/16572
2024-02-16 09:58:11 +00:00
Lukas Wirth c00c9ee959 fix: Respect textual length of paths in find-path 2024-02-16 10:54:54 +01:00
bors dfa88b328f Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkin
Implement intrinsics with fallback bodies

fixes #93145 (though we can port many more intrinsics)
cc #63585

The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for

* codegen_ssa (so llvm and gcc)
* codegen_cranelift

other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body).

cc `@scottmcm` `@WaffleLapkin`

### todo

* [ ] miri support
* [x] default intrinsic name to name of function instead of requiring it to be specified in attribute
* [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-16 09:53:01 +00:00
Oli Scherer db4ba498d9 Fix an ICE in the recursion lint 2024-02-16 09:29:39 +00:00
bors 5261fb2354 Auto merge of #16576 - michel-slm:add-lsp-server-license, r=Veykril
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
```
2024-02-16 09:10:35 +00:00
Ralf Jung 2611fac03f add back some more attempts at having &mut in the final value of a const/static 2024-02-16 10:09:12 +01:00
Ralf Jung f68e79dcac remove stderr-per-bitwidth from some tests 2024-02-16 10:09:12 +01:00
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 `SnippetTextEdit`s
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