Commit Graph

239639 Commits

Author SHA1 Message Date
Matthias Krüger
0223a811f5
Rollup merge of #118169 - SparrowLii:deadlock_issue, r=compiler-errors
print query map for deadlock when using parallel front end

print query map for deadlock when using parallel front end, so that we can analyze where and why deadlock occurs
2023-11-23 07:06:31 +01:00
Matthias Krüger
9e944c8c1a
Rollup merge of #118167 - RalfJung:unadjusted-abi-is-internal, r=petrochenkov
make the 'abi_unadjusted' feature internal

As [suggested](https://github.com/rust-lang/rust/pull/118127#issuecomment-1820736389) by `@bjorn3.`
2023-11-23 07:06:31 +01:00
Matthias Krüger
add423bcf7
Rollup merge of #118146 - compiler-errors:deref-into-dyn-regions, r=lcnr
Rework supertrait lint once again

I accidentally pushed the wrong commits because I totally didn't check I was on the right computer when updating #118026.
Sorry, this should address all the nits in #118026.

r? lcnr
2023-11-23 07:06:30 +01:00
Matthias Krüger
82538b72c0
Rollup merge of #118131 - lukas-code:multi-default, r=wesleywiser
improve tool-only help for multiple `#[default]` variants

When defining an enum with multiple `#[default]` variants, we emit a tool-only suggestion for every `#[default]`ed variant to remove all other `#[default]`s. This PR improves the suggestion to correctly handle the cases where one variant has multiple `#[default]`s and where different `#[default]`s have the same span due to macro expansions.

fixes https://github.com/rust-lang/rust/issues/118119
2023-11-23 07:06:30 +01:00
The Miri Conjob Bot
03f19ab7bb Merge from rustc 2023-11-23 05:01:28 +00:00
The Miri Conjob Bot
804afa4a94 Preparing for merge from rustc 2023-11-23 04:55:03 +00:00
Nicholas Nethercote
62ffb14c3d Remove unnecessary and misleading .. in a pattern.
All the fields are named.
2023-11-23 15:29:26 +11:00
Nicholas Nethercote
b8d340db14 Remove unnecessary ValueAnalysisWrapper::Direction.
`Forward` is the default.
2023-11-23 15:29:26 +11:00
Nicholas Nethercote
64a8c4ddda Reduce pub usage. 2023-11-23 15:29:24 +11:00
bors
193466525d Auto merge of #115159 - solid-rs:patch/kmc-solid/io-safety, r=workingjubilee
kmc-solid: I/O safety

Adds the I/O safety API (#87329) for socket file descriptors in [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets. All new public items are gated by the `solid_ext` library feature.

This PR adds the following public types and traits:

    std::os::solid::io::AsFd
    std::os::solid::io::BorrowedFd
    std::os::solid::io::OwnedFd

    std::os::solid::prelude::AsFd (re-export)
    std::os::solid::prelude::BorrowedFd (re-export)
    std::os::solid::prelude::OwnedFd (re-export)

And trait implementations:

    From<std::net::TcpListener> for std::os::solid::io::OwnedFd
    From<std::net::TcpStream> for std::os::solid::io::OwnedFd
    From<std::net::UdpSocket> for std::os::solid::io::OwnedFd
    From<std::os::solid::io::OwnedFd> for std::net::TcpListener
    From<std::os::solid::io::OwnedFd> for std::net::TcpStream
    From<std::os::solid::io::OwnedFd> for std::net::UdpSocket
    std::fmt::Debug for std::os::solid::io::BorrowedFd<'_>
    std::fmt::Debug for std::os::solid::io::OwnedFd
    std::io::IsTerminal for std::os::solid::io::BorrowedFd<'_>
    std::io::IsTerminal for std::os::solid::io::OwnedFd
    std::os::fd::AsRawFd for std::os::solid::io::BorrowedFd<'_>
    std::os::fd::AsRawFd for std::os::solid::io::OwnedFd
    std::os::fd::FromRawFd for std::os::solid::io::OwnedFd
    std::os::fd::IntoRawFd for std::os::solid::io::OwnedFd
    std::os::solid::io::AsFd for &impl std::os::solid::io::AsFd
    std::os::solid::io::AsFd for &mut impl std::os::solid::io::AsFd
    std::os::solid::io::AsFd for Arc<impl std::os::solid::io::AsFd>
    std::os::solid::io::AsFd for Box<impl std::os::solid::io::AsFd>
    std::os::solid::io::AsFd for Rc<impl std::os::solid::io::AsFd>
    std::os::solid::io::AsFd for std::net::TcpListener
    std::os::solid::io::AsFd for std::net::TcpStream
    std::os::solid::io::AsFd for std::net::UdpSocket
    std::os::solid::io::AsFd for std::os::solid::io::BorrowedFd<'_>
    std::os::solid::io::AsFd for std::os::solid::io::OwnedFd

Taking advantage of the above change, this PR also refactors the internal details of `std::sys::solid::net` to match the design of other targets, e.g., by redefining `Socket` as a newtype of `OwnedFd`.
2023-11-23 04:24:09 +00:00
Ben Kimock
f5dae8e73c Miri: GC the dead_alloc_map too 2023-11-22 22:40:55 -05:00
Nicholas Nethercote
c16d3f32a4 Avoid unnecessary exports. 2023-11-23 14:06:57 +11:00
Nicholas Nethercote
ca741945f4 Remove indexes module.
It's not useful, and only obfuscates things.
2023-11-23 14:06:46 +11:00
Nicholas Nethercote
e7781c75f8 Move has_rustc_mir_with.
`lib.rs` is a strange place for it, and it's only used within
`rustc_peek.rs`, so it doesn't need to be `pub`.
2023-11-23 14:06:32 +11:00
Nicholas Nethercote
36b25f5386 Reorder some use items.
The current order is a mess.
2023-11-23 14:06:25 +11:00
SparrowLii
c238e87573 Nit of deadlock detected 2023-11-23 10:35:33 +08:00
bors
360bafad68 Auto merge of #118065 - estebank:core-not-found-404, r=TaKO8Ki
When failing to import `core`, suggest `std`
2023-11-23 02:26:52 +00:00
bors
c387f012b1 Auto merge of #118154 - ChrisDenton:win-clippy, r=scottmcm
Fix some clippy lints for library/std/src/sys/windows

These issues were shown by running `x clippy` on `library/std` and filtering for `windows/` paths. I think running clippy on the full std would be great but I wanted to start smaller and with something that's hopefully easier to review. It'd be good to eventually run clippy in CI but that's a bigger conversation.

I've created separate commits for each clippy lint fixed (with the commit title set to the lint name) and reviewed the changes myself. Most of the fixes here are trivial.

r? libs
2023-11-23 00:30:15 +00:00
Michael Goulet
4ec68576d3 Cache flags for ty::Const 2023-11-22 23:28:28 +00:00
Michael Goulet
15fbcc3636 Rework supertrait lint once again 2023-11-22 21:51:39 +00:00
onur-ozkan
111ad61ab3 Recompile LLVM when it changes in the git sources
Utilize a smart hash for 'llvm-finished-building' to enable
recompilation of LLVM with each change in the git sources.

Each change generates a unique hash value in 'llvm-finished-building',
which ensures LLVM compilations only triggered with further changes.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-11-23 00:44:07 +03:00
Nicholas Nethercote
2052d2b17c Remove unused feature. 2023-11-23 08:15:11 +11:00
bors
1e9dda77b5 Auto merge of #118120 - compiler-errors:closure-kind, r=lcnr
Remove `PredicateKind::ClosureKind`

We don't need the `ClosureKind` predicate kind -- instead, `Fn`-family trait goals are left as ambiguous, and we only need to make progress on `FnOnce` projection goals for inference purposes.

This is similar to how we do confirmation of `Fn`-family trait and projection goals in the new trait solver, which also doesn't use the `ClosureKind` predicate.

Some hacky logic is added in the second commit so that we can keep the error messages the same.
2023-11-22 21:09:01 +00:00
Tamir Duberstein
55393b6eca
rustc_session: implement latent TODO 2023-11-22 14:37:12 -05:00
Esteban Küber
ec50f1c90b When failing to import core, suggest std 2023-11-22 19:30:47 +00:00
Tamir Duberstein
45bad64ab4
rustc_lint: remove superfluous assertion
`Option::unwrap` is called on the next line.
2023-11-22 14:25:22 -05:00
bors
06d1afe518 Auto merge of #118178 - compiler-errors:rollup-0i11w85, r=compiler-errors
Rollup of 6 pull requests

Successful merges:

 - #118012 (Add support for global allocation in smir)
 - #118013 (Enable Rust to use the EHCont security feature of Windows)
 - #118100 (Enable profiler in dist-powerpc64-linux)
 - #118142 (Tighten up link attributes for llvm-wrapper bindings)
 - #118147 (Fix some unnecessary casts)
 - #118161 (Allow defining opaques in `check_coroutine_obligations`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-22 18:49:51 +00:00
bors
41d7012a8e Auto merge of #3180 - eduardosm:check-intrinsics-target-feature, r=RalfJung
Check that target features required by LLVM intrinsics are enabled

Fixes https://github.com/rust-lang/miri/issues/3178
2023-11-22 18:01:35 +00:00
Michael Goulet
4ec548afbe
Rollup merge of #118161 - compiler-errors:coroutine-obligation-opaques, r=lcnr
Allow defining opaques in `check_coroutine_obligations`

In the new trait solver, when an obligation stalls on an unresolved coroutine witness, we will stash away the *root* obligation, even if the stalled obligation is only a distant descendent of the root obligation, since the new solver is purely recursive.

This means that we may need to reprocess alias-relate obligations (and others) which may define opaque types in the new solver. Currently, we use the coroutine's def id as the defining anchor in `check_coroutine_obligations`, which will allow defining no opaque types, resulting in errors like:

```
error[E0271]: type mismatch resolving `{coroutine@<source>:6:5: 6:17} <: impl Clone`
 --> <source>:6:5
  |
6 | /     move |_: ()| {
7 | |         let () = yield ();
8 | |     }
  | |_____^ types differ
```

So this PR fixes the defining anchor and does the same trick as `check_opaque_well_formed`, where we manually compare opaques that were defined against their hidden types to make sure they weren't defined differently when processing these stalled coroutine obligations.

r? `@lcnr` cc `@cjgillot`
2023-11-22 09:28:52 -08:00
Michael Goulet
040151a4be
Rollup merge of #118147 - Nilstrieb:no-redundant-casts, r=WaffleLapkin
Fix some unnecessary casts

`x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-22 09:28:51 -08:00
Michael Goulet
dd9f3ad806
Rollup merge of #118142 - saethlin:llvm-linkage, r=tmiasko
Tighten up link attributes for llvm-wrapper bindings

Fixes https://github.com/rust-lang/rust/issues/118084 by moving all of the declarations of symbols from `llvm_rust` into a separate extern block with `#[link(name = "llvm-wrapper", kind = "static")]`.

This also renames `LLVMTimeTraceProfiler*` to `LLVMRustTimeTraceProfiler*` because those are functions from `llvm_rust`.

r? tmiasko
2023-11-22 09:28:51 -08:00
Michael Goulet
90f04e1b4d
Rollup merge of #118100 - ecnelises:ppc64_profiler, r=Kobzol
Enable profiler in dist-powerpc64-linux
2023-11-22 09:28:50 -08:00
Michael Goulet
1fb2624205
Rollup merge of #118013 - sivadeilra:user/ardavis/ehcont, r=wesleywiser
Enable Rust to use the EHCont security feature of Windows

In the future Windows will enable Control-flow Enforcement Technology (CET aka Shadow Stacks). To protect the path where the context is updated during exception handling, the binary is required to enumerate valid unwind entrypoints in a dedicated section which is validated when the context is being set during exception handling.

The required support for EHCONT Guard has already been merged into LLVM, long ago. This change simply adds the Rust codegen option to enable it.

Relevant LLVM change: https://reviews.llvm.org/D40223

This also adds a new `ehcont-guard` option to the bootstrap config which enables EHCont Guard when building std.

We at Microsoft have been using this feature for a significant period of time; we are confident that the LLVM feature, when enabled, generates well-formed code.

We currently enable EHCONT using a codegen feature, but I'm certainly open to refactoring this to be a target feature instead, or to use any appropriate mechanism to enable it.
2023-11-22 09:28:50 -08:00
Michael Goulet
d58ded9058
Rollup merge of #118012 - celinval:smir-alloc, r=ouz-a
Add support for global allocation in smir

Add APIs to StableMir to support global allocation. Before this change, StableMir users had no API available to retrieve Allocation provenance information. They had to resource to internal APIs instead.

One example is retrieving the Allocation of an `&str`. See test for an example on how the API can be used.
2023-11-22 09:28:49 -08:00
Eduardo Sánchez Muñoz
09358a05c3 Check that target features required by LLVM intrinsics are enabled 2023-11-22 18:26:42 +01:00
bors
6d2b84b3ed Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin
Stabilize RFC3324 dyn upcasting coercion

This PR stabilize the `trait_upcasting` feature, aka https://github.com/rust-lang/rfcs/pull/3324.

The FCP was completed here: https://github.com/rust-lang/rust/issues/65991#issuecomment-1817552398.

~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~

Heavily inspired by https://github.com/rust-lang/rust/pull/101718
Fixes https://github.com/rust-lang/rust/issues/65991
2023-11-22 16:15:34 +00:00
Celina G. Val
591b41abb8 Provide conversion of stable span to internal span
This will allow users to use rustc span messages to display user
friendly messages.
2023-11-22 07:32:56 -08:00
Celina G. Val
d5afea51dc Add CrateDef trait and methods to get def names 2023-11-22 07:32:37 -08:00
bors
73bc12199e Auto merge of #112380 - jieyouxu:useless-bindings-lint, r=WaffleLapkin
Add allow-by-default lint for unit bindings

### Example

```rust
#![warn(unit_bindings)]

macro_rules! owo {
    () => {
        let whats_this = ();
    }
}

fn main() {
    // No warning if user explicitly wrote `()` on either side.
    let expr = ();
    let () = expr;
    let _ = ();

    let _ = expr; //~ WARN binding has unit type
    let pat = expr; //~ WARN binding has unit type
    let _pat = expr; //~ WARN binding has unit type

    // No warning for let bindings with unit type in macro expansions.
    owo!();

    // No warning if user explicitly annotates the unit type on the binding.
    let pat: () = expr;
}
```

outputs

```
warning: binding has unit type `()`
  --> $DIR/unit-bindings.rs:17:5
   |
LL |     let _ = expr;
   |     ^^^^-^^^^^^^^
   |         |
   |         this pattern is inferred to be the unit type `()`
   |
note: the lint level is defined here
  --> $DIR/unit-bindings.rs:3:9
   |
LL | #![warn(unit_bindings)]
   |         ^^^^^^^^^^^^^

warning: binding has unit type `()`
  --> $DIR/unit-bindings.rs:18:5
   |
LL |     let pat = expr;
   |     ^^^^---^^^^^^^^
   |         |
   |         this pattern is inferred to be the unit type `()`

warning: binding has unit type `()`
  --> $DIR/unit-bindings.rs:19:5
   |
LL |     let _pat = expr;
   |     ^^^^----^^^^^^^^
   |         |
   |         this pattern is inferred to be the unit type `()`

warning: 3 warnings emitted
```

This lint is not triggered if any of the following conditions are met:

- The user explicitly annotates the binding with the `()` type.
- The binding is from a macro expansion.
- The user explicitly wrote `let () = init;`
- The user explicitly wrote `let pat = ();`. This is allowed for local lifetimes.

### Known Issue

It is known that this lint can trigger on some proc-macro generated code whose span returns false for `Span::from_expansion` because e.g. the proc-macro simply forwards user code spans, and otherwise don't have distinguishing syntax context compared to non-macro-generated code. For those kind of proc-macros, I believe the correct way to fix them is to instead emit identifers with span like `Span::mixed_site().located_at(user_span)`.

Closes #71432.
2023-11-22 14:03:16 +00:00
Chris Denton
b9fe367b99
x fmt library/std 2023-11-22 13:17:02 +00:00
Chris Denton
6c8ebf174c
redundant_slicing 2023-11-22 13:17:02 +00:00
Chris Denton
852c038393
cmp_null
comparing with null is better expressed by the `.is_null()` method
2023-11-22 13:17:02 +00:00
Chris Denton
c15adf6557
manual_range_contains 2023-11-22 13:17:01 +00:00
Chris Denton
d7e1f1cc08
op_ref
taken reference of right operand
2023-11-22 13:00:30 +00:00
Chris Denton
4c084c576a
manual_map
manual implementation of `Option::map`
2023-11-22 13:00:30 +00:00
Chris Denton
8c85c5b7f4
unnecessary_lazy_evaluations
unnecessary closure used with `bool::then`
2023-11-22 13:00:29 +00:00
Chris Denton
220217af13
redundant_closure 2023-11-22 13:00:29 +00:00
Chris Denton
b962ae1324
duration_subsec
calling `subsec_micros()` is more concise than this calculation
2023-11-22 13:00:29 +00:00
Chris Denton
9e42456a0d
unnecessary_cast
casting to the same type is unnecessary
2023-11-22 13:00:29 +00:00
Chris Denton
24542639aa
needless_borrow
this expression creates a reference which is immediately dereferenced by the compiler
2023-11-22 13:00:29 +00:00