Commit Graph

524 Commits

Author SHA1 Message Date
bors
872631d0f0 Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiser
Use `as_deref` in compiler (but only where it makes sense)

This simplifies some code :3

(there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
2022-11-24 00:17:35 +00:00
Charles Lew
d15b020278 Enable icu sync feature for parallel compiler 2022-11-18 14:46:35 -08:00
Maybe Waffle
94470f4efd Use as_deref in compiler (but only where it makes sense) 2022-11-16 21:58:58 +00:00
Joshua Nelson
a68ec22053 Fix rustdoc --version when used with download-rustc
Previously, rustdoc would unconditionally report the version that *rustc* was compiled with.
That showed things like `nightly-2022-10-30`, which wasn't right, since this was a `dev` build compiled from source.

Fix it by changing `rustc_driver::version` to a macro expanded at invocation time.
2022-11-09 02:54:51 -06:00
Nilstrieb
04583f29c8
Simplify code 2022-11-05 17:54:06 +01:00
Dylan DPC
bd9e6e05d2
Rollup merge of #103660 - ozkanonur:master, r=jyn514
improve `filesearch::get_or_default_sysroot`

`fn get_or_default_sysroot` is now improved and used in `miri` and `clippy`, and tests are still passing as they should. So we no longer need to implement custom workarounds/hacks to find sysroot in tools like miri/clippy.

Resolves https://github.com/rust-lang/rust/issues/98832

re-opened from #103581
2022-11-05 11:31:28 +05:30
Onur Özkan
71a3a48ee5 improve filesearch::get_or_default_sysroot r=ozkanonur
Signed-off-by: Onur Özkan <work@onurozkan.dev>
2022-11-04 17:06:47 +03:00
bors
11ebe6512b Auto merge of #103217 - mejrs:track, r=eholk
Track where diagnostics were created.

This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`.

For example, the following code...

```rust
struct A;
struct B;

fn main(){
    let _: A = B;
}
```
...now emits the following error message:

```
error[E0308]: mismatched types
 --> src\main.rs:5:16
  |
5 |     let _: A = B;
  |            -   ^ expected struct `A`, found struct `B`
  |            |
  |            expected due to this
-Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31
```
2022-11-01 21:09:45 +00:00
Nicholas Nethercote
c8c25ce5a1 Rename some OwnerId fields.
spastorino noticed some silly expressions like `item_id.def_id.def_id`.

This commit renames several `def_id: OwnerId` fields as `owner_id`, so
those expressions become `item_id.owner_id.def_id`.

`item_id.owner_id.local_def_id` would be even clearer, but the use of
`def_id` for values of type `LocalDefId` is *very* widespread, so I left
that alone.
2022-10-29 20:28:38 +11:00
Vadim Petrochenkov
34eb73c72d privacy: Rename "accessibility levels" to "effective visibilities"
And a couple of other naming tweaks

Related to https://github.com/rust-lang/rust/issues/48054
2022-10-26 16:34:53 +04:00
mejrs
fae0be5d50 fix tracking hash test 2022-10-26 13:42:41 +02:00
Vadim Petrochenkov
919673ea03 rustc_middle: Rearrange resolver outputs structures slightly 2022-10-25 15:42:29 +04:00
mejrs
854b3166a0 Address some comments 2022-10-24 20:52:51 +02:00
Jakub Beránek
c5c86806c8
Introduce dedicated -Zdylib-lto flag for enabling LTO on dylibs 2022-10-23 13:48:03 +02:00
Nilstrieb
c65ebae221
Migrate all diagnostics 2022-10-23 10:09:44 +02:00
bors
0940040c04 Auto merge of #103310 - lcnr:rustc_hir_typeck, r=compiler-errors
move hir typeck into separate crate

second part https://github.com/rust-lang/compiler-team/issues/529

I avoided pretty much anything that wasn't just a simple move + path adjustment. Left fixmes for methods which are at an odd place

r? `@compiler-errors`
2022-10-21 09:52:18 +00:00
lcnr
fb3ab13a1c rustc_hir_typeck: fix paths and partially mv files 2022-10-20 17:53:14 +02:00
Nicholas Nethercote
5d716fd0e9 Add a comment to Compiler.
It took me a while to work this out.
2022-10-19 17:37:50 +11:00
Nicholas Nethercote
cf13d9143d Clarify run_in_thread_pool_with_globals.
- Make the structure of the two variants more similar.
- Add some comments.
- Move various conditional `use` items inside the function that uses
  them.
- Inline some closures.
2022-10-19 17:37:48 +11:00
Nicholas Nethercote
63db9e540c Replace a spawn_unchecked with spawn_scoped. 2022-10-19 08:09:40 +11:00
Nicholas Nethercote
ec409f95bf Apply Lrc later to sess and codegen_backend.
This avoids the need for a degenerate `Lrc::get_mut` call.
2022-10-19 08:09:40 +11:00
Nicholas Nethercote
b6ae1453cb Inline and remove create_compiler_and_run.
It has a single call site.
2022-10-19 08:09:36 +11:00
Nicholas Nethercote
dcc194e4bf Reduce visibility of some functions. 2022-10-19 07:23:14 +11:00
Nicholas Nethercote
134e9d36ce Inline and remove scoped_thread.
It has a single call site, and removing it slightly improves the
confusing tangle of nested closures present at startup.
2022-10-19 07:23:14 +11:00
Nicholas Nethercote
641f8249f9 Remove RunCompiler::emitter.
It's no longer used.
2022-10-18 08:48:58 +11:00
Nilstrieb
7bfef19844 Use tidy-alphabetical in the compiler 2022-10-12 17:49:10 +05:30
Camille GILLOT
a474ec50b7 Move lifetime resolution module to rustc_hir_analysis. 2022-10-10 17:40:52 +00:00
Matthias Krüger
42df0a580f
Rollup merge of #102725 - nnethercote:rm-Z-time, r=davidtwco
Remove `-Ztime`

Because it has a lot of overlap with `-Ztime-passes` but is generally less useful. Plus some related cleanups.

Best reviewed one commit at a time.

r? `@davidtwco`
2022-10-06 16:29:45 +02:00
Nicholas Nethercote
9110d925d0 Remove -Ztime option.
The compiler currently has `-Ztime` and `-Ztime-passes`. I've used
`-Ztime-passes` for years but only recently learned about `-Ztime`.

What's the difference? Let's look at the `-Zhelp` output:
```
  -Z        time=val -- measure time of rustc processes (default: no)
  -Z time-passes=val -- measure time of each rustc pass (default: no)
```
The `-Ztime-passes` description is clear, but the `-Ztime` one is less so.
Sounds like it measures the time for the entire process?

No. The real difference is that `-Ztime-passes` prints out info about passes,
and `-Ztime` does the same, but only for a subset of those passes. More
specifically, there is a distinction in the profiling code between a "verbose
generic activity" and an "extra verbose generic activity". `-Ztime-passes`
prints both kinds, while `-Ztime` only prints the first one. (It took me
a close reading of the source code to determine this difference.)

In practice this distinction has low value. Perhaps in the past the "extra
verbose" output was more voluminous, but now that we only print stats for a
pass if it exceeds 5ms or alters the RSS, `-Ztime-passes` is less spammy. Also,
a lot of the "extra verbose" cases are for individual lint passes, and you need
to also use `-Zno-interleave-lints` to see those anyway.

Therefore, this commit removes `-Ztime` and the associated machinery. One thing
to note is that the existing "extra verbose" activities all have an extra
string argument, so the commit adds the ability to accept an extra argument to
the "verbose" activities.
2022-10-06 15:49:44 +11:00
bors
0152393048 Auto merge of #99324 - reez12g:issue-99144, r=jyn514
Enable doctests in compiler/ crates

Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-06 03:01:57 +00:00
nils
e8f1bfe193
Fix typo 2022-09-30 21:02:53 +02:00
Camille Gillot
4b1cf846bd
Update compiler/rustc_interface/src/queries.rs 2022-09-30 19:50:48 +02:00
nils
477846f491
Add comment explaining why we flush delayed bugs before codegen 2022-09-30 14:11:18 +02:00
reez12g
9a4c5abe45 Remove from compiler/ crates 2022-09-29 16:49:04 +09:00
Nilstrieb
8a96884981
Flush delayed bugs before codegen
Sometimes it can happen that invalid code like a TyKind::Error makes
its way through the compiler without triggering any errors (this is
always a bug in rustc but bugs do happen sometimes :)). These ICEs
will manifest in the backend like as cg_llvm not being able to get
the layout of `[type error]`, which makes it hard to debug. By flushing
before codegen, we display all the delayed bugs, making it easier to
trace it to the root of the problem.
2022-09-27 20:56:05 +02:00
lcnr
1fc86a63f4 rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
Pietro Albini
3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
fee1-dead
07467c5308
Rollup merge of #101997 - cuviper:drop-legacy-pm, r=nikic
Remove support for legacy PM

This removes support for optimizing with LLVM's legacy pass manager, as well as the unstable `-Znew-llvm-pass-manager` option. We have been defaulting to the new PM since LLVM 13 (except for s390x that waited for 14), and LLVM 15 removed support altogether. The only place we still use the legacy PM is for writing the output file, just like `llc` does.

cc #74705
r? ``@nikic``
2022-09-25 22:06:38 +08:00
Takayuki Maeda
8fe936099a separate definitions and HIR owners
fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-24 23:21:19 +09:00
Jhonny Bill Mena
a3396b2070 UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
Jhonny Bill Mena
19b348fed4 UPDATE - rename DiagnosticHandler trait to IntoDiagnostic 2022-09-21 11:39:52 -04:00
Josh Stone
38e0e8f7bb Remove -Znew-llvm-pass-manager 2022-09-18 13:26:03 -07:00
est31
173eb6f407 Only enable the let_else feature on bootstrap
On later stages, the feature is already stable.

Result of running:

rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-15 21:06:45 +02:00
Daniil Belov
ffa83596fe change rlib format to discern native dependencies 2022-09-12 16:45:03 +03:00
bors
ff479b1f3c Auto merge of #100801 - Kobzol:track-pgo-profile-paths, r=michaelwoerister
Track PGO profiles in depinfo

This PR makes sure that PGO profiles (`-Cprofile-use` and `-Cprofile-sample-use`) are tracked in depinfo, so that when they change, the compilation session will be invalidated.

This approach was discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Tracking.20PGO.20profile.20files.20in.20cargo).

I tried it locally and it seems that the code is recompiled just with this change, and https://github.com/rust-lang/rust/pull/100413 is not even needed. But it's possible that not everything required is recompiled, so we will probably want to land both changes.

Another approach to implement this could be to store the PGO profiles in `sess.parse_sess.file_depinfo` when the session is being created, but then the paths would have to be converted to a string and then to a symbol, which seemed unnecessarily complicated.

CC `@michaelwoerister`

r? `@Eh2406`
2022-09-07 03:17:10 +00:00
Dylan DPC
5d55009b79
Rollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwco
Improve HIR stats

#100398 improve the AST stats collection done by `-Zhir-stats`. This PR does the same for HIR stats collection.

r? `@davidtwco`
2022-09-05 14:15:51 +05:30
Guillaume Gomez
edf79cb86b
Rollup merge of #100552 - petrochenkov:flavorcompat, r=lqd
rustc_target: Add a compatibility layer to separate internal and user-facing linker flavors

I want to do some refactorings in `rustc_target` - merge `lld_flavor` and `linker_is_gnu` into `linker_flavor`, support combination gcc+lld (https://github.com/rust-lang/rust/pull/96827).
This PR adds some compatibility infra that makes that possible without making any changes to user-facing interfaces - `-Clinker-flavor` values and json target specs. (For json target specs this infra may eventually go away since they are not very stable.)

The second commit does some light refactoring of internal linker flavors (applies changes from 53eca42973 that don't require mass-editing target specs).
2022-09-02 11:34:49 +02:00
Oli Scherer
ee3c835018 Always import all tracing macros for the entire crate instead of piecemeal by module 2022-09-01 14:54:27 +00:00
Vadim Petrochenkov
a0e21ff105 rustc_target: Refactor internal linker flavors slightly
Remove one unstable user-facing linker flavor (l4-bender)
2022-09-01 16:54:52 +03:00
Dezhi Wu
b1430fb7ca Fix a bunch of typo
This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-08-31 18:24:55 +08:00