Commit Graph

1007 Commits

Author SHA1 Message Date
Michael Goulet
c80d9b8d67 Don't ICE when encountering placeholders in layout computation 2025-03-24 16:57:07 +00:00
Nicholas Nethercote
8121958fda Use -Wunused_crate_dependencies for compiler crates.
It's very useful. There are some false positives involving integration
tests in `rustc_pattern_analysis` and `rustc_serialize`. There is also a
false positive involving `rustc_driver_impl`'s
`rustc_randomized_layouts` feature. And I removed a `rustc_span` mention
in a doc comment in `rustc_log` because it wasn't integral to the
comment but caused a dev-dependency.
2025-03-20 08:59:43 +11:00
Michael Goulet
93b31d9b21 Remove existing AFIDT implementation 2025-03-18 17:35:26 +00:00
Michael Goulet
b88f85a410 Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
Michael Goulet
e5a2220327 Fold visit into ty 2025-03-15 06:34:36 +00:00
Michael Goulet
dc0cdfd753 Squash fold into ty 2025-03-15 06:34:36 +00:00
bors
8536f201ff Auto merge of #138416 - Manishearth:rollup-fejor9p, r=Manishearth
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-13 01:37:26 +00:00
bors
249cb84316 Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr
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-12 17:27:43 +00:00
Manish Goregaokar
84a2b689ac
Rollup merge of #138394 - lcnr:yeet-variant, r=compiler-errors
remove unnecessary variant
2025-03-12 10:19:32 -07:00
Manish Goregaokar
245d3a90ca
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 10:19:30 -07:00
Manish Goregaokar
f88f27aff0
Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar
Move methods from Map to TyCtxt, part 4.

A follow-up to https://github.com/rust-lang/rust/pull/137350.

r? ```@Zalathar```
2025-03-12 10:19:26 -07: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
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
lcnr
adbcb910f0 remove unnecessary variant 2025-03-12 10:12:53 +01: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
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
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
Oli Scherer
69a1bb8bdb Error on define_opaques entries without any opaques actually referenced 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
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
许杰友 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
916f9552e9 Reject wrapping ranges of pattern types 2025-03-10 09:27:13 +00:00
Matthias Krüger
bfa1a62fd4
Rollup merge of #138158 - moulins:move-layout-to-rustc_abi, r=workingjubilee
Move more layouting logic to `rustc_abi`

Move all `LayoutData`-constructing code to `rustc_abi`:
- Infaillible operations get a new `LayoutData` constructor method;
- Faillible ones get a new method on `LayoutCalculator`.
2025-03-09 10:34:51 +01:00
Matthias Krüger
48caf81484
Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxu
Use workspace lints for crates in `compiler/`

This is nicer and hopefully less error prone than specifying lints via bootstrap.

r? ``@jieyouxu``
2025-03-09 10:34:50 +01:00
Matthias Krüger
5a46f82d7e
Rollup merge of #136968 - oli-obk:bye-bye, r=compiler-errors
Turn order dependent trait objects future incompat warning into a hard error

fixes #56484

r? ``@ghost``

will FCP when we have a crater result
2025-03-09 10:34:47 +01:00
Moulins
08530d3e99 Move coroutine layout logic to rustc_abi 2025-03-08 16:16:23 +01:00
Moulins
b8a217081d Refactor coroutine layout logic to precompute all sublayouts
Also properly attaches spans on layouts of non-promoted coroutine
locals, which slightly improves the error messages for some coroutine tests.
2025-03-08 12:36:45 +01:00
Moulins
e69491ac60 Move SIMD layout logic to rustc_abi 2025-03-08 12:35:32 +01:00
Moulins
9917173575 Remove most manual LayoutData creations and move them to rustc_abi
...either as:
- methods on LayoutCalculator, for faillible operations;
- constructors on LayoutData, for infaillible ones.
2025-03-08 12:27:19 +01:00
Nicholas Nethercote
8a3e03392e Remove #![warn(unreachable_pub)] from all compiler/ crates.
(Except for `rustc_codegen_cranelift`.)

It's no longer necessary now that `unreachable_pub` is in the workspace
lints.
2025-03-08 08:41:43 +11:00
Nicholas Nethercote
beba32cebb Specify rust lints for compiler/ crates via Cargo.
By naming them in `[workspace.lints.rust]` in the top-level
`Cargo.toml`, and then making all `compiler/` crates inherit them with
`[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`,
because they're a bit different.)

The advantages of this over the current approach:
- It uses a standard Cargo feature, rather than special handling in
  bootstrap. So, easier to understand, and less likely to get
  accidentally broken in the future.
- It works for proc macro crates.

It's a shame it doesn't work for rustc-specific lints, as the comments
explain.
2025-03-08 08:41:09 +11:00
Matthias Krüger
0defc4f27f
Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorino
Reduce `kw::Empty` usage, part 1

This PR fixes some confusing `kw::Empty` usage, fixing a crash test along the way.

r? ```@spastorino```
2025-03-07 19:15:34 +01:00
Matthias Krüger
f5a143f796
Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis
Ergonomic ref counting

This is an experimental first version of ergonomic ref counting.

This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations.

RFC: https://github.com/rust-lang/rfcs/pull/3680
Tracking issue: https://github.com/rust-lang/rust/issues/132290
Project goal: https://github.com/rust-lang/rust-project-goals/issues/107

r? ```@nikomatsakis```
2025-03-07 19:15:33 +01:00
Nicholas Nethercote
af92a33dee Make synthetic RPITIT assoc ty name handling more rigorous.
Currently it relies on special treatment of `kw::Empty`, which is really
easy to get wrong. This commit makes the special case clearer in the
type system by using `Option`. It's a bit clumsy, but the synthetic name
handling itself is a bit clumsy; better to make it explicit than sneak
it in.

Fixes #133426.
2025-03-07 20:59:45 +11:00
Nicholas Nethercote
7943932384 Pass Option<Symbol> to def_path_data/create_def methods.
It's clearer than using `kw::Empty` to mean `None`.
2025-03-07 20:53:00 +11:00
Nicholas Nethercote
293fe0a966 Increase recursion_limit in numerous crates.
This is temporarily needed for `x doc compiler` to work. They can be
removed once the `Nonterminal` is removed (#124141).
2025-03-07 14:51:07 +11:00
Santiago Pastorino
b43b700250
Account for UseCloned on expr_use_visitor 2025-03-06 17:58:34 -03:00
Santiago Pastorino
05c516446a
Implement .use keyword as an alias of clone 2025-03-06 17:58:32 -03:00
Oli Scherer
e8f7a382be Remove the Option part of range ends in the HIR 2025-03-06 10:47:40 +00:00
Oli Scherer
0e7b283573 Avoid having to handle an Option in the type system 2025-03-06 10:03:11 +00:00
Oli Scherer
4f2b108816 Prefer a two value enum over bool 2025-03-06 10:03:11 +00:00
许杰友 Jieyou Xu (Joe)
fe4c0850fe
Rollup merge of #138028 - workingjubilee:is-rustic-abi, r=compiler-errors
compiler: add `ExternAbi::is_rustic_abi`

Various parts of the compiler were hand-rolling this extremely simple check that is nonetheless easy to get wrong as the compiler evolves over time. Discourage them from being so "original" again by replacing it with a single implementation on the type that represents these ABIs. This simplifies a surprising amount of code as a result.

Also fixes #132981, an ICE that emerged due to other checks being made stricter.
2025-03-05 21:46:46 +08:00
许杰友 Jieyou Xu (Joe)
257b4947ed
Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk
Remove unsizing coercions for tuples

See https://github.com/rust-lang/rust/issues/42877#issuecomment-2686010847 and below comments for justification.

Tracking issue: #42877
Fixes: #135217
2025-03-05 21:46:44 +08:00
Jubilee Young
8a689878ce compiler: use is_rustic_abi in ty_utils
expands some conditionals to include different "rustic" ABIs, so that we
actually handle passing args through all "rustic" ABIs
2025-03-04 19:57:51 -08:00
Moulins
cbe32a7647 Remove layouting dead code for non-array SIMD types.
These aren't supported anymore, and are already rejected in type checking.
2025-03-02 12:50:14 +01:00
Matthias Krüger
3bf976542a
Rollup merge of #137804 - RalfJung:backend-repr-simd-vector, r=workingjubilee
rename BackendRepr::Vector → SimdVector

For many Rustaceans, "vector" does not imply "SIMD", so let's be more clear in this type that is used pervasively in the compiler.

r? `@workingjubilee`
2025-03-01 16:03:10 +01:00
Ralf Jung
aac65f562b rename BackendRepr::Vector → SimdVector 2025-02-28 17:17:45 +01:00
许杰友 Jieyou Xu (Joe)
0cb9827d70
Rollup merge of #137770 - compiler-errors:unsafe-binder-sized-crit, r=oli-obk
Fix sized constraint for unsafe binder

Fixes #137705
r? oli-obk
2025-02-28 22:29:56 +08:00