Commit graph

1194 commits

Author SHA1 Message Date
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
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
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
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
Nicholas Nethercote
936a8232df Change signature of target_features_cfg.
Currently it is called twice, once with `allow_unstable` set to true and
once with it set to false. This results in some duplicated work. Most
notably, for the LLVM backend, `LLVMRustHasFeature` is called twice for
every feature, and it's moderately slow. For very short running
compilations on platforms with many features (e.g. a `check` build of
hello-world on x86) this is a significant fraction of runtime.

This commit changes `target_features_cfg` so it is only called once, and
it now returns a pair of feature sets. This halves the number of
`LLVMRustHasFeature` calls.
2025-03-05 09:49:17 +11:00
Zalathar
32c5449d45 Remove some unnecessary aliases from rustc_data_structures::sync
With the removal of `cfg(parallel_compiler)`, these are always shared
references and `std::sync::OnceLock`.
2025-03-03 20:20:24 +11:00
bors
15469f8f8a Auto merge of #137420 - matthiaskrgr:rollup-rr0q37f, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #136910 (Implement feature `isolate_most_least_significant_one` for integer types)
 - #137183 (Prune dead regionck code)
 - #137333 (Use `edition = "2024"` in the compiler (redux))
 - #137356 (Ferris 🦀 Identifier naming conventions)
 - #137362 (Add build step log for `run-make-support`)
 - #137377 (Always allow reusing cratenum in CrateLoader::load)
 - #137388 (Fix(lib/fs/tests): Disable rename POSIX semantics FS tests under Windows 7)
 - #137410 (Use StableHasher + Hash64 for dep_tracking_hash)
 - #137413 (jubilee cleared out the review queue)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-22 13:32:44 +00:00
Matthias Krüger
72e41e5d65
Rollup merge of #137356 - nik-rev:FERRIS, r=compiler-errors
Ferris 🦀 Identifier naming conventions

You cannot use Ferris as an identifier in Rust, this code will suggest to correct the  🦀 to `ferris`:

```rs
fn main() {
  let  🦀 = 4;
}
```

But it also suggests to correct to `ferris` in these cases, too:

```rs
struct  🦀 {}
fn main() {}
```

^ suggests: `ferris`
~ with this PR: `Ferris`

```rs
static 🦀: &str = "ferris!";
fn main() {}
```

^ suggests: `ferris`
~ with this PR: `FERRIS`

This is my first pull requests here!
2025-02-22 11:36:44 +01:00
Manuel Drehwald
e2d250c3f6 update autodiff flags 2025-02-21 21:51:20 -05:00
Michael Goulet
e1819a889a Fix overcapturing, unsafe extern blocks, and new unsafe ops 2025-02-22 00:01:48 +00:00
Michael Goulet
76d341fa09 Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
Nikita Revenco
ec88bc2e00 fix: naming convention "ferris" suggestion for idents named 🦀
test: add tests for correct ferris capitalization

fix: add "struct"

style: use rustfmt

style: remove newline

fix: _

_

_

_

_
2025-02-21 20:44:35 +00:00
Nicholas Nethercote
fd7b4bf4e1 Move methods from Map to TyCtxt, part 2.
Continuing the work started in #136466.

Every method gains a `hir_` prefix, though for the ones that already
have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-18 10:17:44 +11:00
Matthias Krüger
0c051c8196
Rollup merge of #136671 - nnethercote:middle-limits, r=Nadrieril
Overhaul `rustc_middle::limits`

In particular, to make `pattern_complexity` work more like other limits, which then enables some other simplifications.

r? ``@Nadrieril``
2025-02-17 06:37:35 +01:00
Nicholas Nethercote
f86f7ad5f2 Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11:00
Nicholas Nethercote
7a8c0fc117 Rename pattern_complexity attr as pattern_complexity_limit.
For consistency with `recursion_limit`, `move_size_limit`, and
`type_length_limit`.
2025-02-17 09:30:40 +11:00
Nicholas Nethercote
223c95fd59 Move rustc_middle::limits to rustc_interface.
It's always good to make `rustc_middle` smaller. `rustc_interface` is
the best destination, because it's the only crate that calls
`get_recursive_limit`.
2025-02-17 09:30:39 +11:00
León Orell Valerian Liehr
9b6fd35738
Reject macro calls inside of #![crate_name] 2025-02-15 16:47:30 +01:00
bors
124cc92199 Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrum
Update bootstrap compiler and rustfmt

The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same
time.
2025-02-09 15:44:16 +00:00
Jubilee
5e4d6278af
Rollup merge of #136706 - workingjubilee:finish-up-rustc-abi-updates, r=compiler-errors
compiler: mostly-finish `rustc_abi` updates

This almost-finishes all the updates in the compiler to use `rustc_abi` and removes some of the reexports of `rustc_abi` items in `rustc_target` that were previously available.

r? ```@compiler-errors```
2025-02-08 20:41:21 -08:00
bjorn3
1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
Matthias Krüger
688fc9bd21
Rollup merge of #136589 - GuillaumeGomez:enable-jump-to-def-compiler, r=oli-obk
Enable "jump to def" feature on rustc docs

This PR enables the rustdoc "jump to def" feature which is visible on the source code pages.

r? ``@oli-obk``
2025-02-07 21:31:01 +01:00
Jubilee Young
1f37b9a643 compiler: remove rustc_target::abi entirely 2025-02-07 11:23:12 -08:00
Matthias Krüger
79e5424e31
Rollup merge of #136636 - bjorn3:error_cleanup, r=compiler-errors
Couple of minor cleanups to the diagnostic infrastructure
2025-02-06 21:56:28 +01:00
bjorn3
9a833de62a Construct DiagCtxt a bit earlier in build_session 2025-02-06 17:29:15 +00:00
bors
942db6782f Auto merge of #136641 - matthiaskrgr:rollup-lajwje5, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #136073 (Always compute coroutine layout for eagerly emitting recursive layout errors)
 - #136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern)
 - #136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types)
 - #136315 (Use short ty string for binop and unop errors)
 - #136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns)
 - #136435 (Simplify some code for lowering THIR patterns)
 - #136630 (Change two std process tests to not output to std{out,err}, and fix test suite stat reset in bootstrap CI test rendering)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: aarch64-gnu-debug
2025-02-06 17:08:45 +00:00
bors
2f92f050e8 Auto merge of #136471 - safinaskar:parallel, r=SparrowLii
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`

tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`

This is continuation of https://github.com/rust-lang/rust/pull/132282 .

I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement.

There are other possibilities, through.

We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase.

So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge.

cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 )

r? SparrowLii

`@rustbot` label WG-compiler-parallel
2025-02-06 10:50:05 +00:00
Michael Goulet
d0b0b028a6 Eagerly detect coroutine recursion pre-mono when possible 2025-02-05 18:36:17 +00:00
Guillaume Gomez
e58aa2105f Re-enable "jump to def" feature on rustc docs 2025-02-05 17:40:33 +01:00
Askar Safin
0a21f1d0a2 tree-wide: parallel: Fully removed all Lrc, replaced with Arc 2025-02-03 13:25:57 +03:00
bors
7daf4cf911 Auto merge of #133138 - azhogin:azhogin/target-modifiers, r=davidtwco,saethlin
Target modifiers (special marked options) are recorded in metainfo

Target modifiers (special marked options) are recorded in metainfo and compared to be equal in different linked crates.

PR for this RFC: https://github.com/rust-lang/rfcs/pull/3716

Option may be marked as `TARGET_MODIFIER`, example: `regparm: Option<u32> = (None, parse_opt_number, [TRACKED TARGET_MODIFIER]`.
If an TARGET_MODIFIER-marked option has non-default value, it will be recorded in crate metainfo as a `Vec<TargetModifier>`:
```
pub struct TargetModifier {
    pub opt: OptionsTargetModifiers,
    pub value_name: String,
}
```

OptionsTargetModifiers is a macro-generated enum.

Option value code (for comparison) is generated using `Debug` trait.

Error example:
```
error: mixing `-Zregparm` will cause an ABI mismatch in crate `incompatible_regparm`
  --> $DIR/incompatible_regparm.rs:10:1
   |
LL | #![crate_type = "lib"]
   | ^
   |
   = help: the `-Zregparm` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
   = note: `-Zregparm=1` in this crate is incompatible with `-Zregparm=2` in dependency `wrong_regparm`
   = help: set `-Zregparm=2` in this crate or `-Zregparm=1` in `wrong_regparm`
   = help: if you are sure this will not cause problems, use `-Cunsafe-allow-abi-mismatch=regparm` to silence this error

error: aborting due to 1 previous error
```

`-Cunsafe-allow-abi-mismatch=regparm,reg-struct-return` to disable list of flags.
2025-02-03 07:16:57 +00:00
Andrew Zhogin
05c88a31e7 Target modifiers (special marked options) are recorded in metainfo and compared to be equal in different crates 2025-02-02 22:12:49 +07:00
Zalathar
9e4f10db65 Rename tcx.ensure_with_value() to tcx.ensure_done() 2025-02-01 12:42:39 +11:00
Zalathar
24cdaa146a Rename tcx.ensure() to tcx.ensure_ok() 2025-02-01 12:38:54 +11:00
bors
7f36543a48 Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhpratt
Rollup of 9 pull requests

Successful merges:

 - #132156 (When encountering unexpected closure return type, point at return type/expression)
 - #133429 (Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle)
 - #136281 (`rustc_hir_analysis` cleanups)
 - #136297 (Fix a typo in profile-guided-optimization.md)
 - #136300 (atomic: extend compare_and_swap migration docs)
 - #136310 (normalize `*.long-type.txt` paths for compare-mode tests)
 - #136312 (Disable `overflow_delimited_expr` in edition 2024)
 - #136313 (Filter out RPITITs when suggesting unconstrained assoc type on too many generics)
 - #136323 (Fix a typo in conventions.md)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-31 09:42:28 +00:00
Jacob Pratt
c19c4b91f5
Rollup merge of #133429 - EnzymeAD:autodiff-middle, r=oli-obk
Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle

This PR should not be merged until the rustc_codegen_llvm part is merged.
I will also alter it a little based on what get's shaved off from the cg_llvm PR,
and address some of the feedback I received in the other PR (including cleanups).

I am putting it already up to
1) Discuss with `@jieyouxu` if there is more work needed to add tests to this and
2) Pray that there is someone reviewing who can tell me why some of my autodiff invocations get lost.

Re 1: My test require fat-lto. I also modify the compilation pipeline. So if there are any other llvm-ir tests in the same compilation unit then I will likely break them. Luckily there are two groups who currently have the same fat-lto requirement for their GPU code which I have for my autodiff code and both groups have some plans to enable support for thin-lto. Once either that work pans out, I'll copy it over for this feature. I will also work on not changing the optimization pipeline for functions not differentiated, but that will require some thoughts and engineering, so I think it would be good to be able to run the autodiff tests isolated from the rest for now. Can you guide me here please?
For context, here are some of my tests in the samples folder: https://github.com/EnzymeAD/rustbook

Re 2: This is a pretty serious issue, since it effectively prevents publishing libraries making use of autodiff: https://github.com/EnzymeAD/rust/issues/173. For some reason my dummy code persists till the end, so the code which calls autodiff, deletes the dummy, and inserts the code to compute the derivative never gets executed. To me it looks like the rustc_autodiff attribute just get's dropped, but I don't know WHY? Any help would be super appreciated, as rustc queries look a bit voodoo to me.

Tracking:

- https://github.com/rust-lang/rust/issues/124509

r? `@jieyouxu`
2025-01-31 00:26:30 -05:00
Michael Goulet
37a430e6ea Remove print_vtable_sizes 2025-01-30 15:30:04 +00:00
Manuel Drehwald
1f30517d40 upstream rustc_codegen_ssa/rustc_middle changes for enzyme/autodiff 2025-01-29 21:31:13 -05:00
León Orell Valerian Liehr
7e123e4940
Rollup merge of #136147 - RalfJung:required-target-features-check-not-add, r=workingjubilee
ABI-required target features: warn when they are missing in base CPU

Part of https://github.com/rust-lang/rust/pull/135408:
instead of adding ABI-required features to the target we build for LLVM, check that they are already there. Crucially we check this after applying `-Ctarget-cpu` and `-Ctarget-feature`, by reading `sess.unstable_target_features`. This means we can tweak the ABI target feature check without changing the behavior for any existing user; they will get warnings but the target features behave as before.

The test changes here show that we are un-doing the "add all required target features" part. Without the full #135408, there is no way to take a way an ABI-required target feature with `-Ctarget-cpu`, so we cannot yet test that part.

Cc ``@workingjubilee``
2025-01-29 03:12:21 +01:00
bors
aa6f5ab18e Auto merge of #133929 - saethlin:remove-inline-in-all-cgus, r=nnethercote
Remove -Zinline-in-all-cgus and clean up tests/codegen-units/

Implementation of https://github.com/rust-lang/compiler-team/issues/814

I've taken some liberties with cleaning up the CGU partitioning tests, because that's the only place this flag was used and also mattered. I've often fought a lot with the contents of `tests/codegen-units` and it has never been clear to me when a test failure indicates a problem with my changes as opposed to a test just needing to be manually blessed. Hopefully the combination of the new README, new comments, and using `-Zprint-mono-items=lazy` in the partitioning tests improves that.

I've also deleted some of the `tests/run-make/sepcomp` tests. I think all the "sepcomp" tests have been obviated for years by better-designed (less flaky, clearer failures) test suites, but here I'm just deleting the ones I'm confident in.
2025-01-28 09:43:03 +00:00
Ben Kimock
bf9df97660 Remove -Zinline-in-all-cgus and clean up CGU partitioning tests 2025-01-27 23:48:47 -05:00
Ralf Jung
93ee180cfa ABI-required target features: warn when they are missing in base CPU (rather than silently enabling them) 2025-01-28 04:40:42 +01:00
Matthias Krüger
7d31ae7f35
Rollup merge of #135880 - bjorn3:misc_driver_refactors, r=oli-obk
Get rid of RunCompiler

The various `set_*` methods that have been removed can be replaced by setting the respective fields in the `Callbacks::config` implementation. `set_using_internal_features` was often forgotten and it's equivalent is now done automatically.
2025-01-23 19:54:26 +01:00
bjorn3
241f8244e8 Remove outdated sentence 2025-01-23 09:38:58 +00:00
bjorn3
974db1a6e4 Remove set_make_codegen_backend and set_file_loader
They can both be set inside the config callback too.
2025-01-23 09:38:58 +00:00
bjorn3
4f9b9a43c1 Remove the need to manually call set_using_internal_features 2025-01-23 09:38:58 +00:00
Matthias Krüger
5fab5429c4
Rollup merge of #135596 - compiler-errors:stack, r=oli-obk
Properly note when query stack is being cut off

cc #70953

also, i'm not certain whether we should even limit this at all. i don't see the problem with printing the full query stack, apparently it was limited b/c we used to ICE? but we're already printing the full stack to disk since #108714.

r? oli-obk
2025-01-22 20:37:25 +01:00
Matthias Krüger
c8c5fa4893
Rollup merge of #135330 - bjorn3:respect_sysroot_in_version_printing, r=lqd
Respect --sysroot for rustc -vV and -Cpasses=list

This is necessary when the specified codegen backend is in a custom sysroot.

Fixes https://github.com/rust-lang/rust/issues/135165
2025-01-20 20:58:35 +01:00