Commit Graph

1358 Commits

Author SHA1 Message Date
bors
8679004993 Auto merge of #125434 - nnethercote:rm-more-extern-tracing, r=jackh726
Remove more `#[macro_use] extern crate tracing`

Because explicit importing of macros via use items is nicer (more standard and readable) than implicit importing via `#[macro_use]`. Continuing the work from #124511 and #124914.

r? `@jackh726`
2024-05-23 21:36:54 +00:00
Matthias Krüger
c9e457dbd6
Rollup merge of #125409 - tbu-:pr_raw_dylib_only_windows, r=lcnr
Rename `FrameworkOnlyWindows` to `RawDylibOnlyWindows`

Frameworks are Apple-specific, no idea why it had "framework" in the name before.
2024-05-23 14:09:24 +02:00
Matthias Krüger
eda4a35f36
Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk
rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from https://github.com/rust-lang/rust/pull/121167.
2024-05-23 14:09:23 +02:00
Nicholas Nethercote
d787fb062c Remove #[macro_use] extern crate tracing from rustc_metadata. 2024-05-23 18:02:40 +10:00
bors
22f5bdc42b Auto merge of #124686 - saethlin:rust-file-footer, r=fmease
Add a footer in FileEncoder and check for it in MemDecoder

We have a few reports of ICEs due to decoding failures, where the fault does not lie with the compiler. The goal of this PR is to add some very lightweight and on-by-default validation to the compiler's outputs. If validation fails, we emit a fatal error for rmeta files in general that mentions the path that didn't load, and for incremental compilation artifacts we emit a verbose warning that tries to explain the situation and treat the artifacts as outdated.

The validation currently implemented here is very crude, and yet I think we have 11 ICE reports currently open (you can find them by searching issues for `1002111927320821928687967599834759150`) which this simple validation would have detected. The structure of the code changes here should permit the addition of further validation code, such as a checksum, if it is merited. I would like to have code to detect corruption such as reported in https://github.com/rust-lang/rust/issues/124719, but I'm not yet sure how to do that efficiently, and this PR is already a good size.

The ICE reports I have in mind that this PR would have smoothed over are:
https://github.com/rust-lang/rust/issues/124469
https://github.com/rust-lang/rust/issues/123352
https://github.com/rust-lang/rust/issues/123376 [^1]
https://github.com/rust-lang/rust/issues/99763
https://github.com/rust-lang/rust/issues/93900.

---

[^1]: This one might be a compiler bug, but even if it is I think the workflow described is pushing the envelope of what we can support. This issue is one of the reasons this warning still asks people to file an issue.
2024-05-22 15:59:56 +00:00
Vadim Petrochenkov
711338bd9f rustc: Use tcx.used_crates(()) more
And explain when it should be used.
2024-05-22 18:02:51 +03:00
Tobias Bucher
72968e5198 Rename FrameworkOnlyWindows to RawDylibOnlyWindows
Frameworks are Apple-specific, no idea why it had "framework" in the
name before.
2024-05-22 16:29:27 +02:00
Ben Kimock
c3a606237d PR feedback 2024-05-21 20:12:30 -04:00
Ben Kimock
95150d7246 Add a footer in FileEncoder and check for it in MemDecoder 2024-05-21 20:12:29 -04:00
Xiretza
98dd6c7e8f Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
Xiretza
8004e6a379 Make early lints translatable 2024-05-21 20:16:39 +00:00
Xiretza
b7abf014ec Convert uses of BuiltinLintDiag::Normal to custom variants
This ensures all diagnostic messages are created at diagnostic emission
time, making them translatable.
2024-05-21 20:16:39 +00:00
Nicholas Nethercote
d8ea468994 Reorder some use items. 2024-05-21 14:55:37 +10:00
Nicholas Nethercote
eb10eb2b45 Reorder top-level attributes.
And remove an unnecessary `feature(try_blocks)`.
2024-05-21 14:55:37 +10:00
Nicholas Nethercote
00cfb45b54 Remove extern crate rustc_middle from rustc_metadata. 2024-05-13 08:20:18 +10:00
Michael Goulet
1c19b6ad60 Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
Guillaume Gomez
871f047c4c
Rollup merge of #124582 - RalfJung:std-not-found, r=Nilstrieb
always print nice 'std not found' error when std is not found

Fixes https://github.com/rust-lang/miri/issues/3529

Arguably Miri is doing something odd by letting people create no-std sysroots for arbitrary targets -- but equally arguably, there's no good reason for rustc to special-case the host triple here. Being a non-host triple does not imply the target is a no-std target, after all.
2024-05-02 15:11:22 +02:00
Mark Rousskov
a64f941611 Step bootstrap cfgs 2024-05-01 22:19:11 -04:00
Ralf Jung
6115cf6f41 always print nice 'std not found error' when std is not found 2024-05-01 17:11:49 +02:00
Nicholas Nethercote
4814fd0a4b Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
Oli Scherer
aef0f4024a Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00
bors
244da22fab Auto merge of #123126 - oli-obk:feed_crate_num, r=davidtwco
Enable `CrateNum` query feeding via `TyCtxt`

Instead of having a magic function that violates some `TyCtxtFeed` invariants, add a `create_def` equivalent for `CrateNum`s.

Note that this still isn't tracked by the query system (unlike `create_def`), and that feeding most `CrateNum` queries for crates other than the local one will likely cause performance regressions.

These things should be attempted on their own separately, but this PR should stand on its own
2024-04-23 20:46:48 +00:00
Matthias Krüger
36316df9fe
Rollup merge of #124067 - RalfJung:weak-lang-items, r=davidtwco
weak lang items are not allowed to be #[track_caller]

For instance the panic handler will be called via this import
```rust
        extern "Rust" {
            #[lang = "panic_impl"]
            fn panic_impl(pi: &PanicInfo<'_>) -> !;
        }
```
A `#[track_caller]` would add an extra argument and thus make this the wrong signature.

The 2nd commit is a consistency rename; based on the docs [here](https://doc.rust-lang.org/unstable-book/language-features/lang-items.html) and [here](https://rustc-dev-guide.rust-lang.org/lang-items.html) I figured "lang item" is more widely used. (In the compiler output, "lang item" and "language item" seem to be pretty even.)
2024-04-23 12:10:25 +02:00
Markus Reiter
33e68aadc9
Stabilize generic NonZero. 2024-04-22 18:48:47 +02:00
Oli Scherer
9e63e991e9 Prepare for CrateNum query feeding on creation 2024-04-19 14:16:18 +00:00
Oli Scherer
0025c9cc50 Isolate CrateNum creation to TyCtxt methods 2024-04-19 14:16:18 +00:00
Oli Scherer
fbc9b94064 Move stable_crate_ids from CrateStore to Untracked
This way it's like `Definitions`, which creates `DefId`s by interning `DefPathData`s, but for interning stable crate hashes
2024-04-19 14:16:18 +00:00
Oli Scherer
10be74569c Create new CrateNum only after knowing it's going to succeed 2024-04-19 14:09:19 +00:00
Ralf Jung
8b35be741f consistency rename: language item -> lang item 2024-04-17 13:00:43 +02:00
Vadim Petrochenkov
ed62b57c86 linker: Remove laziness and caching from native search directory walks
It shouldn't be necessary for performance now.
2024-04-12 17:28:00 +03:00
Matthias Krüger
7f111834ad
Rollup merge of #123827 - petrochenkov:searchdirs, r=Nadrieril
linker: Avoid some allocations in search directory iteration

This is more a cleanup than actual optimization.
2024-04-12 04:38:23 +02:00
Vadim Petrochenkov
4ded0b82ca linker: Avoid some allocations in search directory iteration 2024-04-12 00:41:08 +03:00
Matthias Krüger
f9ca213510 remove some things that do not need to be 2024-04-11 21:09:52 +02:00
bors
bd12986fd6 Auto merge of #123099 - oli-obk:span_tcx, r=petrochenkov
Replace some `CrateStore` trait methods with hooks.

Just like with the `CrateStore` trait, this avoids the cyclic definition issues with `CStore` being
defined after TyCtxt, but needing to be used in TyCtxt.
2024-04-09 03:04:20 +00:00
Urgau
106146fd95 Replace RemapFileNameExt::for_codegen with explicit calls 2024-03-28 18:47:26 +01:00
Oli Scherer
24fc6e96d6 Make def_path_hash_to_def_id a hook 2024-03-27 08:20:06 +00:00
Oli Scherer
0f5911c626 Move CrateStore::expn_hash_to_expn_id to a hook 2024-03-27 08:20:06 +00:00
Oli Scherer
32bd3c30d8 Start replacing CStore trait methods with hooks.
This also avoids the cyclic definition issues with CrateStore being
defined after TyCtxt, but needing to be used in TyCtxt.
2024-03-27 08:20:00 +00:00
Matthias Krüger
04eedb24c9
Rollup merge of #122757 - h1467792822:priv-dep, r=davidtwco
Fixed the `private-dependency` bug

Fixed the private-dependency bug: If the directly dependent crate is loaded last and is not configured with `--extern`, it may be incorrectly set to `private-dependency`

Fixes #122756
2024-03-24 17:08:15 +01:00
Michael Goulet
3361488681 Always encode implied_predicates query for traits
With associated type bounds enabled, the implied_predicates and super_predicates
queries may differ for traits, since associated type bounds are also
implied but are not counted as super predicates.
2024-03-22 13:20:54 -04:00
bors
47dd709bed Auto merge of #121123 - compiler-errors:item-assumptions, r=oli-obk
Split an item bounds and an item's super predicates

This is the moral equivalent of #107614, but instead for predicates this applies to **item bounds**. This PR splits out the item bounds (i.e. *all* predicates that are assumed to hold for the alias) from the item *super predicates*, which are the subset of item bounds which share the same self type as the alias.

## Why?

Much like #107614, there are places in the compiler where we *only* care about super-predicates, and considering predicates that possibly don't have anything to do with the alias is problematic. This includes things like closure signature inference (which is at its core searching for `Self: Fn(..)` style bounds), but also lints like `#[must_use]`, error reporting for aliases, computing type outlives predicates.

Even in cases where considering all of the `item_bounds` doesn't lead to bugs, unnecessarily considering irrelevant bounds does lead to a regression (#121121) due to doing extra work in the solver.

## Example 1 - Trait Aliases

This is best explored via an example:

```
type TAIT<T> = impl TraitAlias<T>;

trait TraitAlias<T> = A + B where T: C;
```

The item bounds list for `Tait<T>` will include:
* `Tait<T>: A`
* `Tait<T>: B`
* `T: C`

While `item_super_predicates` query will include just the first two predicates.

Side-note: You may wonder why `T: C` is included in the item bounds for `TAIT`? This is because when we elaborate `TraitAlias<T>`, we will also elaborate all the predicates on the trait.

## Example 2 - Associated Type Bounds

```
type TAIT<T> = impl Iterator<Item: A>;
```

The `item_bounds` list for `TAIT<T>` will include:
* `Tait<T>: Iterator`
* `<Tait<T> as Iterator>::Item: A`

But the `item_super_predicates` will just include the first bound, since that's the only bound that is relevant to the *alias* itself.

## So what

This leads to some diagnostics duplication just like #107614, but none of it will be user-facing. We only see it in the UI test suite because we explicitly disable diagnostic deduplication.

Regarding naming, I went with `super_predicates` kind of arbitrarily; this can easily be changed, but I'd consider better names as long as we don't block this PR in perpetuity.
2024-03-21 06:12:24 +00:00
Michael Goulet
aa39dbb962 Split item bounds and item super predicates 2024-03-20 13:00:34 -04:00
bors
94b72d6beb Auto merge of #122359 - Zoxc:missing-static-notes, r=wesleywiser
Print the crates not available as static

This prints out the crates not available to be statically linked when static linking is preferred and we run into an error with duplicated crates.
2024-03-20 15:46:15 +00:00
h1467792822
92325a95b3 Fixed the private-dependency bug: If the directly dependent crate is loaded last and is not configured with --extern, it may be incorrectly set to private-dependency 2024-03-20 16:33:50 +08:00
Matthias Krüger
4f3050b85a
Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obk
various clippy fixes

We need to keep the order of the given clippy lint rules before passing them.
Since clap doesn't offer any useful interface for this purpose out of the box,
we have to handle it manually.

Additionally, this PR makes `-D` rules work as expected. Previously, lint rules were limited to `-W`. By enabling `-D`, clippy began to complain numerous lines in the tree, all of which have been resolved in this PR as well.

Fixes #121481
cc `@matthiaskrgr`
2024-03-20 05:51:22 +01:00
onur-ozkan
81d7d7aabd resolve clippy errors
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-20 00:12:00 +03:00
Matthias Krüger
ea7ea2df86
Rollup merge of #122695 - surechen:make_only_local_explict_argument, r=lcnr
Change only_local to a enum type.

Change only_local to enum type and change the macros to always require a variant of that enum.

r? `@lcnr`
2024-03-19 18:03:52 +01:00
surechen
db48dfcd03 Change only_local to enum type and change the macros to always require a variant of that enum. 2024-03-19 20:13:40 +08:00
Oli Scherer
a8f71cf289 Remove all checks of IntrinsicDef::must_be_overridden except for the actual overrides in codegen 2024-03-19 09:19:58 +00:00
Oli Scherer
7f9830b16c Make const_eval_select a rustc_intrinsic 2024-03-19 09:12:58 +00:00