about summary refs log tree commit diff
path: root/compiler/rustc_interface
AgeCommit message (Collapse)AuthorLines
2022-01-23rustc_lint: Stop creating a fake `ast::Crate` for running early lintsVadim Petrochenkov-10/+15
Add a trait generalizing over the crate root and freshly loaded modules instead This also makes node IDs used for pre-expansion linting more precise
2022-01-23rustc_lint: Reuse the set of registered tools from resolverVadim Petrochenkov-9/+10
2022-01-23rustc_lint: Remove some redundant fields from `EarlyContext`Vadim Petrochenkov-11/+11
Use consistent function parameter order for early context construction and early linting Rename some functions to make it clear that they do not necessarily work on the whole crate
2022-01-21Rollup merge of #93046 - est31:let_else, r=davidtwcoMatthias Krüger-46/+47
Use let_else in even more places Followup of #89933, #91018, #91481.
2022-01-21Rollup merge of #92835 - iwanders:issue-66450-improve-cfg-error-message, ↵Matthias Krüger-1/+10
r=nagisa Improve error message for key="value" cfg arguments. Hi, I ran into difficulties using the `--cfg` flag syntax, first hit when googling for the error was issue https://github.com/rust-lang/rust/issues/66450. Reading that issue, it sounded like the best way to improve the experience was to improve the error message, this is low risk and doesn't introduce any additional argument parsing. The issue mentions that it is entirely dependent on the shell, while this may be true, I think guiding the the user into the realization that the quotes may need to be escaped is helpful. The two suggested escapings both work in Bash and in the Windows command prompt. fyi `@ehuss`
2022-01-20Rollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pnkfelixMatthias Krüger-1/+0
Stabilize `-Z print-link-args` as `--print link-args` We have stable options for adding linker arguments; we should have a stable option to help debug linker arguments. Add documentation for the new option. In the documentation, make it clear that the *exact* format of the output is not a stable guarantee.
2022-01-18Rollup merge of #90782 - ricobbe:binutils-dlltool, r=michaelwoeristerMatthias Krüger-0/+1
Implement raw-dylib support for windows-gnu Add support for `#[link(kind = "raw-dylib")]` on windows-gnu targets. Work around binutils's linker's inability to read import libraries produced by LLVM by calling out to the binutils `dlltool` utility to create an import library from a temporary .DEF file; this approach is effectively a slightly refined version of `@mati865's` earlier attempt at this strategy in PR #88801. (In particular, this attempt at this strategy adds support for `#[link_ordinal(...)]` as well.) In support of #58713.
2022-01-18Use let_else in even more placesest31-46/+47
2022-01-17Update term for use in more placeskadmin-0/+2
Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the future, but slightly worried it allows items which are consts which only accept types.
2022-01-17Add termkadmin-4/+6
Instead of having a separate enum variant for types and consts have one but have either a const or type.
2022-01-17add eq constraints on associated constantskadmin-2/+3
2022-01-16Limit scope of the hint about escaping.Ivor Wanders-4/+10
2022-01-15Deny mixing bin crate type with lib crate typesbjorn3-2/+10
The produced library would get a main shim too which conflicts with the main shim of the executable linking the library. ``` $ cat > main1.rs <<EOF fn main() {} pub fn bar() {} EOF $ cat > main2.rs <<EOF extern crate main1; fn main() { main1::bar(); } EOF $ rustc --crate-type bin --crate-type lib main1.rs $ rustc -L. main2.rs error: linking with `cc` failed: exit status: 1 [...] = note: /usr/bin/ld: /tmp/crate_bin_lib/libmain1.rlib(main1.main1.707747aa-cgu.0.rcgu.o): in function `main': main1.707747aa-cgu.0:(.text.main+0x0): multiple definition of `main'; main2.main2.02a148fe-cgu.0.rcgu.o:main2.02a148fe-cgu.0:(.text.main+0x0): first defined here collect2: error: ld returned 1 exit status ```
2022-01-12Improve error message for cfg arguments.Ivor Wanders-1/+4
This provides the user with a helpful error message in case a key="value" message was specified but couldn't be parsed.
2022-01-12Call out to binutils' dlltool for raw-dylib on windows-gnu platforms.Richard Cobbe-0/+1
2022-01-10Update rayon and rustc-rayonJosh Stone-2/+2
2022-01-09Stabilize -Z print-link-args as --print link-argsJosh Triplett-1/+0
We have stable options for adding linker arguments; we should have a stable option to help debug linker arguments.
2022-01-05ast: Always keep a `NodeId` in `ast::Crate`Vadim Petrochenkov-2/+2
This makes it more uniform with other expanded nodes
2022-01-02Auto merge of #90128 - joshtriplett:stabilize-symbol-mangling-version, ↵bors-0/+1
r=wesleywiser Stabilize -Z symbol-mangling-version=v0 as -C symbol-mangling-version=v0 This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options. This does not change the default symbol-mangling-version. See https://github.com/rust-lang/rust/pull/89917 for a pull request changing the default. Rationale, from #89917: Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain . characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters A-Z, a-z, 0-9, and _. Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers). This pull request allows enabling the new v0 symbol-mangling-version. See #89917 for references to the implementation of v0, and for references to the tool changes to decode Rust symbols.
2022-01-01Stabilize -Z instrument-coverage as -C instrument-coverageJosh Triplett-0/+1
Continue supporting -Z instrument-coverage for compatibility for now, but show a deprecation warning for it. Update uses and documentation to use the -C option. Move the documentation from the unstable book to stable rustc documentation.
2022-01-01Stabilize -Z symbol-mangling-version as -C symbol-mangling-versionJosh Triplett-0/+1
This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options. Continue supporting -Z symbol-mangling-version for compatibility for now, but show a deprecation warning for it.
2022-01-01Rollup merge of #92468 - NieDzejkob:silent-cfg, r=petrochenkovMatthias Krüger-19/+19
Emit an error for `--cfg=)` Fixes #73026 See also: #64467, #89468 The issue stems from a `FatalError` being silently raised in `panictry_buffer`. Normally this is not a problem, because `panictry_buffer` emits the causes of the error, but they are not themselves fatal, so they get filtered out by the silent emitter. To fix this, we use a parser entrypoint which doesn't use `panictry_buffer`, and we handle the error ourselves.
2022-01-01Emit an error for `--cfg=)`Jakub Kądziołka-19/+19
Fixes #73026 See also: #64467, #89468 The issue stems from a `FatalError` being silently raised in `panictry_buffer`. Normally this is not a problem, because `panictry_buffer` emits the causes of the error, but they are not themselves fatal, so they get filtered out by the silent emitter. To fix this, we use a parser entrypoint which doesn't use `panictry_buffer`, and we handle the error ourselves.
2022-01-01Auto merge of #92294 - Kobzol:rustdoc-meta-kind, r=GuillaumeGomezbors-1/+1
Add Attribute::meta_kind The `AttrItem::meta` function is being called on a lot of places, however almost always the caller is only interested in the `kind` of the result `MetaItem`. Before, the `path` had to be cloned in order to get the kind, now it does not have to be. There is a larger related "problem". In a lot of places, something wants to know contents of attributes. This is accessed through `Attribute::meta_item_list`, which calls `AttrItem::meta` (now `AttrItem::meta_kind`), among other methods. When this function is called, the meta item list has to be recreated from scratch. Everytime something asks a simple question (like is this item/list of attributes `#[doc(hidden)]`?), the tokens of the attribute(s) are cloned, parsed and the results are allocated on the heap. That seems really unnecessary. What would be the best way to cache this? Turn `meta_item_list` into a query perhaps? Related PR: https://github.com/rust-lang/rust/pull/92227 r? rust-lang/rustdoc
2021-12-29Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisabors-2/+7
Add codegen option for branch protection and pointer authentication on AArch64 The branch-protection codegen option enables the use of hint-space pointer authentication code for AArch64 targets.
2021-12-26Add Attribute::meta_kindJakub Beránek-1/+1
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-4/+4
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Rollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514Matthias Krüger-1/+1
fix clippy::single_char_pattern perf findings
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-2/+2
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-1/+1
2021-12-13Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`Tomasz Miąsko-2/+5
The resulting profile will include the crate name and will be stored in the `--out-dir` directory. This implementation makes it convenient to use LLVM time trace together with cargo, in the contrast to the previous implementation which would overwrite profiles or store them in `.cargo/registry/..`.
2021-12-12Auto merge of #90716 - euclio:libloading, r=cjgillotbors-25/+22
replace dynamic library module with libloading This PR deletes the `rustc_metadata::dynamic_lib` module in favor of the popular and better tested [`libloading` crate](https://github.com/nagisa/rust_libloading/). We don't benefit from `libloading`'s symbol lifetimes since we end up leaking the loaded library in all cases, but the call-sites look much nicer by improving error handling and abstracting away some transmutes. We also can remove `rustc_metadata`'s direct dependencies on `libc` and `winapi`. This PR also adds an exception for `libloading` (and its license) to tidy, so this will need sign-off from the compiler team.
2021-12-09Rollup merge of #91476 - m-ou-se:ferris-identifier, r=estebankMatthias Krüger-5/+21
Improve 'cannot contain emoji' error. Before: ``` error: identifiers cannot contain emoji: `🦀` --> src/main.rs:2:9 | 2 | let 🦀 = 1; | ^^ ``` After: ``` error: Ferris cannot be used as an identifier --> src/main.rs:2:9 | 2 | let 🦀 = 1; | ^^ help: try using their name instead: `ferris` ``` r? `@estebank`
2021-12-06replace dynamic library module with libloadingAndy Russell-25/+22
2021-12-04Stabilize `-Z emit-future-incompat` as `--json future-incompat`Aaron Hill-1/+0
2021-12-03Improve 'cannot contain emoji' error.Mara Bos-5/+21
2021-12-01Review commentsJamie Cunliffe-4/+4
- Changed the separator from '+' to ','. - Moved the branch protection options from -C to -Z. - Additional test for incorrect branch-protection option. - Remove LLVM < 12 code. - Style fixes. Co-authored-by: James McGregor <james.mcgregor2@arm.com>
2021-12-01Add codegen option for branch protection and pointer authentication on AArch64James McGregor-2/+7
The branch-protection codegen option enables the use of hint-space pointer authentication code for AArch64 targets
2021-11-28expand: Turn `ast::Crate` into a first class expansion targetVadim Petrochenkov-1/+1
And stop creating a fake `mod` item for the crate root when expanding a crate.
2021-11-25Rollup merge of #91185 - camelid:rm-force-overflow-checks, r=wesleywiserMatthias Krüger-1/+0
Remove `-Z force-overflow-checks` It was replaced several years ago by the stable option `-C overflow-checks`. The goal was to delete the `-Z` flag once users had migrated [1]. Now that it's been several years, it makes sense to delete the old flag. See also the discussion on Zulip [2]. [1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097 [2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224 r? ```@wesleywiser``` cc ```@RalfJung```
2021-11-24Remove `-Z force-overflow-checks`Noah Lev-1/+0
It was replaced several years ago by the stable option `-C overflow-checks`. The goal was to delete the `-Z` flag once users had migrated [1]. Now that it's been several years, it makes sense to delete the old flag. See also the discussion on Zulip [2]. [1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097 [2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224
2021-11-23Sort `FxHashSet`'s contents before emitting errors for consistent outputEsteban Kuber-1/+4
2021-11-23review comment: plural of emoji is emojiEsteban Kuber-1/+1
2021-11-23Tokenize emoji as if they were valid indentifiersEsteban Kuber-1/+11
In the lexer, consider emojis to be valid identifiers and reject them later to avoid knock down parse errors.
2021-11-22add rustc option for using LLVM stack smash protectionBenjamin A. Bjørnseth-5/+8
LLVM has built-in heuristics for adding stack canaries to functions. These heuristics can be selected with LLVM function attributes. This patch adds a rustc option `-Z stack-protector={none,basic,strong,all}` which controls the use of these attributes. This gives rustc the same stack smash protection support as clang offers through options `-fno-stack-protector`, `-fstack-protector`, `-fstack-protector-strong`, and `-fstack-protector-all`. The protection this can offer is demonstrated in test/ui/abi/stack-protector.rs. This fills a gap in the current list of rustc exploit mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html), originally discussed in #15179. Stack smash protection adds runtime overhead and is therefore still off by default, but now users have the option to trade performance for security as they see fit. An example use case is adding Rust code in an existing C/C++ code base compiled with stack smash protection. Without the ability to add stack smash protection to the Rust code, the code base artifacts could be exploitable in ways not possible if the code base remained pure C/C++. Stack smash protection support is present in LLVM for almost all the current tier 1/tier 2 targets: see test/assembly/stack-protector/stack-protector-target-support.rs. The one exception is nvptx64-nvidia-cuda. This patch follows clang's example, and adds a warning message printed if stack smash protection is used with this target (see test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3 targets has not been checked. Since the heuristics are applied at the LLVM level, the heuristics are expected to add stack smash protection to a fraction of functions comparable to C/C++. Some experiments demonstrating how Rust code is affected by the different heuristics can be found in test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is potential for better heuristics using Rust-specific safety information. For example it might be reasonable to skip stack smash protection in functions which transitively only use safe Rust code, or which uses only a subset of functions the user declares safe (such as anything under `std.*`). Such alternative heuristics could be added at a later point. LLVM also offers a "safestack" sanitizer as an alternative way to guard against stack smashing (see #26612). This could possibly also be included as a stack-protection heuristic. An alternative is to add it as a sanitizer (#39699). This is what clang does: safestack is exposed with option `-fsanitize=safe-stack`. The options are only supported by the LLVM backend, but as with other codegen options it is visible in the main codegen option help menu. The heuristic names "basic", "strong", and "all" are hopefully sufficiently generic to be usable in other backends as well. Reviewed-by: Nikita Popov <nikic@php.net> Extra commits during review: - [address-review] make the stack-protector option unstable - [address-review] reduce detail level of stack-protector option help text - [address-review] correct grammar in comment - [address-review] use compiler flag to avoid merging functions in test - [address-review] specify min LLVM version in fortanix stack-protector test Only for Fortanix test, since this target specifically requests the `--x86-experimental-lvi-inline-asm-hardening` flag. - [address-review] specify required LLVM components in stack-protector tests - move stack protector option enum closer to other similar option enums - rustc_interface/tests: sort debug option list in tracking hash test - add an explicit `none` stack-protector option Revert "set LLVM requirements for all stack protector support test revisions" This reverts commit a49b74f92a4e7d701d6f6cf63d207a8aff2e0f68.
2021-11-19Auto merge of #90329 - nbdd0121:typeck, r=nagisabors-0/+1
Try all stable method candidates first before trying unstable ones Currently we try methods in this order in each step: * Stable by value * Unstable by value * Stable autoref * Unstable autoref * ... This PR changes it to first try pick methods without any unstable candidates, and if none is found, try again to pick unstable ones. Fix #90320 CC #88971, hopefully would allow us to rename the "unstable_*" methods for integer impls back. `@rustbot` label T-compiler T-libs-api
2021-11-19Rollup merge of #90386 - pierwill:assert-incr-state-85864, r=Aaron1011Yuki Okushi-0/+1
Add `-Zassert-incr-state` to assert state of incremental cache Closes #85864.
2021-11-15Stabilize -Z strip as -C stripJosh Triplett-1/+1
Leave -Z strip available temporarily as an alias, to avoid breaking cargo until cargo transitions to using -C strip. (If the user passes both, the -C version wins.)
2021-11-15Try all stable candidates first before trying unstable onesGary Guo-0/+1