Commit Graph

244330 Commits

Author SHA1 Message Date
bors
0e4243538b Auto merge of #116152 - cjgillot:unchunck, r=nnethercote
Only use dense bitsets in dataflow analyses

When a dataflow state has the size close to the number of locals, we should prefer a dense bitset, like we already store locals in a dense vector.
Other occurrences of `ChunkedBitSet` need to be justified by the size of the dataflow state.
2024-01-23 11:56:30 +00:00
Nikita Popov
f4f589a028 Remove support for no-system-llvm
Also add tests for min-system-llvm-version.
2024-01-23 11:19:51 +01:00
Nikita Popov
31f5f033e9 Remove uses of no-system-llvm
It looks like none of these are actually needed.
2024-01-23 10:31:07 +01:00
bors
8b94152af6 Auto merge of #117958 - risc0:erik/target-triple, r=davidtwco,Mark-Simulacrum
riscv32im-risc0-zkvm-elf: add target

This pull request adds RISC Zero's Zero Knowledge Virtual Machine (zkVM) as a target for rust. The zkVM used to produce proofs of execution of RISC-V ELF binaries. In order to do this, the target will execute the ELF to generate a receipt containing the output of the computation along with a cryptographic seal. This receipt can be verified to ensure the integrity of the computation and its result. This target is implemented as software only; it has no hardware implementation.

## Tier 3 target policy:

Here is a copy of the tier 3 target policy:

> Tier 3 target policy:
>
> At this tier, the Rust project provides no official support for a target, so we
> place minimal requirements on the introduction of targets.
>
> A proposed new tier 3 target must be reviewed and approved by a member of the
> compiler team based on these requirements. The reviewer may choose to gauge
> broader compiler team consensus via a [[Major Change Proposal (MCP)](https://forge.rust-lang.org/compiler/mcp.html)](https://forge.rust-lang.org/compiler/mcp.html).
>
> A proposed target or target-specific patch that substantially changes code
> shared with other targets (not just target-specific code) must be reviewed and
> approved by the appropriate team for that shared code before acceptance.
>
> - A tier 3 target must have a designated developer or developers (the "target
> maintainers") on record to be CCed when issues arise regarding the target.
> (The mechanism to track and CC such developers may evolve over time.)

The maintainers are named in the target description file

> - Targets must use naming consistent with any existing targets; for instance, a
> target for the same CPU or OS as an existing Rust target should use the same
> name for that CPU or OS. Targets should normally use the same names and
> naming conventions as used elsewhere in the broader ecosystem beyond Rust
> (such as in other toolchains), unless they have a very good reason to
> diverge. Changing the name of a target can be highly disruptive, especially
> once the target reaches a higher tier, so getting the name right is important
> even for a tier 3 target.
> - Target names should not introduce undue confusion or ambiguity unless
> absolutely necessary to maintain ecosystem compatibility. For example, if
> the name of the target makes people extremely likely to form incorrect
> beliefs about what it targets, the name should be changed or augmented to
> disambiguate it.
> - If possible, use only letters, numbers, dashes and underscores for the name.
> Periods (`.`) are known to cause issues in Cargo.
>

We understand.

> - Tier 3 targets may have unusual requirements to build or use, but must not
> create legal issues or impose onerous legal terms for the Rust project or for
> Rust developers or users.
>     - The target must not introduce license incompatibilities.

We understand and will not introduce incompatibilities. All of our code that we publish is licensed under Apache-2.0.

> - Anything added to the Rust repository must be under the standard Rust license (`MIT OR Apache-2.0`).

We understand. We are open to either license for the Rust repository.

> - The target must not cause the Rust tools or libraries built for any other
> host (even when supporting cross-compilation to the target) to depend
> on any new dependency less permissive than the Rust licensing policy. This
> applies whether the dependency is a Rust crate that would require adding
> new license exceptions (as specified by the `tidy` tool in the
> rust-lang/rust repository), or whether the dependency is a native library
> or binary. In other words, the introduction of the target must not cause a
> user installing or running a version of Rust or the Rust tools to be
> subject to any new license requirements.

We understand. The runtime libraries and the execution environment and software associated with this environment uses `Apache-2.0` so this should not be an issue.

> - Compiling, linking, and emitting functional binaries, libraries, or other
> code for the target (whether hosted on the target itself or cross-compiling
> from another target) must not depend on proprietary (non-FOSS) libraries.
> Host tools built for the target itself may depend on the ordinary runtime
> libraries supplied by the platform and commonly used by other applications
> built for the target, but those libraries must not be required for code
> generation for the target; cross-compilation to the target must not require
> such libraries at all. For instance, `rustc` built for the target may
> depend on a common proprietary C runtime library or console output library,
> but must not depend on a proprietary code generation library or code
> optimization library. Rust's license permits such combinations, but the
> Rust project has no interest in maintaining such combinations within the
> scope of Rust itself, even at tier 3.

We understand. We only depend on FOSS libraries. Dependencies such as runtime libraries for this target are licensed as `Apache-2.0`.

> - "onerous" here is an intentionally subjective term. At a minimum, "onerous"
> legal/licensing terms include but are *not* limited to: non-disclosure
> requirements, non-compete requirements, contributor license agreements
> (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms,
> requirements conditional on the employer or employment of any particular
> Rust developers, revocable terms, any requirements that create liability
> for the Rust project or its developers or users, or any requirements that
> adversely affect the livelihood or prospects of the Rust project or its
> developers or users.

There are no such terms present

> - Neither this policy nor any decisions made regarding targets shall create any
> binding agreement or estoppel by any party. If any member of an approving
> Rust team serves as one of the maintainers of a target, or has any legal or
> employment requirement (explicit or implicit) that might affect their
> decisions regarding a target, they must recuse themselves from any approval
> decisions regarding the target's tier status, though they may otherwise
> participate in discussions.

I am not the reviewer of this pull request

> - This requirement does not prevent part or all of this policy from being
> cited in an explicit contract or work agreement (e.g. to implement or
> maintain support for a target). This requirement exists to ensure that a
> developer or team responsible for reviewing and approving a target does not
> face any legal threats or obligations that would prevent them from freely
> exercising their judgment in such approval, even if such judgment involves
> subjective matters or goes beyond the letter of these requirements.

We understand.

> - Tier 3 targets should attempt to implement as much of the standard libraries
> as possible and appropriate (`core` for most targets, `alloc` for targets
> that can support dynamic memory allocation, `std` for targets with an
> operating system or equivalent layer of system-provided functionality), but
> may leave some code unimplemented (either unavailable or stubbed out as
> appropriate), whether because the target makes it impossible to implement or
> challenging to implement. The authors of pull requests are not obligated to
> avoid calling any portions of the standard library on the basis of a tier 3
> target not implementing those portions.

The target implements core and alloc. And std support is currently experimental as some functionalities in std are either a) not applicable to our target or b) more work in research and experimentation needs to be done. For more information about the characteristics of this target, please refer to the target description file.

> - The target must provide documentation for the Rust community explaining how
> to build for the target, using cross-compilation if possible. If the target
> supports running binaries, or running tests (even if they do not pass), the
> documentation must explain how to run such binaries or tests for the target,
> using emulation if possible or dedicated hardware if necessary.

See file target description file

> - Tier 3 targets must not impose burden on the authors of pull requests, or
> other developers in the community, to maintain 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 a tier 3 target. Do not send automated messages or
> notifications (via any medium, including via ``@`)` to a PR author or others
> involved with a PR regarding a tier 3 target, unless they have opted into
> such messages.

We understand.

> - 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.

We understand.

> - Patches adding or updating tier 3 targets must not break any existing tier 2
> or tier 1 target, and must not knowingly break another tier 3 target without
> approval of either the compiler team or the maintainers of the other tier 3
> target.
>     - In particular, this may come up when working on closely related targets,
>     such as variations of the same architecture with different features. Avoid
>     introducing unconditional uses of features that another variation of the
>     target may not have; use conditional compilation or runtime detection, as
>     appropriate, to let each target run code supported by that target.

We understand.

> If a tier 3 target stops meeting these requirements, or the target maintainers
> no longer have interest or time, or the target shows no signs of activity and
> has not built for some time, or removing the target would improve the quality
> of the Rust codebase, we may post a PR to remove it; any such PR will be CCed
> to the target maintainers (and potentially other people who have previously
> worked on the target), to check potential interest in improving the situation.

We understand.
2024-01-23 09:30:36 +00:00
Nikita Popov
823e8b041a Allow disjoint flag in codegen test 2024-01-23 10:12:36 +01:00
bors
e35a56d96f Auto merge of #119892 - joboet:libs_use_assert_unchecked, r=Nilstrieb,cuviper
Use `assert_unchecked` instead of `assume` intrinsic in the standard library

Now that a public wrapper for the `assume` intrinsic exists, we can use it in the standard library.

CC #119131
2024-01-23 06:45:58 +00:00
Esteban Küber
34f4f3da4f Suggest boxing both arms of if expr if that solves divergent arms involving impl Trait
When encountering the following

```rust
// run-rustfix
trait Trait {}
struct Struct;
impl Trait for Struct {}
fn foo() -> Box<dyn Trait> {
    Box::new(Struct)
}
fn bar() -> impl Trait {
    Struct
}
fn main() {
    let _ = if true {
        Struct
    } else {
        foo() //~ ERROR E0308
    };
    let _ = if true {
        foo()
    } else {
        Struct //~ ERROR E0308
    };
    let _ = if true {
        Struct
    } else {
        bar() // impl Trait
    };
    let _ = if true {
        bar() // impl Trait
    } else {
        Struct
    };
}
```

suggest boxing both arms

```rust
    let _ = if true {
        Box::new(Struct) as Box<dyn Trait>
    } else {
        Box::new(bar())
    };
    let _ = if true {
        Box::new(bar()) as Box<dyn Trait>
    } else {
        Box::new(Struct)
    };
```
2024-01-23 04:42:26 +00:00
HTGAzureX1212.
f3682a1304
add list of characters to uncommon codepoints lint 2024-01-23 10:56:33 +08:00
bors
0011fac90d Auto merge of #120017 - nnethercote:lint-api, r=oli-obk
Fix naming in the lint API

Methods for emit lints are named very inconsistently. This PR fixes that up.

r? `@compiler-errors`
2024-01-23 00:06:57 +00:00
Camille GILLOT
afaac75ac7 Do not thread through Assert terminator. 2024-01-23 00:00:24 +00:00
Camille GILLOT
d7a7be4049 Add test for jump-threading assume. 2024-01-23 00:00:22 +00:00
Camille GILLOT
161c674ef0 Add Assume custom MIR. 2024-01-22 23:55:10 +00:00
Camille GILLOT
e07ffe97b8 Use a plain bitset for liveness analyses. 2024-01-22 23:18:45 +00:00
Camille GILLOT
7e64de431e Remove uses of HybridBitSet. 2024-01-22 22:53:20 +00:00
bors
d6b151fc77 Auto merge of #120251 - matthiaskrgr:rollup-gttrw68, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #119664 (Fix tty detection for msys2's `/dev/ptmx`)
 - #120104 (never_patterns: Count `!` bindings as diverging)
 - #120109 (Move cmath into `sys`)
 - #120143 (Consolidate logic around resolving built-in coroutine trait impls)
 - #120159 (Track `verbose` and `verbose_internals`)
 - #120216 (Fix a `trimmed_def_paths` assertion failure.)
 - #120220 (Document `Token{Stream,Tree}::Display` more thoroughly.)
 - #120233 (Revert stabilization of trait_upcasting feature)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-22 22:04:50 +00:00
lcnr
c6088f7dd1 RawTy to LoweredTy 2024-01-22 22:20:55 +01:00
David Carlier
ed4b99a99c fixing build for the BSD 2024-01-22 21:17:46 +00:00
Matthias Krüger
a787232abb
Rollup merge of #120233 - oli-obk:revert_trait_obj_upcast_stabilization, r=lcnr
Revert stabilization of trait_upcasting feature

Reverts #118133

This reverts commit 6d2b84b3ed, reversing changes made to 73bc12199e.

The feature has a soundness bug:

* #120222

It is unclear to me whether we'll actually want to destabilize, but I thought it was still prudent to open the PR for easy destabilization once we get there.
2024-01-22 22:12:10 +01:00
Matthias Krüger
a4307184be
Rollup merge of #120220 - nnethercote:TokenStream-Display-docs, r=petrochenkov
Document `Token{Stream,Tree}::Display` more thoroughly.

To expressly warn against the kind of proc macro implementation that was broken in #119875.

r? ``@petrochenkov``
2024-01-22 22:12:10 +01:00
Matthias Krüger
31b56a8a35
Rollup merge of #120216 - nnethercote:fix-trimmed_def_paths-assertion, r=compiler-errors
Fix a `trimmed_def_paths` assertion failure.

`RegionHighlightMode::force_print_trimmed_def_path` can call `trimmed_def_paths` even when `tcx.sess.opts.trimmed_def_paths` is false. Based on the `force` in the method name, it seems this is deliberate, so I have removed the assertion.

Fixes #120035.

r? `@compiler-errors`
2024-01-22 22:12:09 +01:00
Matthias Krüger
8966d60650
Rollup merge of #120159 - jyn514:track-verbose, r=wesleywiser
Track `verbose` and `verbose_internals`

`verbose_internals` has been UNTRACKED since it was introduced. When i added `verbose` in https://github.com/rust-lang/rust/pull/119129 i made it UNTRACKED as well.

``@bjorn3`` says: https://github.com/rust-lang/rust/pull/119286#discussion_r1436134354
> On errors we don't finalize the incr comp cache, but non-fatal diagnostics are cached afaik.
Otherwise we would have to replay the query in question, which we may not be able to do if the query key is not reconstructible from the dep node fingerprint.

So we must track these flags to avoid replaying incorrect diagnostics.

r? incremental
2024-01-22 22:12:09 +01:00
Matthias Krüger
221115cbd6
Rollup merge of #120143 - compiler-errors:consolidate-instance-resolve-for-coroutines, r=oli-obk
Consolidate logic around resolving built-in coroutine trait impls

Deduplicates a lot of code. Requires defining a new lang item for `Coroutine::resume` for consistency, but it seems not harmful at worst, and potentially later useful at best.

r? oli-obk
2024-01-22 22:12:08 +01:00
Matthias Krüger
42e1db52ac
Rollup merge of #120109 - joboet:move_pal_cmath, r=ChrisDenton
Move cmath into `sys`

Part of #117276.

r? ``@ChrisDenton``
2024-01-22 22:12:08 +01:00
Matthias Krüger
042cc7269c
Rollup merge of #120104 - Nadrieril:never-pat-diverges, r=compiler-errors
never_patterns: Count `!` bindings as diverging

A binding that is a never pattern is not reachable, hence counts as diverging code. This allows in particular `fn foo(!: Void) -> SomeType {}` to typecheck.

r? ``@compiler-errors``
2024-01-22 22:12:07 +01:00
Matthias Krüger
67d093682c
Rollup merge of #119664 - ChrisDenton:mingw-pty, r=thomcc
Fix tty detection for msys2's `/dev/ptmx`

Our "true negative" detection assumes that if at least one std handle is a Windows console then no other handle will be a msys2 tty pipe. This turns out to be a faulty assumption in the case of redirection to  `/dev/ptmx` in an msys2 shell. Maybe this is an msys2 bug but in any case we should try to make it work.

An alternative to this would be to replace the "true negative" detection with an attempt to detect if we're in an msys environment (e.g. by sniffing environment variables) but that seems like it'd be flaky too.

Fixes #119658
2024-01-22 22:12:06 +01:00
Nicholas Nethercote
15a4c4fc6f Rename struct_lint_level as lint_level. 2024-01-23 08:09:08 +11:00
Nicholas Nethercote
e164cf30f8 Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
Nicholas Nethercote
82ca070c16 Rename TyCtxt::emit_lint as TyCtxt::emit_node_lint. 2024-01-23 08:09:03 +11:00
Nicholas Nethercote
cfdea760f5 Rename TyCtxt::struct_span_lint_hir as TyCtxt::node_span_lint. 2024-01-23 08:09:01 +11:00
Nicholas Nethercote
681b9aa363 Rename TyCtxt::struct_lint_node as TyCtxt::node_lint. 2024-01-23 08:08:32 +11:00
Nicholas Nethercote
36e6514606 Rename LintLevelsBuilder::emit_spanned_lint as LintLevelsBuilder::emit_span_lint. 2024-01-23 08:08:29 +11:00
Nicholas Nethercote
749afe2050 Rename LintLevelsBuilder::struct_lint as LintLevelsBuilder::opt_span_lint. 2024-01-23 08:08:27 +11:00
Nicholas Nethercote
1881bfaa2b Rename LintContext::emit_spanned_lint as LintContext::emit_span_lint. 2024-01-23 08:08:25 +11:00
Nicholas Nethercote
c915e90f7e Rename LintContext::lookup_with_diagnostics as LintContext::span_lint_with_diagnostics. 2024-01-23 07:59:45 +11:00
Nicholas Nethercote
2de5242ea6 Rename LintContext::lookup as LintContext::opt_span_lint. 2024-01-23 07:59:45 +11:00
Nicholas Nethercote
c56d71f418 Rename LintContext::struct_span_lint as LintContext::span_lint. 2024-01-23 07:59:45 +11:00
Esteban Küber
ac56a2b564 Suggest boxing if then expr if that solves divergent arms
When encountering

```rust
let _ = if true {
    Struct
} else {
    foo() // -> Box<dyn Trait>
};
```

if `Struct` implements `Trait`, suggest boxing the then arm tail expression.

Part of #102629.
2024-01-22 20:53:41 +00:00
Esteban Küber
390ef9ba02 Fix incorrect suggestion for boxing tail expression in blocks 2024-01-22 20:51:19 +00:00
Erik Kaneda
42556b4e4d
assembly test: add riscv32im_risc0_zkvm_elf target 2024-01-22 12:04:56 -08:00
Esteban Küber
ce11b70979 Re-add estebank to review rotation 2024-01-22 19:02:35 +00:00
Markus Reiter
a77cc2ce97
Use Self in NonZero* implementations. 2024-01-22 19:44:38 +01:00
Erik Kaneda
05f8650fe8
update ui test result 2024-01-22 10:25:57 -08:00
bors
d5fd099729 Auto merge of #120242 - matthiaskrgr:rollup-a93yj3i, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #117910 (Refactor uses of `objc_msgSend` to no longer have clashing definitions)
 - #118639 (Undeprecate lint `unstable_features` and make use of it in the compiler)
 - #119801 (Fix deallocation with wrong allocator in (A)Rc::from_box_in)
 - #120058 (bootstrap: improvements for compiler builds)
 - #120059 (Make generic const type mismatches not hide trait impls from the trait solver)
 - #120097 (Report unreachable subpatterns consistently)
 - #120137 (Validate AggregateKind types in MIR)
 - #120164 (`maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe`)
 - #120181 (Allow any `const` expression blocks in `thread_local!`)
 - #120218 (rustfmt: Check that a token can begin a nonterminal kind before parsing it as a macro arg)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-22 18:22:32 +00:00
Erik Kaneda
75d7d7091a
zkvm: add partial std support
Co-authored-by: Frank Laub <flaub@risc0.com>
Co-authored-by: nils <nils@risc0.com>
Co-authored-by: Victor Graf <victor@risczero.com>
Co-authored-by: weikengchen <w.k@berkeley.edu>
2024-01-22 10:15:11 -08:00
Erik Kaneda
966b94e0a2
rustc: implement support for riscv32im_risc0_zkvm_elf
This also adds changes in the rust test suite in order to get a few of them to
pass.

Co-authored-by: Frank Laub <flaub@risc0.com>
Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
2024-01-22 10:07:36 -08:00
Erik Kaneda
06fbe07901
Add target description for riscv32im-risc0-zkvm-elf
Co-authored-by: Frank Laub <github@frank.laub.io>
2024-01-22 10:07:36 -08:00
Esteban Küber
29bdf9ea51 Account for single where bound being removed 2024-01-22 17:52:36 +00:00
David Carlier
dec4740b7c compiler: update freebsd and netbsd base specs.
both support thread local.
2024-01-22 17:09:44 +00:00
Michael Goulet
f700ee4e70 Do not normalize closure signature when building FnOnce shim 2024-01-22 16:50:30 +00:00
Wesley Wiser
21e5beae3c
Use debug_assert instead of expanded equivalent 2024-01-22 10:10:00 -06:00