Commit graph

31293 commits

Author SHA1 Message Date
bors
62a7468d46 Auto merge of #17690 - lnicola:unsafe_op_in_unsafe_fn, r=lnicola
internal: Fix and enable unsafe_op_in_unsafe_fn

Closes #17689
2024-07-25 06:05:30 +00:00
Laurențiu Nicola
b392eb4eb5 Fix and enable unsafe_op_in_unsafe_fn 2024-07-25 08:41:30 +03:00
bors
eeb192b79a Auto merge of #17674 - davidbarsky:david/add-more-information-to-status-command, r=Veykril
internal: add more output to the status command

Bit of a lazy change, but this is was pretty handy. I think I should clean up the configuration into something a bit more legible (maybe serialize as JSON?), but I think this is a good enough starting point that we might as well start asking people for it in issue reports.
2024-07-24 10:10:58 +00:00
bors
c155ad0695 Auto merge of #17610 - regexident:impl-all_in_module, r=Veykril
Add method `Impl::all_in_module(…)` for allowing more localized querying

This PR is motivated by an [outside use](https://github.com/regexident/cargo-modules) of the `ra_ap_hir` crate that would benefit from being able to more efficiently query for all impls of a given module (instead of having to query for its parent crate's impls and then filtering on `impl_hir.module(db) == module_hir`).

I have the suspicion that the code as is won't quite work for file-level modules, since those don't have a block, afaict, but with all the crate-rename and version shenanigans around the `ra_ap_` release process I haven't yet been able to figure out how to patch a `ra_ap_` dependency from a third-party crate (let alone how to test this from inside of `rust-analyzer`), so haven't been able to actually run and test this. 😔

Any hints on how to make this (i.e. the code itself, as well as the testing) work are more than welcome!
2024-07-24 09:56:56 +00:00
bors
fbfda1b566 Auto merge of #17661 - alibektas:read_ratoml_on_startup, r=Veykril
minor: Read workspace root ratomls on startup
2024-07-24 09:42:49 +00:00
Winston H.
5af51fa476
fix: use cannot have optional generics
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2024-07-24 10:42:20 +01:00
bors
fff570a7a6 Auto merge of #127153 - NobodyXu:pipe, r=ChrisDenton
Initial implementation of anonymous_pipe API

ACP completed in rust-lang/libs-team#375
Tracking issue: #127154

try-job: x86_64-msvc
try-job: i686-mingw
2024-07-24 00:03:14 +00:00
winstxnhdw
4a91453409 fix: move use parsing to outer match arm 2024-07-23 22:36:46 +01:00
winstxnhdw
e4941c0c73 chore: update codegens 2024-07-23 22:36:46 +01:00
winstxnhdw
61b232369b feat: add arm for use type bound 2024-07-23 22:36:46 +01:00
winstxnhdw
fa3484f39f feat: add use type bound grammar 2024-07-23 22:36:46 +01:00
bors
eb5da56d83 Auto merge of #17395 - davidbarsky:david/remove-unindexed-project-notification, r=Veykril
chore: remove `UnindexinedProject` notification

This PR is split out from https://github.com/rust-lang/rust-analyzer/pull/17246/ (and contains its changes, which is a little annoying from a review perspective...). I'd like to land this change a week or so after #17246 lands in order to give any users of the unindexed project notification time to adopt migrate.
2024-07-23 17:38:41 +00:00
David Barsky
2783aa7312 internal: remove UnindexedProject notification
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
2024-07-23 13:34:04 -04:00
bors
7507695a16 Auto merge of #17483 - alibektas:ratoml/fixes, r=alibektas
minor : fixes for ratoml module

This is a follow-up PR to #17058.

- Parse errors are reflected as such by defining a new variant called `ConfigError::ParseError`
- New error collection has been added to store config level agnostic errors.

EDIT : Some things that this PR promised to solve are removed and will be addressed by other PRs
2024-07-23 14:13:45 +00:00
Ali Bektas
784d46e814 rename config::ConfigChange::other_errors to validation_errors 2024-07-23 15:54:39 +02:00
Ali Bektas
af88940dca minor changes 2024-07-23 15:50:12 +02:00
Vincent Esche
acb50efb3a Add method Impl::all_in_module(…) for supporting more localized querying 2024-07-23 14:43:38 +02:00
bors
a7c72b477b Auto merge of #127755 - no1wudi:master, r=michaelwoerister
Add NuttX based targets for RISC-V and ARM

Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. It is scalable from 8-bit to 64-bit microcontroller environments. The primary governing standards in NuttX are POSIX and ANSI standards.

NuttX adopts additional standard APIs from Unix and other common RTOSs, such as VxWorks. These APIs are used for functionality not available under the POSIX and ANSI standards. However, some APIs, like fork(), are not appropriate for deeply-embedded environments and are not implemented in NuttX.

For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX.

I'll be adding libstd support for NuttX in the future, but for now I'll just add the targets.

Tier 3 policy:

> A tier 3 target must have a designated developer or developers (the "target
>  maintainers") on record to be CCed when issues arise regarding the target.
>  (The mechanism to track and CC such developers may evolve over time.)

I will be the target maintainer for this target on matters that pertain to the NuttX part of the triple. For matters pertaining to the riscv or arm part of the triple, there should be no difference from all other targets. If there are issues, I will address issues regarding the target.

> Targets must use naming consistent with any existing targets; for instance, a
> target for the same CPU or OS as an existing Rust target should use the same
> name for that CPU or OS. Targets should normally use the same names and
> naming conventions as used elsewhere in the broader ecosystem beyond Rust
> (such as in other toolchains), unless they have a very good reason to
> diverge. Changing the name of a target can be highly disruptive, especially
> once the target reaches a higher tier, so getting the name right is important
> even for a tier 3 target.

This is a new supported OS, so I have taken the origin target like `riscv32imac-unknown-none-elf` or `thumbv7m-none-eabi` and changed the `os` section to `nuttx`.

> Target names should not introduce undue confusion or ambiguity unless
> absolutely necessary to maintain ecosystem compatibility. For example, if
> the name of the target makes people extremely likely to form incorrect
> beliefs about what it targets, the name should be changed or augmented to
> disambiguate it.

I feel that the target name does not introduce any ambiguity.

> Tier 3 targets may have unusual requirements to build or use, but must not
> create legal issues or impose onerous legal terms for the Rust project or for
> Rust developers or users.

The only unusual requirement for building the compiler-builtins crate is a standard RISC-V or ARM C compiler supported by cc-rs, and using this target does not require any additional software beyond what is shipped by rustup.

> The target must not introduce license incompatibilities.

All of the additional code will use Apache-2.0.

> Anything added to the Rust repository must be under the standard Rust
> license (`MIT OR Apache-2.0`).

Agreed, and there is no problem here.

> The target must not cause the Rust tools or libraries built for any other
> host (even when supporting cross-compilation to the target) to depend
> on any new dependency less permissive than the Rust licensing policy. This
> applies whether the dependency is a Rust crate that would require adding
> new license exceptions (as specified by the `tidy` tool in the
> rust-lang/rust repository), or whether the dependency is a native library
> or binary. In other words, the introduction of the target must not cause a
> user installing or running a version of Rust or the Rust tools to be
> subject to any new license requirements.

No new dependencies are added.

> Compiling, linking, and emitting functional binaries, libraries, or other
> code for the target (whether hosted on the target itself or cross-compiling
> from another target) must not depend on proprietary (non-FOSS) libraries.
> Host tools built for the target itself may depend on the ordinary runtime
> libraries supplied by the platform and commonly used by other applications
> built for the target, but those libraries must not be required for code
> generation for the target; cross-compilation to the target must not require
> such libraries at all. For instance, `rustc` built for the target may
> depend on a common proprietary C runtime library or console output library,
> but must not depend on a proprietary code generation library or code
> optimization library. Rust's license permits such combinations, but the
> Rust project has no interest in maintaining such combinations within the
> scope of Rust itself, even at tier 3.

Linking is performed by rust-lld

> "onerous" here is an intentionally subjective term. At a minimum, "onerous"
> legal/licensing terms include but are *not* limited to: non-disclosure
> requirements, non-compete requirements, contributor license agreements
> (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms,
> requirements conditional on the employer or employment of any particular
> Rust developers, revocable terms, any requirements that create liability
> for the Rust project or its developers or users, or any requirements that
> adversely affect the livelihood or prospects of the Rust project or its
> developers or users.

There are no terms. NuttX is distributed under the Apache 2.0 license.

> Neither this policy nor any decisions made regarding targets shall create any
> binding agreement or estoppel by any party. If any member of an approving
> Rust team serves as one of the maintainers of a target, or has any legal or
> employment requirement (explicit or implicit) that might affect their
> decisions regarding a target, they must recuse themselves from any approval
> decisions regarding the target's tier status, though they may otherwise
> participate in discussions.

I'm not the reviewer here.

> This requirement does not prevent part or all of this policy from being
> cited in an explicit contract or work agreement (e.g. to implement or
> maintain support for a target). This requirement exists to ensure that a
> developer or team responsible for reviewing and approving a target does not
> face any legal threats or obligations that would prevent them from freely
> exercising their judgment in such approval, even if such judgment involves
> subjective matters or goes beyond the letter of these requirements.

Again I'm not the reviewer here.

> Tier 3 targets should attempt to implement as much of the standard libraries
> as possible and appropriate (`core` for most targets, `alloc` for targets
> that can support dynamic memory allocation, `std` for targets with an
> operating system or equivalent layer of system-provided functionality), but
> may leave some code unimplemented (either unavailable or stubbed out as
> appropriate), whether because the target makes it impossible to implement or
> challenging to implement. The authors of pull requests are not obligated to
> avoid calling any portions of the standard library on the basis of a tier 3
> target not implementing those portions.
> The target must provide documentation for the Rust community explaining how
> to build for the target, using cross-compilation if possible. If the target
> supports running binaries, or running tests (even if they do not pass), the
> documentation must explain how to run such binaries or tests for the target,
> using emulation if possible or dedicated hardware if necessary.

Building is described in platform support doc, but libstd is not supported now, I'll implement it later.

> Tier 3 targets must not impose burden on the authors of pull requests, or
> other developers in the community, to maintain the target. In particular,
> do not post comments (automated or manual) on a PR that derail or suggest a
> block on the PR based on a tier 3 target. Do not send automated messages or
> notifications (via any medium, including via ``@`)` to a PR author or others
> involved with a PR regarding a tier 3 target, unless they have opted into
> such messages.

Understood.

> Backlinks such as those generated by the issue/PR tracker when linking to
> an issue or PR are not considered a violation of this policy, within
> reason. However, such messages (even on a separate repository) must not
> generate notifications to anyone involved with a PR who has not requested
> such notifications.

Understood.

> Patches adding or updating tier 3 targets must not break any existing tier 2
> or tier 1 target, and must not knowingly break another tier 3 target without
> approval of either the compiler team or the maintainers of the other tier 3
> target.

I believe I didn't break any other target.

> In particular, this may come up when working on closely related targets,
> such as variations of the same architecture with different features. Avoid
> introducing unconditional uses of features that another variation of the
> target may not have; use conditional compilation or runtime detection, as
> appropriate, to let each target run code supported by that target.

I think there are no such problems in this PR.

> Tier 3 targets must be able to produce assembly using at least one of
> rustc's supported backends from any host target. (Having support in a fork
> of the backend is not sufficient, it must be upstream.)

Yes, it use standard RISCV or ARM backend to generate assembly.
2024-07-23 09:45:28 +00:00
bors
b2e3cec51e Auto merge of #17675 - PaulDotSH:remove-lens-force-custom-commands-config, r=lnicola
Remove lens.forceCustomCommands config

Closes https://github.com/rust-lang/rust-analyzer/issues/17643
A very simple PR that removes the lens.forceCustomCommands config feature without side effects.
2024-07-23 08:25:58 +00:00
PaulDotSH
49184a138c Remove lens.forceCustomCommands config 2024-07-23 03:27:28 -04:00
bors
28091734f2 Auto merge of #128015 - Nadrieril:two-step-or-expansion, r=compiler-errors
match exhaustiveness: Expand or-patterns as a separate step

To compute exhaustiveness, we must expand or-patterns. Previously, we expanded them at the same time that we pushed patterns into the matrix. This made it harder to track pattern reachability, because the or-pattern itself would never show up in the matrix so we had to recover missing information.

This PR changes that: we no longer expand or-patterns as we push them into the matrix. Instead, if we find an or-pattern in the matrix we expand them in a step very much like the specialization we already do. This simplifies a bunch of things, and should greatly simplify the implementation of https://github.com/rust-lang/rust/issues/127870.

r? `@compiler-errors`
2024-07-23 06:35:42 +00:00
bors
e7ffce3b21 Auto merge of #127778 - Oneirical:artificial-intestlligence, r=jieyouxu
Migrate `staticlib-blank-lib`, `rlib-format-packed-bundled-libs-3` and `issue-97463-abi-param-passing` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Please try:

try-job: aarch64-gnu
try-job: armhf-gnu
try-job: test-various
try-job: x86_64-mingw
try-job: x86_64-msvc
try-job: x86_64-gnu-llvm-18
2024-07-23 01:51:57 +00:00
David Barsky
d0017cef9b internal: add more output to the status command 2024-07-22 15:23:49 -04:00
bors
329adb5ab1 Auto merge of #17671 - Veykril:binding-size, r=Veykril
internal: Shrink size of `Binding`

This should save a bit of memory now that we LRU the source map
2024-07-22 15:16:05 +00:00
Lukas Wirth
7c374a10bd internal: Shrink size of Binding 2024-07-22 17:14:17 +02:00
bors
36f58f5fff Auto merge of #17670 - Veykril:mem, r=Veykril
LRU `body_with_source_map` query

This query is being invalidated all the time anyways (we have an extra query on top of it for the body incrementality that is not source dependent), so there is little reason to keep these around all the time when only some IDE features are interested in them.
2024-07-22 14:48:05 +00:00
Lukas Wirth
bd359b32b0 LRU body_with_source_map query 2024-07-22 16:34:59 +02:00
bors
9d86412498 Auto merge of #17668 - Veykril:incorrect-nevers, r=Veykril
Remove incorrect never! invocations

These can crop up when the `Future` related lang items are missing
2024-07-22 09:36:15 +00:00
bors
d092f7d78f Auto merge of #17542 - roife:fix-issue-17517, r=Veykril
feat: go-to-def and find-references on control-flow keywords

fix #17517.

This PR implements **go-to-definition** and **find-references** functionalities for control flow keywords, which is similar to the behaviors in the `highlight-related` module. Besides, this PR also fixes some incorrect behaviors in `highlight-related`.

## Changes

1. **Support for go-to-definition on control flow keywords**:
   This PR introduces functionality allowing users to navigate on the definition of control flow keywords (`return`, `break`, `continue`).
   Commit: 2a3244ee147f898dd828c06352645ae1713c260f..7391e7a608634709db002a4cb09229de4d12c056.

2. **Bug fixes and refactoring in highlight-related**:
   - **Handling return/break/continue within try_blocks**:
     This PR adjusted the behavior of these keywords when they occur within `try_blocks`. When encounter these keywords, the program should exit the outer function or loop which containing the `try_blocks`, rather than the `try_blocks` itself; while the `?` will cause the program to exit `try_blocks`.
     Commit: 59d697e807f0197f59814b37dca1563959da4aa1.
   - **Support highlighting keywords in macro expansion for highlight-related**:
     Commit: 88df24f01727c23a667a763ee3ee0cec22d5ad52.
   - Detailed description for the bug fixes
     + The previous implementation of `preorder_expr` incorrectly treated `try_blocks` as new contexts, thereby r-a will not continue to traverse inner `return` and `break/continue` statements. To resolve this, a new function `preorder_expr_with_ctx_checker` has been added, allowing users to specify which expressions to skip.
       * For example, when searching for the `?` in the context, r-a should skip `try_blocks` where the `?` insides just works for `try_blocks`. But when search for the `return` keyword, r-a should collect both the `return` keywords inside and outside the `try_blocks`
     + Thus, this PR added `WalkExpandedExprCtx` (builder pattern). It offers the following improvements: customizable context skipping, maintenance of loop depth (for `break`/`continue`), and handling macro expansion during traversal.

3. **Support for find-references on control flow keywords**:
   This PR enables users to find all references to control flow keywords.
   Commit: 9202a33f81218fb9c2edb5d42e6b4de85b0323a8.
2024-07-22 09:22:13 +00:00
bors
6f3030f316 Auto merge of #17586 - ShoyuVanilla:tuple-arg-macro-rest, r=Veykril
Allow macro expansions into `RestPat` in tuple args work as ellipsis like plain `RestPat`

Fixes #17292

Currently, Rust Analyzer lowers `ast::Pat::RestPat` into `Pat::Missing` in general cases on the following lines;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1359-L1367)

And in some proper positions such as `TupleStruct(..)`, it is specially handed on the following lines;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1429-L1437)

This behavior is reasonable because rustc does similar things in
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L108-L111)
and
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L123-L142)

But this sometimes works differently because Rust Analyzer expands macros while ast lowering;

ffbc5ad993/crates/hir-def/src/body/lower.rs (L1386-L1398)
ffbc5ad993/crates/hir-def/src/body/lower.rs (L941-L963)
but rustc uses expanded ast in the corresponding tuple-handling process, so it does not have macro patterns there.
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L114)

So, if a macro expansion in a tuple arg results in `..`, rustc permits it like plain `..` pattern, but Rust Analyzer rejects it.
This is the root cause of #17292 and this PR allows macros expanded into `..` in a tuple arg position work as ellipsis like that.
2024-07-22 09:08:12 +00:00
bors
44f1eb415c Auto merge of #17667 - Veykril:r-a-component-override, r=Veykril
Use rustup rust-analyzer component when there is a toolchain file override for the opened workspace

Fixes https://github.com/rust-lang/rust-analyzer/issues/17663
2024-07-22 08:54:06 +00:00
Lukas Wirth
5806950712 Remove incorrect never! invocations 2024-07-22 10:53:18 +02:00
Lukas Wirth
02c8b7df64 Use rustup rust-analyzer component when there is a toolchain file override for the opened workspace 2024-07-22 10:49:32 +02:00
bors
c29bac1cdf Auto merge of #17647 - joshka:jm/rename-commands, r=Veykril
Rename rust-analyzer commands

The commands `editor.action.triggerParameterHints` and
`editor.action.rename` are now renamed to
`rust-analyzer.triggerParameterHints` and `rust-analyzer.rename`

This change helps make it clear that these commands are specific to
rust-analyzer and not part of the default set of commands provided by
VSCode.

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

Note: This seems like it will be a breaking change for any RA client that previously reacted to `editor.action.triggerParameterHints` - naive search: https://github.com/search?q=editor.action.triggerParameterHints+AND+%28NOT+is%3Afork%29+rust-analyzer&type=code
2024-07-22 08:10:03 +00:00
bors
274c214b16 Auto merge of #17666 - Veykril:simplify, r=Veykril
Simplify
2024-07-22 07:56:04 +00:00
Lukas Wirth
e3f16223c8 Simplify 2024-07-22 09:54:31 +02:00
bors
232e55515f Auto merge of #17660 - ObsidianMinor:fix/17645, r=Veykril
Fix more path resolution for included submodules

Now with more comprehensive testing! This adds tests for includes within modules. Previous testing was not comprehensive enough since submodules that use `include!` didn't actually work either! The `ModDir` used for resolving mods relative to included files has to be `ModDir::root()`. The original test just so happened to put the submodules in the root which made this work, but if you put the `include!` inside a `mod` block it didn't work.

With this change, when collecting a macro expansion, if the macro call is an `include!`, we use the `ModDir::root()` instead of the current module we're in.
2024-07-22 07:00:54 +00:00
bors
6512e29a80 Auto merge of #17658 - alibektas:rename_get_field, r=Veykril
minor: Rename `config::get_field` to `config::get_field_json`
2024-07-22 06:24:53 +00:00
bors
586f106567 Auto merge of #127442 - saethlin:alloc-decoding-lock, r=oli-obk
Try to fix ICE from re-interning an AllocId with different allocation contents

As far as I can tell, based on my investigation in https://github.com/rust-lang/rust/issues/126741, the racy decoding scheme implemented here was never fully correct, but the arrangement of Allocations that's required to ICE the compiler requires some very specific MIR optimizations to create. As far as I can tell, GVN likes to create the problematic pattern, which is why we're noticing this problem now.

So the solution here is to not do racy decoding. If two threads race to decoding an AllocId, one of them is going to sit on a lock until the other is done.
2024-07-22 05:56:05 +00:00
Ali Bektas
e0db833082 Read rust-analyzer.toml files on startup 2024-07-22 02:42:39 +02:00
Sydney Acksman
cdd7b18149 Fix more path resolution for included submodules
Now with much more comprehensive testing! This
adds tests for includes within modules.
2024-07-21 19:04:19 -05:00
Ali Bektas
db2ba64540 Add FIXME to root ratoml tests. 2024-07-22 01:42:50 +02:00
Ali Bektas
4f8735fd56 Apply changes to ratoml/fixes 2024-07-22 01:33:15 +02:00
Ali Bektas
97bad3582a Minor fixes for ratoml module
- Parse errors are reflected as such by defining a new variant called `ConfigError::ParseError`
- New error collection has been added to store config level agnostic errors.
2024-07-22 01:31:38 +02:00
bors
220a07b8cc Auto merge of #120812 - compiler-errors:impl-sorting, r=lcnr
Remove unnecessary impl sorting in queries and metadata

Removes unnecessary impl sorting because queries already return their keys in HIR definition order: https://github.com/rust-lang/rust/issues/120371#issuecomment-1926422838

r? `@cjgillot` or `@lcnr` -- unless I totally misunderstood what was being asked for here? 😆

fixes #120371
2024-07-21 22:43:47 +00:00
Ali Bektas
d4214ec502 Rename config::get_field to config::get_field_json 2024-07-21 22:52:37 +02:00
bors
4afe0d5393 Auto merge of #17657 - Veykril:cfg-slim, r=lnicola
internal: Make `CfgExpr` slimmer
2024-07-21 15:50:31 +00:00
Lukas Wirth
1141c35a4b Make CfgExpr slimmer 2024-07-21 14:50:44 +02:00
bors
db1343e1d6 Auto merge of #17656 - Veykril:flyimport-builtin-mod, r=Veykril
fix: Allow flyimport to import primitive shadowing modules

Fixes https://github.com/rust-lang/rust-analyzer/issues/16371
2024-07-21 11:35:12 +00:00
Lukas Wirth
0851d21d1e fix: Allow flyimport to import primitive shadowing modules 2024-07-21 13:26:19 +02:00