Commit Graph

44841 Commits

Author SHA1 Message Date
Matthias Krüger
0c4415cdd6
Rollup merge of #138387 - RalfJung:intrinsic-arg-names, r=oli-obk
intrinsics: remove unnecessary leading underscore from argument names

This is unnecessary since https://github.com/rust-lang/rust/pull/135840.
2025-03-12 17:59:10 +01:00
Matthias Krüger
de7e5e96be
Rollup merge of #138345 - oli-obk:autodiff-cleanup, r=compiler-errors
Some autodiff cleanups

cc ````@ZuseZ4````

just some things I noticed
2025-03-12 17:59:09 +01:00
Matthias Krüger
d93ef397ce
Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu
Use `RUSTC_LINT_FLAGS` more

An alternative to the failed #138084.

Fixes #138106.

r? ````@jieyouxu````
2025-03-12 17:59:08 +01:00
Matthias Krüger
4ffbc32f17
Rollup merge of #137701 - cuviper:sharded-hashtable, r=fmease
Convert `ShardedHashMap` to use `hashbrown::HashTable`

The `hash_raw_entry` feature (#56167) has finished fcp-close, so the compiler
should stop using it to allow its removal. Several `Sharded` maps were
using raw entries to avoid re-hashing between shard and map lookup, and
we can do that with `hashbrown::HashTable` instead.
2025-03-12 17:59:07 +01:00
Matthias Krüger
d55e2e4333
Rollup merge of #137314 - lcnr:cycles-with-unknown-kind, r=compiler-errors
change definitely unproductive cycles to error

builds on top of #136824 by adding a third variant to `PathKind` for paths which may change to be coinductive in the future but must not be so right now. Most notably, impl where-clauses of not yet coinductive traits.

With this, we can change cycles which are definitely unproductive to a proper error. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/114. This does not affect stable as we keep these cycles as ambiguous during coherence.

r? ````````@compiler-errors```````` ````````@nikomatsakis````````
2025-03-12 17:59:06 +01:00
Michael Goulet
42773bfcac Disentangle ForwardGenericParamBan and ConstParamTy ribs 2025-03-12 16:56:26 +00:00
bjorn3
1543256e6f Remove unused host_tlib_path field 2025-03-12 15:05:25 +00:00
bjorn3
f51d1d29f7 Rename user_provided_sysroot argument of fluent_bundle 2025-03-12 15:05:25 +00:00
bjorn3
7e8494f0a5 Don't return an error from get_or_default_sysroot
All callers unwrap the result.
2025-03-12 15:05:25 +00:00
bjorn3
0a679514d4 Avoid unnecessary argument mutation in fluent_bundle 2025-03-12 15:05:24 +00:00
bjorn3
b54398e4ea Make opts.maybe_sysroot non-optional
build_session_options always uses materialize_sysroot anyway.
2025-03-12 15:05:24 +00:00
bors
aaa2d47dae Auto merge of #138083 - nnethercote:rm-NtItem-NtStmt, r=petrochenkov
Remove `NtItem` and `NtStmt`

Another piece of #124141.

r? `@petrochenkov`
2025-03-12 14:18:36 +00:00
Bryanskiy
ccdba16f42 Delegation: reject C-variadics 2025-03-12 17:14:51 +03:00
Bryanskiy
7bfe2136e4 Delegation: one more ICE fix for MethodCall generation 2025-03-12 15:59:37 +03:00
lcnr
adbcb910f0 remove unnecessary variant 2025-03-12 10:12:53 +01:00
Scott McMurray
143f39362a Don't alloca just to look at a discriminant
Today we're making LLVM do a bunch of extra work for every enum you match on, even trivial stuff like `Option<bool>`.  Let's not.
2025-03-12 00:56:43 -07:00
Matthias Krüger
76f9cda260
Rollup merge of #138377 - nnethercote:rustc_hir_typeck, r=compiler-errors
Remove unnecessary lifetime from `PatInfo`.

r? ```@jackh726```
2025-03-12 08:06:51 +01:00
Matthias Krüger
4c6edb1df8
Rollup merge of #138376 - nnethercote:hir-ItemKind-ident-precursors, r=compiler-errors
Item-related cleanups

I have been looking at `hir::Item` closely and found a few minor cleanup opportunities.

r? ```@spastorino```
2025-03-12 08:06:51 +01:00
Matthias Krüger
2bdb10f164
Rollup merge of #138372 - Eclips4:issue-138196, r=scottmcm
Refactor `pick2_mut` & `pick3_mut` to use `get_disjoint_mut`

Closes #138196
2025-03-12 08:06:50 +01:00
Matthias Krüger
b849aa9f61
Rollup merge of #138360 - Urgau:fix-fp-expr_or_init, r=wesleywiser
Fix false-positive in `expr_or_init` and in the `invalid_from_utf8` lint

This PR fixes the logic for finding initializer in the `expr_or_init` and `expr_or_init_with_outside_body` functions.

If the binding were to be mutable (`let mut`), the logic wouldn't consider that the initializer expression could have been modified and would return the init expression even-trough multiple subsequent assignments could have been done.

Example:
```rust
let mut a = [99, 108, 130, 105, 112, 112]; // invalid, not UTF-8
loop {
    a = *b"clippy"; // valid
    break;
}
std::str::from_utf8_mut(&mut a); // currently warns, with this PR it doesn't
```

This PR modifies the logic to excludes mutable let bindings.

Found when using `expr_or_init` in https://github.com/rust-lang/rust/pull/119220.

r? compiler
2025-03-12 08:06:50 +01:00
Matthias Krüger
5833dfa78a
Rollup merge of #138347 - nnethercote:less-kw-Empty-2, r=compiler-errors
Reduce `kw::Empty` usage, part 2

A few small `kw::Empty` removals, or steps toward removals.

r? fmease
2025-03-12 08:06:49 +01:00
Matthias Krüger
143eb4f03e
Rollup merge of #138174 - compiler-errors:elaborate-unsize-self-pred, r=BoxyUwU
Elaborate trait assumption in `receiver_is_dispatchable`

Fixes #138172. See comment on the linked test.

Probably not a fix for the general problem, bc I think this may still be incomplete for other weird `where` clauses on the receiver. But 🤷, supertraits seems like an obvious one to fix.
2025-03-12 08:06:47 +01:00
Ralf Jung
cf318a79d6 intrinsics: remove unnecessary leading underscore from argument names 2025-03-12 08:04:09 +01:00
Nicholas Nethercote
c0cee43af5 Remove unnecessary lifetime from PatInfo. 2025-03-12 13:03:18 +11:00
bors
d2b52c5c48 Auto merge of #137795 - Jarcho:idx_opt, r=davidtwco
Allow bounds checks when enumerating `IndexSlice` to be elided

Without this hint, each loop iteration has to separately bounds check the index. See https://godbolt.org/z/zrfPY4Ten for an example.

This is technically a behaviour change, but only in cases where the compiler is going to crash anyways.
2025-03-12 00:30:16 +00:00
Nicholas Nethercote
ee9ef82795 Factor out some repeated code in parse_item_impl. 2025-03-12 09:55:29 +11:00
Nicholas Nethercote
ed10418363 Inline and remove State::print_item_type.
It has a single call site. The removal of the closure argument is a nice
touch.
2025-03-12 09:55:15 +11:00
Nicholas Nethercote
d7029d7e2d Remove unused OwnerNode::ident method. 2025-03-12 09:54:25 +11:00
Josh Stone
576bcfcd4e Update compiletest's has_asm_support to match rustc
The list of `ASM_SUPPORTED_ARCHS` was missing a few from the compiler's
actual stable list.
2025-03-11 15:42:33 -07:00
Kirill Podoprigora
7398b39a0b Make panic's more specific 2025-03-12 00:35:16 +02:00
Nicholas Nethercote
4eadaff184 Convert a kw::Empty occurrence to sym::dummy.
`adjust_ident_and_get_scope` returns the symbol it receives unchanged,
and the call site ignores the returned symbol, so this symbol is unused.
2025-03-12 09:35:13 +11:00
Nicholas Nethercote
0b2d7062c4 Introduce sym::dummy and Ident::dummy.
The idea is to identify cases of symbols/identifiers that are not
expected to be used. There isn't a perfectly sharp line between "dummy"
and "not dummy", but I think it's useful nonetheless.
2025-03-12 09:35:11 +11:00
Nicholas Nethercote
fe04460f6f Remove an unnecessary kw::Empty check.
Replace it with an assert for now, just in case it is reachable.
2025-03-12 09:34:21 +11:00
Nicholas Nethercote
763db5dcd9 Convert a delayed bug to a bug.
This is never hit in the test suite.

At some point the check should be removed entirely. There are a million
places in the compiler where an empty symbol doesn't make sense, so a
check of this nature has almost zero value. But I'll leave it in place
for now just in case it gets hit by fuzzing or in the wild.
2025-03-12 09:34:21 +11:00
Nicholas Nethercote
256c27e748 Move methods from Map to TyCtxt, part 4.
Continuing the work from #137350.

Removes the unused methods: `expect_variant`, `expect_field`,
`expect_foreign_item`.

Every method gains a `hir_` prefix.
2025-03-12 08:55:37 +11:00
Nicholas Nethercote
281af35cc3 Rename hir_attrs query as hir_attr_map.
To make room for the moving of `Map::attrs` to `TyCtxt::hir_attrs` in
the next commit. (It makes sense to rename the query, because it has
many fewer uses than the method.)
2025-03-12 08:55:35 +11:00
Nicholas Nethercote
d2642abed3 Adjust Map's to_string functionality.
`Map::node_to_string` just calls the free function `hir_id_to_string`.
This commit removes the former and changes the latter into a `TyCtxt`
method.
2025-03-12 08:30:03 +11:00
bors
c625102320 Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #137715 (Allow int literals for pattern types with int base types)
 - #138002 (Disable CFI for weakly linked syscalls)
 - #138051 (Add support for downloading GCC from CI)
 - #138231 (Prevent ICE in autodiff validation by emitting user-friendly errors)
 - #138245 (stabilize `ci_rustc_if_unchanged_logic` test for local environments)
 - #138256 (Do not feed anon const a type that references generics that it does not have)
 - #138284 (Do not write user type annotation for const param value path)
 - #138296 (Remove `AdtFlags::IS_ANONYMOUS` and `Copy`/`Clone` condition for anonymous ADT)
 - #138352 (miri native_calls: ensure we actually expose *mutable* provenance to the memory FFI can access)
 - #138354 (remove redundant `body`  arguments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-11 21:17:18 +00:00
Kirill Podoprigora
64d143326f Refactor pick2_mut & pick3_mut to use get_disjoint_mut 2025-03-11 22:57:01 +02:00
Urgau
faa5b3f7de Fix false-positive in expr_or_init and in the invalid_from_utf8 lint 2025-03-11 21:56:53 +01:00
Matthias Krüger
4c1a1867c7
Rollup merge of #138354 - lcnr:goodbye-TypeVerifier, r=compiler-errors
remove redundant `body`  arguments

it's already stored in the `TypeChecker` itself
2025-03-11 19:35:35 +01:00
Matthias Krüger
4feb86684d
Rollup merge of #138352 - RalfJung:miri-native-calls-exposed, r=oli-obk
miri native_calls: ensure we actually expose *mutable* provenance to the memory FFI can access

In native call mode, the interpreter memory itself is accessed directly by external code via pointers created from integers and passed via libffi, so we have to ensure the provenance in Miri itself (on the meta level) is sufficiently exposed. So far we only exposed the provenance for read-only accesses. This may we enough as that may actually be the same provenance as for mutable accesses, but it's hard to be sure, and anyway there's no reason to do such a gambit -- we have this function, `prepare_for_native_call`, which iterates all memory the call can access. let's just also (re-)expose Miri's own allocations there. We expose the read-only provenance for all of them and the mutable provenance for the mutable allocations.

r? ``@oli-obk``
2025-03-11 19:35:34 +01:00
Matthias Krüger
954b88ed2a
Rollup merge of #138296 - compiler-errors:deanonymous, r=lcnr
Remove `AdtFlags::IS_ANONYMOUS` and `Copy`/`Clone` condition for anonymous ADT

cc #131045, which removed anonymous ADTs from the compiler

I forgot more stuff I guess.
2025-03-11 19:35:33 +01:00
Matthias Krüger
16ff824133
Rollup merge of #138284 - compiler-errors:const-param-ty-annotation, r=BoxyUwU
Do not write user type annotation for const param value path

As I noted in the code comment, `DefKind::ConstParam` isn't actually *generic* over its own args, we just use the identity args from the body when lowering the value path so we have something to plug into the `EarlyBinder` we get back from `type_of` for the const param. So skip over it in `write_user_type_annotation_from_args`.

Somewhat unrelated, but I left an explanation for a somewhat mysterious quirk in the THIR lowering of user type annotations for patterns having to do with ctors and their `type_of` not actually being the type of the pattern node it's ascribing.

Fixes #138048

r? ``@BoxyUwU``
2025-03-11 19:35:32 +01:00
Matthias Krüger
4ff58c9103
Rollup merge of #138256 - compiler-errors:anon-const-ty, r=BoxyUwU
Do not feed anon const a type that references generics that it does not have

Fixes #137865

See the comment I left in the code. We could alternatively give these anon consts the generics from the parent, but that would be moving in a GCE-esque direction that we may not want. Open to tweaks here.

r? BoxyUwU
2025-03-11 19:35:31 +01:00
Matthias Krüger
caa2d008f9
Rollup merge of #138231 - Sa4dUs:autodiff-ice, r=ZuseZ4
Prevent ICE in autodiff validation by emitting user-friendly errors

This PR moves `valid_ret_activity` and `valid_input_activity` checks to the macro expansion phase in compiler/rustc_builtin_macros/src/autodiff.rs, replacing the following internal compiler error (ICE):
```
error: internal compiler error:
compiler/rustc_codegen_ssa/src/codegen_attrs.rs:935:13:
Invalid input activity Dual for Reverse mode
```
with a more user-friendly message.

The issue specifically affected the test file `tests/ui/autodiff/autodiff_illegal.rs`, impacting the functions `f5` and `f6`.

The ICE can be reproduced by following [Enzyme's Rustbook](https://enzymead.github.io/rustbook/installation.html) installation guide.

Additionally, this PR adds tests for invalid return activity in `autodiff_illegal.rs`, which previously triggered an unnoticed ICE before these fixes.

r? ``@oli-obk``
2025-03-11 19:35:29 +01:00
Matthias Krüger
8a2e3acb45
Rollup merge of #137715 - oli-obk:pattern-type-literals, r=BoxyUwU
Allow int literals for pattern types with int base types

r? ``@BoxyUwU``

I also added an error at layout computation time for layouts that contain wrapping ranges (happens at monomorphization time). This is obviously hacky, but at least prevents such types from making it to codegen for now. It made writing the tests for int literals easier as I didn't have to think about that edge case

Basically this PR allows you to stop using transmutes for creating pattern types and instead just use literals:

```rust
let x: pattern_type!(u32 is 5..10) = 7;
```

works, and if the literal is out of range you get a type mismatch because it just stays at the base type and the base type can't be coerced to the pattern type.

cc ``@joshtriplett`` ``@scottmcm``
2025-03-11 19:35:27 +01:00
bors
6650252439 Auto merge of #128440 - oli-obk:defines, r=lcnr
Add `#[define_opaques]` attribute and require it for all type-alias-impl-trait sites that register a hidden type

Instead of relying on the signature of items to decide whether they are constraining an opaque type, the opaque types that the item constrains must be explicitly listed.

A previous version of this PR used an actual attribute, but had to keep the resolved `DefId`s in a side table.

Now we just lower to fields in the AST that have no surface syntax, instead a builtin attribute macro fills in those fields where applicable.

Note that for convenience referencing opaque types in associated types from associated methods on the same impl will not require an attribute. If that causes problems `#[defines()]` can be used to overwrite the default of searching for opaques in the signature.

One wart of this design is that closures and static items do not have generics. So since I stored the opaques in the generics of functions, consts and methods, I would need to add a custom field to closures and statics to track this information. During a T-types discussion we decided to just not do this for now.

fixes #131298
2025-03-11 18:13:31 +00:00
Michael Goulet
c170d0f12f Elaborate param-env built for checking DispatchFromDyn for dyn compat 2025-03-11 16:32:56 +00:00
lcnr
a5eb387d61 merge TypeChecker and TypeVerifier 2025-03-11 16:34:15 +01:00
lcnr
50f5f607b4 unify last_span computation 2025-03-11 16:18:06 +01:00
lcnr
2f6aca8206 change TypeChecker to a MIR visitor 2025-03-11 16:08:53 +01:00
bors
f2d69d5a7c Auto merge of #138350 - Kobzol:rollup-4kj94rq, r=Kobzol
Rollup of 10 pull requests

Successful merges:

 - #135987 (Clarify iterator by_ref docs)
 - #137967 ([AIX] Fix hangs during testing)
 - #138063 (Improve `-Zunpretty=hir` for parsed attrs)
 - #138147 (Add maintainers for powerpc64le-unknown-linux-gnu)
 - #138288 (Document -Z crate-attr)
 - #138300 (add tracking issue for unqualified_local_imports)
 - #138307 (Allow specifying glob patterns for try jobs)
 - #138315 (use next_back() instead of last() on DoubleEndedIterator)
 - #138330 (Remove unnecessary `[lints.rust]` sections.)
 - #138335 (Fix post-merge workflow)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-11 15:08:43 +00:00
lcnr
ba6c406854 let the bodies hit the floor
remove unnecessary `body`  arguments
2025-03-11 15:30:39 +01:00
Ralf Jung
3846f94230 miri native_calls: ensure we actually expose *mutable* provenance to the memory FFI can access 2025-03-11 14:34:21 +01:00
Jakub Beránek
7e4c08b82b
Rollup merge of #138330 - nnethercote:rm-lints-rust-sections, r=jieyouxu
Remove unnecessary `[lints.rust]` sections.

`bootstrap` and `llvm_enzyme` are now both in the extra `check-cfg` list in bootstrap, so they doesn't need to be handled explicitly in `Cargo.toml` files.

r? ```@jieyouxu```
2025-03-11 13:30:56 +01:00
Jakub Beránek
03a79a77ac
Rollup merge of #138315 - matthiaskrgr:nextback, r=fmease
use next_back() instead of last() on DoubleEndedIterator
2025-03-11 13:30:55 +01:00
Jakub Beránek
07f33e22bf
Rollup merge of #138300 - RalfJung:unqualified-local-imports, r=jieyouxu
add tracking issue for unqualified_local_imports

Tracking issue: https://github.com/rust-lang/rust/issues/138299

r? ``````@jieyouxu``````
2025-03-11 13:30:53 +01:00
Jakub Beránek
c054bac89a
Rollup merge of #138063 - compiler-errors:improve-attr-unpretty, r=jdonszelmann
Improve `-Zunpretty=hir` for parsed attrs

0. Rename `print_something` to `should_render` to make it distinct from `print_attribute` in that it doesn't print anything, it's just a way to probe if a type renders anything.
1. Fixes a few bugs in the `PrintAttribute` derive. Namely, the `__printed_anything` variable was entangled with the `should_render` call, leading us to always render field names but never render commas.
2. Remove the outermost `""` from the attr.
3. Debug print `Symbol`s. I know that this is redundant for some parsed attributes, but there's no good way to distinguish symbols that are ident-like and symbols which are cooked string literals. We could perhaps *conditionally* to fall back to a debug printing if the symbol doesn't match an ident? But seems like overkill.

Based on #138060, only review the commits not in that one.
2025-03-11 13:30:51 +01:00
bors
ebf0cf75d3 Auto merge of #137586 - nnethercote:SetImpliedBits, r=bjorn3
Speed up target feature computation

The LLVM backend calls `LLVMRustHasFeature` twice for every feature. In short-running rustc invocations, this accounts for a surprising amount of work.

r? `@bjorn3`
2025-03-11 12:05:16 +00:00
Oli Scherer
69a1bb8bdb Error on define_opaques entries without any opaques actually referenced 2025-03-11 12:05:02 +00:00
Oli Scherer
43e39260f9 Keep items around even if builtin macros on them fail to parse 2025-03-11 12:05:02 +00:00
Oli Scherer
3e4e65ee8b Test invalid define_opaques attributes 2025-03-11 12:05:02 +00:00
Oli Scherer
cb4751d4b8 Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
Oli Scherer
9882eca151 Remove some dead code 2025-03-11 08:41:15 +00:00
Oli Scherer
ff5a8ad2ab Explain the actual reason why stripping binders is fine 2025-03-11 08:40:35 +00:00
Sa4dUs
8546e015b4 Add individual activity span availability FIXME 2025-03-11 09:37:53 +01:00
Sa4dUs
33f9a491eb Combine autodiff errors together 2025-03-11 09:37:53 +01:00
Marcelo Domínguez
cf8e1f5e0f Fix ICE for invalid return activity and proper error handling 2025-03-11 09:36:57 +01:00
bors
705421b522 Auto merge of #135651 - arjunr2:master, r=davidtwco
Support for `wasm32-wali-linux-musl` Tier-3 target

Adding a new target -- `wasm32-wali-linux-musl` -- to the compiler can target the [WebAssembly Linux Interface](https://github.com/arjunr2/WALI) according to MCP rust-lang/compiler-team#797
Preliminary support involves minimal changes, primarily

* A new target spec for `wasm32_wali_linux_musl` that bridges linux options with supported wasm options. Right now, since there is no canonical Linux ABI for Wasm, we use `wali` in the vendor field, but this can be migrated in future version.
* Dependency patches to the following crates are required and these crates can be updated to bring target support:
  - **stdarch** rust-lang/stdarch#1702
  - **libc** rust-lang/libc#4244
  - **cc** rust-lang/cc-rs#1373
* Minimal additions for FFI support

cc `@tgross35` for libc-related changes

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 take responsibility for maintaining this target as well as issues

> 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 name is consistent with naming patterns from currently supported targets for arch (wasm32), OS, (linux) and env (musl)

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

No naming confusion is introduced.

> If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.

Compliant

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

It's fully open source

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

Noted

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

Compliant

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

All tools are open-source

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

I am not a reviewer

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

This target supports the full standard library with appropriate configuration stubs where necessary (however, similar to all existing wasm32 targets, it excludes dynamic linking or hardware-specific features)

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

Preliminary documentation is provided at https://github.com/arjunr2/WALI. Further detailed docs (if necessary) can be added once this PR lands

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

To the best of my knowledge, it does not break any existing target in the ecosystem -- only minimal configuration-specific additions were made to support the target.

> Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)

We can upstream LLVM target support
2025-03-11 07:21:45 +00:00
bors
374ce1f909 Auto merge of #136932 - m-ou-se:fmt-width-precision-u16, r=scottmcm
Reduce formatting `width` and `precision` to 16 bits

This is part of https://github.com/rust-lang/rust/issues/99012

This is reduces the `width` and `precision` fields in format strings to 16 bits. They are currently full `usize`s, but it's a bit nonsensical that we need to support the case where someone wants to pad their value to eighteen quintillion spaces and/or have eighteen quintillion digits of precision.

By reducing these fields to 16 bit, we can reduce `FormattingOptions` to 64 bits (see https://github.com/rust-lang/rust/pull/136974) and improve the in memory representation of `format_args!()`. (See additional context below.)

This also fixes a bug where the width or precision is silently truncated when cross-compiling to a target with a smaller `usize`. By reducing the width and precision fields to the minimum guaranteed size of `usize`, 16 bits, this bug is eliminated.

This is a breaking change, but affects almost no existing code.

---

Details of this change:

There are three ways to set a width or precision today:

1. Directly a formatting string, e.g. `println!("{a:1234}")`
2. Indirectly in a formatting string, e.g. `println!("{a:width$}", width=1234)`
3. Through the unstable `FormattingOptions::width` method.

This PR:

- Adds a compiler error for 1. (`println!("{a:9999999}")` no longer compiles and gives a clear error.)
- Adds a runtime check for 2. (`println!("{a:width$}, width=9999999)` will panic.)
- Changes the signatures of the (unstable) `FormattingOptions::[get_]width` methods to use a `u16` instead.

---

Additional context for improving `FormattingOptions` and `fmt::Arguments`:

All the formatting flags and options are currently:

- The `+` flag (1 bit)
- The `-` flag (1 bit)
- The `#` flag (1 bit)
- The `0` flag (1 bit)
- The `x?` flag (1 bit)
- The `X?` flag (1 bit)
- The alignment (2 bits)
- The fill character (21 bits)
- Whether a width is specified (1 bit)
- Whether a precision is specified (1 bit)
- If used, the width (a full usize)
- If used, the precision (a full usize)

Everything except the last two can simply fit in a `u32` (those add up to 31 bits in total).

If we can accept a max width and precision of u16::MAX, we can make a `FormattingOptions` that is exactly 64 bits in size; the same size as a thin reference on most platforms.

If, additionally, we also limit the number of formatting arguments, we can also reduce the size of `fmt::Arguments` (that is, of a `format_args!()` expression).
2025-03-11 04:07:05 +00:00
Nicholas Nethercote
ff0a5fe975 Remove #![warn(unreachable_pub)] from all compiler/ crates.
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-11 13:14:21 +11:00
Nicholas Nethercote
55505ab1d3 Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates.
And fix the new errors in the handful of crates that didn't have a
`#![warn(unreachable_pub)]`.
2025-03-11 13:14:21 +11:00
Arjun Ramesh
336a327f7c Target definition for wasm32-wali-linux-musl to support the Wasm Linux
Interface

This commit does not patch libc, stdarch, or cc
2025-03-10 21:26:45 -04:00
Nicholas Nethercote
32afef411b Remove unnecessary [lints.rust] sections.
`bootstrap` and `llvm_enzyme` are now both in the extra `check-cfg` list
in bootstrap, so they doesn't need to be handled explicitly in
`Cargo.toml` files.
2025-03-11 12:11:04 +11:00
bors
90384941aa Auto merge of #138302 - matthiaskrgr:rollup-an2up80, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #136395 (Update to rand 0.9.0)
 - #137279 (Make some invalid codegen attr errors structured/translatable)
 - #137585 (Update documentation to consistently use 'm' in atomic synchronization example)
 - #137926 (Add a test for `-znostart-stop-gc` usage with LLD)
 - #138074 (Support `File::seek` for Hermit)
 - #138238 (Fix dyn -> param suggestion in struct ICEs)
 - #138270 (chore: Fix some comments)
 - #138286 (triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search (…)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-11 00:55:25 +00:00
Josh Stone
3b0c2585c8 Convert ShardedHashMap to use hashbrown::HashTable
The `hash_raw_entry` feature has finished fcp-close, so the compiler
should stop using it to allow its removal. Several `Sharded` maps were
using raw entries to avoid re-hashing between shard and map lookup, and
we can do that with `hashbrown::HashTable` instead.
2025-03-10 17:08:30 -07:00
Folkert de Vries
c0957ef45a
naked functions: on windows emit .endef without the symbol name
also add test with `fastcall`, which on i686 uses a different mangling scheme
2025-03-11 00:27:32 +01:00
Matthias Krüger
dcf6137b5c use next_back() instead of last() on DoubleEndedIterator 2025-03-10 19:03:51 +01:00
Matthias Krüger
44ec67fffb
Rollup merge of #138306 - jieyouxu:revert-workspace-lints, r=Noratrieb
Revert "Use workspace lints for crates in `compiler/` #138084"

Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). The problem is that the `rustc-src` component doesn't include the root `Cargo.toml` manifest.

This breakage was reported in https://github.com/rust-lang/rust/issues/138304.

This reverts commit 48caf81484, reversing changes made to c6662879b2.

cc `@RalfJung`

r? `@nnethercote` (sorry, I didn't consider this being a thing 💀)
2025-03-10 15:57:22 +01:00
Matthias Krüger
0d6311931b
Rollup merge of #138278 - Bryanskiy:delegation-ice-1, r=petrochenkov
Delegation: fix ICE with invalid `MethodCall` generation

`ExprKind::MethodCall` is now generated instead of `ExprKind::Call` if
- the resolved function has a `&self` argument
- the resolved function is an associated item <- was missed before

Fixes https://github.com/rust-lang/rust/issues/128190
Fixes https://github.com/rust-lang/rust/issues/128119
Fixes https://github.com/rust-lang/rust/issues/127916

r? `@petrochenkov`
2025-03-10 15:57:14 +01:00
Michael Goulet
bc4f0bb486 Pass InferCtxt to InlineAsmCtxt to properly taint on error
Split up some of the tests bc tainting causes some errors to become
suppressed
2025-03-10 14:28:09 +00:00
Bryanskiy
61122d1829 Delegation: fix ICE with invalid MethodCall generation 2025-03-10 17:08:29 +03:00
Folkert de Vries
9213cb80c2
fix ICE in pretty-printing global_asm! 2025-03-10 14:46:01 +01:00
Mara Bos
2ce0205735 Share implementation of expr_u{16,32,size}. 2025-03-10 13:57:23 +01:00
morine0122
112f7b01a1 make precise capturing args in rustdoc Json typed 2025-03-10 21:40:09 +09:00
Mara Bos
fb9ce02976 Limit formatting width and precision to 16 bits. 2025-03-10 12:20:05 +01:00
许杰友 Jieyou Xu (Joe)
063ef18fdc Revert "Use workspace lints for crates in compiler/ #138084"
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to
consider options that avoids breaking downstream usages of cargo on
distributed `rustc-src` artifacts, where such cargo invocations fail due
to inability to inherit `lints` from workspace root manifest's
`workspace.lints` (this is only valid for the source rust-lang/rust
workspace, but not really the distributed `rustc-src` artifacts).

This breakage was reported in
<https://github.com/rust-lang/rust/issues/138304>.

This reverts commit 48caf81484, reversing
changes made to c6662879b2.
2025-03-10 18:12:47 +08:00
Oli Scherer
f87e58f194 Allow int literals for pattern types with int base types 2025-03-10 09:33:33 +00:00
Oli Scherer
916f9552e9 Reject wrapping ranges of pattern types 2025-03-10 09:27:13 +00:00
Matthias Krüger
86065acbc3
Rollup merge of #138270 - StevenMia:master, r=compiler-errors
chore: Fix some comments

 Fix some comments
2025-03-10 09:32:15 +01:00
Matthias Krüger
1ae083ddd5
Rollup merge of #138238 - compiler-errors:dyn-suggestion-in-struct, r=nnethercote
Fix dyn -> param suggestion in struct ICEs

Makes the logic from #138042 a bit less ICEy and more clean. Also fixes an incorrect suggestion when the struct already has generics. I'll point out the major changes and observations in the code.

Fixes #138229
Fixes #138211

r? nnethercote since you reviewed the original pr, or re-roll if you don't want to review this
2025-03-10 09:32:14 +01:00
Matthias Krüger
c8194f1da3
Rollup merge of #137279 - estebank:codegen-structured-errors, r=nnethercote
Make some invalid codegen attr errors structured/translatable
2025-03-10 09:32:11 +01:00
Ralf Jung
b827087a41 add tracking issue for unqualified_local_imports 2025-03-10 08:51:19 +01:00
Michael Goulet
f525b173ed Remove AdtFlags::IS_ANONYMOUS and Copy/Clone condition for anonymous ADT 2025-03-10 02:31:33 +00:00
Michael Goulet
279377f87a Fix pretty printing of parsed attrs in hir_pretty 2025-03-10 02:04:26 +00:00
Michael Goulet
6a38322d26 Rename print_something to should_render 2025-03-10 02:03:19 +00:00
Chris Denton
1c7aaf95e1
Update rand to 0.9.0 2025-03-10 01:21:57 +00:00
bors
2b4694a698 Auto merge of #137695 - nnethercote:always-inline-query_get_at, r=saethlin
Always inline `query_get_at`.

r? `@saethlin`
2025-03-09 21:36:57 +00:00
Michael Goulet
ed6dfddfeb Do not feed anon const a type that references generics that it does not have 2025-03-09 20:03:13 +00:00