about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2023-07-26Auto merge of #113893 - mdibaiee:type-name-spill-flag, r=compiler-errorsbors-0/+1
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-26rustdoc: fix cross-crate impl-SizedLeón Orell Valerian Liehr-25/+71
2023-07-26rustdoc: stylistic changesLeón Orell Valerian Liehr-21/+15
2023-07-25Add `sym::iter_mut` + `sym::as_mut_ptr`blyxyas-1/+1
2023-07-25Auto merge of #114076 - matthiaskrgr:rollup-cpqq1n9, r=matthiaskrgrbors-20/+44
Rollup of 5 pull requests Successful merges: - #112995 (Check for `<&NotClone as Clone>::clone()` calls and suggest to add Clone trait appropriately) - #113578 (Don't say that a type is uncallable if its fn signature has errors in it) - #113661 (Double check that hidden types match the expected hidden type) - #114044 (factor out more stable impls) - #114062 (CI: split nested GHA groups instead of panicking) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-25Rollup merge of #114062 - Kobzol:ci-group-splitting, r=Mark-SimulacrumMatthias Krüger-19/+43
CI: split nested GHA groups instead of panicking Bootstrap uses Github Actions groups to reduce clutter in CI job output. However, GHA doesn't support group nesting, and currently, when a group would be nested, bootstrap would panic. This is causing intermittent CI failures, because it's not trivial to make sure that groups won't be nested, and subtle changes in bootstrap (or even in caches being present) can cause nesting. This PR changes the logic so that groups are never nested. Instead, when a group would be nested, the previous group is ended, and only then is the subgroup started. When the subgroup finishes, it will then restart any previously ended parent group. r? `@Mark-Simulacrum`
2023-07-25Rollup merge of #113661 - oli-obk:tait_wtf, r=lcnrMatthias Krüger-1/+1
Double check that hidden types match the expected hidden type Fixes https://github.com/rust-lang/rust/issues/113278 specifically, but I left a TODO for where we should also add some hardening. It feels a bit like papering over the issue, but at least this way we don't get unsoundness, but just surprising errors. Errors will be improved and given spans before this PR lands. r? `@compiler-errors` `@lcnr`
2023-07-25Auto merge of #114027 - arlosi:update-cargo, r=ehussbors-49/+0
Update cargo 8 commits in 1b15556767f4b78a64e868eedf4073c423f02b93..7ac9416d82cd4fc5e707c9ec3574d22dff6466e5 2023-07-18 14:44:47 +0000 to 2023-07-24 14:29:38 +0000 - fix(cargo-credential): should enable feature `serde/derive` (rust-lang/cargo#12396) - fix: encode URL params correctly for SourceId in Cargo.lock (rust-lang/cargo#12280) - docs: format config override caveat as a note (rust-lang/cargo#12392) - credential provider implementation (rust-lang/cargo#12334) - feat(crates-io): expose HTTP headers and Error type (rust-lang/cargo#12310) - chore: Don't update test data (rust-lang/cargo#12380) - fix: only skip mtime check on `~/.cargo/{git,registry}` (rust-lang/cargo#12369) - Update docs for artifact JSON debuginfo levels. (rust-lang/cargo#12376) Since rust-lang/cargo#12334 makes built-in credential providers part of the cargo binary, it's no longer needed to build them in bootstrap.
2023-07-25make MPlaceTy non-CopyRalf Jung-12/+12
2023-07-25interpret: make read functions generic over operand typeRalf Jung-45/+45
2023-07-25interpret: make write functions generic over the place typeRalf Jung-71/+71
2023-07-25Allow using external builds of the compiler-rt profile libJosh Stone-6/+28
This changes the bootstrap config `target.*.profiler` from a plain bool to also allow a string, which will be used as a path to the pre-built profiling runtime for that target. Then `profiler_builtins/build.rs` reads that in a `LLVM_PROFILER_RT_LIB` environment variable.
2023-07-25Split nested GHA groups instead of panickingJakub Beránek-19/+43
2023-07-25Auto merge of #114063 - matthiaskrgr:rollup-c90czu6, r=matthiaskrgrbors-2/+4
Rollup of 7 pull requests Successful merges: - #114008 (coverage: Obtain the `__llvm_covfun` section name outside a per-function loop) - #114014 (builtin_macros: expect raw strings too) - #114043 (docs(LazyLock): add example pass local LazyLock variable to struct) - #114051 (Add regression test for invalid "unused const" in method) - #114052 (Suggest `{Option,Result}::as_ref()` instead of `cloned()` in some cases) - #114058 (Add help for crate arg when crate name is invalid) - #114060 (abi: unsized field in union - assert to delay bug ) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-25Remove credential providers from bootstrapArlo Siemsen-49/+0
since they are now built-in to the Cargo binary
2023-07-25Rollup merge of #114058 - chenyukang:yukang-fix-113981-crate-arg, ↵Matthias Krüger-1/+3
r=fmease,oli-obk Add help for crate arg when crate name is invalid Fixes #113981
2023-07-25Rollup merge of #114014 - davidtwco:issue-114010-env-rawstr, r=cjgillotMatthias Krüger-1/+1
builtin_macros: expect raw strings too Fixes #114010. `expr_to_string` allows raw strings through so this code should be expected to handle those.
2023-07-25Auto merge of #113393 - compiler-errors:next-solver-unsize-rhs, r=lcnrbors-2/+2
Normalize the RHS of an `Unsize` goal in the new solver `Unsize` goals are... tricky. Not only do they structurally match on their self type, but they're also structural on their other type parameter. I'm pretty certain that it is both incomplete and also just plain undesirable to not consider normalizing the RHS of an unsize goal. More practically, I'd like for this code to work: ```rust trait A {} trait B: A {} impl A for usize {} impl B for usize {} trait Mirror { type Assoc: ?Sized; } impl<T: ?Sized> Mirror for T { type Assoc = T; } fn main() { // usize: Unsize<dyn B> let x = Box::new(1usize) as Box<<dyn B as Mirror>::Assoc>; // dyn A: Unsize<dyn B> let y = x as Box<<dyn A as Mirror>::Assoc>; } ``` --- In order to achieve this, we add `EvalCtxt::normalize_non_self_ty` (naming modulo bikeshedding), which *must* be used for all non-self type arguments that are structurally matched in candidate assembly. Currently this is only necessary for `Unsize`'s argument, but I could see future traits requiring this (hopefully rarely) in the future. It uses `repeat_while_none` to limit infinite looping, and normalizes the self type until it is no longer an alias. Also, we need to fix feature gate detection for `trait_upcasting` and `unsized_tuple_coercion` when HIR typeck has unnormalized types. We can do that by checking the `ImplSource` returned by selection, which necessitates adding a new impl source for tuple upcasting.
2023-07-25Make everything builtin!Michael Goulet-2/+2
2023-07-26Add help for crate arg when crate name is invalidyukang-1/+3
2023-07-25CI: fix CMake installation for 32 and 64bit `dist` LinuxJakub Beránek-4/+2
2023-07-25Auto merge of #114011 - RalfJung:place-projection, r=oli-obkbors-110/+99
interpret: Unify projections for MPlaceTy, PlaceTy, OpTy For ~forever, we didn't really have proper shared code for handling projections into those three types. This is mostly because `PlaceTy` projections require `&mut self`: they might have to `force_allocate` to be able to represent a project part-way into a local. This PR finally fixes that, by enhancing `Place::Local` with an `offset` so that such an optimized place can point into a part of a place without having requiring an in-memory representation. If we later write to that place, we will still do `force_allocate` -- for now we don't have an optimized path in `write_immediate` that would avoid allocation for partial overwrites of immediately stored locals. But in `write_immediate` we have `&mut self` so at least this no longer pollutes all our type signatures. (Ironically, I seem to distantly remember that many years ago, `Place::Local` *did* have an `offset`, and I removed it to simplify things. I guess I didn't realize why it was so useful... I am also not sure if this was actually used to achieve place projection on `&self` back then.) The `offset` had type `Option<Size>`, where `None` represent "no projection was applied". This is needed because locals *can* be unsized (when they are arguments) but `Place::Local` cannot store metadata: if the offset is `None`, this refers to the entire local, so we can use the metadata of the local itself (which must be indirect); if a projection gets applied, since the local is indirect, it will turn into a `Place::Ptr`. (Note that even for indirect locals we can have `Place::Local`: when the local appears in MIR, we always start with `Place::Local`, and only check `frame.locals` later. We could eagerly normalize to `Place::Ptr` but I don't think that would actually simplify things much.) Having done all that, we can finally properly abstract projections: we have a new `Projectable` trait that has the basic methods required for projecting, and then all projection methods are implemented for anything that implements that trait. We can even implement it for `ImmTy`! (Not that we need that, but it seems neat.) The visitor can be greatly simplified; it doesn't need its own trait any more but it can use the `Projectable` trait. We also don't need the separate `Mut` visitor any more; that was required only to reflect that projections on `PlaceTy` needed `&mut self`. It is possible that there are some more `&mut self` that can now become `&self`... I guess we'll notice that over time. r? `@oli-obk`
2023-07-25Use a builder instead of boolean/option argumentsOli Scherer-4/+1
2023-07-25Use a builder instead of boolean/option argumentsOli Scherer-13/+7
2023-07-25Improve performance of `first_non_private`Guillaume Gomez-22/+18
2023-07-25bless moreRalf Jung-4/+4
2023-07-25interpret: refactor projection code to work on a common trait, and use that ↵Ralf Jung-103/+92
for visitors
2023-07-25clippy: `env!` invocations can't be b"" literalsDavid Wood-1/+1
Signed-off-by: David Wood <david@davidtw.co>
2023-07-25Auto merge of #113411 - unikraft:unikraft, r=wesleywiserbors-2/+74
Add `x86_64-unikraft-linux-musl` target This introduces `x86_64-unikraft-linux-musl` as the first Rust target for the [Unikraft] Unikernel Development Kit. [Unikraft]: https://unikraft.org/ Unikraft imitates Linux and uses musl as libc. It is extremely configurable, and does not even provide a `poll` implementation or a network stack, unless enabled by the end user who compiles the application. Our approach for integrating the build process with `rustc` is to hide the build process as well as the actual final linking step behind a linker-shim (`kraftld`, see https://github.com/unikraft/kraftkit/issues/612). ## Tier 3 target 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 will be the target maintainer. > - 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. > - 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. > - If possible, use only letters, numbers, dashes and underscores for the name. > Periods (`.`) are known to cause issues in Cargo. The target name `x86_64-unikraft-linux-musl` was derived from `x86_64-unknown-linux-musl`, setting Unikraft as vendor. Unikraft exactly imitates Linux + musl. > - 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. > - The target must not introduce license incompatibilities. > - Anything added to the Rust repository must be under the standard Rust > license (`MIT OR Apache-2.0`). > - 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. > - 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. > - "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. No dependencies were added to Rust. Requirements for linking are [Unikraft] and [KraftKit] (both BSD-3-Clause), but none of these are added to Rust. [KraftKit]: https://github.com/unikraft/kraftkit > - 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. > - 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. Understood. I am not a member of a Rust team. > - 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. Understood. `std` is supported. > - 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. Building is described in the platform support doc. It will be updated once proper `kraftld` support has landed. > - 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. > - 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. > - 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 don't think this PR breaks anything. r? compiler-team
2023-07-24bootstrap: Define CMake platform if DragonFly.Alex Zepeda-1/+8
CMAKE_SYSTEM_NAME is defined on a cross build if the target is recognized. Without this explicit definition cmake will assume that we're building for the host platform which can bring in unwanted compiler and linker flags. Also, add a warning on cross builds with unknown target to aid in cross builds for future platforms.
2023-07-25Auto merge of #113958 - lukas-code:doc-links, r=GuillaumeGomez,petrochenkovbors-16/+31
fix intra-doc links on nested `use` and `extern crate` items This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested `use` or `extern crate` items, for example: ```rust /// Re-export [`fmt`] and [`io`]. pub use std::{fmt, io}; // "nested" use = use with braces /// Re-export [`std`]. pub extern crate std; ``` Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested `use` items that are declared `pub`. <details> During AST->HIR lowering, nested `use` items are desugared like this: ```rust pub use std::{}; // "list stem" pub use std::fmt; pub use std::io; ``` Each of these HIR nodes has it's own effective visibility and the list stem is always considered private. To check the effective visibility of an AST node, the AST node is mapped to a HIR node with `Resolver::local_def_id`, which returns the (private) list stem for nested use items. </details> For `extern crate`, there was a hack in rustdoc that stored the `DefId` of the crate itself in the cleaned item, instead of the `DefId` of the `extern crate` item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the `extern crate` item. I've removed this hack and instead translate the `DefId` in the appropriate places. As as side effect of fixing `extern crate`, i've turned ```rust #[doc(masked)] extern crate self as _; ``` into a no-op instead of hiding all trait impls. Proper verification for `doc(masked)` is included as a bonus. fixes https://github.com/rust-lang/rust/issues/113896
2023-07-24typosTshepang Mbambo-2/+2
2023-07-24Update cargoArlo Siemsen-0/+0
2023-07-24Auto merge of #114024 - matthiaskrgr:rollup-uhdbq64, r=matthiaskrgrbors-18/+42
Rollup of 8 pull requests Successful merges: - #113969 (add dynamic for smir) - #113985 (Use erased self type when autoderefing for trait error suggestion) - #113987 (Comment stuff in the new solver) - #113992 (arm-none fixups) - #113993 (Optimize format usage) - #113994 (Optimize format usage) - #114006 (Update sparc-unknown-none-elf platform README) - #114021 (Add missing documentation for `Session::time`) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-24bootstrap: Don't bundle musl on UnikraftMartin Kröning-2/+2
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24compiler: Add `*-unikraft-linux-musl` documentationMartin Kröning-0/+69
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24compiler: Add `x86_64-unikraft-linux-musl` targetMartin Kröning-0/+3
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-07-24Rollup merge of #114006 - jonathanpallant:update-sparc-unknown-readme, r=AmanieuMatthias Krüger-18/+42
Update sparc-unknown-none-elf platform README Cherry picked a couple of commits that didn't quite make it in #113535
2023-07-24Perform OpaqueCast field projection on HIR, too.Oli Scherer-0/+2
This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field).
2023-07-24Auto merge of #113956 - fmease:rustdoc-fix-x-crate-rpitits, ↵bors-3/+6
r=GuillaumeGomez,compiler-errors rustdoc: handle cross-crate RPITITs correctly Filter out the internal associated types synthesized during the desugaring of RPITITs, they really shouldn't show up in the docs. This also fixes #113929 since we're no longer invoking `is_impossible_associated_item` (renamed from `is_impossible_method`) which cannot handle them (leading to an ICE). I don't think it makes sense to try to make `is_impossible_associated_item` handle this exotic kind of associated type (CC original author `@compiler-errors).` @ T-rustdoc reviewers, currently I'm throwing out ITIT assoc tys before cleaning assoc tys at each usage-site. I'm thinking about making `clean_middle_assoc_item` return an `Option<_>` instead and doing the check inside of it to prevent any call sites from forgetting the check for ITITs. Since I wasn't sure if you would like that approach, I didn't go through with it. Let me know what you think. <details><summary>Explanation on why <code>is_impossible_associated_item(itit_assoc_ty)</code> leads to an ICE</summary> Given the following code: ```rs pub trait Trait { fn def<T>() -> impl Default {} } impl Trait for () {} ``` The generated associated type looks something like (simplified): ```rs type {opaque#0}<T>: Default = impl Default; // the name is actually `kw::Empty` but this is the `def_path_str` repr ``` The query `is_impossible_associated_item` goes through all predicates of the associated item – in this case `<T as Sized>` – to check if they contain any generic parameters from the (generic) associated type itself. For predicates that don't contain any *own* generics, it does further processing, part of which is instantiating the predicate with the generic arguments of the impl block (which is only correct if they truly don't contain any own generics since they wouldn't get instantiated this way leading to an ICE). It checks if `parent_def_id(T) == assoc_ty_def_id` to get to know if `T` is owned by the assoc ty. Unfortunately this doesn't work for ITIT assoc tys. In this case, the parent of `T` is `Trait::def` (!) which is the associated function (I'm pretty sure this is very intentional) which is of course not equal to the assoc ty `Trait::{opaque#0}`. </details> `@rustbot` label A-cross-crate-reexports
2023-07-24Fix span for punnycodeEric Huss-1/+1
2023-07-24Cache qpath first public resultGuillaume Gomez-27/+50
2023-07-24Revert "Remove needs for transmute"Guillaume Gomez-28/+20
This reverts commit ea9a17b9995b7a076283777b7d462a360fece2d6.
2023-07-24Remove needs for transmuteGuillaume Gomez-20/+28
2023-07-24Re-add missing generics in `first_non_private`Guillaume Gomez-3/+23
2023-07-24Add support for `--document-hidden-items` in `first_non_private`Guillaume Gomez-1/+2
2023-07-24Add test for private itemsGuillaume Gomez-0/+3
2023-07-24Correctly handle `super` and `::`Guillaume Gomez-1/+10
2023-07-24Rename `first_not_private` into `first_non_private`Guillaume Gomez-2/+2
2023-07-24Improve code readabilityGuillaume Gomez-32/+27