Commit graph

242478 commits

Author SHA1 Message Date
Celina G. Val efab0dcb25 Add more information to visit_projection_elem
Without the starting place, it's hard to retrieve any useful information
from visiting a projection.
2024-01-11 17:15:21 -08:00
bors 090d5eac72 Auto merge of #119542 - lnicola:sync-from-ra2, r=lnicola
Subtree update of `rust-analyzer`

r? ghost
2024-01-04 07:23:39 +00:00
bors 139fb22146 Auto merge of #119549 - fmease:rollup-jxvbfes, r=fmease
Rollup of 21 pull requests

Successful merges:

 - #119086 (Query panic!() to useful diagnostic)
 - #119239 (Remove unnecessary arm in `check_expr_yield`)
 - #119298 (suppress change-tracker warnings in CI containers)
 - #119319 (Document that File does not buffer reads/writes)
 - #119434 (rc: Take *const T in is_dangling)
 - #119444 (Rename `TyCtxt::is_closure` to `TyCtxt::is_closure_or_coroutine`)
 - #119474 (Update tracking issue of naked_functions)
 - #119476 (Pretty-print always-const trait predicates correctly)
 - #119477 (rustdoc ui: adjust tooltip z-index to be above sidebar)
 - #119479 (Remove two unused feature gates from rustc_query_impl)
 - #119487 (Minor improvements in comment on `freshen.rs`)
 - #119492 (Update books)
 - #119494 (Deny defaults for higher-ranked generic parameters)
 - #119498 (Update deadlinks of `strict_provenance` lints)
 - #119505 (Don't synthesize host effect params for trait associated functions marked const)
 - #119510 (Report I/O errors from rmeta encoding with emit_fatal)
 - #119512 (Mark myself as back from leave)
 - #119514 (coverage: Avoid a query stability hazard in `function_coverage_map`)
 - #119523 (llvm: Allow `noundef` in codegen tests)
 - #119534 (Update `thread_local` examples to use `local_key_cell_methods`)
 - #119544 (Fix: Properly set vendor in i686-win7-windows-msvc target)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-03 18:37:41 +00:00
bors 1a47f5b448 Auto merge of #119485 - weihanglo:update-cargo, r=weihanglo
Update cargo

11 commits in ac6bbb33293d8d424c17ecdb42af3aac25fb7295..add15366eaf3f3eb84717d3b8b71902ca36a7c84
2023-12-26 23:22:08 +0000 to 2024-01-02 03:24:42 +0000
- chore(deps): update gix (rust-lang/cargo#13230)
- chore(deps): update alpine docker tag to v3.19 (rust-lang/cargo#13228)
- rustfix: Support inserting new lines. (rust-lang/cargo#13226)
- Fix fix::fix_in_dependency to not rely on rustc (rust-lang/cargo#13220)
- cleanup: Remove error-format special-case in `cargo fix` (rust-lang/cargo#13224)
- `cargo fix`: always inherit the jobserver (rust-lang/cargo#13225)
- Bump cargo-credential to 0.4.3 (rust-lang/cargo#13221)
- `cargo add` - fix for adding features from repository with multiple packages. (rust-lang/cargo#13213)
- Remove repetitive words (rust-lang/cargo#13216)
- Add cargo:rustc-cdylib-link-arg into RESERVED_PREFIXES list (rust-lang/cargo#13212)
- chore(doc): doc for custom subcommands look up. (rust-lang/cargo#13203)
2024-01-03 16:39:17 +00:00
León Orell Valerian Liehr 9b2a44adc2
Rollup merge of #119544 - roblabla:new-win7-targets, r=Nilstrieb
Fix: Properly set vendor in i686-win7-windows-msvc target

In #118150 , setting the `vendor` field of the `i686-win7-windows-msvc` target was forgotten, preventing us from easily checking the target using `cfg(target_vendor)`.

With this PR, we set the target vendor to "win7".
2024-01-03 16:08:33 +01:00
León Orell Valerian Liehr a79fccc288
Rollup merge of #119534 - tgross35:thread-local-example-updates, r=JohnTitor
Update `thread_local` examples to use `local_key_cell_methods`

`local_key_cell_methods` has been stable for a while and provides a much less clunky way to interface with thread-local

Additionaly add context to the documentation about why types with interior mutability are needed.

r? libs
2024-01-03 16:08:33 +01:00
León Orell Valerian Liehr fcec407f4a
Rollup merge of #119523 - maurer:fix-sparc-llvm-18, r=nikic
llvm: Allow `noundef` in codegen tests

LLVM 18 will automatically infer `noundef` in some situations. Adjust codegen tests to accept this.

See llvm/llvm-project#76553 for why `noundef` is being generated now.

``@rustbot`` label:+llvm-main
2024-01-03 16:08:32 +01:00
León Orell Valerian Liehr ea39f19fab
Rollup merge of #119514 - Zalathar:query-stability, r=wesleywiser
coverage: Avoid a query stability hazard in `function_coverage_map`

When #118865 started enforcing the `rustc::potential_query_instability` lint in `rustc_codegen_llvm`, it added an exemption for this site, arguing that the entries are only used to create a list of filenames that is later sorted.

However, the list of entries also gets traversed when creating the function coverage records in LLVM IR, which may be sensitive to hash-based ordering.

This patch therefore changes `function_coverage_map` to use `FxIndexMap`, which should avoid hash-based instability by iterating in insertion order.

cc ``@Enselic``
2024-01-03 16:08:32 +01:00
León Orell Valerian Liehr c2debecf98
Rollup merge of #119512 - oli-obk:unleave, r=oli-obk
Mark myself as back from leave
2024-01-03 16:08:31 +01:00
León Orell Valerian Liehr a34754e7d5
Rollup merge of #119510 - saethlin:fatal-io-errors, r=WaffleLapkin,Nilstrieb
Report I/O errors from rmeta encoding with emit_fatal

https://github.com/rust-lang/rust/issues/119456 reminded me that I never did systematic testing to provoke the out-of-disk ICEs so I grepped through a recent crater run (https://github.com/rust-lang/rust/pull/119440#issuecomment-1873393963) for more out-of-disk ICEs on current master and yep there's 2 in there.

So I finally cooked up a way to provoke for these crashes. I wrote a little `cdylib` crate that has a `#[no_mangle] pub extern "C" fn write` which occasionally reports `ENOSPC`, and prints a backtrace when it does.
<details><summary><strong>code for the dylib</strong></summary>
<p>

```rust
// cargo add libc rand backtrace
use rand::Rng;

#[no_mangle]
pub extern "C" fn write(
    fd: libc::c_int,
    buf: *const libc::c_void,
    count: libc::size_t,
) -> libc::ssize_t {
    if fd > 2 && rand::thread_rng().gen::<u8>() == 0 {
        let mut count = 0;
        backtrace::trace(|frame| {
            backtrace::resolve_frame(frame, |symbol| {
                if let Some(name) = symbol.name() {
                    if count > 3 {
                        eprintln!("{}", name);
                    }
                }
                count += 1;
            });
            true
        });

        unsafe {
            *libc::__errno_location() = libc::ENOSPC;
        }
        return -1;
    } else {
        unsafe {
            let res =
                libc::syscall(libc::SYS_write, fd as usize, buf as usize, count as usize) as isize;
            if res < 0 {
                *libc::__errno_location() = -res as i32;
                -1
            } else {
                res
            }
        }
    }
}
```

</p>
</details>

Then `LD_PRELOAD` that dylib and repeatedly build a big project until it ICEs, such as with this:
```bash
while true; do
    cargo clean
    LD_PRELOAD=/home/ben/evil/target/release/libevil.so cargo +stage1 check 2> errors
    if grep "thread 'rustc' panicked" errors; then
        break
    fi
done
```
My "big project" for testing was an otherwise-empty project with `cargo add axum`.

Before this PR, the above procedure finds a crash in between 1 and 15 minutes. With this PR, I have not found a crash in 30 minutes, and I'll be leaving this to run overnight (starting now). (A night has now passed, no crashes were found)

I believe the problem is that even though since https://github.com/rust-lang/rust/pull/117301 we correctly check `FileEncoder` for errors on all paths, we use `emit_err`, so there is a window of time between the call to `emit_err` and the full error reporting where rustc believes it has emitted a valid rmeta file and will permit Cargo to launch a build for a dependent crate. Changing these calls to `emit_fatal` closes that window.

I think there are a number of other cases where `emit_err` has been used instead of the more-correct `emit_fatal` such as e51e98dde6/compiler/rustc_codegen_ssa/src/back/write.rs (L542) but unlike rmeta encoding I am not aware of those cases of those causing problems.

r? ``@WaffleLapkin``
2024-01-03 16:08:31 +01:00
León Orell Valerian Liehr 8bce6fc35e
Rollup merge of #119505 - fmease:no-host-param-for-trait-fns, r=fee1-dead
Don't synthesize host effect params for trait associated functions marked const

Fixes #113378.

r? fee1-dead or compiler
2024-01-03 16:08:30 +01:00
León Orell Valerian Liehr 39c2e6db3f
Rollup merge of #119498 - ShE3py:provenance-lints-doc, r=Nilstrieb
Update deadlinks of `strict_provenance` lints

Some hyperlinks on the following page redirect to 404 pages:
<https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#explanation-5>

---

```@rustbot``` label +A-docs
2024-01-03 16:08:30 +01:00
León Orell Valerian Liehr b5618bc222
Rollup merge of #119494 - fmease:deny-hr-param-defaults, r=compiler-errors
Deny defaults for higher-ranked generic parameters

Fixes #119489 (incl. https://github.com/rust-lang/rust/issues/119489#issuecomment-1873399208).
Partially reverts #119042.

cc ```@bvanjoi```
r? ```@compiler-errors``` or compiler
2024-01-03 16:08:29 +01:00
León Orell Valerian Liehr 14226154c4
Rollup merge of #119492 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/reference

1 commits in f9f5b5babd95515e7028c32d6ca4d9790f64c146..3565c7978cfc9662f5963b135690ff9cbbfa0318
2023-12-29 21:01:19 UTC to 2023-12-29 21:01:19 UTC

- Use proper footnote for number literals `_` separator note (rust-lang/reference#1444)

## rust-lang/rust-by-example

1 commits in 4c2b24ff9d9cf19f2fcff799a3a49b9a2c50ae8e..c0be6299e52e4164c30ba6f41bd0ad0aaee64972
2023-12-21 15:22:11 UTC to 2023-12-21 15:22:11 UTC

- point to raw indentifiers, talking about fields (rust-lang/rust-by-example#1789)

## rust-lang/rustc-dev-guide

5 commits in 0610665a8687b1b0aa037917a1598b9f2a21e3ef..d13e85152a977cd0bcaf583cf5f49e86225697de
2023-12-30 09:58:25 UTC to 2023-12-19 10:02:34 UTC

- Prominently mention `profiler = true` on the coverage page (rust-lang/rustc-dev-guide#1844)
- Add a description of `unpretty=hir` to the HIR docs (rust-lang/rustc-dev-guide#1842)
- Fix typo in unsize docs (rust-lang/rustc-dev-guide#1843)
- Suggest `gcc_multi` to make `mir_opts` run on nixos (rust-lang/rustc-dev-guide#1841)
- bootstrapping: Clarify that stage0 std code is not executed to produce stage1 compiler (rust-lang/rustc-dev-guide#1840)
2024-01-03 16:08:29 +01:00
León Orell Valerian Liehr 5d6e35b811
Rollup merge of #119487 - gurry:improve-freshner-comment, r=Nilstrieb
Minor improvements in comment on `freshen.rs`

- Removed a stray "if"
- Changed a numeric "2" to "two" because it reads better
2024-01-03 16:08:28 +01:00
León Orell Valerian Liehr 394aaeed05
Rollup merge of #119479 - bjorn3:remove_unused_feature_gates, r=compiler-errors
Remove two unused feature gates from rustc_query_impl
2024-01-03 16:08:28 +01:00
León Orell Valerian Liehr 493792b37b
Rollup merge of #119477 - lukas-code:tooltip-z-index, r=notriddle
rustdoc ui: adjust tooltip z-index to be above sidebar

In https://github.com/rust-lang/rust/pull/115660 the sidebar's z-index was changed to 100. This PR changes the tooltip's z-index to 101 to be above the sidebar again.

Fixes [after beta-backport] https://github.com/rust-lang/rust/issues/119472.
2024-01-03 16:08:27 +01:00
León Orell Valerian Liehr b41b16971c
Rollup merge of #119476 - fmease:pp-always-const-trait-preds, r=compiler-errors
Pretty-print always-const trait predicates correctly

Follow-up to #119099.

r? fee1-dead
2024-01-03 16:08:27 +01:00
León Orell Valerian Liehr 699a70bdbd
Rollup merge of #119474 - nbdd0121:naked, r=Nilstrieb
Update tracking issue of naked_functions

The original tracking issue #32408 was superseded by the new one #90957 (constrainted naked functions) and therefore is closed.
2024-01-03 16:08:26 +01:00
León Orell Valerian Liehr 3053ced813
Rollup merge of #119444 - compiler-errors:closure-or-coroutine, r=oli-obk
Rename `TyCtxt::is_closure` to `TyCtxt::is_closure_or_coroutine`

This function has always been used to test whether the def-id was a closure **or** coroutine: https://github.com/rust-lang/rust/pull/118311/files#diff-69ebec59f7d38331dd1be84ede7957977dcaa39e30ed2869b04aa8c99b2079ccR552 -- the name is just confusing because it disagrees with other fns named `is_closure`, like `Ty::is_closure`.

So let's rename it.
2024-01-03 16:08:26 +01:00
León Orell Valerian Liehr 34ef194859
Rollup merge of #119434 - taiki-e:rc-is-dangling, r=Mark-Simulacrum
rc: Take *const T in is_dangling

It is not important which one is used since `is_dangling` does not access memory, but `*const` removes the needs of `*const T` -> `*mut T` casts in `from_raw_in`.
2024-01-03 16:08:25 +01:00
León Orell Valerian Liehr 4e265d9fe0
Rollup merge of #119319 - chfogelman:buffered-file-doc, r=the8472
Document that File does not buffer reads/writes

...and refer to `BufReader`/`BufWriter`.

This is a common source of efficiency issues in Rust programs written naively. Including this information with the `File` docs, and adding a link to the wrapper types, will help discoverability.
2024-01-03 16:08:25 +01:00
León Orell Valerian Liehr 907922b472
Rollup merge of #119298 - onur-ozkan:silence-change-tracker-warning-for-ci, r=Mark-Simulacrum
suppress change-tracker warnings in CI containers

Fixes #119296
2024-01-03 16:08:24 +01:00
León Orell Valerian Liehr 893b6f6538
Rollup merge of #119239 - compiler-errors:yield-coercion, r=davidtwco
Remove unnecessary arm in `check_expr_yield`

We always set up the `resume_yield_tys` for async blocks and fns, so this arm was unreachable.
2024-01-03 16:08:24 +01:00
León Orell Valerian Liehr 093bd0888a
Rollup merge of #119086 - RossSmyth:query_panics, r=compiler-errors
Query panic!() to useful diagnostic

Changes some more ICEs from bare panic!()s

Adds an `expect_job()` helper method as that is a moral equivalent of what was happening at the uses.

re:#118955
2024-01-03 16:08:23 +01:00
Ross Smyth 0d421c5ace Add useful panic messages if queries fail to start 2024-01-03 09:51:58 -05:00
bors 2e79c8deb0 Auto merge of #119546 - jdno:temporarily-disable-m1-runners, r=Kobzol
Temporarily disable M1 runners on GitHub Actions

This commit temporarily reverts the addition of M1 runners on GitHub Actions to work around a billing issue related to their beta.

The runners for `dist-aarch64-apple` were originally changed in 821b03d767, and the `aarch64-apple` job was added in 6909992501.
2024-01-03 14:27:31 +00:00
Jan David 0f9844d10c
Temporarily disable M1 runners on GitHub Actions
This commit temporarily reverts the addition of M1 runners on GitHub
Actions to work around a billing issue related to their beta. It also
removes the `aarch64-apple` job, which was only added after the addition
of M1 runners. Since it has never been tested on the prior hardware, we
are skipping the tests to reduce the risk of build failures.
2024-01-03 15:20:03 +01:00
roblabla d9d23fa68d Fix: Properly set vendor in i686-win7-windows-msvc target 2024-01-03 14:09:31 +01:00
Laurențiu Nicola b91d1c0cf9 Add proc_macro_def_site to r-a ALLOW_FEATURES 2024-01-03 11:37:06 +02:00
Laurențiu Nicola a8f2484733 Allow unexpected_cfgs in proc-macro-test imp 2024-01-03 11:36:05 +02:00
Laurențiu Nicola f0108b9d5e Merge commit '426d2842c1f0e5cc5e34bb37c7ac3ee0945f9746' into sync-from-ra2 2024-01-03 11:35:07 +02:00
Trevor Gross 6f49080fa8 Update thread_local examples to use local_key_cell_methods
`local_key_cell_methods` has been stable for a while and provides a much less
clunky way to interface with thread-local variables.

Additionaly add context to the documentation about why types with interior
mutability are needed.
2024-01-02 22:24:26 -06:00
Matthew Maurer ee86b1f84c llvm: Allow noundef in codegen tests
LLVM 18 will automatically infer `noundef` in some situations.
Adjust codegen tests to accept this.

See llvm/llvm-project#76553 for why `noundef` is being generated now.
2024-01-02 18:02:17 +00:00
Weihang Lo dcc043ac2d
Update cargo 2024-01-02 10:45:55 -05:00
bors 426d2842c1 Auto merge of #16222 - rosefromthedead:unresolved-assoc-item, r=Veykril
add unresolved-assoc-item assist

I tried to copy from private-assoc-item for this
2024-01-02 15:06:13 +00:00
bors 86e559bf3f Auto merge of #16211 - tetsuharuohzeki:update-lint, r=Veykril
Use Cargo's [workspace.lints.*] to config clippy

This change begin to use [`[workspace.lints.*]`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table) that is stabilized since [Rust 1.74](https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html).

By this change, we make the configure more readable and simplify `xargo lint` more.
2024-01-02 14:53:22 +00:00
bors 1a0b772a43 Auto merge of #16153 - Veykril:err-msg, r=Veykril
fix: Notify user that linkedProjects is set when failing to discover projects

Fixes https://github.com/rust-lang/rust-analyzer/issues/15171
2024-01-02 14:42:03 +00:00
Lukas Wirth 8136e739f5 fix: Notify user that linkedProjects is set when failing to discover projects 2024-01-02 15:24:21 +01:00
bors df94a87ea8 Auto merge of #16139 - jimmyhmiller:master, r=Veykril
Make functions in impl have a container name

fixes #16015
2024-01-02 14:08:37 +00:00
bors 7040cef07d Auto merge of #16068 - roife:fix-introduce-named-generic-name-conflicts, r=Veykril
fix: pick up new names when the name conflicts in 'introduce_named_generic'

Improve generation of names for generic parameters in `introduce_named_generics`.

fix #15731.

### Changes

- Modified `for_generic_parameter` function in `suggest_name.rs` to handle conflicts with existing generic parameters and generate unique names accordingly.
- Update `introduce_named_generic` function and pass existing params to `for_generic_parameter`, enabling the detection and handling of name collisions.
2024-01-02 13:58:06 +00:00
bors f7a29e4e88 Auto merge of #16100 - Young-Flash:assoc_func_quickfix, r=Veykril
feat: add assoc func quickfix for `unresolved_method` diagnostic

![demo](https://github.com/rust-lang/rust-analyzer/assets/71162630/1ea1d8b8-3436-4251-a512-e0f9de01a13c)

close https://github.com/rust-lang/rust-analyzer/issues/13247

EDIT: I think add a demo gif would be helpful to `@lnicola` when he make a release change log :)
2024-01-02 13:46:35 +00:00
bors 76591096fb Auto merge of #16136 - saiintbrisson:fix/completion/a-tad-smarter-with-fns, r=Veykril
fix(completion): make the expected type a tad smarter with `Fn`s

This commit changes how the expected type is calculated when
working with Fn pointers, making the parenthesis stop vanishing
when completing the function name.

I've been bugged by the behavior of parenthesis completion for
a long while now. R-a assumes that the `LetStmt` type is the same
as the function type I've just written. Worse is that all parenthesis
vanish, even from functions that have completely different signatures.
It will now verify if the signature is the same.

While working on this, I noticed that record fields behave the same,
so I also made it prioritize the field type instead of the current
expression when possible, but I'm unsure if this is OK, so input is
appreciated.

ImplTraits as return types will still behave weirdly because lowering
is disallowed at the time it resolves the function types.

![image](https://github.com/rust-lang/rust-analyzer/assets/29989290/c06d6c93-5cac-4ebe-a93b-923017a6ae8c)
![image](https://github.com/rust-lang/rust-analyzer/assets/29989290/31594d82-fa4d-446c-a77e-47e9de1a9a67)
![image](https://github.com/rust-lang/rust-analyzer/assets/29989290/cf33856e-a485-411b-91af-11090d78a44e)
2024-01-02 13:35:42 +00:00
roife 919ecc6c32 Use HashSet to enhance performance in for_unique_generic_name in suggest_name 2024-01-02 21:33:06 +08:00
roife bc1a5774fd fix: handle with type bounds in existing_params 2024-01-02 21:30:57 +08:00
roife 186553dab8 refactor: extracted the fn handling conflicts in generics and add docs
* Extracted the function `for_unique_generic_name` that handling generics with identical names for reusability.
* Renamed `for_generic_params` to `for_impl_trait_as_generic` for clarity
* Added documentations for `for_impl_trait_as_generic` and `for_unique_generic_name`
2024-01-02 21:30:57 +08:00
roife e8dc8ccc59 fix: pick up new names when the name exists in 'introduce_named_generic' 2024-01-02 21:30:55 +08:00
Luiz Carvalho 9a36bc393d
fix(completion): render fn type 2024-01-02 10:30:16 -03:00
Young-Flash 91bd59682a fix: make editing range accommodate for macros 2024-01-02 21:30:13 +08:00
Luiz Carvalho ed216e285d
fix(completion): make the expected type a tad smarter with Fns
This commit changes how the expected type is calculated when working
with Fn pointers, making the parenthesis stop vanishing when completing
the function name.

I've been bugged by the behaviour on parenthesis completion for a long
while now. R-a assumes that the `LetStmt` type is the same as the
function type I've just written. Worse is that all parenthesis vanish,
even from functions that have completely different signatures. It will
now verify if the signature is the same.

While working on this, I noticed that record fields behave the same, so
I also made it prioritize the field type instead of the current
expression when possible, but I'm unsure if this is OK, so input is
appreciated.

ImplTraits as return types will still behave weirdly because lowering is
disallowed at the time it resolves the function types.
2024-01-02 10:28:49 -03:00