Commit Graph

256000 Commits

Author SHA1 Message Date
Arpad Borsos
004100c222
Process a single not-ASCII-printable char per iteration
This avoids having to collect a non-ASCII-printable run before processing it.
2024-05-23 21:12:08 +02:00
Augie Fackler
a0581b5b7f cleanup: run rustfmt 2024-05-23 15:10:04 -04:00
Augie Fackler
3ea494190f cleanup: standardize on summary over index in names
I did this in the user-facing logic, but I noticed while fixing a minor
defect that I had missed it in a few places in the internal details.
2024-05-23 15:07:43 -04:00
Augie Fackler
de8200c5a4 thinlto: only build summary file if needed
If we don't do this, some versions of LLVM (at least 17, experimentally)
will double-emit some error messages, which is how I noticed this. Given
that it seems to be costing some extra work, let's only request the
summary bitcode production if we'll actually bother writing it down,
otherwise skip it.
2024-05-23 14:58:30 -04:00
bors
6259991f04 Auto merge of #17287 - Veykril:sysroot-encode-empty, r=Veykril
Allow sysroots to only consist of the source root dir

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

This PR encodes the `None` case of an optional sysroot into `Sysroot` itself. This simplifies a lot of things and allows us to have sysroots that consist of nothing, only standard library sources, everything but the standard library sources or everything. This makes things a lot more flexible. Additionally, this removes the workspace status bar info again, as it turns out that that can be too much information for the status bar to handle (this is better rendered somewhere else, like in the status view).
2024-05-23 18:13:47 +00:00
Lukas Wirth
f93256ca42 Allow sysroots to only consist of the source root dir 2024-05-23 20:12:31 +02:00
León Orell Valerian Liehr
55a16a4803
Rollup merge of #125454 - mu001999-contrib:master, r=oli-obk
Improve the doc of query associated_item

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

This query also maps from a impl item to the impl item "descriptor". So it's a bit confused, I skipped it cause it doesn't say it contains impl items.

```rust
fn associated_item(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AssocItem {
    let id = tcx.local_def_id_to_hir_id(def_id);
    let parent_def_id = tcx.hir().get_parent_item(id);
    let parent_item = tcx.hir().expect_item(parent_def_id.def_id);
    match parent_item.kind {
        hir::ItemKind::Impl(impl_) => {
            if let Some(impl_item_ref) = impl_.items.iter().find(|i| i.id.owner_id.def_id == def_id)
            {
                let assoc_item = associated_item_from_impl_item_ref(impl_item_ref);
                debug_assert_eq!(assoc_item.def_id.expect_local(), def_id);
                return assoc_item;
            }
        }

        hir::ItemKind::Trait(.., trait_item_refs) => {
            if let Some(trait_item_ref) =
                trait_item_refs.iter().find(|i| i.id.owner_id.def_id == def_id)
            {
                let assoc_item = associated_item_from_trait_item_ref(trait_item_ref);
                debug_assert_eq!(assoc_item.def_id.expect_local(), def_id);
                return assoc_item;
            }
        }

        _ => {}
    }

    span_bug!(
        parent_item.span,
        "unexpected parent of trait or impl item or item not found: {:?}",
        parent_item.kind
    )
}
```
2024-05-23 20:09:10 +02:00
León Orell Valerian Liehr
72cc4de660
Rollup merge of #125401 - GuillaumeGomez:migrate-rustdoc-scrape-examples-macros, r=jieyouxu
Migrate `run-make/rustdoc-scrape-examples-macros` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? `````@jieyouxu`````
2024-05-23 20:09:10 +02:00
León Orell Valerian Liehr
c70059062a
Rollup merge of #125336 - momvart:smir-77-intrinsic, r=celinval
Add dedicated definition for intrinsics

Closes rust-lang/project-stable-mir#77
2024-05-23 20:09:09 +02:00
León Orell Valerian Liehr
d392d6849c
Rollup merge of #125227 - Oneirical:seventh, r=jieyouxu
Migrate `run-make/issue-30063` 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).

(Sorry about the [inconvenience](https://github.com/rust-lang/rust/pull/125224#issuecomment-2118340932) of all these PRs, this is the last one batched for today. I will discuss how we can cut these down a bit.)

The last check was previously commented out in the Makefile, and I have readded it. If it fails the CI, this can be reconsidered.
2024-05-23 20:09:09 +02:00
León Orell Valerian Liehr
e282b1f753
Rollup merge of #125224 - Oneirical:sixth, r=jieyouxu
Migrate `run-make/issue-53964` 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).

This is extremely similar to #125146. Could it be interesting to merge the two in some way? This one seems to do the same thing as the #125146, but with an added check that a useless lint is not shown.
2024-05-23 20:09:08 +02:00
León Orell Valerian Liehr
f862f6d292
Rollup merge of #124389 - CensoredUsername:master, r=petrochenkov
Add a warning to proc_macro::Delimiter::None that rustc currently does not respect it.

It does not provide the behaviour it is indicated to provide when used in a proc_macro context.

This seems to be a bug, (https://github.com/rust-lang/rust/issues/67062), but it is a long standing one, and hard to discover.

This pull request adds a warning to inform users of this issue, with a link to the relevant issue, and a version number of the last known affected rustc version.
2024-05-23 20:09:08 +02:00
León Orell Valerian Liehr
c99b3f24c2
Rollup merge of #122382 - mu001999:dead_code/enhance, r=petrochenkov
Detect unused structs which implement private traits

Fixes #122361
2024-05-23 20:09:07 +02:00
bors
606afbb617 Auto merge of #117804 - saethlin:no-recursive-panics, r=joboet
Panic directly in Arguments::new* instead of recursing

This has been bothering me because it looks very silly in MIR.
2024-05-23 17:11:11 +00:00
blyxyas
d6e6918857 Make clamp inline 2024-05-23 18:45:03 +02:00
Oli Scherer
4387eea7f7 Support constraining opaque types while trait upcasting with binders 2024-05-23 16:02:24 +00:00
Oli Scherer
7f292f41a0 Allow defining opaque types during trait object upcasting.
No stable code is affected, as this requires the `trait_upcasting` feature gate.
2024-05-23 16:02:20 +00:00
Oli Scherer
29a630eb72 When checking whether an impl applies, constrain hidden types of opaque types.
We already handle this case this way on the coherence side, and it matches the new solver's behaviour. While there is some breakage around type-alias-impl-trait (see new "type annotations needed" in tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs), no stable code breaks, and no new stable code is accepted.
2024-05-23 15:52:10 +00:00
r0cky
b1fa845d42 Improve the doc of query associated_item 2024-05-23 23:50:39 +08:00
Oli Scherer
dc8d1bc373 Add more tests 2024-05-23 15:48:06 +00:00
Rémy Rakic
d64a8bd1e5 emit an error if we can't find a path to the self-contained linker 2024-05-23 15:47:35 +00:00
Rémy Rakic
fab28f2a4d rust-lld: fallback to the default default sysroot where rustc is currently located 2024-05-23 15:47:35 +00:00
Mohammad Omidvar
6743fc7704 Add conversion from IntrinsicDef to FnDef 2024-05-23 15:35:18 +00:00
bors
9c8a58fdb8 Auto merge of #116123 - joboet:rewrite_native_tls, r=m-ou-se
Rewrite native thread-local storage

(part of #110897)

The current native thread-local storage implementation has become quite messy, uses indescriptive names and unnecessarily adds code to the macro expansion. This PR tries to fix that by using a new implementation that also allows more layout optimizations and potentially increases performance by eliminating unnecessary TLS accesses.

This does not change the recursive initialization behaviour I described in [this comment](https://github.com/rust-lang/rust/issues/110897#issuecomment-1525705682), so it should be a library-only change. Changing that behaviour should be quite easy now, however.

r? `@m-ou-se`
`@rustbot` label +T-libs
2024-05-23 14:53:41 +00:00
Urgau
45ad60d05a Copy core/alloc check-cfg message also in std 2024-05-23 16:08:34 +02:00
Urgau
28689850e5 Move some expected cfgs to std build.rs as per Cargo recommandation 2024-05-23 16:08:31 +02:00
Strophox
1b374dfd9b differentiate between layout and alloc_layout 2024-05-23 16:00:23 +02:00
Urgau
a59589b1cc Replace fake "restricted-std" Cargo feature by custom cfg 2024-05-23 15:54:02 +02:00
Ben Kimock
75f3cef756 panic_nounwind in Arguments::new* instead of recursing 2024-05-23 09:21:21 -04:00
Urgau
324b66c553 Expect any feature cfg in core and std crates 2024-05-23 15:20:25 +02:00
Strophox
56c363b43e fix alloc_bytes (always allocate at least 1B) 2024-05-23 14:59:51 +02:00
bors
ed172dbbaf Auto merge of #125448 - matthiaskrgr:rollup-vn6nleh, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #124297 (Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type)
 - #124516 (Allow monomorphization time const eval failures if the cause is a type layout issue)
 - #124976 (rustc: Use `tcx.used_crates(())` more)
 - #125210 (Cleanup: Fix up some diagnostics)
 - #125409 (Rename `FrameworkOnlyWindows` to `RawDylibOnlyWindows`)
 - #125416 (Use correct param-env in `MissingCopyImplementations`)
 - #125421 (Rewrite `core-no-oom-handling`, `issue-24445` and `issue-38237` `run-make` tests to new `rmake.rs` format)
 - #125438 (Remove unneeded string conversion)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-23 12:44:13 +00:00
Matthias Krüger
cf92f4c52f
Rollup merge of #125438 - tbu-:pr_rm_to_string_lossy, r=jieyouxu
Remove unneeded string conversion
2024-05-23 14:09:26 +02:00
Matthias Krüger
eb1b9b0048
Rollup merge of #125421 - Oneirical:bundle-them-yet-again, r=jieyouxu
Rewrite `core-no-oom-handling`, `issue-24445` and `issue-38237` `run-make` tests to new `rmake.rs` format

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

The test which is now called `non-pie-thread-local` has an unexplained "only-linux" flag. Could it be worth trying to remove it and changing the CI to test non-Linux platforms on it?
2024-05-23 14:09:25 +02:00
Matthias Krüger
e713b2a00c
Rollup merge of #125416 - compiler-errors:param-env-missing-copy, r=lcnr
Use correct param-env in `MissingCopyImplementations`

We shouldn't assume the param-env is empty for this lint, since although we check the struct has no parameters, there still may be trivial where-clauses.

fixes #125394
2024-05-23 14:09:25 +02:00
Matthias Krüger
c9e457dbd6
Rollup merge of #125409 - tbu-:pr_raw_dylib_only_windows, r=lcnr
Rename `FrameworkOnlyWindows` to `RawDylibOnlyWindows`

Frameworks are Apple-specific, no idea why it had "framework" in the name before.
2024-05-23 14:09:24 +02:00
Matthias Krüger
337987bf63
Rollup merge of #125210 - fmease:fix-up-some-diags, r=davidtwco
Cleanup: Fix up some diagnostics

Several diagnostics contained their error code inside their primary message which is no bueno.
This PR moves them out of the message and turns them into structured error codes.

Also fixes another occurrence of `->` after a selector in a Fluent message which is not correct. I've fixed two other instances of this issue in #104345 (2022) but didn't update all instances as I've noted here: https://github.com/rust-lang/rust/pull/104345#issuecomment-1312705977 (“the future is now!”).
2024-05-23 14:09:24 +02:00
Matthias Krüger
eda4a35f36
Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk
rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from https://github.com/rust-lang/rust/pull/121167.
2024-05-23 14:09:23 +02:00
Matthias Krüger
eb6b35b5bc
Rollup merge of #124516 - oli-obk:taint_const_eval, r=RalfJung
Allow monomorphization time const eval failures if the cause is a type layout issue

r? `@RalfJung`

fixes  #124348
2024-05-23 14:09:23 +02:00
Matthias Krüger
abcf400a28
Rollup merge of #124297 - oli-obk:define_opaque_types13, r=jackh726
Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type

r? `@compiler-errors`

This accepts more code on stable. It is now possible to have match arms return a function item `foo` and a different function item `bar` in another, and that will constrain OpaqueTypeInDefiningScope to have the hidden type ConcreteType and make the type of the match arms a function pointer that matches the signature. So the following function will now compile, but on master it errors with a type mismatch on the second match arm

```rust
fn foo<T>(t: T) -> T {
    t
}

fn bar<T>(t: T) -> T {
    t
}

fn k() -> impl Sized {
    fn bind<T, F: FnOnce(T) -> T>(_: T, f: F) -> F {
        f
    }
    let x = match true {
        true => {
            let f = foo;
            bind(k(), f)
        }
        false => bar::<()>,
    };
    todo!()
}
```

cc https://github.com/rust-lang/rust/issues/116652

This is very similar to https://github.com/rust-lang/rust/pull/123794, and with the same rationale:

> this is for consistency with `-Znext-solver`. the new solver does not have the concept of "non-defining use of opaque" right now and we would like to ideally keep it that way. Moving to `DefineOpaqueTypes::Yes` in more cases removes subtlety from the type system. Right now we have to be careful when relating `Opaque` with another type as the behavior changes depending on whether we later use the `Opaque` or its hidden type directly (even though they are equal), if that later use is with `DefineOpaqueTypes::No`*
2024-05-23 14:09:22 +02:00
joboet
60bf1ab466
delete UI tests that only check internal implementation details of thread-locals 2024-05-23 13:44:56 +02:00
joboet
085b3d49c9
std: rewrite native thread-local storage 2024-05-23 13:44:55 +02:00
joboet
c398b2c193
core: use Copy in TAIT to fix clippy lint 2024-05-23 13:38:52 +02:00
Oli Scherer
4cf34cb752 Allow const eval failures if the cause is a type layout issue 2024-05-23 10:51:52 +00:00
Oli Scherer
301c8decce Add regression tests 2024-05-23 10:48:39 +00:00
Guillaume Gomez
de644626c3 Migrate run-make/rustdoc-with-short-out-dir-option to rmake.rs 2024-05-23 12:28:51 +02:00
bors
ecadf37df4 Auto merge of #17284 - Veykril:doc-links, r=Veykril
fix: Use correct toolchain channel when generating builtin type doc links
2024-05-23 08:55:08 +00:00
Lukas Wirth
616fdd04bb Use correct toolchain channel when generating builtin type doc links 2024-05-23 10:42:15 +02:00
bors
6e8646df8b Auto merge of #17174 - Kohei316:fix-infer-async-block-with-tail-return-expr, r=Veykril
Fix: infer type of async block with tail return expr

Fixes #17106
The `infer_async_block` method calls the `infer_block` method internally, which returns the never type without coercion when `tail_expr` is `None` and `ctx.diverges` is `Diverges::Always`.This is the reason for the bug in this issue.
cfce2bb46d/crates/hir-ty/src/infer/expr.rs (L1411-L1413)

This PR solves the bug by adding a process to coerce after calling `infer_block` method.

This code passes all the tests, including tests I added for this isuue, however, I am not sure if this solution is right. I think that this solution is an ad hoc solution. So, I would appreciate to have your review.
I apologize if I'm off the mark, but `infer_async_block` method should be rewritten to share code with the process of infering type of `expr::Closure` instead of the `infer_block` method. That way it will be closer to the infer process of rustc.
2024-05-23 08:42:09 +00:00
Lukas Wirth
425ed6a181
Update crates/hir-ty/src/infer/expr.rs 2024-05-23 10:36:57 +02:00