summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2023-08-18Add the relocation_model to the cfgLuca Barbato-1/+11
This way is possible to write inline assembly code aware of it.
2023-08-13Remove reached_eof from ParseSessbjorn3-4/+1
It was only ever set in a function which isn't called anywhere.
2023-08-11rustc: Move `features` from `Session` to `GlobalCtxt`Vadim Petrochenkov-19/+1
Removes two pieces of mutable state. Follow up to #114622.
2023-08-09rustc: Move `stable_crate_id` from `Session` to `GlobalCtxt`Vadim Petrochenkov-12/+0
Removes a piece of mutable state. Follow up to #114578.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-42/+0
Removes a piece of mutable state. Follow up to #114578.
2023-08-08Rollup merge of #113593 - rcvalle:rust-cfi-fix-90546, r=wesleywiserMatthias Krüger-3/+13
CFI: Fix error compiling core with LLVM CFI enabled Fix #90546 by filtering out global value function pointer types from the type tests, and adding the LowerTypeTests pass to the rustc LTO optimization pipelines.
2023-08-07CFI: Fix error compiling core with LLVM CFI enabledRamon de C Valle-3/+13
Fix #90546 by filtering out global value function pointer types from the type tests, and adding the LowerTypeTests pass to the rustc LTO optimization pipelines.
2023-08-04Auto merge of #114104 - oli-obk:syn2, r=compiler-errorsbors-24/+10
Lots of tiny incremental simplifications of `EmitterWriter` internals ignore the first commit, it's https://github.com/rust-lang/rust/pull/114088 squashed and rebased, but it's needed to use to use `derive_setters`, as they need a newer `syn` version. Then this PR starts out with removing many arguments that are almost always defaulted to `None` or `false` and replace them with builder methods that can set these fields in the few cases that want to set them. After that it's one commit after the other that removes or merges things until everything becomes some very simple trait objects
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-07-31Replace the many arguments of `EmitterWriter::stderr` with builder methodsOli Scherer-24/+10
2023-07-31Fix a comment.Nicholas Nethercote-0/+1
Make it match the corresponding comment at the start of the unstable options.
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-7/+4
2023-07-27Rollup merge of #114139 - Urgau:make-print-with-path-unstable, r=jackh726Jubilee-0/+6
Make `--print` with path unstable https://github.com/rust-lang/rust/pull/113780 should have gone through an MCP+FCP but wasn't, but instead of reverting the original PR, this PR just make that new option unstable. [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202023-07-27/near/379199738) cc `@dtolnay`
2023-07-27Make `--print KIND=PATH` unstableUrgau-0/+6
https://github.com/rust-lang/rust/pull/113780 should have gone through an MCP+FCP but wasn't, but instead of reverting the original PR, this PR just make that new option unstable.
2023-07-27Rollup merge of #114098 - klensy:drop-atty, r=fee1-deadMatthias Krüger-1/+2
replace atty crate with std's IsTerminal
2023-07-26Rollup merge of #114073 - ehuss:remove-z-diagnostic-width, r=fee1-deadMatthias Krüger-2/+0
Remove -Z diagnostic-width This removes the `-Z diagnostic-width` option since it is ignored and does nothing. `-Z diagnostic-width` was stabilized as `--diagnostic-width` in #95635. It is not entirely clear why the `-Z` flag was kept, but in part its final use was removed in #102216, but the `-Z` flag itself was not removed.
2023-07-26replace atty crate with std's isTerminalklensy-1/+2
2023-07-26Auto merge of #114054 - oli-obk:cleanups, r=estebankbors-32/+12
Split some functions with many arguments into builder pattern functions r? `@estebank` This doesn't resolve all of the ones in rustc, mostly because I need to do other cleanups in order to be able to use some builder derives from crates.io Works around https://github.com/rust-lang/rust/issues/90672 by making `x test rustfmt --bless` format itself instead of testing that it is formatted
2023-07-26Auto merge of #113893 - mdibaiee:type-name-spill-flag, r=compiler-errorsbors-0/+2
new unstable option: -Zwrite-long-types-to-disk This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-25Remove -Z diagnostic-widthEric Huss-2/+0
2023-07-25Rollup merge of #114058 - chenyukang:yukang-fix-113981-crate-arg, ↵Matthias Krüger-2/+19
r=fmease,oli-obk Add help for crate arg when crate name is invalid Fixes #113981
2023-07-26Add help for crate arg when crate name is invalidyukang-2/+19
2023-07-25Use a builder instead of boolean/option argumentsOli Scherer-15/+11
2023-07-25Remove some arguments that are always the sameOli Scherer-19/+3
2023-07-24Add missing documentation for `Session::time`Guillaume Gomez-0/+1
2023-07-24new unstable option: -Zwrite-long-types-to-diskMahdi Dibaiee-0/+2
This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-23Auto merge of #113975 - matthiaskrgr:clippy_07_2023, r=fee1-deadbors-4/+2
clippy::style fixes r? `@oli-obk` filter_map_identity iter_kv_map needless_question_mark redundant_at_rest_pattern filter_next derivable_impls useless_format
2023-07-23fix couple of clippy findings:Matthias Krüger-4/+2
filter_map_identity iter_kv_map needless_question_mark redundant_at_rest_pattern filter_next derivable_impls
2023-07-23match on chars instead of &strs for .split() or .strip_prefix()Matthias Krüger-3/+3
2023-07-21Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"David Tolnay-32/+0
This reverts commit 557359f92512ca88b62a602ebda291f17a953002, reversing changes made to 1e6c09a803fd543a98bfbe1624d697a55300a786.
2023-07-21Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obkbors-0/+32
Prototype: Add unstable `-Z reference-niches` option MCP: rust-lang/compiler-team#641 Relevant RFC: rust-lang/rfcs#3204 This prototype adds a new `-Z reference-niches` option, controlling the range of valid bit-patterns for reference types (`&T` and `&mut T`), thereby enabling new enum niching opportunities. Like `-Z randomize-layout`, this setting is crate-local; as such, references to built-in types (primitives, tuples, ...) are not affected. The possible settings are (here, `MAX` denotes the all-1 bit-pattern): | `-Z reference-niches=` | Valid range | |:---:|:---:| | `null` (the default) | `1..=MAX` | | `size` | `1..=(MAX- size)` | | `align` | `align..=MAX.align_down_to(align)` | | `size,align` | `align..=(MAX-size).align_down_to(align)` | ------ This is very WIP, and I'm not sure the approach I've taken here is the best one, but stage 1 tests pass locally; I believe this is in a good enough state to unleash this upon unsuspecting 3rd-party code, and see what breaks.
2023-07-21Auto merge of #113707 - sivadeilra:user/ardavis/sha256, r=eholkbors-1/+1
Use SHA256 source file checksums by default when targeting MSVC Currently, when targeting Windows (more specifically, the MSVC toolchain), Rust will use SHA1 source file checksums by default. SHA1 has been superseded by SHA256, and Microsoft recommends migrating to SHA256. As of Visual Studio 2022, MSVC defaults to SHA256. This change aligns Rust and MSVC. LLVM can already use SHA256 checksums, so this does not require any change to LLVM. MSVC docs on source file checksums: https://learn.microsoft.com/en-us/cpp/build/reference/zh?view=msvc-170
2023-07-21Rollup merge of #113780 - dtolnay:printkindpath, r=b-naberMatthias Krüger-37/+85
Support `--print KIND=PATH` command line syntax As is already done for `--emit KIND=PATH` and `-L KIND=PATH`. In the discussion of #110785, it was pointed out that `--print KIND=PATH` is nicer than trying to apply the single global `-o` path to `--print`'s output, because in general there can be multiple print requests within a single rustc invocation, and anyway `-o` would already be used for a different meaning in the case of `link-args` and `native-static-libs`. I am interested in using `--print cfg=PATH` in Buck2. Currently Buck2 works around the lack of support for `--print KIND=PATH` by [indirecting through a Python wrapper script](https://github.com/facebook/buck2/blob/d43cf3a51a31f00be2c2248e78271b0fef0452b4/prelude/rust/tools/get_rustc_cfg.py) to redirect rustc's stdout into the location dictated by the build system. From skimming Cargo's usages of `--print`, it definitely seems like it would benefit from `--print KIND=PATH` too. Currently it is working around the lack of this by inserting `--crate-name=___ --print=crate-name` so that it can look for a line containing `___` as a delimiter between the 2 other `--print` informations it actually cares about. This is commented as a "HACK" and "abuse". https://github.com/rust-lang/cargo/blob/31eda6f7c360d9911f853b3014e057db61238f3e/src/cargo/core/compiler/build_context/target_info.rs#L242 (FYI `@weihanglo` as you dealt with this recently in https://github.com/rust-lang/cargo/pull/11633.) Mentioning reviewers active in #110785: `@fee1-dead` `@jyn514` `@bjorn3`
2023-07-21Rollup merge of #113723 - khei4:khei4/llvm-stats, r=oli-obk,nikicMatthias Krüger-0/+7
Resurrect: rustc_llvm: Add a -Z `print-codegen-stats` option to expose LLVM statistics. This resurrects PR https://github.com/rust-lang/rust/pull/104000, which has sat idle for a while. And I want to see the effect of stack-move optimizations on LLVM (like https://reviews.llvm.org/D153453) :). I have applied the changes requested by `@oli-obk` and `@nagisa` https://github.com/rust-lang/rust/pull/104000#discussion_r1014625377 and https://github.com/rust-lang/rust/pull/104000#discussion_r1014642482 in the latest commits. r? `@oli-obk` ----- LLVM has a neat [statistics](https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option) feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too. ----- (Edit: fix broken link (Edit2: fix segmentation fault and use malloc If `rustc` is built with ```toml [llvm] assertions = true ``` Then you can see like ``` rustc +stage1 -Z print-codegen-stats -C opt-level=3 tmp.rs ===-------------------------------------------------------------------------=== ... Statistics Collected ... ===-------------------------------------------------------------------------=== 3 aa - Number of MayAlias results 193 aa - Number of MustAlias results 531 aa - Number of NoAlias results ... ``` And the current default build emits only ``` $ rustc +stage1 -Z print-codegen-stats -C opt-level=3 tmp.rs ===-------------------------------------------------------------------------=== ... Statistics Collected ... ===-------------------------------------------------------------------------=== $ ``` This might be better to emit the message to tell assertion flag necessity, but now I can't find how to do that...
2023-07-21add crate-local `-Z reference_niches` unstable flag (does nothing for now)Moulins-0/+32
2023-07-20Move OutFileName writing into rustc_sessionDavid Tolnay-0/+20
2023-07-20Disallow overlapping prints to the same locationDavid Tolnay-0/+15
2023-07-20Parse --print KIND=PATH command line syntaxDavid Tolnay-8/+14
2023-07-20Store individual output file name with every PrintRequestDavid Tolnay-31/+38
2023-07-20Don't translate compiler-internal bug messagesOli Scherer-1/+1
2023-07-20Auto merge of #108714 - estebank:ice_dump, r=oli-obkbors-4/+15
On nightly, dump ICE backtraces to disk Implement rust-lang/compiler-team#578. When an ICE is encountered on nightly releases, the new rustc panic handler will also write the contents of the backtrace to disk. If any `delay_span_bug`s are encountered, their backtrace is also added to the file. The platform and rustc version will also be collected. <img width="1032" alt="Screenshot 2023-03-03 at 2 13 25 PM" src="https://user-images.githubusercontent.com/1606434/222842420-8e039740-4042-4563-b31d-599677171acf.png"> The current behavior will *always* write to disk on nightly builds, regardless of whether the backtrace is printed to the terminal, unless the environment variable `RUSTC_ICE_DISK_DUMP` is set to `0`. This is a compromise and can be changed.
2023-07-19Rollup merge of #113765 - compiler-errors:at-least, r=oli-obkDylan DPC-6/+6
Make it clearer that edition functions are `>=`, not `==` r? `@Nilstrieb` We could also perhaps derive `Ord` on `Edition` and use comparison operators.
2023-07-19Rollup merge of #113754 - cjgillot:simplify-foreign, r=petrochenkovDylan DPC-0/+2
Simplify native_libs query Drive-by cleanup I saw while implementing https://github.com/rust-lang/rust/pull/113734
2023-07-19Make it clearer that edition functions are >=, not ==Michael Goulet-6/+6
2023-07-19On nightly, dump ICE backtraces to diskEsteban Küber-4/+15
Implement rust-lang/compiler-team#578. When an ICE is encountered on nightly releases, the new rustc panic handler will also write the contents of the backtrace to disk. If any `delay_span_bug`s are encountered, their backtrace is also added to the file. The platform and rustc version will also be collected.
2023-07-18Add `#[track_caller]` to lint related diagnostic functionsMaybe Waffle-0/+9
2023-07-17Do not fetch HIR in native_libs.Camille GILLOT-0/+2
2023-07-17print on rustc_codegen_llvm and rename malloc and cpy c_charkhei4-4/+4
2023-07-16Don't enable by default :)Patrick Walton-1/+1
2023-07-16rustc_llvm: Add a `-Z print-llvm-stats` option to expose LLVM statistics.Patrick Walton-0/+7
LLVM has a neat [statistics] feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too. [statistics]: https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option