Commit Graph

783 Commits

Author SHA1 Message Date
Maybe Waffle
9fe8ae792e Rename rust_2015 => is_rust_2015 2023-02-02 08:17:13 +00:00
Matthias Krüger
f41f154dfb
Rollup merge of #107533 - pnkfelix:distinguish-generator-state-in-print-type-sizes, r=compiler-errors
Extend `-Z print-type-sizes` to distinguish generator upvars+locals from "normal" fields.

For example, for this code:

```rust
async fn wait() {}

async fn test(arg: [u8; 8192]) {
    wait().await;
    drop(arg);
}

async fn test_ideal(_rg: [u8; 8192]) {
    wait().await;
    // drop(arg);
}

fn main() {
    let gen_t = test([0; 8192]);
    let gen_i = test_ideal([0; 8192]);
    println!("expect {}, got: {}",
             std::mem::size_of_val(&gen_i),
             std::mem::size_of_val(&gen_t));
}
```

the `-Z print-type-sizes` output used to start with:

```
print-type-size type: `[async fn body@issue-62958-a.rs:3:32: 6:2]`: 16386 bytes, alignment: 1 bytes
print-type-size     discriminant: 1 bytes
print-type-size     variant `Suspend0`: 16385 bytes
print-type-size         field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size         field `.arg`: 8192 bytes
print-type-size         field `.__awaitee`: 1 bytes
...
print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
print-type-size     field `.value`: 8192 bytes
...
```

but with this change, it now instead prints:

```
print-type-size type: `[async fn body@issue-62958-a.rs:3:32: 6:2]`: 16386 bytes, alignment: 1 bytes
print-type-size     discriminant: 1 bytes
print-type-size     variant `Suspend0`: 16385 bytes
print-type-size         upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size         local `.arg`: 8192 bytes
print-type-size         local `.__awaitee`: 1 bytes
...
print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
print-type-size     field `.value`: 8192 bytes
```

(spawned off of investigation of https://github.com/rust-lang/rust/issues/62958 )
2023-02-01 05:54:40 +01:00
Guillaume Gomez
fe44f3bdd0
Rollup merge of #107508 - WaffleLapkin:uneq'15, r=oli-obk
`Edition` micro refactor

r? ``@oli-obk``
2023-01-31 23:38:53 +01:00
Felix S. Klock II
91f1b224ee placate tidy. 2023-01-31 17:10:58 -05:00
Felix S. Klock II
a37b3061fc Extend -Z print-type-sizes to distinguish generator upvars and locals from "normal" ADT fields. 2023-01-31 15:59:29 -05:00
Maybe Waffle
5d90413d75 Document rust_2015 methods 2023-01-31 10:09:22 +00:00
Maybe Waffle
fd5774a4d7 Use Edition methods a bit more 2023-01-31 10:09:22 +00:00
David Wood
2575b1abc9 session: diagnostic migration lint on more fns
Apply the diagnostic migration lint to more functions on `Session`.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30 17:11:35 +00:00
David Wood
d45004806d session: impl IntoDiagnosticArg for CrateType
Forward the `Display` implementation for `CrateType` to
`IntoDiagnosticArg` so that it can be used in diagnostic structs.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30 17:11:34 +00:00
Matthias Krüger
45446824e3
Rollup merge of #107006 - b-naber:thir-tree, r=jackh726
Output tree representation on thir-tree

The current output of `-Zunpretty=thir-tree` is really cumbersome to work with, using an actual tree representation should make it easier to see what the thir looks like.
2023-01-29 20:03:37 +01:00
bors
3cdd0197e7 Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk
Use stable metric for const eval limit instead of current terminator-based logic

This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only.

The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made).

Also see: #103877
2023-01-29 04:11:27 +00:00
Camille GILLOT
a20078f044 Add drop_tracking_mir option. 2023-01-27 18:57:34 +00:00
Yuki Okushi
bf321ece1e
Rollup merge of #106856 - vadorovsky:fix-atomic-annotations, r=joshtriplett
core: Support variety of atomic widths in width-agnostic functions

Before this change, the following functions and macros were annotated with `#[cfg(target_has_atomic = "8")]` or
`#[cfg(target_has_atomic_load_store = "8")]`:

* `atomic_int`
* `strongest_failure_ordering`
* `atomic_swap`
* `atomic_add`
* `atomic_sub`
* `atomic_compare_exchange`
* `atomic_compare_exchange_weak`
* `atomic_and`
* `atomic_nand`
* `atomic_or`
* `atomic_xor`
* `atomic_max`
* `atomic_min`
* `atomic_umax`
* `atomic_umin`

However, none of those functions and macros actually depend on 8-bit width and they are needed for all atomic widths (16-bit, 32-bit, 64-bit etc.). Some targets might not support 8-bit atomics (i.e. BPF, if we would enable atomic CAS for it).

This change fixes that by removing the `"8"` argument from annotations, which results in accepting the whole variety of widths.

Fixes #106845
Fixes #106795

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-01-27 12:57:54 +09:00
b-naber
9438126fd1 previous thir unpretty output through thir-flat 2023-01-26 23:39:57 +01:00
Matthias Krüger
1b442befca
Rollup merge of #106904 - khuey:preserve_debuginfo_for_rlibs, r=davidtwco
Preserve split DWARF files when building archives.

r? ```@davidtwco```
2023-01-26 15:02:19 +01:00
Michal Rostecki
1cd7dbfbf8 Add target_has_atomic* symbols if any atomic width is supported
Atomic operations for different widths (8-bit, 16-bit, 32-bit etc.) are
guarded by `target_has_atomic = "value"` symbol (i.e. `target_has_atomic
= "8"`) (and the other derivatives), but before this change, there was
no width-agnostic symbol indicating a general availability of atomic
operations.

This change introduces:

* `target_has_atomic_load_store` symbol when atomics for any integer
  width are supported by the target.
* `target_has_atomic` symbol when also CAS is supported.

Fixes #106845

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-01-25 10:44:03 +08:00
Bryan Garza
eea42733ac Replace terminator-based const eval limit
- Remove logic that limits const eval based on terminators, and use the
  stable metric instead (back edges + fn calls)
- Add unstable flag `tiny-const-eval-limit` to add UI tests that do not
  have to go up to the regular 2M step limit
2023-01-23 23:56:22 +00:00
bors
65d2f2a5f9 Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkov
Various cleanups around pre-TyCtxt queries and functions

part of #105462

based on https://github.com/rust-lang/rust/pull/106776 (everything starting at [0e2b39f](0e2b39fd1f) is new in this PR)

r? `@petrochenkov`

I think this should be most of the uncontroversial part of #105462.
2023-01-19 05:23:40 +00:00
Matthias Krüger
68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
Oli Scherer
1355559367 Avoid an unnecessary allocation 2023-01-16 14:46:44 +00:00
Oli Scherer
9f5cd03153 Move compiler input and ouput paths into session 2023-01-16 14:46:44 +00:00
gftea
2c5583efbd check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736) 2023-01-16 11:09:53 +01:00
Oli Scherer
f5c601492e Remove redundant input_path field from Config 2023-01-16 08:03:06 +00:00
Kyle Huey
2b99b9fd25 Preserve split DWARF files when building archives.
The optimization that removes artifacts when building libraries is correct
from the compiler's perspective but not from a debugger's perspective.
Unpacked split debuginfo is referred to by filename and debuggers need
the artifact that contains debuginfo to continue to exist at that path.

Ironically the test expects the correct behavior but it was not running.
2023-01-15 09:40:46 -08:00
André Vennberg
da3623abab Removed various double spaces in compiler source comments. 2023-01-14 17:34:59 +01:00
nils
082ff0f08d
Rollup merge of #106709 - khuey:disable_split_dwarf_inlining_by_default, r=davidtwco
Disable "split dwarf inlining" by default.

This matches clang's behavior and makes split-debuginfo behave as expected (i.e. actually split the debug info).

Fixes #106592
2023-01-11 17:30:56 +01:00
Yuki Omoto
4e2a3567bc Add log-backtrace option to show backtraces along with logging 2023-01-12 00:17:48 +09:00
Kyle Huey
aca2f88d1e Disable "split dwarf inlining" by default.
This matches clang's behavior and makes split-debuginfo behave as expected (i.e. actually split the debug info).

Fixes #106592
2023-01-10 22:35:10 -08:00
Yuki Okushi
c2d1cac36b
Rollup merge of #106671 - tmiasko:opt-bool, r=wesleywiser
Change flags with a fixed default value from Option<bool> to bool
2023-01-11 14:18:57 +09:00
Tomasz Miąsko
72f8d6a659 Change type of box_noalias to bool 2023-01-10 10:14:59 +01:00
Tomasz Miąsko
78075e1e26 Change type of mutable_noalias to bool 2023-01-10 10:14:51 +01:00
Eric Huss
d0c47bdcc9 Fix help docs for -Zallow-features 2023-01-09 14:20:34 -08:00
Matthias Krüger
a1b3393f5f
Rollup merge of #106542 - sigaloid:master, r=bjorn3
Add default and latest stable edition to --edition in rustc (attempt 2)

Fixes #106041

No longer leaks string like my first attempt PR, #106094 - uses LazyLock to construct a `&'static str`

It will now output the default edition and latest stable edition in the help message for the `--edition` flag.

Going to request the same reviewer as the first attempt for continuity - r? `@Nilstrieb`
2023-01-06 21:26:12 +01:00
Matthias Krüger
7568c49bf0
Rollup merge of #106287 - Nilstrieb:its-bugging-me-how-we-dont-have-docs, r=jyn514
Add some docs to `bug`, `span_bug` and `delay_span_bug`

cc `@mejrs` as you wanted me to do this, does this look good and understandable?
2023-01-06 21:26:09 +01:00
Matthew E
893938f64f
Update compiler/rustc_session/src/config.rs
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2023-01-06 14:36:52 -05:00
Matthew Esposito
5cda0a2f39 Add default and latest stable edition to --edition in rustc 2023-01-06 14:07:12 -05:00
Michael Goulet
8b0f43b19d Rename stock solver to classic 2023-01-04 18:40:02 +00:00
Michael Goulet
a4974fa9c7 Split -Zchalk flag into -Ztrait-solver=(stock|chalk|next) flag 2023-01-04 18:12:42 +00:00
Matthias Krüger
11020b93b6
Rollup merge of #106361 - clubby789:int-literal-too-large, r=estebank
Note maximum integer literal for `IntLiteralTooLarge`

Closes #105908

`@rustbot` label +A-diagnostics
2023-01-04 07:28:56 +01:00
Matthias Krüger
fbfaeb6795
Rollup merge of #106274 - jyn514:dump-mono-stats, r=lqd
Add JSON output to -Zdump-mono-stats

Follow-up to https://github.com/rust-lang/rust/pull/105481

r? `@lqd` cc `@wesleywiser`
2023-01-04 07:28:54 +01:00
Joshua Nelson
eb53eea609 Add json output to -Zdump-mono-stats
This allows analyzing the output programatically; for example, finding
the item with the highest `total_estimate`.

I also took the liberty of adding `untracked` tests to `rustc_session` and documentation to the unstable book for `dump-mono-items`.
2023-01-02 23:02:58 +00:00
bors
fb9dfa8cef Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov
Encode spans relative to the enclosing item -- enable on nightly

Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default.

This PR seeks to remove one of the main shortcomings of incremental: the handling of spans.
Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed.
Within one file: all the spans in HIR change, so typechecking had to be re-done.
Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span).

The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query.

Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent.

In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode:
- the parent when the `SyntaxContext` is 0;
- the `SyntaxContext` when the parent is `None`.
Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans.

The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required.

Possible future directions:
- validate that all spans are marked in HIR validation;
- mark macro-expanded spans relative to the def-site and not the use-site.
2023-01-02 13:10:16 +00:00
clubby789
537c7f4fa9 Print correct base for too-large literals
Also update tests
2023-01-02 11:43:07 +00:00
clubby789
cafdd2f7bb Note maximum integer literal for IntLiteralTooLarge 2023-01-02 03:52:29 +00:00
Nilstrieb
0047e25090 Add some docs to bug, span_bug and delay_span_bug 2022-12-30 16:47:56 +01:00
Matthias Krüger
6689d2df08
Rollup merge of #105955 - Nilstrieb:no-trivial-opt-wrappers-we-have-field-accesses-for-that, r=cjgillot
Remove wrapper functions for some unstable options

They are trivial and just forward to the option. Like most other options, we can just access it directly.
2022-12-25 22:15:00 +01:00
Camille GILLOT
40c8165395 Only enable relative span hashing on nightly. 2022-12-25 18:48:36 +00:00
Camille GILLOT
65f342daea Enable relative span hashing. 2022-12-25 18:48:31 +00:00
Camille GILLOT
44972b2ce7 Mark incremental-ignore-spans as TRACKED.
Using that options basically changes all stable hashes we may compute.
Adding/removing as UNTRACKED it makes everything ICE (unstable fingerprint
everywhere).  As TRACKED, it can still do its job without ICEing.
2022-12-25 16:42:14 +00:00