about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-03-13Auto merge of #138249 - compiler-errors:auto-self, r=lcnrbors-15/+1
Do not register `Self: AutoTrait` when confirming auto trait (in old solver) Every built-in auto impl for a trait goal like `Ty: Auto` immediately registers another obligation of `Ty: Auto` as one of its nested obligations, leading to us stressing the cycle detection machinery a lot more than we need to. This is because all traits have a `Self: Trait` predicate. To fix this, remove the call to `impl_or_trait_obligations` in `vtable_auto_impl`, since auto traits do not have where clauses. r? lcnr
2025-03-13Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearthbors-1205/+1133
Rollup of 12 pull requests Successful merges: - #134076 (Stabilize `std::io::ErrorKind::InvalidFilename`) - #137504 (Move methods from Map to TyCtxt, part 4.) - #138175 (Support rmeta inputs for --crate-type=bin --emit=obj) - #138259 (Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs) - #138280 (fix ICE in pretty-printing `global_asm!`) - #138318 (Rustdoc: remove a bunch of `@ts-expect-error` from main.js) - #138331 (Use `RUSTC_LINT_FLAGS` more) - #138357 (merge `TypeChecker` and `TypeVerifier`) - #138394 (remove unnecessary variant) - #138403 (Delegation: one more ICE fix for `MethodCall` generation) - #138407 (Delegation: reject C-variadics) - #138409 (Use sa_sigaction instead of sa_union.__su_sigaction for AIX) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-12Auto merge of #138076 - tmiasko:pred-count, r=matthewjasperbors-3/+6
Calculate predecessor count directly Avoid allocating a vector of small vectors merely to determine how many predecessors each basic block has. Additionally use u8 and saturating operations. The pass only needs to distinguish between [0..1] and [2..].
2025-03-12Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgrbors-254/+337
Rollup of 7 pull requests Successful merges: - #137314 (change definitely unproductive cycles to error) - #137701 (Convert `ShardedHashMap` to use `hashbrown::HashTable`) - #138269 (uefi: fs: Implement FileType, FilePermissions and FileAttr) - #138331 (Use `RUSTC_LINT_FLAGS` more) - #138345 (Some autodiff cleanups) - #138387 (intrinsics: remove unnecessary leading underscore from argument names) - #138390 (fix incorrect tracing log) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-12Rollup merge of #138407 - Bryanskiy:delegation-variadic, r=petrochenkovManish Goregaokar-0/+5
Delegation: reject C-variadics The explanation is contained in attached issues. Fixes https://github.com/rust-lang/rust/issues/127443 Fixes https://github.com/rust-lang/rust/issues/127413 r? `@petrochenkov`
2025-03-12Rollup merge of #138403 - Bryanskiy:delegation-ice-2, r=petrochenkovManish Goregaokar-0/+1
Delegation: one more ICE fix for `MethodCall` generation self-explanatory Fixes https://github.com/rust-lang/rust/issues/138362 r? `@petrochenkov`
2025-03-12Rollup merge of #138394 - lcnr:yeet-variant, r=compiler-errorsManish Goregaokar-11/+6
remove unnecessary variant
2025-03-12Rollup merge of #138357 - lcnr:goodbye-TypeVerifier-rarw, r=compiler-errorsManish Goregaokar-798/+689
merge `TypeChecker` and `TypeVerifier` Stacked on top of #138354. Best reviewed commit by commit. r? `@compiler-errors`
2025-03-12Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, ↵Manish Goregaokar-79/+15
r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed #138084. Fixes #138106. r? `````@jieyouxu`````
2025-03-12Rollup merge of #138280 - folkertdev:mir-dump-asm-const, r=compiler-errorsManish Goregaokar-1/+4
fix ICE in pretty-printing `global_asm!` fixes https://github.com/rust-lang/rust/issues/138260 since https://github.com/rust-lang/rust/pull/137180, `global_asm!` gets a fake body, that the pretty printing logic did not know what to do with. based on [#t-compiler/help > tests for MIR pretty printing](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/tests.20for.20MIR.20pretty.20printing) I created `tests/ui/unpretty/mir` which seemed as good a place as any for a test. If there is a better place, let me know. try-job: test-various try-job: x86_64-apple-2
2025-03-12Rollup merge of #138259 - compiler-errors:disentangle-ribs, r=BoxyUwUManish Goregaokar-50/+122
Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs In #137617, the `ConstParamTy` rib was adjusted to act kinda like the `ForwardGenericParamBan`. However, this means that it no longer served its purpose banning generics from *parent items*. Although we still are checking for param type validity using the `ConstParamTy_` trait, which means that we weren't accepting code we shouldn't, I think it's a bit strange for us not to be rejecting code like this during *resolution* and instead letting these malformed const generics leak into the type system: ```rust trait Foo<T> { fn bar<const N: T>() {} } ``` This PR does a few things: 1. Introduce a `ForwardGenericParamBanReason` enum, and start using the `ForwardGenericParamBan` rib to ban forward-declared params in const tys when `generic_const_parameter_types` is enabled. 2. Start using the `ConstParamTy` rib to ban *all* generics when `generic_const_parameter_types` is disabled. 3. Improve the diagnostics for both of the cases above, and for forward-declared params in parameter defaults too :3 r? `@BoxyUwU` or reassign
2025-03-12Rollup merge of #138175 - sam-mccall:binobj, r=nnethercoteManish Goregaokar-1/+1
Support rmeta inputs for --crate-type=bin --emit=obj This already works for --emit=metadata, but is possible anytime we're not linking. Tests: - `rmeta_bin` checks we're not changing --emit=link (already passes) - `rmeta_bin-pass` tests the new behavior for --emit=obj (would fail today) and also --emit=metadata which isn't changing
2025-03-12Rollup merge of #137504 - nnethercote:remove-Map-4, r=ZalatharManish Goregaokar-344/+305
Move methods from Map to TyCtxt, part 4. A follow-up to https://github.com/rust-lang/rust/pull/137350. r? ```@Zalathar```
2025-03-12Rollup merge of #138387 - RalfJung:intrinsic-arg-names, r=oli-obkMatthias Krüger-16/+16
intrinsics: remove unnecessary leading underscore from argument names This is unnecessary since https://github.com/rust-lang/rust/pull/135840.
2025-03-12Rollup merge of #138345 - oli-obk:autodiff-cleanup, r=compiler-errorsMatthias Krüger-11/+5
Some autodiff cleanups cc ````@ZuseZ4```` just some things I noticed
2025-03-12Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, ↵Matthias Krüger-79/+15
r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed #138084. Fixes #138106. r? ````@jieyouxu````
2025-03-12Rollup merge of #137701 - cuviper:sharded-hashtable, r=fmeaseMatthias Krüger-66/+107
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-12Rollup merge of #137314 - lcnr:cycles-with-unknown-kind, r=compiler-errorsMatthias Krüger-82/+194
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-12Disentangle ForwardGenericParamBan and ConstParamTy ribsMichael Goulet-50/+122
2025-03-12Auto merge of #138083 - nnethercote:rm-NtItem-NtStmt, r=petrochenkovbors-99/+182
Remove `NtItem` and `NtStmt` Another piece of #124141. r? `@petrochenkov`
2025-03-12Delegation: reject C-variadicsBryanskiy-0/+5
2025-03-12Delegation: one more ICE fix for `MethodCall` generationBryanskiy-0/+1
2025-03-12remove unnecessary variantlcnr-11/+6
2025-03-12Rollup merge of #138377 - nnethercote:rustc_hir_typeck, r=compiler-errorsMatthias Krüger-25/+27
Remove unnecessary lifetime from `PatInfo`. r? ```@jackh726```
2025-03-12Rollup merge of #138376 - nnethercote:hir-ItemKind-ident-precursors, ↵Matthias Krüger-56/+24
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-12Rollup merge of #138372 - Eclips4:issue-138196, r=scottmcmMatthias Krüger-15/+20
Refactor `pick2_mut` & `pick3_mut` to use `get_disjoint_mut` Closes #138196
2025-03-12Rollup merge of #138360 - Urgau:fix-fp-expr_or_init, r=wesleywiserMatthias Krüger-2/+14
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-12Rollup merge of #138347 - nnethercote:less-kw-Empty-2, r=compiler-errorsMatthias Krüger-21/+41
Reduce `kw::Empty` usage, part 2 A few small `kw::Empty` removals, or steps toward removals. r? fmease
2025-03-12Rollup merge of #138174 - compiler-errors:elaborate-unsize-self-pred, r=BoxyUwUMatthias Krüger-7/+12
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-12intrinsics: remove unnecessary leading underscore from argument namesRalf Jung-16/+16
2025-03-12Remove unnecessary lifetime from `PatInfo`.Nicholas Nethercote-25/+27
2025-03-12Auto merge of #137795 - Jarcho:idx_opt, r=davidtwcobors-0/+10
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-12Factor out some repeated code in `parse_item_impl`.Nicholas Nethercote-24/+13
2025-03-12Inline and remove `State::print_item_type`.Nicholas Nethercote-22/+11
It has a single call site. The removal of the closure argument is a nice touch.
2025-03-12Remove unused `OwnerNode::ident` method.Nicholas Nethercote-10/+0
2025-03-12Make panic's more specificKirill Podoprigora-10/+13
2025-03-12Convert a `kw::Empty` occurrence to `sym::dummy`.Nicholas Nethercote-3/+3
`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-12Introduce `sym::dummy` and `Ident::dummy`.Nicholas Nethercote-8/+29
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-12Remove an unnecessary `kw::Empty` check.Nicholas Nethercote-9/+8
Replace it with an assert for now, just in case it is reachable.
2025-03-12Convert a delayed bug to a bug.Nicholas Nethercote-1/+1
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-12Move methods from `Map` to `TyCtxt`, part 4.Nicholas Nethercote-224/+184
Continuing the work from #137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
2025-03-12Rename `hir_attrs` query as `hir_attr_map`.Nicholas Nethercote-6/+6
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-12Adjust `Map`'s `to_string` functionality.Nicholas Nethercote-131/+132
`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-11Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgrbors-218/+286
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-11Refactor pick2_mut & pick3_mut to use get_disjoint_mutKirill Podoprigora-8/+10
2025-03-11Fix false-positive in `expr_or_init` and in the `invalid_from_utf8` lintUrgau-2/+14
2025-03-11Rollup merge of #138354 - lcnr:goodbye-TypeVerifier, r=compiler-errorsMatthias Krüger-173/+153
remove redundant `body` arguments it's already stored in the `TypeChecker` itself
2025-03-11Rollup merge of #138352 - RalfJung:miri-native-calls-exposed, r=oli-obkMatthias Krüger-0/+9
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-11Rollup merge of #138296 - compiler-errors:deanonymous, r=lcnrMatthias Krüger-18/+1
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-11Rollup merge of #138284 - compiler-errors:const-param-ty-annotation, r=BoxyUwUMatthias Krüger-3/+30
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``