Begin to abstract `rustc_type_ir` for rust-analyzer
This adds the "nightly" feature which is used by the compiler, and falls back to more simple implementations when that is not active.
r? `@lcnr` or `@jackh726`
When encountering struct fn call literal with private fields, suggest all builders
When encountering code like `Box(42)`, suggest `Box::new(42)` and *all* other associated functions that return `-> Box<T>`.
Add a way to give pre-sorted suggestions.
Ensure sanity of all computed ABIs
This moves the ABI sanity assertions from the codegen backend to the ABI computation logic. Sadly, due to past mistakes, we [have to](https://github.com/rust-lang/rust/pull/117351#issuecomment-1788495503) be able to compute a sane ABI for nonsensical function types like `extern "C" fn(str) -> str`. So to make the sanity check pass we first need to make all ABI adjustment deal with unsized types... and we have no shared infrastructure for those adjustments, so that's a bunch of copy-paste. At least we have assertions failing loudly when one accidentally sets a different mode for an unsized argument.
To achieve this, this re-lands the parts of https://github.com/rust-lang/rust/pull/80594 that got reverted in https://github.com/rust-lang/rust/pull/81388. To avoid breaking wasm ABI again, that ABI now explicitly opts-in to the (wrong, broken) ABI that we currently keep for backwards compatibility. That's still better than having *every* ABI use the wrong broken default!
Cc `@bjorn3`
Fixes https://github.com/rust-lang/rust/issues/115845
doc: add release notes to standalone doc bundle
Preview: http://notriddle.com/rustdoc-html-demo-5/release-notes/releases.html
This is a workaround for #101714 on top of being a useful addition in its own right. It is intended to change the "canonical URL" for viewing the release notes from GitHub, which is relatively slow, to a pre-rendered HTML file that loads from the same CDN as the standard library docs. It also means you get a copy of the release notes when installing the rust-docs with rustup.
rustdoc-search: optimize unifyFunctionTypes
Final profile output:
https://notriddle.com/rustdoc-html-demo-5/profile-4/index.html
This PR contains three commits that improve performance of this hot inner loop: reduces the number of allocations, a fast path for the 1-element basic query case, and reconstructing the multi-element query case to use recursion instead of an explicit `backtracking` array. It also adds new test cases that I found while working on this.
r? `@GuillaumeGomez`
Lint pinned `#[must_use]` pointers (in particular, `Box<T>` where `T` is `#[must_use]`) in `unused_must_use`.
Fixes: #111458
This is motivated by a common async/await pattern:
```rs
fn foo() -> Pin<Box<dyn Future<Output = i32>>> {
Box::pin(async { 42 })
}
// call `foo`, but forget to await the result
foo();
```
Unlike with `async fn` or return position `impl Future`, this does not currently warn the user that the `Future` is unused.
To fix this, I've extended the `unused_must_use` lint to catch `Pin<P>`, where `P` must be used. In particular, this applies to `Pin<Box<T>>`, where `T` must be used. I'm not sure if there are other pointers where this applies, but I can't think of any situation the user wouldn't want to be warned.
Remove unneeded `unknown` variable and `Symbol` creation when iterating over items in rustdoc rendering
I realized that we were creating a `Symbol` but never actually used it since we check that `item.name` is always `Some()`.
r? `@notriddle`
Adjust frame IP in backtraces relative to image base for SGX target
This is followup to https://github.com/rust-lang/backtrace-rs/pull/566.
The backtraces printed by `panic!` or generated by `std::backtrace::Backtrace` in SGX target are not usable. The frame addresses need to be relative to image base address so they can be used for symbol resolution. Here's an example panic backtrace generated before this change:
```
$ cargo r --target x86_64-fortanix-unknown-sgx
...
stack backtrace:
0: 0x7f8fe401d3a5 - <unknown>
1: 0x7f8fe4034780 - <unknown>
2: 0x7f8fe401c5a3 - <unknown>
3: 0x7f8fe401d1f5 - <unknown>
4: 0x7f8fe401e6f6 - <unknown>
```
Here's the same panic after this change:
```
$ cargo +stage1 r --target x86_64-fortanix-unknown-sgx
stack backtrace:
0: 0x198bf - <unknown>
1: 0x3d181 - <unknown>
2: 0x26164 - <unknown>
3: 0x19705 - <unknown>
4: 0x1ef36 - <unknown>
```
cc `@jethrogb` and `@workingjubilee`
Set `CFG_OMIT_GIT_HASH=1` during builds when `omit-git-hash` is enabled
This environment variable will allow tools like Cargo to disable their own detection when `omit-git-hash` is set to `true`.
I created this PR because of https://github.com/rust-lang/cargo/pull/12968. There is not a dependency between the two PRs, they can land in any order. They just won't do anything until both of them are merged into the repo.
This is significantly faster, because
- It allows the one-element fast path to kick in on multi-
element queries.
- It constructs intermediate data structures more lazily
than the old system did.
It's measurably faster than the old algo even without the fast path, but
that fast path still helps significantly.
deprecate `if-available` value of `download-ci-llvm`
This PR deprecates the use of the `if-available` value for `download-ci-llvm` since `if-unchanged` serves the same purpose when no changes are detected. In cases where changes are present, it is assumed that compiling LLVM is acceptable (otherwise, why make changes there?).
This was probably missing in the #110087 issue before.
cc `@RalfJung`
Rollup of 5 pull requests
Successful merges:
- #116750 (Add Seek::seek_relative)
- #117110 (Suggest field typo through derefs)
- #117961 (Add `x suggest` entries for testing `mir-opt` and `coverage`)
- #118020 (Fix links to `From<{OwnedHandle, OwnedFd}> for std::process::Child{Stdin, Stdout, Stderr}` in 1.74 release notes)
- #118034 (bump few deps to fix unsoundness and drop few dup deps)
r? `@ghost`
`@rustbot` modify labels: rollup
Add `x suggest` entries for testing `mir-opt` and `coverage`
The `x suggest` subcommand uses git to find paths that have been modified, and uses those paths to suggest relevant test suites to run.
This PR adds suggestions for `x test mir-opt` and `x test coverage` .
Suggest field typo through derefs
Take into account implicit dereferences when suggesting fields.
```
error[E0609]: no field `longname` on type `Arc<S>`
--> $DIR/suggest-field-through-deref.rs:10:15
|
LL | let _ = x.longname;
| ^^^^^^^^ help: a field with a similar name exists: `long_name`
```
CC https://github.com/rust-lang/rust/issues/78374#issuecomment-719564114
Add Seek::seek_relative
The `BufReader` struct has a `seek_relative` method because its `Seek::seek` implementation involved dumping the internal buffer (https://github.com/rust-lang/rust/issues/31100).
Unfortunately, there isn't really a good way to take advantage of that method in generic code. This PR adds the same method to the main `Seek` trait with the straightforward default method, and an override for `BufReader` that calls its implementation.
_Also discussed in [this](https://internals.rust-lang.org/t/add-seek-seek-relative/19546) internals.rust-lang.org thread._
Update cargo
11 commits in 2c03e0e2dcd05dd064fcf10cc1050d342eaf67e3..9765a449d9b7341c2b49b88da41c2268ea599720
2023-11-16 04:21:44 +0000 to 2023-11-17 20:58:23 +0000
- refactor(toml): Clean up workspace inheritance (rust-lang/cargo#12971)
- docs: Recommend a wider selection of libsecret-compatible password managers (rust-lang/cargo#12993)
- feat(cli): add color output for `cargo --list` (rust-lang/cargo#12992)
- refactor: log when loading config from file (rust-lang/cargo#12991)
- Link to rustc lint levels (rust-lang/cargo#12990)
- chore(ci): Catch naive use of AtomicU64 early (rust-lang/cargo#12988)
- cargo-credential-1password: Add missing `--account` argument to `op signin` command (rust-lang/cargo#12985)
- chore: dogfood Cargo `-Zlints` table feature (rust-lang/cargo#12178)
- cargo-credential-1password: Fix README (rust-lang/cargo#12986)
- Fix a rustflags test using a wrong buildfile name (rust-lang/cargo#12987)
- Fix some test output validation. (rust-lang/cargo#12982)
r? ghost
Remove option_payload_ptr; redundant to offset_of
The `option_payload_ptr` intrinsic is no longer required as `offset_of` supports traversing enums (#114208). This PR removes it in order to dogfood offset_of (as suggested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790907626). However, it will not build until those changes reach beta (which I think is within the next 8 days?) so I've opened it as a draft.
When a local binding shadows a fn, point at fn def in call failure
When a local binding shadows a function that is then called, this local binding will cause an E0618 error. We now point not only at the binding definition, but also at the locally defined function of the same name.
```
error[E0618]: expected function, found `&str`
--> $DIR/issue-22468.rs:3:13
|
LL | let foo = "bar";
| --- `foo` has type `&str`
LL | let x = foo("baz");
| ^^^-------
| |
| call expression requires function
...
LL | fn foo(file: &str) -> bool {
| -------------------------- this function of the same name is available here, but it shadowed by the local binding of the same name
```
Fix#53841
Expose tests for {f32,f64}.total_cmp in docs
Expose tests for {f32,f64}.total_cmp in docs
Uncomment the helpful `assert_eq!` line, which is stripped out completely in docs, and leaves the reader to mentally play through the algorithm, or go to the playground and add a println!, to see what the result will be.
(If these tests are known to fail on some platforms, is there some mechanism to conditionalize this or escape the test so the `assert_eq!` source will be visible on the web? I am a newbie, which is why I was reading docs ;)