Commit Graph

254825 Commits

Author SHA1 Message Date
Benoît du Garreau
a197ff3259 Address review comments 2024-05-20 17:00:11 +02:00
Benoît du Garreau
cfb04795a1 Fix read_exact and read_buf_exact for &[u8] and io:Cursor 2024-05-14 16:16:33 +02:00
bors
31026b7fe3 Auto merge of #125023 - morr0ne:linux-none-target, r=Nilstrieb
Add x86_64-unknown-linux-none target

Adds a freestanding linux binary with no libc dependency. This is useful for writing programs written only in rust. It is also essential for writing low level stuff like libc or a dynamic linker.

Tier 3 policy:

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

I will be the designed maintainer for this target

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

The target triple is consistent with other targets

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

There is no confusion with other targets since it explicitly adds "none" at the end instead of omitting the environment

>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 does not introduce any unusual requirement

>The target must not introduce license incompatibilities.

There are no license incompatibilities

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

Everything added is under that license

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

There are no new dependencies

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

There is no proprietary dependencies

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

No such terms exist for this target

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

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

Understood

>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 already implements core. It might be possible in the future to add support for alloc and std by leveraging crates such as [origin](https://github.com/sunfishcode/origin/) and [rustix](https://github.com/bytecodealliance/rustix)

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

I believe the proper docs are added

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

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

Understood

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

No other targets are effected

>Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target.

The same backends used by other linux targets work without issues
2024-05-14 10:07:49 +00:00
Federico Maria Morrone
68407f9049
fix typo in x86_64-unknown-linux-none docs
Co-authored-by: Trevor Gross <t.gross35@gmail.com>
2024-05-14 10:28:00 +02:00
bors
c45e831d8f Auto merge of #124228 - compiler-errors:lint-overcaptures, r=oli-obk
Warn against changes in opaque lifetime captures in 2024

Adds a (mostly[^1]) machine-applicable lint `IMPL_TRAIT_OVERCAPTURES` which detects cases where we will capture more lifetimes in edition 2024 than in edition <= 2021, which may lead to erroneous borrowck errors.

This lint is gated behind the `precise_capturing` feature gate and marked `Allow` for now.

[^1]: Except when there are APITs -- I may work on that soon

r? oli-obk
2024-05-14 07:44:16 +00:00
bors
58426f4a5b Auto merge of #125026 - Oneirical:clink-tests, r=jieyouxu
Migrate `run-make/c-link-to-rust-va-list-fn` to `rmake`

Part of #121876.

r? `@jieyouxu`
2024-05-14 05:35:13 +00:00
Michael Goulet
052de1da4f And finally add tests 2024-05-13 23:57:56 -04:00
Michael Goulet
1529c661e4 Warn against redundant use<...> 2024-05-13 23:57:56 -04:00
Michael Goulet
f3fb727b08 Don't suggest using use<> syntax to capture APITs 2024-05-13 23:57:56 -04:00
Michael Goulet
6afe1352d9 Suggest adding use<> syntax 2024-05-13 23:57:56 -04:00
Michael Goulet
554becc180 Add some commenting 2024-05-13 23:57:56 -04:00
Michael Goulet
d57e57ca1f Implement initial IMPL_TRAIT_OVERCAPTURES lint 2024-05-13 23:47:35 -04:00
bors
fba5f44bd8 Auto merge of #125098 - jhpratt:rollup-2qm4gga, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - #116675 ([ptr] Document maximum allocation size)
 - #124997 (Fix ICE while casting a type with error)
 - #125072 (Add test for dynamic dispatch + Pin::new soundness)
 - #125090 (Migrate fuchsia docs from `pm` to `ffx`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-14 03:19:44 +00:00
Oneirical
812f89728a fix fmt 2024-05-13 22:15:11 -04:00
Jacob Pratt
32d74f1800
Rollup merge of #125090 - erickt:bump-fuchsia, r=tmandry
Migrate fuchsia docs from `pm` to `ffx`

The `pm` tool has been deprecated, so this migrates the fuchsia documentation to the new `ffx` based tooling.
2024-05-13 21:14:16 -04:00
Jacob Pratt
209703af85
Rollup merge of #125072 - Darksonn:pin-dyn-dispatch-sound, r=jhpratt
Add test for dynamic dispatch + Pin::new soundness

While working on [the `#[derive(SmartPointer)]` RFC][1], I realized that the soundness of <code>impl [DispatchFromDyn](https://doc.rust-lang.org/stable/std/ops/trait.DispatchFromDyn.html) for [Pin](https://doc.rust-lang.org/stable/std/pin/struct.Pin.html)</code> relies on the restriction that you can't implement [`Unpin`](https://doc.rust-lang.org/stable/std/marker/trait.Unpin.html) for trait objects.

As far as I can tell, the relevant error exists to solve some unrelated issues with coherence. To avoid cases where `Pin` is made unsound due to changes in the coherence-related errors, add a test that verifies that unsound use of `Pin` and `DispatchFromDyn` does not become allowed in the future.

[1]: https://github.com/rust-lang/rfcs/pull/3621
2024-05-13 21:14:16 -04:00
Jacob Pratt
18d9c039bb
Rollup merge of #124997 - gurry:124848-ice-should-be-sized, r=Nadrieril
Fix ICE while casting a type with error

Fixes #124848

The ICE originates here: f9a3fd9661/compiler/rustc_hir_typeck/src/cast.rs (L143) The underlying cause is that a type with error, `MyType` was involved in a cast. During cast checks the below method `pointer_kind` was called: f9a3fd9661/compiler/rustc_hir_typeck/src/cast.rs (L87-L91) Thanks to the changes in PR #123491, `type_is_sized_modulo_regions` in `pointer_kind` returned `false` which caused control to reach the `span_bug` here: f9a3fd9661/compiler/rustc_hir_typeck/src/cast.rs (L143) resulting in an ICE.

This PR fixes the issue by changing the `span_bug` to a `span_delayed_bug`.
2024-05-13 21:14:15 -04:00
Jacob Pratt
74a78af0e2
Rollup merge of #116675 - joshlf:patch-10, r=scottmcm
[ptr] Document maximum allocation size

Partially addresses https://github.com/rust-lang/unsafe-code-guidelines/issues/465
2024-05-13 21:14:15 -04:00
bors
9105c57b7f Auto merge of #124256 - nnethercote:rm-NtIdent-NtLifetime, r=petrochenkov
Remove `NtIdent` and `NtLifetime`

This is one part of the bigger "remove `Nonterminal` and `TokenKind::Interpolated`" change drafted in #114647. More details in the individual commit messages.

r? `@petrochenkov`
2024-05-14 01:10:38 +00:00
bors
34582118af Auto merge of #125076 - compiler-errors:alias-term, r=lcnr
Split out `ty::AliasTerm` from `ty::AliasTy`

Splitting out `AliasTerm` (for use in project and normalizes goals) and `AliasTy` (for use in `ty::Alias`)

r? lcnr
2024-05-13 22:20:43 +00:00
Nicholas Nethercote
95e519ecbf Remove NtIdent and NtLifetime.
The extra span is now recorded in the new `TokenKind::NtIdent` and
`TokenKind::NtLifetime`. These both consist of a single token, and so
there's no operator precedence problems with inserting them directly
into the token stream.

The other way to do this would be to wrap the ident/lifetime in invisible
delimiters, but there's a lot of code that assumes an interpolated
ident/lifetime fits in a single token, and changing all that code to work with
invisible delimiters would have been a pain. (Maybe it could be done in a
follow-up.)

This change might not seem like much of a win, but it's a first step toward the
much bigger and long-desired removal of `Nonterminal` and
`TokenKind::Interpolated`. That change is big and complex enough that it's
worth doing this piece separately. (Indeed, this commit is based on part of a
late commit in #114647, a prior attempt at that big and complex change.)
2024-05-14 08:19:58 +10:00
Michael Goulet
fa84018c2e Apply nits 2024-05-13 16:55:58 -04:00
bors
ab14f944af Auto merge of #125086 - matthiaskrgr:rollup-xob4lof, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #119515 (style-guide: Format single associated type `where` clauses on the same line)
 - #119959 ([meta] Clarify prioritization alert)
 - #123817 (Stabilize `seek_seek_relative`)
 - #125063 (Don't call `env::set_var` in `rustc_driver::install_ice_hook`)
 - #125071 (Migrate rustdoc target spec json path)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-13 20:14:47 +00:00
Erick Tryzelaar
58ee9192e0 Migrate fuchsia docs from pm to ffx
The `pm` tool has been deprecated, so this migrates the fuchsia
documentation to the new `ffx` based tooling.
2024-05-13 20:14:31 +00:00
Matthias Krüger
ed2c2c06e6
Rollup merge of #125071 - GuillaumeGomez:migrate-rustdoc-target-spec-json-path, r=jieyouxu
Migrate rustdoc target spec json path

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

r? `@jieyouxu`
2024-05-13 20:29:19 +02:00
Matthias Krüger
472391dbf6
Rollup merge of #125063 - tbu-:pr_set_ice_hook_env, r=michaelwoerister
Don't call `env::set_var` in `rustc_driver::install_ice_hook`

Modifying an environment variable would make the function unsafe to call.
2024-05-13 20:29:19 +02:00
Matthias Krüger
b0cbd4e5f3
Rollup merge of #123817 - slanterns:seek_relative, r=dtolnay
Stabilize `seek_seek_relative`

This PR stabilizes `seek_seek_relative`:

```rust
// std::io::Seek

trait Seek {
    fn seek_relative(&mut self, offset: i64) -> Result<()>;
}
```

<br>

Tracking issue: https://github.com/rust-lang/rust/issues/117374.
Implementation PR: https://github.com/rust-lang/rust/pull/116750.

FCPs already completed in the tracking issue.

Closes https://github.com/rust-lang/rust/issues/117374.

r? libs-api
2024-05-13 20:29:18 +02:00
Matthias Krüger
cf8a084d26
Rollup merge of #119959 - fmease:triagebot-prioritization-alert-label, r=apiraino
[meta] Clarify prioritization alert

Apparently, there used to exist the label <kbd>I-nominated</kbd> judging from this entry:

8847bda592/triagebot.toml (L393)

Since it was replaced with individual team labels, I think it makes sense to update the prioritization alert. Of course, it's not super important since the members of WG-prioritization already know that. This is just cleanup.

r? apiraino or wg-prioritization
2024-05-13 20:29:17 +02:00
Matthias Krüger
4d1cce9de5
Rollup merge of #119515 - joshtriplett:style-guide-gat-where-clause-same-line, r=compiler-errors
style-guide: Format single associated type `where` clauses on the same line

In particular, lifetime-generic associated types often have a
`where Self: 'a` bound, which we can format on the same line.
2024-05-13 20:29:17 +02:00
Joshua Liebow-Feeser
293b5cb1ca [ptr] Document maximum allocation size 2024-05-13 11:14:45 -07:00
Michael Goulet
3bcdf3058e split out AliasTy -> AliasTerm 2024-05-13 11:59:42 -04:00
bors
030a12ce2b Auto merge of #125074 - bjorn3:sync_cg_clif-2024-05-13, r=bjorn3
Subtree sync for rustc_codegen_cranelift

A variety of bug fixes, added support for naked functions, a couple more vendor intrinsics implemented.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-05-13 15:30:18 +00:00
Josh Triplett
163b1a6615 Reword formatting for where clauses
Suggested-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2024-05-13 16:43:13 +02:00
Josh Triplett
9ff777bf50 style-guide: Also format where clauses on one line for short function decls 2024-05-13 16:43:13 +02:00
Josh Triplett
2af29af710 style-guide: Not all where clauses can be written as inline bounds 2024-05-13 16:43:13 +02:00
Josh Triplett
2f20bb4a97 style-guide: Give a second example for associated type formatting
Show an example that has bounds.
2024-05-13 16:43:13 +02:00
Josh Triplett
3742a4bd90 style-guide: Format single associated type where clauses on the same line
In particular, lifetime-generic associated types often have a
`where Self: 'a` bound, which we can format on the same line.
2024-05-13 16:42:47 +02:00
bjorn3
75f8bdbca4 Merge commit '3270432f4b0583104c8b9b6f695bf97d6bbf3ac2' into sync_cg_clif-2024-05-13 2024-05-13 13:26:33 +00:00
bors
421f7ca3a9 Auto merge of #125061 - RalfJung:interpret-error, r=cjgillot
interpret: move error macros into error.rs
2024-05-13 13:25:00 +00:00
bjorn3
3270432f4b Rustup to rustc 1.80.0-nightly (ef0027897 2024-05-12) 2024-05-13 13:22:02 +00:00
Guillaume Gomez
b515de83af Migrate run-make/rustdoc-target-spec-json-path to rmake 2024-05-13 15:21:13 +02:00
Guillaume Gomez
4057a7b1e3 Add library_search_path to Rustdoc 2024-05-13 15:21:12 +02:00
Guillaume Gomez
eea00ca354 Add target method to Rustdoc type 2024-05-13 15:04:10 +02:00
Alice Ryhl
b3a78c1d09 Add test for dynamic dispatch + Pin::new soundness 2024-05-13 14:25:03 +02:00
bors
abb95639ef Auto merge of #125024 - Oneirical:master, r=jieyouxu
Rewrite 3 very similar `run-make` alloc tests to rmake

Part of #121876

#121918 attempted to port these 3 tests 2 months ago. However, since then, the structure of `run-make-support` has changed a bit and new helper functions were added. Since there has been no activity on the PR, they are good low-hanging fruit to knock down, using the new functions of the current library.

There is also the removal of a useless import on a very similar test.
2024-05-13 11:20:00 +00:00
bors
6be7b0c7d2 Auto merge of #124999 - scottmcm:unify-aggregate, r=nnethercote
Unify `Rvalue::Aggregate` paths in cg_ssa

In #123840 and #123886 I added two different codepaths for `Rvalue::Aggregate` in `cg_ssa`.

This merges them into one, since raw pointers are also immediates that can be built from the immediates of their "fields".
2024-05-13 09:08:18 +00:00
Tobias Bucher
b98b8d76b1 Don't call env::set_var in rustc_driver::install_ice_hook
Modifying an environment variable would make the function unsafe to
call.
2024-05-13 09:37:29 +02:00
bors
982c9c1e81 Auto merge of #125055 - nnethercote:Comment-FIXME, r=compiler-errors
Avoid clone in `Comments::next`

`Comments::next`, in `rustc_ast_pretty`, has this comment:
```
// FIXME: This shouldn't probably clone lmao
```
The obvious thing to try is to return `Option<&Comment>` instead of `Option<Comment>`. But that leads to multiple borrows all over the place, because `Comments` must be borrowed from `PrintState` and then processed by `&mut self` methods within `PrintState`.

This PR instead rearranges things so that comments are consumed as they are used, preserving the `Option<Comment>` return type without requiring any cloning.

r? `@compiler-errors`
2024-05-13 06:30:25 +00:00
Ralf Jung
b15d09a6dd interpret: move error macros into error.rs 2024-05-13 08:15:45 +02:00
Nicholas Nethercote
9a63a42cb7 Remove a Span from TokenKind::Interpolated.
This span records the declaration of the metavariable in the LHS of the macro.
It's used in a couple of error messages. Unfortunately, it gets in the way of
the long-term goal of removing `TokenKind::Interpolated`. So this commit
removes it, which degrades a couple of (obscure) error messages but makes
things simpler and enables the next commit.
2024-05-13 10:30:30 +10:00