about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/util.rs
AgeCommit message (Collapse)AuthorLines
2022-02-27Use the first codegen backend in the config.toml as defaultbjorn3-6/+2
It is currently hard coded to llvm if enabled and cranelift otherwise. This made some sense when cranelift was the only alternative codegen backend. Since the introduction of the gcc backend this doesn't make much sense anymore. Before this PR bootstrapping rustc using a backend other than llvm or cranelift required changing the source of rustc_interface. With this PR it becomes a matter of putting the right backend as first enabled backend in config.toml.
2022-02-20Rollup merge of #94146 - est31:let_else, r=cjgillotMatthias Krüger-4/+1
Adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.
2022-02-19Adopt let else in more placesest31-4/+1
2022-02-18Rollup merge of #93915 - Urgau:rfc-3013, r=petrochenkovMatthias Krüger-0/+8
Implement --check-cfg option (RFC 3013), take 2 This pull-request implement RFC 3013: Checking conditional compilation at compile time (https://github.com/rust-lang/rfcs/pull/3013) and is based on the previous attempt https://github.com/rust-lang/rust/pull/89346 by `@mwkmwkmwk` that was closed due to inactivity. I have address all the review comments from the previous attempt and added some more tests. cc https://github.com/rust-lang/rust/issues/82450 r? `@petrochenkov`
2022-02-16Implement --check-cfg option (RFC 3013)Loïc BRANSTETT-0/+8
Co-authored-by: Urgau <lolo.branstett@numericable.fr> Co-authored-by: Marcelina Kościelnicka <mwk@0x04.net>
2022-02-13Remove Config::stderrbjorn3-14/+3
1. It captured stdout and not stderr 2. It isn't used anywhere 3. All error messages should go to the DiagnosticOutput instead 4. It modifies thread local state
2022-02-12Move setup_callbacks call to create_compiler_and_runbjorn3-6/+2
This ensures that it is called even when run_in_thread_pool_with_globals is avoided and reduces code duplication between the parallel and non-parallel version of run_in_thread_pool_with_globals
2022-02-11Make two functions privatebjorn3-2/+2
2022-01-18Use let_else in even more placesest31-46/+46
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
2021-12-26Add Attribute::meta_kindJakub Beránek-1/+1
2021-12-06replace dynamic library module with libloadingAndy Russell-25/+21
2021-11-11Auto merge of #83846 - torhovland:issue-10971, r=davidtwcobors-0/+3
Added the --temps-dir option Fixes #10971. The new `--temps-dir` option puts intermediate files in a user-specified directory. This provides a fix for the issue where parallel invocations of rustc would overwrite each other's intermediate files. No files are kept in the intermediate directory unless `-C save-temps=yes`. If additional files are specifically requested using `--emit asm,llvm-bc,llvm-ir,obj,metadata,link,dep-info,mir`, these will be put in the output directory rather than the intermediate directory. This is a backward-compatible change, i.e. if `--temps-dir` is not specified, the behavior is the same as before.
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-2/+2
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-02Added the --temps-dir option.Tor Hovland-0/+3
2021-10-01Fix clippy lintsGuillaume Gomez-2/+2
2021-09-25Check for macros in built-in attributes that don't support them.Eric Huss-1/+15
2021-09-23Simplify scoped_threadMark Rousskov-19/+5
Avoids a bunch of manual pointer manipulation.
2021-09-20Enable 2021 compatibility lints for all in-tree codeMark Rousskov-0/+1
This just applies the suggested fixes from the compatibility warnings, leaving any that are in practice spurious in. This is primarily intended to provide a starting point to identify possible fixes to the migrations (e.g., by avoiding spurious warnings). A secondary commit cleans these up where they are false positives (as is true in many of the cases).
2021-09-03Detect bare blocks with type ascription that were meant to be a `struct` literalEsteban Kuber-0/+1
Address part of #34255. Potential improvement: silence the other knock down errors in `issue-34255-1.rs`.
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-3/+3
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-07-18Remove deadlock virtual call.Camille GILLOT-1/+3
2021-07-08Rework SESSION_GLOBALS API to prevent overwriting itGuillaume Gomez-7/+8
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-36/+0
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-06-07Revert "Merge CrateDisambiguator into StableCrateId"bjorn3-0/+36
This reverts commit d0ec85d3fb6d322496cb8f4bc1c21e19f23284ad.
2021-06-04Use SyncOnceCell in get_codegen_backendbjorn3-11/+9
This reduces the amount of unsafe code in get_codegen_backend
2021-06-04Allow printing the version of the default codegen backend if it isn't llvmbjorn3-22/+15
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-36/+0
2021-05-15fix version_str commentRalf Jung-1/+1
2021-05-10Adjust target search algorithm for rustlib pathSimonas Kazlauskas-2/+1
With this the concerns expressed in #83800 should be addressed.
2021-04-06Auto merge of #81641 - bjorn3:find_codegen_backend, r=davidtwcobors-8/+17
Find codegen backends in more locations * Search in the sysroot passed using `--sysroot` in addition to the default sysroot. * Search for `librustc_codegen_$name.so` in addition to `librustc_codegen_$name-$release.so`. This combined would allow putting `librustc_codegen_cranelift.so` in the right location of a sysroot passed using `--sysroot`.
2021-03-13Document `everybody_loops`Camelid-10/+18
2021-03-08Rollup merge of #82047 - the8472:fast-rename, r=davidtwcoDylan DPC-0/+18
bypass auto_da_alloc for metadata files This saves about 0.7% when rerunning the UI test suite. I.e. when the metadata files exist and will be overwritten. No improvements expected for a clean build. So it might show up in incr-patched perf results. ``` regular rename: Benchmark #1: touch src/tools/compiletest/src/main.rs ; RUSTC_WRAPPER="" schedtool -B -e ./x.py test src/test/ui Time (mean ± σ): 47.305 s ± 0.170 s [User: 1631.540 s, System: 412.648 s] Range (min … max): 47.125 s … 47.856 s 20 runs non-durable rename: Benchmark #1: touch src/tools/compiletest/src/main.rs ; RUSTC_WRAPPER="" schedtool -B -e ./x.py test src/test/ui Time (mean ± σ): 46.930 s ± 0.064 s [User: 1634.344 s, System: 396.038 s] Range (min … max): 46.759 s … 47.043 s 20 runs ``` There are more places that trigger auto_da_alloc behavior by overwriting existing files with O_TRUNC, but those are much harder to locate because `O_TRUNC` is set on `open()` but the writeback is triggered on `close()`. The latter is the part which shows up in profiles.
2021-02-19Move handle_deadlock where it is used.Camille GILLOT-4/+28
2021-02-13bypass auto_da_alloc for metadata filesThe8472-0/+18
2021-02-01Find codegen backends in more locationsbjorn3-8/+17
* Search in the sysroot passed using `--sysroot` in addition to the default sysroot. * Search for `librustc_codegen_$name.so` in addition to `librustc_codegen_$name-$release.so`.
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-2/+2
2020-11-26Properly handle attributes on statementsAaron Hill-2/+0
We now collect tokens for the underlying node wrapped by `StmtKind` instead of storing tokens directly in `Stmt`. `LazyTokenStream` now supports capturing a trailing semicolon after it is initially constructed. This allows us to avoid refactoring statement parsing to wrap the parsing of the semicolon in `parse_tokens`. Attributes on item statements (e.g. `fn foo() { #[bar] struct MyStruct; }`) are now treated as item attributes, not statement attributes, which is consistent with how we handle attributes on other kinds of statements. The feature-gating code is adjusted so that proc-macro attributes are still allowed on item statements on stable. Two built-in macros (`#[global_allocator]` and `#[test]`) needed to be adjusted to support being passed `Annotatable::Stmt`.
2020-11-24Move lev_distance to rustc_ast, make non-genericArlie Davis-3/+6
rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST would not have any dependency its lexer, for minimizing unnecessarily design-time dependencies. Breaking this dependency would also have practical benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast. This commit does not remove the rustc_ast --> rustc_lexer dependency, but it does remove one of the sources of this dependency, which is the code that handles fuzzy matching between symbol names for making suggestions in diagnostics. Since that code depends only on Symbol, it is easy to move it to rustc_span. It might even be best to move it to a separate crate, since other tools such as Cargo use the same algorithm, and have simply contain a duplicate of the code. This changes the signature of find_best_match_for_name so that it is no longer generic over its input. I checked the optimized binaries, and this function was duplicated at nearly every call site, because most call sites used short-lived iterator chains, generic over Map and such. But there's no good reason for a function like this to be generic, since all it does is immediately convert the generic input (the Iterator impl) to a concrete Vec<Symbol>. This has all of the costs of generics (duplicated method bodies) with no benefit. Changing find_best_match_for_name to be non-generic removed about 10KB of code from the optimized binary. I know it's a drop in the bucket, but we have to start reducing binary size, and beginning to tame over-use of generics is part of that.
2020-11-10Merge set_panic and set_print into set_output_capture.Mara Bos-2/+2
There were no use cases for setting them separately. Merging them simplifies some things.
2020-11-10Use Vec<u8> for LOCAL_STD{OUT,ERR} instead of dyn Write.Mara Bos-6/+2
It was only ever used with Vec<u8> anyway. This simplifies some things. - It no longer needs to be flushed, because that's a no-op anyway for a Vec<u8>. - Writing to a Vec<u8> never fails. - No #[cfg(test)] code is needed anymore to use `realstd` instead of `std`, because Vec comes from alloc, not std (like Write).
2020-11-10Remove io::LocalOutput and use Arc<Mutex<dyn>> for local streams.Mara Bos-18/+3
2020-11-09Rollup merge of #78710 - petrochenkov:macvisit, r=davidtwcoDylan DPC-6/+0
rustc_ast: Do not panic by default when visiting macro calls Panicking by default made sense when we didn't have HIR or MIR and everything worked on AST, but now all AST visitors run early and majority of them have to deal with macro calls, often by ignoring them. The second commit renames `visit_mac` to `visit_mac_call`, the corresponding structures were renamed earlier in https://github.com/rust-lang/rust/pull/69589.
2020-11-04fix a couple of clippy warnings:Matthias Krüger-5/+4
filter_next manual_strip redundant_static_lifetimes single_char_pattern unnecessary_cast unused_unit op_ref redundant_closure useless_conversion
2020-11-03rustc_ast: Do not panic by default when visiting macro callsVadim Petrochenkov-6/+0
2020-10-27Auto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-sebors-0/+5
Capture output from threads spawned in tests This is revival of #75172. Original text: > Fixes #42474. > > r? `@​dtolnay` since you expressed interest in this, but feel free to redirect if you aren't the right person anymore. --- Closes #75172.
2020-10-26Add support for using cg_clif to bootstrap rustcbjorn3-7/+128
2020-10-22Capture output from threads spawned in testsTyler Mandry-0/+5
Fixes #42474.