Commit graph

379 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
Michael Goulet
76d341fa09 Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
Urgau
1391f75512
Rollup merge of #137151 - Urgau:register-more-signals, r=workingjubilee
Install more signal stack trace handlers

This PR install the signal stack handler to more signals (`SIGILL`, ~~`SIGTRAP`~~, ~~`SIGABRT`~~, ~~`SIGFPE`~~, `SIGBUS`, ~~`SIGQUIT`~~).

Noticed in https://github.com/rust-lang/rust/issues/137138 that we didn't print anything for `SIGILL`, so I though we could just handle more signals.

r? `````@workingjubilee````` since you last touched it
2025-02-18 18:34:14 +01: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
Urgau
a0a8e02e66 Install more signal stack trace handlers 2025-02-17 18:58:31 +01:00
Nicholas Nethercote
f666361caa Remove TyCtxt::hir_krate.
It's a trivial wrapper around the `hir_crate` query with a small number
of uses.
2025-02-17 13:24:40 +11: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
León Orell Valerian Liehr
9b6fd35738
Reject macro calls inside of #![crate_name] 2025-02-15 16:47:30 +01:00
Jubilee Young
8abff35b41 compiler: compare and hash ExternAbi like its string
Directly map each ExternAbi variant to its string and back again.
This has a few advantages:
- By making the ABIs compare equal to their strings, we can easily
  lexicographically sort them and use that sorted slice at runtime.
- We no longer need a workaround to make sure the hashes remain stable,
  as they already naturally are (by being the hashes of unique strings).
- The compiler can carry around less &str wide pointers
2025-02-11 20:18:01 -08:00
Jubilee Young
54ff6e0ad5 compiler: remove rustc_target::spec::abi reexports 2025-02-09 20:45:47 -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
8a0adec05b Avoid manually producing FatalError in a couple of places 2025-02-06 17:29:15 +00:00
bjorn3
e27495c015 Couple of changes to run rustc in miri 2025-02-05 13:52:22 +00:00
Oli Scherer
f0308938ba Use a different hir type for patterns in pattern types than we use in match patterns 2025-02-03 08:18:30 +00:00
Matthias Krüger
f1bdf3ba4a
Rollup merge of #136445 - bjorn3:diag_ctxt_cleanup, r=oli-obk
Couple of cleanups to DiagCtxt and EarlyDiagCtxt
2025-02-02 23:06:57 +01:00
bjorn3
d237378cd1 Some cleanups around EarlyDiagCtxt
All callers of EarlyDiagCtxt::early_error now emit a fatal error.
2025-02-02 16:06:43 +00:00
Zalathar
24cdaa146a Rename tcx.ensure() to tcx.ensure_ok() 2025-02-01 12:38:54 +11:00
Nicholas Nethercote
4b025ca083 Remove the thir_{tree,flat} hooks.
They were downgraded from queries in #123995 but they can just be
vanilla functions because they are not called in `rustc_middle`.
2025-01-31 15:13:51 +11:00
Mohammad Omidvar
5dfe0f8cf4 Make crate AST mutation accessible for driver callback 2025-01-28 19:45:20 +00: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
a77776cc1d Remove RunCompiler
It has become nothing other than a wrapper around run_compiler.
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
klensy
84ce2e129a bumpt compiler and tools to windows 0.59 2025-01-21 16:48:44 +03: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
bjorn3
056a9cebe9 Respect --target in get_backend_from_raw_matches 2025-01-20 15:47:26 +00:00
Zalathar
93f69b2300 Don't skip argument parsing when running rustc with no arguments
Setting up the argument parser to parse no arguments is a tiny bit of wasted
work, but avoids an otherwise-unnecessary special case.

In particular, this lets us avoid having to deal with multiple different APIs
to determine whether the compiler is nightly or not.
2025-01-19 13:40:37 +11:00
Michael Goulet
be56f10a69 Properly note when query stack is being cut off 2025-01-16 19:12:22 +00:00
bjorn3
3b6e3642ce Respect --sysroot for rustc -vV and -Cpasses=list
This is necessary when the specified codegen backend is in a custom
sysroot.
2025-01-10 11:22:47 +00:00
klensy
37f26311eb add deprecated and do nothing flag to options table
inline_threshold mark deprecated

no-stack-check

print deprecation message for -Car too

inline_threshold deprecated and do nothing: make in untracked

make OptionDesc struct from tuple
2025-01-06 15:38:02 +03:00
Stuart Cook
f4db757cb5
Rollup merge of #131439 - mu001999-contrib:cleanup/static-mut, r=estebank
Remove allowing static_mut_refs lint
2025-01-01 16:35:29 +11:00
jyn
801c1d8b90 fix default-backtrace-ice test
when running `tests/ui/panics/default-backtrace-ice.rs locally it gave this error:
```
failures:

---- [ui] tests/ui/panics/default-backtrace-ice.rs stdout ----
Saved the actual stderr to "/home/jyn/src/rust3/build/x86_64-unknown-linux-gnu/test/ui/panics/default-backtrace-ice/default-backtrace-ice.stderr"
diff of stderr:

7
8	aborting due to `-Z treat-err-as-bug=1`
9	stack backtrace:
-	(end_short_backtrace)
-	(begin_short_backtrace)
-	(end_short_backtrace)
-	(begin_short_backtrace)
+	      [... omitted 22 frames ...]
+
```

this is a regression from setting RUST_BACKTRACE=1 by default. we need to turn off the new behavior when running UI tests so that they reflect our dist compiler. normally that's done by checking `sess.unstable_opts.ui_testing`, but this happens extremely early in the compiler before we've expanded arg files. do an extremely simple hack that doesn't work in all cases - we don't need it to work in all cases, only when running UI tests.
2024-12-25 19:47:28 -05:00
jyn
c7a28d579b Default to short backtraces for dev builds of rustc itself
A dev build almost certainly means that whoever's built the compiler
has the opportunity to rerun it to collect a more complete trace. So
we don't need to default to a complete trace; we should hide irrelevant
details by default.
2024-12-24 20:41:26 -05:00
bjorn3
701e2f708b Reduce the amount of explicit FatalError.raise()
Instead use dcx.abort_if_error() or guar.raise_fatal() instead. These
guarantee that an error actually happened previously and thus we don't
silently abort.
2024-12-20 14:09:25 +00:00
许杰友 Jieyou Xu (Joe)
099faa8beb
Rollup merge of #134420 - Integral-Tech:pathbuf-refactor, r=compiler-errors
refactor: replace &PathBuf with &Path to enhance generality

- According to [style.md](https://github.com/rust-lang/rust/blob/master/src/tools/rust-analyzer/docs/dev/style.md#useless-types):

> More generally, always prefer types on the left
```rust
// GOOD      BAD
&[T]         &Vec<T>
&str         &String
Option<&T>   &Option<T>
&Path        &PathBuf
```
2024-12-18 22:56:56 +08:00
Nicholas Nethercote
2620eb42d7 Re-export more rustc_span::symbol things from rustc_span.
`rustc_span::symbol` defines some things that are re-exported from
`rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some
closely related things such as `Ident` and `kw`. So you can do `use
rustc_span::{Symbol, sym}` but you have to do `use
rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good
reason.

This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`,
and changes many `rustc_span::symbol::` qualifiers in `compiler/` to
`rustc_span::`. This is a 200+ net line of code reduction, mostly
because many files with two `use rustc_span` items can be reduced to
one.
2024-12-18 13:38:53 +11:00
bors
a4cb3c8318 Auto merge of #134381 - jdonszelmann:move-attribute-types, r=oli-obk
Split up attribute parsing code and move data types to `rustc_attr_data_structures`

This change renames `rustc_attr` to `rustc_attr_parsing`, and splits up the parsing code. At the same time, all the data types used move to `rustc_attr_data_structures`. This is in preparation of also having a third crate: `rustc_attr_validation`

I initially envisioned this as two separate PRs, but I think doing it in one go reduces the number of ways others would have to rebase their changes on this. However, I can still split them.

r? `@oli-obk` (we already discussed how this is a first step in a larger plan)

For a more detailed plan on how attributes are going to change, see https://github.com/rust-lang/rust/issues/131229

Edit: this looks like a giant PR, but the changes are actually rather trivial. Each commit is reviewable on its own, and mostly moves code around. No new logic is added.
2024-12-17 18:50:50 +00:00
Integral
7eb0d84424
refactor: replace &PathBuf with &Path to enhance generality 2024-12-18 00:28:34 +08:00
Jonathan Dönszelmann
efb98b6552
rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00
bjorn3
7738929097 Remove two unnecessary references 2024-12-14 14:24:49 +00:00
bjorn3
87802536f4 Remove the parse query 2024-12-14 14:24:49 +00:00
bjorn3
6ece803632 Get rid of of the global_ctxt query 2024-12-14 14:24:35 +00:00
Matthias Krüger
87bbbcd1bb
Rollup merge of #134251 - bjorn3:various_cleanups2, r=oli-obk
A bunch of cleanups (part 2)

Just like https://github.com/rust-lang/rust/pull/133567 these were all found while looking at the respective code, but are not blocking any other changes I want to make in the short term.
2024-12-14 03:54:35 +01:00
bjorn3
981f625ba7 Remove registered_lints field from Session
It only exists to pass some information from one part of the driver to
another part. We can directly pass this information to the function that
needs it to reduce the amount of mutation of the Session.
2024-12-13 10:46:53 +00:00