A Rust compiler front-end for IDEs
Find a file
bors 45ad364b10 Auto merge of #136539 - matthewjasper:late-normalize-errors, r=compiler-errors
Emit dropck normalization errors in borrowck

Borrowck generally assumes that any queries it runs for type checking will succeed, thinking that HIR typeck will have errored first if there was a problem. However as of #98641, dropck isn't run on HIR, so there's no direct guarantee that it doesn't error. While a type being well-formed might be expected to ensure that its fields are well-formed, this is not the case for types containing a type projection:

```rust
pub trait AuthUser {
    type Id;
}

pub trait AuthnBackend {
    type User: AuthUser;
}

pub struct AuthSession<Backend: AuthnBackend> {
    data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>,
}

pub trait Authz: Sized {
    type AuthnBackend: AuthnBackend<User = Self>;
}

pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {}
// ^ No User: AuthUser bound is required or inferred.
```

While improvements to trait solving might fix this in the future, for now we go for a pragmatic solution of emitting an error from borrowck (by rerunning dropck outside of a query) and making drop elaboration check if an error has been emitted previously before panicking for a failed normalization.

Closes #103899
Closes #135039

r? `@compiler-errors` (feel free to re-assign)
2025-02-19 07:49:08 +00:00
.cargo fix: Fix generated markers not being patchable in package.json 2024-06-08 12:54:43 +02:00
.github fix off-by-one error 2025-02-09 15:23:53 -05:00
.vscode feat: use vscode log format for client logs 2024-07-27 21:43:35 -07:00
assets Automatically change text color in logo based on dark mode 2022-03-06 23:06:53 +11:00
bench_data Spelling 2023-04-19 09:45:55 -04:00
crates Rollup merge of #137173 - lnicola:sync-from-ra, r=lnicola 2025-02-17 17:06:14 +01:00
docs manual: Separate out installation and configuration pages 2025-02-12 10:21:09 -08:00
editors/code add cargo's git checkouts to the list of paths to mark as read-only in vscode 2025-02-13 18:48:36 -08:00
lib line-index: don't try to use neon on big-endian aarch64. 2025-02-04 15:22:49 +00:00
xtask manual: Fix URLs to rustdoc pages 2025-02-11 12:10:32 -08:00
.editorconfig Fix editorconfig glob 2024-10-19 01:10:31 +03:00
.git-blame-ignore-revs Fix some mir eval/lowerings 2025-02-03 14:42:41 +01:00
.gitattributes Fix .gitattributes for test_data 2022-07-24 14:05:35 +02:00
.gitignore manual: Convert to mdbook 2025-01-24 13:23:22 -08:00
.typos.toml Bump typos 2024-12-13 11:45:44 +02:00
Cargo.lock Update lockfile 2025-02-17 14:50:39 +02:00
Cargo.toml Bump rustc crates 2025-02-17 14:11:12 +02:00
clippy.toml Enforce a current directory being set for spawned commands 2024-12-29 12:51:13 +01:00
CONTRIBUTING.md Add CONTRIBUTING.md 2024-04-18 10:24:40 +02:00
LICENSE-APACHE Drop Apache license appendices 2024-08-27 14:52:34 +03:00
LICENSE-MIT Licenses 2018-01-10 22:47:04 +03:00
PRIVACY.md Update PRIVACY.md 2025-02-07 20:18:21 +01:00
README.md Update README.md links for mdbook manual 2025-02-07 12:07:18 -08:00
rust-version Preparing for merge from rust-lang/rust 2025-02-17 13:20:07 +02:00
rustfmt.toml Shuffle hir-expand things around 2024-01-26 19:28:39 +01:00
triagebot.toml Enable triagebot transfer feature 2024-11-04 21:35:10 +02:00

rust-analyzer logo

rust-analyzer is a modular compiler frontend for the Rust language. It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.

Quick Start

https://rust-analyzer.github.io/book/installation.html

Documentation

If you want to contribute to rust-analyzer check out the CONTRIBUTING.md or if you are just curious about how things work under the hood, check the ./docs/dev folder.

If you want to use rust-analyzer's language server with your editor of choice, check the manual. It also contains some tips & tricks to help you be more productive when using rust-analyzer.

Security and Privacy

See the security and privacy sections of the manual.

Communication

For usage and troubleshooting requests, please use "IDEs and Editors" category of the Rust forum:

https://users.rust-lang.org/c/ide/14

For questions about development and implementation, join rust-analyzer working group on Zulip:

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer

License

rust-analyzer is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.