33355 Commits

Author SHA1 Message Date
Lukas Wirth
1329e6be49
Merge pull request #18993 from ChayimFriedman2/iter-config
feat: Provide a config to control auto-insertion of `await` and `iter()`
2025-01-24 13:31:30 +00:00
Lukas Wirth
8acea502ee
Merge pull request #18994 from Wilfred/failed_rustc_cfg_as_warning
internal: Treat cfg fetching failures as a warning
2025-01-24 13:31:00 +00:00
Lukas Wirth
93de80d833
Merge pull request #19016 from Veykril/push-moqnsytyrupu
fix: Fix `ItemScope` not recording glob imports
2025-01-24 13:25:39 +00:00
Lukas Wirth
3ab96c40b3 fix: Fix flycheck panicking with "once" invocation strategy
We only ever have one flycheck runner no matter the number of workspaces, so just kick off flycheck for it immediately
2025-01-24 14:23:11 +01:00
Lukas Wirth
a64667f2ab
Merge pull request #19014 from darichey/fix-cfg-macro
Check cfg when collecting macro defs
2025-01-24 13:13:48 +00:00
Lukas Wirth
3b88a2f134 Fix ItemScope not recording glob imports
This caused us other code to incorrectly assume in dealing with a declaration when in fact it was dealing with a glob imported definition
2025-01-24 14:11:45 +01:00
David Richey
1b6f95e885 Check cfg when collecting macro defs 2025-01-23 17:36:45 -06:00
bors
b4c71e7222 Auto merge of #132666 - dingxiangfei2009:skip-if-let-rescope-lint, r=compiler-errors
Skip `if-let-rescope` lint unless requested by migration

Tracked by #124085
Related to https://github.com/rust-lang/rust/pull/131984#issuecomment-2448329667

Given that `if-let-rescope` is a lint to be enabled globally by an edition migration, there is no point in extracting the precise lint level on the HIR expression. This mitigates the performance regression discovered by the earlier perf-run.

cc `@Kobzol` `@rylev` `@traviscross` I propose a `rust-timer` run to measure how much performance that we can recover from the mitigation. 🙇
2025-01-23 23:16:06 +00:00
Laurențiu Nicola
84d44d0a57
Merge pull request #19009 from lnicola/dont-just-die
minor: Rephrase comment
2025-01-23 12:09:49 +00:00
Laurențiu Nicola
788acba2dd Rephrase comment 2025-01-23 13:52:39 +02:00
Chayim Refael Friedman
582af7ee9c
Merge pull request #19004 from teoxoy/patch-1
increase `AUTODEREF_RECURSION_LIMIT` to 20
2025-01-22 21:36:12 +00:00
Teodor Tanasoaia
90533a0ad5
increase AUTODEREF_RECURSION_LIMIT to 20
The limit was introduced in https://github.com/rust-lang/rust-analyzer/pull/1408#discussion_r294059044 to avoid infinite cycles but it effectively caps the number of derefs to 10. Types like `ID3D12Device14` from the `windows` crate run into this because it derefs to `ID3D12Device13`, 13 to 12 and so on. Increasing it to 20 is a quick fix; a better cycle detection method would be nicer long term.
2025-01-22 22:21:02 +01:00
bors
2466c214ca Auto merge of #134478 - compiler-errors:attr-span, r=oli-obk
Properly record metavar spans for other expansions other than TT

This properly records metavar spans for nonterminals other than tokentree. This means that we operations like `span.to(other_span)` work correctly for macros. As you can see, other diagnostics involving metavars have improved as a result.

Fixes #132908
Alternative to #133270

cc `@ehuss`
cc `@petrochenkov`
2025-01-22 14:46:41 +00:00
Laurențiu Nicola
1f23156f51
Merge pull request #18878 from Wilfred/document_build_info
manual: Document all rust-project.json fields
2025-01-22 06:27:41 +00:00
bors
baf92a89c9 Auto merge of #135674 - scottmcm:assume-better, r=estebank
Update our range `assume`s to the format that LLVM prefers

I found out in https://github.com/llvm/llvm-project/issues/123278#issuecomment-2597440158 that the way I started emitting the `assume`s in #109993 was suboptimal, and as seen in that LLVM issue the way we're doing it -- with two `assume`s sometimes -- can at times lead to CVP/SCCP not realize what's happening because one of them turns into a `ne` instead of conveying a range.

So this updates how it's emitted from
```
assume( x >= LOW );
assume( x <= HIGH );
```
or
```
// (for ranges that wrap the range)
assume( (x <= LOW) | (x >= HIGH) );
```
to
```
assume( (x - LOW) <= (HIGH - LOW) );
```
so that we don't need multiple `icmp`s nor multiple `assume`s for a single value, and both wrappping and non-wrapping ranges emit the same shape.

(And we don't bother emitting the subtraction if `LOW` is zero, since that's trivial for us to check too.)
2025-01-22 04:18:30 +00:00
Wilfred Hughes
86a4b2fdd7 manual: Document all rust-project.json fields
Ensure that all the fields that rust-analyzer understands are in the
manual, they all have doc comments, and they use consistent
punctuation (`;` rather than mixing `,` and `;`).

Whilst we're here, fix the `sysroot_src` example and add 2024 as a
legal value for Rust edition.
2025-01-21 12:00:13 -08:00
bors
5749bf78a4 Auto merge of #134299 - RalfJung:remove-start, r=compiler-errors
remove support for the (unstable) #[start] attribute

As explained by `@Noratrieb:`
`#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction.

I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple:
- `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail)
- `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways*

`#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is  a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program.
So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place.

Note that this feature has **not** been RFCed in the first place.

*This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.*

Closes https://github.com/rust-lang/rust/issues/29633

try-job: x86_64-gnu-nopt
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: test-various
2025-01-21 19:46:20 +00:00
Wilfred Hughes
8f6a1e5ee5 internal: Treat cfg fetching failures as a warning
If the user doesn't have rustc on $PATH, rust-analyzer won't be able
to run `rustc --print cfg`. This isn't really an error, as
rust-analyzer can still proceed without it.

This is particularly noticeable when loading crates defined in a
rust-project.json. Until the configuration is loaded, the opened files
are briefly treated as detached files and users see this error.

Environments with rust-project.json generally have a sysroot and rustc
elsewhere, so the error confuses users.
2025-01-21 11:07:07 -08:00
Chayim Refael Friedman
47f4f3f0b2 Provide a config to control auto-insertion of await and iter() 2025-01-21 18:51:09 +02:00
Lukas Wirth
f5b86e056b Keep already computed inlay hint properties instead of late resolving them 2025-01-21 16:16:51 +01:00
Lukas Wirth
1977aa99b0 Make InlayHint::linked_location computation lazy 2025-01-21 16:16:50 +01:00
Luuk Wester
5ad3de8b29 remove is_pwr2 2025-01-21 14:47:07 +01:00
Luuk Wester
705eb84941 switch from using leading zeros to trailing zeros 2025-01-21 14:45:30 +01:00
bors
fef5ac96be Auto merge of #133830 - compiler-errors:span-key, r=lcnr
Rework dyn trait lowering to stop being so intertwined with trait alias expansion

This PR reworks the trait object lowering code to stop handling trait aliases so funky, and removes the `TraitAliasExpander` in favor of a much simpler design. This refactoring is important for making the code that I'm writing in https://github.com/rust-lang/rust/pull/133397 understandable and easy to maintain, so the diagnostics regressions are IMO inevitable.

In the old trait object lowering code, we used to be a bit sloppy with the lists of traits in their unexpanded and expanded forms. This PR largely rewrites this logic to expand the trait aliases *once* and handle them more responsibly throughout afterwards.

Please review this with whitespace disabled.

r? lcnr
2025-01-21 12:33:33 +00:00
Lukas Wirth
831e3535e6 Fix Param::as_local treating closures wrong 2025-01-21 11:15:36 +01:00
Chayim Refael Friedman
0b68402d78
Merge pull request #18988 from ChayimFriedman2/iter-relevance
fix: Sort completion items that skip `await` and  `iter()` behind those that don't
2025-01-21 09:58:19 +00:00
Chayim Refael Friedman
8e0bc9f67f Sort completion items that skip await and iter() behind those that don't
I don't think my ranking is perfect, because it places them even behind snippet completions, but this is something.
2025-01-21 11:44:38 +02:00
Luuk Wester
6b6e019593 make large niche description more terse, switch to using u128::is_power_of_two 2025-01-21 10:33:28 +01:00
Lukas Wirth
2c040c03cf
Merge pull request #18986 from Veykril/push-zlwvwlowpzqm
Goto `Display::fmt` when invoked on `to_string`
2025-01-21 09:25:05 +00:00
Lukas Wirth
8db3331dc7
Merge pull request #18990 from Veykril/push-tqonnqxyrnsv
internal: Cleanup `Name` string rendering
2025-01-21 09:24:42 +00:00
Lukas Wirth
76585539f5 Cleanup Name string rendering 2025-01-21 10:05:32 +01:00
Lukas Wirth
c78cc2baa9
Merge pull request #18977 from ChayimFriedman2/fix-upmapping
fix: Fix missing upmapping in trait impls completion
2025-01-21 07:41:22 +00:00
Lukas Wirth
d1ee154c3a
Merge pull request #18989 from Giga-Bowser/syntax-tree-refresh
fix: Only refresh syntax tree view when the active document changes
2025-01-21 07:23:22 +00:00
bors
8bdf3ec0b3 Auto merge of #135632 - marcoieni:split-x86_64-msvc-2025, r=Kobzol
CI: split x86_64-msvc job using windows 2025

try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: dist-x86_64-msvc
2025-01-21 06:58:11 +00:00
bors
1e579eac4f Auto merge of #135224 - wyfo:tls-panic-outline, r=cuviper
Outline panicking code for `LocalKey::with`

See https://github.com/rust-lang/rust/pull/115491 for prior related modifications.

https://godbolt.org/z/MTsz87jGj shows a reduction of the code size for TLS accesses.
2025-01-21 02:23:15 +00:00
bors
ad0e3fdf9d Auto merge of #134286 - Urgau:unreach_pub-std, r=ibraheemdev
Enable `unreachable_pub` lint in core

This PR enables the [`unreachable_pub`](https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unreachable-pub) as warn in `core`, `rtstartup` and `panic_unwind`.

The motivation is similar to the compiler [MCP: Enable deny(unreachable_pub) on `rustc_*` crates](https://github.com/rust-lang/compiler-team/issues/773#issue-2467219005) :

> "Where is this thing used?" is a question I ask all the time when reading unfamiliar code. Because of this, I generally find it annoying when things are marked with a more permissive visibility than necessary. "This thing marked pub, which other crates is it used in? Oh, it's not used in any other crates."

Another motivation is to help to lint by utilizing it in-tree and seeing it's limitation in more complex scenarios.

The diff was mostly generated with `./x.py fix --stage 1 library/core/ -- --broken-code`, as well as manual edits for code in macros, generated code and other targets.

r? libs
2025-01-20 23:34:04 +00:00
bors
1f947830b4 Auto merge of #135789 - matthiaskrgr:rollup-4cvw8s4, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #133695 (Reexport likely/unlikely in std::hint)
 - #135330 (Respect --sysroot for rustc -vV and -Cpasses=list)
 - #135333 (Partial progress on #132735: Replace extern "rust-intrinsic" with #[rustc_intrinsic] across the codebase)
 - #135741 (Recognise new IPv6 documentation range from IETF RFC 9637)
 - #135770 (Update contributing docs for submodule/subtree changes)
 - #135775 (Subtree update of `rust-analyzer`)
 - #135776 (Subtree sync for rustc_codegen_cranelift)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-20 20:41:33 +00:00
Matthias Krüger
1cebad399d
Rollup merge of #135776 - bjorn3:sync_cg_clif-2025-01-20, r=bjorn3
Subtree sync for rustc_codegen_cranelift

Nothing too exciting this time, but this includes a fix for a linker hang on Windows: https://github.com/rust-lang/rustc_codegen_cranelift/pull/1554

r? ``@ghost``

``@rustbot`` label +A-codegen +A-cranelift +T-compiler
2025-01-20 20:58:38 +01:00
Matthias Krüger
957cd155a2
Rollup merge of #135775 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? ``@ghost``
2025-01-20 20:58:37 +01:00
Matthias Krüger
818b081fb8
Rollup merge of #135333 - vayunbiyani:test-environment, r=RalfJung
Partial progress on #132735: Replace extern "rust-intrinsic" with #[rustc_intrinsic] across the codebase

Part of #132735: Replace `extern "rust-intrinsic"` with `#[rustc_intrinsic]` macro

- Updated all instances of `extern "rust-intrinsic"` to use the `#[rustc_intrinsic]` macro.
- Skipped `.md` files and test files to avoid unnecessary changes.
2025-01-20 20:58:35 +01:00
Matthias Krüger
155d932119
Rollup merge of #133695 - x17jiri:hint_likely, r=Amanieu
Reexport likely/unlikely in std::hint

Since `likely`/`unlikely` should be working now, we could reexport them in `std::hint`. I'm not sure if this is already approved or if it requires approval

Tracking issue: #26179
2025-01-20 20:58:34 +01:00
Chayim Refael Friedman
ce1759635b Fix another bug with completion of trait items inside macros
This time, when completing the keyword (e.g. `fn` + whitespace).

The bug was actually a double-bug:
First, we did not resolve the impl in the macro-expanded file but in the real file, which of course cannot work.
Second, in analysis the whitespace was correlated with the `impl` and not the incomplete `fn`, which caused fake (where we insert an identifier after the whitespace) and real expansions to go out of sync, which failed analysis. The fix is to skip whitespaces in analysis.
2025-01-20 21:21:42 +02:00
Giga Bowser
c272bcdb69 fix: Only refresh syntax tree view when the active document changes 2025-01-20 14:05:19 -05:00
Lukas Wirth
a3eee10638 Goto Display::fmt when invoked on to_string 2025-01-20 17:00:28 +01:00
Lukas Wirth
9aa0ee1bba
Merge pull request #18984 from Veykril/push-nszlmxoxyxss
internal: Move dual blanket impl logic from source analyzer to goto_def
2025-01-20 15:47:43 +00:00
Lukas Wirth
0fdab1be36 Bring back goto def redirect for parse -> FromStr 2025-01-20 16:32:17 +01:00
Lukas Wirth
03ea40369f Move dual blanket impl logic from source analyzer to goto_def 2025-01-20 16:24:42 +01:00
Vishruth-Thimmaiah
bbd09b573e
fix: upmap ranges in convert_tuple_struct_to_named_struct assist
fixes #18766
2025-01-20 19:46:53 +05:30
Lukas Wirth
93a5846784
Merge pull request #18967 from Veykril/push-pwonkmwqmmol
Properly record meaningful imports as re-exports in symbol index
2025-01-20 13:46:52 +00:00
Lukas Wirth
b2f822b074
Merge pull request #18934 from 1hakusai1/goto_definition_from_into
feat: Add the ability to jump from `into` to `from` definitions
2025-01-20 13:46:47 +00:00