Commit Graph

233422 Commits

Author SHA1 Message Date
Guillaume Gomez
e3b6122530
Rollup merge of #115633 - compiler-errors:PRIVATE_BOUNDS-lint-node, r=petrochenkov
Lint node for `PRIVATE_BOUNDS`/`PRIVATE_INTERFACES` is the item which names the private type

The HIR that the `PRIVATE_BOUNDS` lint should be attached to is the item that has the *bounds*, not the private type. This PR also aligns this behavior with the `EXPORTED_PRIVATE_DEPENDENCIES` lint, which also requires putting the `allow` on the item that names the private type.

Fixes #115475

r? petrochenkov
2023-09-08 14:10:51 +02:00
Guillaume Gomez
1fb672c738
Rollup merge of #115201 - notriddle:notriddle/type-alias-impl-list, r=GuillaumeGomez
rustdoc: list matching impls on type aliases

Fixes https://github.com/rust-lang/rust/issues/32077

Fixes #99952

Remake of https://github.com/rust-lang/rust/pull/112429

Partially reverts https://github.com/rust-lang/rust/pull/112543, but keeps the test case.

This version of the PR avoids the infinite loop by structurally matching types instead of using full unification. This version does not support type alias trait bounds, but the compiler does not enforce those anyway (https://github.com/rust-lang/rust/issues/21903).

r? `@GuillaumeGomez`

CC `@lcnr`
2023-09-08 14:10:51 +02:00
Guillaume Gomez
dcb465995d
Rollup merge of #115088 - LuuuXXX:issue-112009, r=albertlarsan68
Fix Step Skipping Caused by Using the `--exclude` Option

The original code was overreacting to the `--exclude` option,
eadf69a6c6/src/bootstrap/builder.rs (L257-L260)
For example:
When `x test --exclude alloc` or `x test --exclude library/alloc` is passed, the entire libraray test is skipped.

Related issues:
https://github.com/rust-lang/rust/issues/112009
2023-09-08 14:10:50 +02:00
Guillaume Gomez
2cceedd0ef
Rollup merge of #104299 - mkrasnitski:discriminant-transmute-docs, r=oli-obk
Clarify stability guarantee for lifetimes in enum discriminants

Since `std::mem::Discriminant` erases lifetimes, it should be clarified that changing the concrete value of a lifetime parameter does not change the value of an enum discriminant for a given variant. This is useful as it guarantees that it is safe to transmute `Discriminant<Foo<'a>>` to `Discriminant<Foo<'b>>` for any combination of `'a` and `'b`. This also holds for type-generics as long as the type parameters do not change, e.g. `Discriminant<Foo<T, 'a>>` can be transmuted to `Discriminant<Foo<T, 'b>>`.

Side note: Is what I've written actually enough to imply soundness (or rather codify it), or should it specifically be spelled out that it's OK to transmute in the above way?
2023-09-08 14:10:49 +02:00
bors
9be4eac264 Auto merge of #113492 - nebulark:pr_96475, r=petrochenkov
Add CL and CMD into to pdb debug info

Partial fix for https://github.com/rust-lang/rust/issues/96475

The Arg0 and CommandLineArgs of the MCTargetOptions cpp class are not set within bb548f9645/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp (L378)

This causes LLVM to not  neither output any compiler path (cl) nor the arguments that were used when invoking it (cmd) in the PDB file.

This fix adds the missing information to the target machine so LLVM can use it.
2023-09-08 10:06:40 +00:00
LuuuX
45abd8caf2 Fix Issue 112009
modify fuction clond() -> cloned()

optimize the code

Handle the problem that the pathset is empty and modify the judgment of the builder::tests::test_exclude_kind

Delete unnecessary judegment conditions

skip test for library/std duo to OOM in benches as library/alloc

Add FIXME for WASM32
2023-09-08 17:10:32 +08:00
bors
de4cba3a98 Auto merge of #115665 - matthiaskrgr:rollup-azdjs2r, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #115345 (MCP661: Move wasm32-wasi-preview1-threads target to Tier 2)
 - #115604 (rustdoc: Render private fields in tuple struct as `/* private fields */`)
 - #115624 (Print the path of a return-position impl trait in trait when `return_type_notation` is enabled)
 - #115629 (Don't suggest dereferencing to unsized type)
 - #115634 (Use `newtype_index` for `IntVid` and `FloatVid`.)
 - #115649 (diagnostics: add test case for trait bounds diagnostic)
 - #115655 (rustdoc: remove unused ID `mainThemeStyle`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-08 07:47:32 +00:00
Matthias Krüger
dfa662253a
Rollup merge of #115655 - notriddle:notriddle/rustdoc-fe-cleanup, r=GuillaumeGomez
rustdoc: remove unused ID `mainThemeStyle`

This was added in https://github.com/rust-lang/rust/pull/47620 and used to build the URL of the theme stylesheets. It isn't used any more, because https://github.com/rust-lang/rust/pull/101702 changed it so that the URL was supplied in a `<meta>` tag, which also provides the hashes of the files.
2023-09-08 08:23:05 +02:00
Matthias Krüger
7ec813643a
Rollup merge of #115649 - notriddle:notriddle/82038, r=compiler-errors
diagnostics: add test case for trait bounds diagnostic

Closes #82038

It was fixed by https://github.com/rust-lang/rust/pull/89580, a wide-reaching obligation tracking improvement. This commit adds a test case.
2023-09-08 08:23:04 +02:00
Matthias Krüger
1979772772
Rollup merge of #115634 - nnethercote:IntVid-FloatVid, r=oli-obk
Use `newtype_index` for `IntVid` and `FloatVid`.

`TyVid` already uses `newtype_index`.
2023-09-08 08:23:04 +02:00
Matthias Krüger
38adedc598
Rollup merge of #115629 - compiler-errors:sugg-deref-unsize, r=oli-obk
Don't suggest dereferencing to unsized type

Rudimentary check that the self type is Sized. I don't really like any of this diagnostics code -- it's really messy and also really prone to false positives and negatives, but oh well.

Fixes #115569
2023-09-08 08:23:03 +02:00
Matthias Krüger
bef5187e8b
Rollup merge of #115624 - compiler-errors:rtn-path, r=WaffleLapkin
Print the path of a return-position impl trait in trait when `return_type_notation` is enabled

When we're printing a return-position impl trait in trait, we usually just print it like an opaque. This is *usually* fine, but can be confusing when using `return_type_notation`. Print the path of the method from where the RPITIT originates when this feature gate is enabled.
2023-09-08 08:23:03 +02:00
Matthias Krüger
403a18f13d
Rollup merge of #115604 - GuillaumeGomez:private-fields-tuple-struct, r=notriddle
rustdoc: Render private fields in tuple struct as `/* private fields */`

Reopening of https://github.com/rust-lang/rust/pull/110552. All that was missing was a test for the different cases so I added it into the second commit.

Description from the original PR:

> I've gotten some feedback that the current rustdoc rendering of...
>
> ```
> struct HasPrivateFields(_);
> ```
>
> ...is confusing, and I agree with that feedback, especially compared to the field struct case:
>
> ```
> struct HasPrivateFields { /* private fields */ }
> ```
>
> So this PR makes it so that when all of the fields of a tuple variant are private, just render it with the `/* private fields */` comment. We can't *always* render it like that, for example when there's a mix of private and public fields.

cc ````@jsha````
r? ````@notriddle````
2023-09-08 08:23:02 +02:00
Matthias Krüger
6b00cfbde7
Rollup merge of #115345 - g0djan:godjan/tier2-wasi-threads, r=WaffleLapkin
MCP661: Move wasm32-wasi-preview1-threads target to Tier 2

https://github.com/rust-lang/compiler-team/issues/661

>A tier 2 target must have value to people other than its maintainers. (It may still be a niche target, but it must not be exclusively useful for an inherently closed group.)

The feature is already implemented in [wasi-sdk(](https://github.com/WebAssembly/wasi-sdk) (C toolchain for WASM), and four different WASM runtimes([Wasmtime](https://github.com/bytecodealliance/wasmtime), [WAMR](https://github.com/bytecodealliance/wasm-micro-runtime), [Wasmer](https://github.com/wasmerio/wasmer), [toywasm](https://github.com/yamt/toywasm)) are compatible with it.

>A tier 2 target must have a designated team of developers (the "target maintainers") available to consult on target-specific build-breaking issues, or if necessary to develop target-specific language or library implementation details. This team must have at least 2 developers.
>The target maintainers should not only fix target-specific issues, but should use any such issue as an opportunity to educate the Rust community about portability to their target, and enhance documentation of the target.

We already have a team of 4 developers. See [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md). The documentation is being updated in this PR as the first occurrence.

>The target must not place undue burden on Rust developers not specifically concerned with that target. Rust developers are expected to not gratuitously break a tier 2 target, but are not expected to become experts in every tier 2 target, and are not expected to provide target-specific implementations for every tier 2 target.

It doesn't as it’s built on top of existing wasm32-wasi tier-2 target and it only extends stdlib by implementing
std:: thread::spawn/join.

> The target must provide documentation for the Rust community explaining how to build for the target using cross-compilation, and explaining how to run tests for the target. If at all possible, this documentation should show how to run Rust programs and tests for the target using emulation, to allow anyone to do so. If the target cannot be feasibly emulated, the documentation should explain how to obtain and work with physical hardware, cloud systems, or equivalent.

For build and running tests see *Building Rust programs* and *Testing* in [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md). Only manual test running is supported at the moment with some tweaks in the test runner codebase.

> The target must document its baseline expectations for the features or versions of CPUs, operating systems, libraries, runtime environments, and similar.

See *Platform requirements* in [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md)

> If introducing a new tier 2 or higher target that is identical to an existing Rust target except for the baseline expectations for the features or versions of CPUs, operating systems, libraries, runtime environments, and similar, then the proposed target must document to the satisfaction of the approving teams why the specific difference in baseline expectations provides sufficient value to justify a separate target.
>Note that in some cases, based on the usage of existing targets within the Rust community, Rust developers or a target's maintainers may wish to modify the baseline expectations of a target, or split an existing target into multiple targets with different baseline expectations. A proposal to do so will be treated similarly to the analogous promotion, demotion, or removal of a target, according to this policy, with the same team approvals required.
>For instance, if an OS version has become obsolete and unsupported, a target for that OS may raise its baseline expectations for OS version (treated as though removing a target corresponding to the older versions), or a target for that OS may split out support for older OS versions into a lower-tier target (treated as though demoting a target corresponding to the older versions, and requiring justification for a new target at a lower tier for the older OS versions).

Justified in https://github.com/rust-lang/compiler-team/issues/574 and I acknowledge these requirements and intend to ensure they are met.

> Tier 2 targets must not leave any significant portions of core or the standard library unimplemented or stubbed out, unless they cannot possibly be supported on the target.
>The right approach to handling a missing feature from a target may depend on whether the target seems likely to develop the feature in the future. In some cases, a target may be co-developed along with Rust support, and Rust may gain new features on the target as that target gains the capabilities to support those features.
>As an exception, a target identical to an existing tier 1 target except for lower baseline expectations for the OS, CPU, or similar, may propose to qualify as tier 2 (but not higher) without support for std if the target will primarily be used in no_std applications, to reduce the support burden for the standard library. In this case, evaluation of the proposed target's value will take this limitation into account.

It does not, as it’s built as an extension of the existing tier 2 target (wasm32-wasi).

> The code generation backend for the target should not have deficiencies that invalidate Rust safety properties, as evaluated by the Rust compiler team. (This requirement does not apply to arbitrary security enhancements or mitigations provided by code generation backends, only to those properties needed to ensure safe Rust code cannot cause undefined behavior or other unsoundness.) If this requirement does not hold, the target must clearly and prominently document any such limitations as part of the target's entry in the target tier list, and ideally also via a failing test in the testsuite. The Rust compiler team must be satisfied with the balance between these limitations and the difficulty of implementing the necessary features.
>For example, if Rust relies on a specific code generation feature to ensure that safe code cannot overflow the stack, the code generation for the target should support that feature.
>If the Rust compiler introduces new safety properties (such as via new capabilities of a compiler backend), the Rust compiler team will determine if they consider those new safety properties a best-effort improvement for specific targets, or a required property for all Rust targets. In the latter case, the compiler team may require the maintainers of existing targets to either implement and confirm support for the property or update the target tier list with documentation of the missing property.

Doesn't apply, the target re-uses existing backend and doesn't extend it

> If the target supports C code, and the target has an interoperable calling convention for C code, the Rust target must support that C calling convention for the platform via extern "C". The C calling convention does not need to be the default Rust calling convention for the target, however.

Target does not support C code
>The target must build reliably in CI, for all components that Rust's CI considers mandatory.

The target reliably builds in CI already https://github.com/rust-lang/rust/blob/master/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L143.

>The approving teams may additionally require that a subset of tests pass in CI, such as enough to build a functional "hello world" program, ./x.py test --no-run, or equivalent "smoke tests". In particular, this requirement may apply if the target builds host tools, or if the tests in question provide substantial value via early detection of critical problems.

The existing tier-2 target and this target as its extension [pass](https://github.com/rust-lang/rust/pull/112922#issuecomment-1634514924) for 14.5k+ tests/ui when tests are run manually(described in *Testing* in in [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md). Can be tested in the CI as soon as the original target does.

> Building the target in CI must not take substantially longer than the current slowest target in CI, and should not substantially raise the maintenance burden of the CI infrastructure. This requirement is subjective, to be evaluated by the infrastructure team, and will take the community importance of the target into account.

It doesn’t as it only slightly extends standard library of the existing target

> Tier 2 targets should, if at all possible, support cross-compiling. Tier 2 targets should not require using the target as the host for builds, even if the target supports host tools.

N/a given as it only extends stdlib of the existing target.

> In addition to the legal requirements for all targets (specified in the tier 3 requirements), because a tier 2 target typically involves the Rust project building and supplying various compiled binaries, incorporating the target and redistributing any resulting compiled binaries (e.g. built libraries, host tools if any) must not impose any onerous license requirements on any members of the Rust project, including infrastructure team members and those operating CI systems. This is a subjective requirement, to be evaluated by the approving teams.
>As an exception to this, if the target's primary purpose is to build components for a Free and Open Source Software (FOSS) project licensed under "copyleft" terms (terms which require licensing other code under compatible FOSS terms), such as kernel modules or plugins, then the standard libraries for the target may potentially be subject to copyleft terms, as long as such terms are satisfied by Rust's existing practices of providing full corresponding source code. Note that anything added to the Rust repository itself must still use Rust's standard license terms.

Requirement are met, no legal issues.

> Tier 2 targets must not impose burden on the authors of pull requests, or other developers in the community, to ensure that tests pass for the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on tests failing for the target. Do not send automated messages or notifications (via any medium, including via `````@)````` to a PR author or others involved with a PR regarding the PR breaking tests on a tier 2 target, unless they have opted into such messages.
>Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

I acknowledge these requirements and intend to ensure they are met.
> The target maintainers should regularly run the testsuite for the target, and should fix any test failures in a reasonably timely fashion.

The tests are run manually every week by `````@g0djan````` now.
While target has been in Tier 3, 2 issues(https://github.com/rust-lang/rust/issues/114608 and https://github.com/rust-lang/rust/issues/114610) have been raised. Both issues were addressed the same day and fixes has been merged by now.

> All requirements for tier 3 apply.

Target was initially accepted as a Tier 3 target in https://github.com/rust-lang/rust/pull/112922 .
2023-09-08 08:23:02 +02:00
bors
3d249706aa Auto merge of #115608 - RalfJung:fn-arg-validity, r=oli-obk
miri: catch function calls where the argument is caller-invalid / the return value callee-invalid

When doing a type-changing copy, we must validate the data both at the old and new type.

Fixes https://github.com/rust-lang/miri/issues/3017
2023-09-08 04:10:14 +00:00
bors
69ec43001a Auto merge of #115586 - Zalathar:query, r=cjgillot
coverage: Simplify the `coverageinfo` query

The `coverageinfo` query walks through a `mir::Body`'s statements to find the total number of coverage counter IDs and coverage expression IDs that have been used, as this information is needed by coverage codegen.

This PR makes 3 nice simplifications to that query:
- Extract a common iterator over coverage statements, shared by both coverage-related queries
- Simplify the query's visitor from two passes to just one pass
- Explicitly track the highest seen IDs in the visitor, and only convert to a count right at the end

I also updated some related comments. Some had been invalidated by these changes, while others had already been invalidated by previous coverage changes.
2023-09-08 02:24:55 +00:00
bors
feb06732c0 Auto merge of #114299 - clarfonthey:char-min, r=dtolnay,BurntSushi
Add char::MIN

ACP: rust-lang/libs-team#252
Tracking issue: #114298

r? `@rust-lang/libs-api`
2023-09-08 00:02:48 +00:00
Florian Schmiderer
4cdc633301 Add missing Debuginfo to PDB debug file on windows.
Set Arg0 and CommandLineArgs in MCTargetoptions so LLVM outputs correct CL and CMD in LF_DEBUGINFO instead of empty/invalid values.
2023-09-08 00:28:40 +02:00
Michael Howell
00b7d70710 rustdoc: remove unused ID mainThemeStyle
This was added in 003b2bc1c6 and used to build
the URL of the theme stylesheets. It isn't used any more, because
f9e1f6ffdf changed it so that the URL was
supplied in a `<meta>` tag, which also provides the hashes of the files.
2023-09-07 13:55:27 -07:00
bors
1e746d7741 Auto merge of #115527 - oli-obk:drop_maybe_uninit_in_const, r=lcnr
Don't require `Drop` for `[PhantomData<T>; N]` where `N` and `T` are generic, if `T` requires `Drop`

fixes https://github.com/rust-lang/rust/issues/115403
fixes https://github.com/rust-lang/rust/issues/115410

This was accidentally regressed in https://github.com/rust-lang/rust/pull/114134, because it was accidentally stabilized in #102204 (cc `@rust-lang/lang,` seems like an innocent stabilization, considering this PR is more of a bugfix than a feature).

While we have a whole month to beta backport this change before the regression hits stable, I'd still prefer not to go through an FCP on this PR (which fixes a regression), if T-lang wants an FCP, I can can open an issue about the change itself.
2023-09-07 19:10:07 +00:00
Michael Howell
31e5dd3a79 diagnostics: add test case for trait bounds diagnostic
Closes #82038

It was fixed by b8e5ab20ed, a wide-reaching
obligation tracking improvement. This commit adds a test case.
2023-09-07 11:36:23 -07:00
Oli Scherer
320bb8116f Don't require Drop for [PhantomData<T>; N] where N and T are generic, if T requires Drop 2023-09-07 18:31:17 +00:00
bors
70c7e4d21c Auto merge of #114855 - Urgau:rustdoc-typedef-inner-variants, r=GuillaumeGomez
rustdoc: show inner enum and struct in type definition for concrete type

This PR implements the [Display enum variants for generic enum in type def page](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Display.20enum.20variants.20for.20generic.20enum.20in.20type.20def.20page) #rustdoc/zulip proposal.

This proposal comes from looking at [`TyKind`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/sty/type.TyKind.html) typedef from the compiler. On that page, the documentation is able to show the layout for each variant, but not the variants themselves. This proposal suggests showing the fields and variants for those "concrete type". This would mean that instead of having many unresolved generics, like in `IrTyKind`:
```rust
    Array(I::Ty, I::Const),
    Slice(I::Ty),
    RawPtr(I::TypeAndMut),
    Ref(I::Region, I::Ty, I::Mutability),
    FnDef(I::DefId, I::GenericArgsRef),
```
those would be resolved with direct links to the proper types in the `TyKind` typedef page:
```rust
    Array(Ty<'tcx>, Const<'tcx>),
    Slice(Ty<'tcx>),
    RawPtr(TypeAndMut<'tcx>),
    Ref(Region<'tcx>, Ty<'tcx>, Mutability<'tcx>),
    FnDef(DefId<'tcx>, GenericArgsRef<'tcx>),
```
Saving both time and confusion.

-----

<details>

<summary>Old description</summary>

I've chosen to add the enums and structs under the "Show Aliased Type" details, as well as showing the variants and fields under the usual "Variants" and "Fields" sections. ~~*under new the `Inner Variants` and `Inner Fields` sections (except for their names, they are identical to the one found in the enum, struct and union pages). Those sections are complementary and do not replace anything else.*~~

This PR proposes the following condition for showing the aliased type (basically, has the aliased type some generics that are all of them resolved):
 - the typedef does NOT have any generics (modulo lifetimes)
 - AND the aliased type has some generics

</details>

### Examples

```rust
pub enum IrTyKind<'a, I: Interner> {
    /// Doc comment for AdtKind
    AdtKind(&'a I::Adt),
    /// and another one for TyKind
    TyKind(I::Adt, I::Ty),
    // no comment
    StructKind { a: I::Adt, },
}

pub type TyKind<'a> = IrTyKind<'a, TyCtxt>;
```
![TyKind](https://github.com/rust-lang/rust/assets/3616612/13307679-6d48-40d6-ad50-6db0b7f36ac7)

<details>
<summary>Old</summary>

![image](https://github.com/rust-lang/rust/assets/3616612/4147c049-d056-42d4-8a01-d43ebe747308)

![TyKind](https://user-images.githubusercontent.com/3616612/260988247-34831aa9-470d-4286-ad9f-3e8002153a92.png)

![TyKind](https://github.com/rust-lang/rust/assets/3616612/62381bb3-fa0f-4b05-926d-77759cf9115a)

</details>

```rust
pub struct One<T> {
    pub val: T,
    #[doc(hidden)]
    pub inner_tag: u64,
    __hidden: T,
}

/// `One` with `u64` as payload
pub type OneU64 = One<u64>;
```
![OneU64](https://github.com/rust-lang/rust/assets/3616612/d551b474-ce88-4f8c-bc94-5c88aba51424)

<details>
<summary>Old</summary>

![image](https://github.com/rust-lang/rust/assets/3616612/1a3f53c0-17bf-4aa7-894d-3fedc15b33da)

![OneU64](https://github.com/rust-lang/rust/assets/3616612/7b124a5b-e287-4efb-b9ca-fdcd1cdeeba8)

![OneU64](https://github.com/rust-lang/rust/assets/3616612/ddd962be-4f76-4ecd-81bd-531f3dd23832)

</details>

r? `@GuillaumeGomez`
2023-09-07 16:23:03 +00:00
bors
f06b7c59a3 Auto merge of #114183 - Urgau:stabilize-print-with-path, r=oli-obk
Stabilize `PATH` option for `--print KIND=PATH`

This PR propose stabilizing the `PATH` option for `--print KIND=PATH`. This option was previously added in https://github.com/rust-lang/rust/pull/113780 (as insta-stable before being un-stablized in https://github.com/rust-lang/rust/pull/114139).

Description of the `PATH` option:
> A filepath may optionally be specified for each requested information kind, in the format `--print KIND=PATH`, just like for `--emit`. When a path is specified, information will be written there instead of to stdout.

------

Description of the original PR [\[link\]](https://github.com/rust-lang/rust/pull/113780#issue-1807080607):
> **Support --print KIND=PATH command line syntax**
>
> As is already done for `--emit KIND=PATH` and `-L KIND=PATH`.
>
> In the discussion of https://github.com/rust-lang/rust/pull/110785, it was pointed out that `--print KIND=PATH` is nicer than trying to apply the single global `-o path` to `--print`'s output, because in general there can be multiple print requests within a single rustc invocation, and anyway `-o` would already be used for a different meaning in the case of `link-args` and `native-static-libs`.
>
> I am interested in using `--print cfg=PATH` in Buck2. Currently Buck2 works around the lack of support for `--print KIND=PATH` by [indirecting through a Python wrapper script](d43cf3a51a/prelude/rust/tools/get_rustc_cfg.py) to redirect rustc's stdout into the location dictated by the build system.
>
> From skimming Cargo's usages of `--print`, it definitely seems like it would benefit from `--print KIND=PATH` too. Currently it is working around the lack of this by inserting `--crate-name=___ --print=crate-name` so that it can look for a line containing `___` as a delimiter between the 2 other `--print` informations it actually cares about. This is commented as a "HACK" and "abuse". 31eda6f7c3/src/cargo/core/compiler/build_context/target_info.rs (L242)

-----

cc `@dtolnay`
r? `@jackh726`
2023-09-07 14:24:46 +00:00
Urgau
caf6ce5ea2 Stabilize PATH option for --print KIND=PATH
Description of the `PATH` option:
> A filepath may optionally be specified for each requested information
> kind, in the format `--print KIND=PATH`, just like for `--emit`. When
> a path is specified, information will be written there instead of to
> stdout.
2023-09-07 15:07:30 +02:00
bors
c5775a776f Auto merge of #115602 - oli-obk:lower_intrinsics, r=petrochenkov
Don't report any errors in `lower_intrinsics`.

Intrinsics should have been type checked earlier.

This is part of moving all mir-opt diagnostics early enough so that they are reliably emitted even in check builds: https://github.com/rust-lang/rust/issues/49292#issuecomment-1692212095
2023-09-07 11:02:54 +00:00
Zalathar
e54204c8e9 coverage: In the visitor, track max counter/expression IDs without +1
This makes the visitor track the highest seen counter/expression IDs directly,
and only add +1 (to convert to a vector length) at the very end.
2023-09-07 18:06:13 +10:00
Zalathar
f191b1c2fc coverage: Simplify the coverageinfo query to a single pass 2023-09-07 18:06:13 +10:00
Zalathar
3f549466a8 coverage: Extract a common iterator over a function's coverage statements
Both of the coverage queries can now use this one helper function to iterate
over all of the `mir::Coverage` payloads in the statements of a `mir::Body`.
2023-09-07 18:06:13 +10:00
Nicholas Nethercote
a932990ed4 Use newtype_index for IntVid and FloatVid.
`TyVid` already uses `newtype_index`.
2023-09-07 17:31:35 +10:00
bors
7f0fa485a6 Auto merge of #115582 - compiler-errors:refine-yeet, r=oli-obk
Implement refinement lint for RPITIT

Implements a lint that warns against accidentally refining an RPITIT in an implementation. This is not a hard error, and can be suppressed with `#[allow(refining_impl_trait)]`, since this behavior may be desirable -- the lint just serves as an acknowledgement from the impl author that they understand that the types they write in the implementation are an API guarantee.

This compares bounds syntactically, not semantically -- semantic implication is more difficult and essentially relies on adding the ability to keep the RPITIT hidden in the trait system so that things can be proven about the type that shows up in the impl without its own bounds leaking through, either via a new reveal mode or something else. This was experimentally implemented in #111931.

Somewhat opinionated choices:
1. Putting the lint behind `refining_impl_trait` rather than a blanket `refine` lint. This could be changed, but I like keeping the lint specialized to RPITITs so the explanation can be tailored to it.
2. This PR does not include the `#[refine]` attribute or the feature gate, since it's kind of orthogonal and can be added in a separate PR.

r? `@oli-obk`
2023-09-07 07:26:26 +00:00
Michael Goulet
3bf3dadbc0 Ensure that dyn trait bounds stay sorted 2023-09-07 06:57:08 +00:00
Michael Goulet
14e59bb317 Lint node for PRIVATE_BOUNDS is the item which has the bounds 2023-09-07 06:48:24 +00:00
bors
d5573d708d Auto merge of #115617 - coastalwhite:bump-stdarch-riscv-intrinsics, r=Amanieu
Bump: Include RISC-V intrinsics for stdarch

This bumps the version of the `stdarch` submodule to the current master. Notably, it now includes intrinsics for the RISC-V Scalar Cryptographic and Bit Manipulation extensions.

r? `@Amanieu`
2023-09-07 05:39:22 +00:00
Michael Goulet
67e7d85ad2 Rename folder typo 2023-09-07 04:52:26 +00:00
Michael Goulet
ee9727e263 Don't suggest dereferencing to unsized type 2023-09-07 04:52:00 +00:00
bors
fece303aeb Auto merge of #115616 - bjorn3:sync_cg_clif-2023-09-06, r=bjorn3
Sync rustc_codegen_cranelift

Not much changed this time. Mostly doing this sync to make it easier to run the entire test suite on the in-tree version.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-09-07 03:56:43 +00:00
bors
f00c139998 Auto merge of #110050 - saethlin:better-u32-encoding, r=nnethercote
Use a specialized varint + bitpacking scheme for DepGraph encoding

The previous scheme here uses leb128 to encode the edge tables that represent the incr comp dependency graph. The problem with that scheme is that leb128 has overhead for larger values, and generally relies on the distribution of encoded values being heavily skewed towards smaller values. That is definitely not the case for a dep node index, since they are handed out sequentially and the whole range is covered, the distribution is actually biased in the opposite direction: Most dep nodes are large.

This PR implements a different varint encoding scheme. Instead of applying varint encoding to individual dep node indices (which is extremely branchy) we now apply it per node.

While being built, each node now stores its edges in a `SmallVec` with a bit of extra logic to track the max value of each edge. Then we varint encode the whole batch. This is a gamble: We save on space by only claiming 2 bits per node instead of ~3 bits per edge which is a nice savings but needs to balance out with the space overhead that a single large index in a node with a lot of edges will encode unnecessary bytes in each of that node's edge indices.

Then, to keep the runtime overhead of this encoding scheme down we deserialize our indices by loading 4 bytes for each then masking off the bytes that are't ours. This is much less code and branches than leb128, but relies on having some readable bytes past the end of each edge list. We explicitly add such padding to the in-memory data during decoding. And we also do this decoding lazily, turning a dense on-disk encoding into a peak memory reduction.

Then we apply a bit-packing scheme; since in https://github.com/rust-lang/rust/pull/115391 we now have unused bits on `DepKind`, we use those unused bits (currently there are 7!) to store the 2 bits that we need for the byte width of the edges in each node, then use the remaining bits to store the length of the edge list, if it fits.

r? `@nnethercote`
2023-09-07 02:09:41 +00:00
Michael Goulet
748476d94d Print the path of an RPITIT in RTN 2023-09-07 02:08:51 +00:00
Michael Goulet
7714db873e Add note 2023-09-07 01:31:33 +00:00
Michael Goulet
4d05da46e7 Don't emit refining_impl_trait for private items 2023-09-07 01:31:32 +00:00
Ben Kimock
469dc8f0fa Add comments with the same level of detail as the PR description 2023-09-06 21:15:03 -04:00
Michael Goulet
4745d34bc3 Use self instead of the actual self ty 2023-09-07 00:49:09 +00:00
Michael Goulet
e10262ca0a Implement refinement lint for RPITIT 2023-09-07 00:49:09 +00:00
bors
4e5b31c2b0 Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-usage, r=est31
Lint on invalid usage of `UnsafeCell::raw_get` in reference casting

This PR proposes to take into account `UnsafeCell::raw_get` method call for non-Freeze types for the `invalid_reference_casting` lint.

The goal of this is to catch those kind of invalid reference casting:
```rust
fn as_mut<T>(x: &T) -> &mut T {
    unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
    //~^ ERROR casting `&T` to `&mut T` is undefined behavior
}
```

r? `@est31`
2023-09-07 00:24:45 +00:00
bors
b0d45536ac Auto merge of #115580 - eduardosm:stdarch-intrinsics, r=davidtwco,bjorn3
Update stdarch submodule and remove special handling in cranelift codegen for some AVX and SSE2 LLVM intrinsics

https://github.com/rust-lang/stdarch/pull/1463 reimplemented some x86 intrinsics to avoid using some x86-specific LLVM intrinsics:

* Store unaligned (`_mm*_storeu_*`) use `<*mut _>::write_unaligned` instead of `llvm.x86.*.storeu.*`.
* Shift by immediate (`_mm*_s{ll,rl,ra}i_epi*`) use `if` (srl, sll) or `min` (sra) to simulate the behaviour when the RHS is out of range. RHS is constant, so the `if`/`min` will be optimized away.

This PR updates the stdarch submodule to pull these changes and removes special handling for those LLVM intrinsics from cranelift codegen. I left gcc codegen untouched because there are some autogenerated lists.
2023-09-06 22:26:37 +00:00
bors
e3abbd4994 Auto merge of #114946 - anforowicz:generic-fix-for-asan-lto, r=tmiasko
Preserve ASAN-related symbols during LTO.

Fixes https://github.com/rust-lang/rust/issues/113404
2023-09-06 20:04:03 +00:00
Gijs Burghoorn
2b02142eab Bump: Include RISC-V intrinsics for stdarch 2023-09-06 20:53:54 +02:00
bjorn3
521ed6e308 Merge commit 'dda103b1e33c4902deca8bccf614991ada781fa6' into sync_cg_clif-2023-09-06 2023-09-06 18:51:03 +00:00
bjorn3
dda103b1e3 Rustup to rustc 1.74.0-nightly (a991861ec 2023-09-05) 2023-09-06 18:33:08 +00:00