about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-10-24Augment `stringify.rs` test.Nicholas Nethercote-0/+7
By adding tests (or placeholders, or comments) for missing AST variants.
2023-10-23Add test and remove double refCelina G. Val-3/+3
2023-10-24compiler: Add target features for LoongArchWANG Rui-0/+18
2023-10-24Auto merge of #116300 - cjgillot:split-move, r=petrochenkovbors-467/+501
Separate move path tracking between borrowck and drop elaboration. The primary goal of this PR is to skip creating a `MovePathIndex` for path that do not need dropping in drop elaboration. The 2 first commits are cleanups. The next 2 commits displace `move` errors from move-path builder to borrowck. Move-path builder keeps the same logic, but does not carry error information any more. The remaining commits allow to filter `MovePathIndex` creation according to types. This is used in drop elaboration, to avoid computing dataflow for paths that do not need dropping.
2023-10-23nitsMichael Goulet-83/+35
2023-10-23Consider regionsMichael Goulet-2/+9
2023-10-23Make things work by using the new solverMichael Goulet-3/+13
2023-10-23Rework negative coherenceMichael Goulet-39/+152
2023-10-23Remove FnPtr hack from trait_ref_is_knowableMichael Goulet-17/+21
2023-10-23pre-cleanupsMichael Goulet-24/+33
2023-10-23Auto merge of #117103 - matthiaskrgr:rollup-96zuuom, r=matthiaskrgrbors-593/+629
Rollup of 6 pull requests Successful merges: - #107159 (rand use getrandom for freebsd (available since 12.x)) - #116859 (Make `ty::print::Printer` take `&mut self` instead of `self`) - #117046 (return unfixed len if pat has reported error) - #117070 (rustdoc: wrap Type with Box instead of Generics) - #117074 (Remove smir from triage and add me to stablemir) - #117086 (Update .mailmap to promote my livename) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-23Remove unsafe and `Rc`Celina G. Val-22/+15
2023-10-23When expecting closure argument but finding block provide suggestionEsteban Küber-5/+48
Detect if there is a potential typo where the `{` meant to open the closure body was written before the body. ``` error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<usize>` --> $DIR/ruby_style_closure_successful_parse.rs:3:31 | LL | let p = Some(45).and_then({|x| | ______________________--------_^ | | | | | required by a bound introduced by this call LL | | 1 + 1; LL | | Some(x * 2) | | ----------- this tail expression is of type `Option<usize>` LL | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<usize>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<usize>` note: required by a bound in `Option::<T>::and_then` --> $SRC_DIR/core/src/option.rs:LL:COL help: you might have meant to open the closure body instead of placing a closure within a block | LL - let p = Some(45).and_then({|x| LL + let p = Some(45).and_then(|x| { | ``` Detect the potential typo where the closure header is missing. ``` error[E0277]: expected a `FnOnce<(&bool,)>` closure, found `bool` --> $DIR/block_instead_of_closure_in_arg.rs:3:23 | LL | Some(true).filter({ | _________________------_^ | | | | | required by a bound introduced by this call LL | |/ if number % 2 == 0 { LL | || number == 0 LL | || } else { LL | || number != 0 LL | || } | ||_________- this tail expression is of type `bool` LL | | }); | |______^ expected an `FnOnce<(&bool,)>` closure, found `bool` | = help: the trait `for<'a> FnOnce<(&'a bool,)>` is not implemented for `bool` note: required by a bound in `Option::<T>::filter` --> $SRC_DIR/core/src/option.rs:LL:COL help: you might have meant to create the closure instead of a block | LL | Some(true).filter(|_| { | +++ ``` Partially address #27300.
2023-10-23Rollup merge of #117046 - bvanjoi:fix-116186, r=oli-obkMatthias Krüger-1/+14
return unfixed len if pat has reported error - Fixes #116186 - Fixes #113021 This issue arises due to the creation of a fixed-length pattern, as a result of the mir body corruption. The corruption taints `tcx.eval_to_allocation_raw`, causing it to return `AlreadyReported`. Consequently, this prevents `len.try_eval_target_usize` from evaluating correctly and returns `None`. Lastly, it results in the return of `[usize; min_len]`. To rectify this issue, my approach is that to return unfixed when encountering `ErrorHandled::Reported`. Additionally, in instances of `ErrorHandled::TooGeneric`, the previous logic has been reinstated.
2023-10-23Rollup merge of #116859 - Nilstrieb:more-more-funny-pretty-printers, r=oli-obkMatthias Krüger-592/+615
Make `ty::print::Printer` take `&mut self` instead of `self` based on #116815 This simplifies the code by removing all the `self` assignments and makes the flow of data clearer - always into the printer. Especially in v0 mangling, which already used `&mut self` in some places, it gets a lot more uniform.
2023-10-23Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkovbors-22/+3
report `unused_import` for empty reexports even it is pub Fixes #116032 An easy fix. r? `@petrochenkov` (Discovered this issue while reviewing #115993.)
2023-10-23Let's see what those opaque types actually areMichael Goulet-7/+39
2023-10-23Handle ReErased in responses in new solverMichael Goulet-2/+10
2023-10-23Validate `since` value in stable attributeDavid Tolnay-8/+21
2023-10-23Validate #[stable(feature = "…")] identifierDavid Tolnay-23/+28
2023-10-23Remove redundant type parameterMichael Goulet-87/+98
2023-10-23Naming nitsMichael Goulet-55/+55
2023-10-23Add `internal()` method counterpart to `stable()`Celina G. Val-1/+5
Note: We do not expect to provide internalizing methods for all StableMIR constructs. They exist only to help migrating efforts to allow users to mix StableMIR and internal constructs.
2023-10-23Add method to convert internal to stable constructsCelina G. Val-121/+196
2023-10-23Auto merge of #107009 - cjgillot:jump-threading, r=pnkfelixbors-113/+998
Implement jump threading MIR opt This pass is an attempt to generalize `ConstGoto` and `SeparateConstSwitch` passes into a more complete jump threading pass. This pass is rather heavy, as it performs a truncated backwards DFS on MIR starting from each `SwitchInt` terminator. This backwards DFS remains very limited, as it only walks through `Goto` terminators. It is build to support constants and discriminants, and a propagating through a very limited set of operations. The pass successfully manages to disentangle the `Some(x?)` use case and the DFA use case. It still needs a few tests before being ready.
2023-10-23Factor signature type walking out of opaque_types_defined_byOli Scherer-44/+155
2023-10-23Auto merge of #117087 - matthiaskrgr:rollup-08kkjkz, r=matthiaskrgrbors-154/+97
Rollup of 5 pull requests Successful merges: - #116960 (Location-insensitive polonius: consider a loan escaping if an SCC has member constraints applied only) - #116978 (Rewrite gdb pretty-printer registration) - #117040 (coverage: Add UI tests for values accepted by `-Cinstrument-coverage`) - #117064 (Eliminate rustc_attrs::builtin::handle_errors in favor of emitting errors directly) - #117073 (Fix suggestion for renamed coroutines feature) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-23Rollup merge of #117073 - ↵Matthias Krüger-1/+1
yotamofek:fix-coroutines-feature-rename-suggestion, r=lqd Fix suggestion for renamed coroutines feature This fixes a small typo from #116958
2023-10-23Rollup merge of #117064 - dtolnay:handleerrors, r=cjgillotMatthias Krüger-128/+73
Eliminate rustc_attrs::builtin::handle_errors in favor of emitting errors directly Suggested in https://github.com/rust-lang/rust/pull/116773#pullrequestreview-1691411257. This `handle_errors` function is originally from https://github.com/rust-lang/rust/pull/34531, in which it was useful because it allowed error messages and error codes (`E0542`) for multiple occurrences of the same error to be centralized in one place. For example rather than repeating this diagnostic in 2 places: ```rust span_err!(diagnostic, attr.span, E0542, "missing 'since'"); ``` one could repeat this instead: ```rust handle_errors(diagnostic, attr.span, AttrError::MissingSince); ``` ensuring that all "missing 'since'" errors always remained consistent in message and error code. Over time as error messages and error codes got factored to fluent diagnostics (https://github.com/rust-lang/rust/pull/100836), this rationale no longer applies. The new code has the same benefit while being less verbose (+73, -128). ```rust sess.emit_err(session_diagnostics::MissingSince { span: attr.span }); ``` r? `@cjgillot`
2023-10-23Rollup merge of #116960 - lqd:applied-member-constraints-scope, r=matthewjasperMatthias Krüger-25/+23
Location-insensitive polonius: consider a loan escaping if an SCC has member constraints applied only The location-insensitive analysis considered loans to escape if there were member constraints, which makes *some* sense for scopes and matches the scopes that NLL computes on all the tests. However, polonius and NLLs differ on the fuzzed case #116657, where an SCC has member constraints but no applied ones (and is kinda surprising). The existing UI tests with member constraints impacting scopes all have some constraint applied. This PR changes the location-insensitive analysis to consider a loan to escape if there are applied member constraints, and for extra paranoia/insurance via fuzzing and crater: actually checks the constraint's min choice is indeed a universal region as we expect. (This could be turned into a `debug_assert` and early return as a slight optimization after these periods of verification) The 4 UI tests where member constraints are meaningful for computing scopes still pass obviously, and this also fixes #116657. r? `@matthewjasper`
2023-10-23return unfixed len if pat has reported errorbohan-1/+14
2023-10-23Auto merge of #116837 - oli-obk:smir_run_macro, r=spastorinobors-60/+72
Avoid having `rustc_smir` depend on `rustc_interface` or `rustc_driver` This is done by moving all the logic into a macro that performs the entire "run" operation in one go. This makes https://github.com/rust-lang/rust/pull/116806 obsolete as a follow up we should make the macro usable without manually having to write ```rust #[macro_use] extern crate rustc_smir; extern crate stable_mir; extern crate rustc_driver; extern crate rustc_interface; use rustc_smir::rustc_internal; ``` in every crate that uses the macro. r? `@spastorino`
2023-10-23fix typos in commentsGoodDaisy-1/+1
2023-10-23Auto merge of #116835 - oli-obk:evaluated_static_in_metadata2, r=RalfJungbors-59/+79
Various const eval cleanups This pulls out the pure refactorings from https://github.com/rust-lang/rust/pull/116564 r? `@RalfJung`
2023-10-23Merge associated types with the other alias typesOli Scherer-18/+7
2023-10-23Auto merge of #116849 - oli-obk:error_shenanigans, r=cjgillotbors-130/+281
Avoid a `track_errors` by bubbling up most errors from `check_well_formed` I believe `track_errors` is mostly papering over issues that a sufficiently convoluted query graph can hit. I made this change, while the actual change I want to do is to stop bailing out early on errors, and instead use this new `ErrorGuaranteed` to invoke `check_well_formed` for individual items before doing all the `typeck` logic on them. This works towards resolving https://github.com/rust-lang/rust/issues/97477 and various other ICEs, as well as allowing us to use parallel rustc more (which is currently rather limited/bottlenecked due to the very sequential nature in which we do `rustc_hir_analysis::check_crate`) cc `@SparrowLii` `@Zoxc` for the new `try_par_for_each_in` function
2023-10-23Sync the logic for inherent and weak type aliasesOli Scherer-5/+6
2023-10-23Make ICE a bit more informativeOli Scherer-3/+12
2023-10-23Avoid having `rustc_smir` depend on `rustc_interface` or `rustc_driver`Oli Scherer-60/+72
2023-10-23Fix suggestion for renamed coroutines featureYotam Ofek-1/+1
2023-10-23Ensure that `eval_to_allocation_raw` isn't called on static items from miriOli Scherer-9/+6
2023-10-23Split `eval_to_allocation_raw_provider`Oli Scherer-2/+9
2023-10-23Pull out const error reporting into its own functionOli Scherer-31/+32
2023-10-23Pull mplace validation logic out into an interpreter methodOli Scherer-21/+33
2023-10-23The mutability was ignored anyway, so just check for staticnessOli Scherer-4/+7
2023-10-23Allow `ensure` queries to return `Result<(), ErrorGuaranteed>`Oli Scherer-9/+75
2023-10-23Rollup merge of #117051 - gvozdvmozgu:fix-incremental-compilation-link, ↵Matthias Krüger-1/+1
r=Nilstrieb fix broken link: update incremental compilation url
2023-10-23Rollup merge of #117049 - Dirreke:csky-unknown-linux-gunabiv2, r=bjorn3Matthias Krüger-1/+23
add a `csky-unknown-linux-gnuabiv2hf` target This is the rustc side changes to support csky based Linux target(`csky-unknown-linux-gnuabiv2`). Tier 3 policy: > A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.) I pledge to do my best maintaining it. > Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target. This `csky` section is the arch name and the `unknown-linux` section is the same as other linux target, and `gnuabiv2` is from the cross-compile toolchain of `gcc`. the `hf`means hardfloat. > Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it. I think the explanation in platform support doc is enough to make this aspect clear. > Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users. It's using open source tools only. > The target must not introduce license incompatibilities. No new license > Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0). Understood. > The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements. There are no new dependencies/features required. > Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3. As previously said it's using open source tools only. > "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users. There are no such terms present/ > Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions. I'm not the reviewer here. > This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements. I'm not the reviewer here. > Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions. It supports for std > The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary. I have added the documentation, and I think it's clear. > Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via ``@)`` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages. Understood. > Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications. Understood. > Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. I believe I didn't break any other target. > In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target. I think there are no such problems in this PR.
2023-10-23Rollup merge of #117042 - Zalathar:file-table, r=cjgillotMatthias Krüger-103/+150
coverage: Emit the filenames section before encoding per-function mappings When embedding coverage information in LLVM IR (and ultimately in the resulting binary), there are two main things that each CGU needs to emit: - A single `__llvm_covmap` record containing a coverage header, which mostly consists of a list of filenames used by the CGU's coverage mappings. - Several `__llvm_covfun` records, one for each instrumented function, each of which contains the hash of the list of filenames in the header. There is a kind of loose cyclic dependency between the two: we need the hash of the file table before we can emit the covfun records, but we need to traverse all of the instrumented functions in order to build the file table. The existing code works by processing the individual functions first. It lazily adds filenames to the file table, and stores the mostly-complete function records in a temporary list. After this it hashes the file table, emits the header (containing the file table), and then uses the hash to emit all of the function records. This PR reverses that order: first we traverse all of the functions (without trying to prepare their function records) to build a *complete* file table, and then emit it immediately. At this point we have the file table hash, so we can then proceed to build and emit all of the function records, without needing to store them in an intermediate list. --- Along the way, this PR makes some necessary changes that are also worthwhile in their own right: - We split `FunctionCoverage` into distinct collector/finished phases, which neatly avoids some borrow-checker hassles when extracting a function's final expression/mapping data. - We avoid having to re-sort a function's mappings when preparing the list of filenames that it uses.
2023-10-23Auto merge of #115324 - francorbacho:master, r=davidtwcobors-4/+145
Suggest removing redundant arguments in format!() Closes #105225. This is also a follow-up to #105635, which seems to have become stale. r? `@estebank`