about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-04-16Auto merge of #124015 - GuillaumeGomez:rollup-s46ksxa, r=GuillaumeGomezbors-124/+150
Rollup of 14 pull requests Successful merges: - #120781 (Correct usage note on OpenOptions::append()) - #121694 (sess: stabilize `-Zrelro-level` as `-Crelro-level`) - #122521 (doc(bootstrap): add top-level doc-comment to utils/tarball.rs) - #123491 (Fix ICE in `eval_body_using_ecx`) - #123574 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 6)) - #123687 (Update ar_archive_writer to 0.2.0) - #123721 (Various visionOS fixes) - #123797 (Better graphviz output for SCCs and NLL constraints) - #123990 (Make `suggest_deref_closure_return` more idiomatic/easier to understand) - #123995 (Make `thir_tree` and `thir_flat` into hooks) - #123998 (Opaque types have no namespace) - #124001 (Fix docs for unstable_features lint.) - #124006 (Move size assertions for `mir::syntax` types into the same file) - #124011 (rustdoc: update the module-level docs of `rustdoc::clean`) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-16Rollup merge of #124006 - Zalathar:static-assert, r=nnethercoteGuillaume Gomez-2/+1
Move size assertions for `mir::syntax` types into the same file A redundant size assertion for `StatementKind` was added in #122937, because the existing assertion was in a different file. This PR cleans that up, and also moves the `TerminatorKind` assertion into the same file where it belongs, to avoid the same thing happening again. r? `@nnethercote`
2024-04-16Rollup merge of #123998 - compiler-errors:opaque-ns, r=davidtwcoGuillaume Gomez-2/+2
Opaque types have no namespace Opaques are never referenced by name -- even when we have `type X = impl Sized;`, `X` is the name of the type alias, not the opaque.
2024-04-16Rollup merge of #123995 - compiler-errors:thir-hooks, r=oli-obkGuillaume Gomez-21/+14
Make `thir_tree` and `thir_flat` into hooks No need for them to be queries, since they are only called with `-Zunpretty`
2024-04-16Rollup merge of #123990 - compiler-errors:suggest-closure-ret-deref, r=oli-obkGuillaume Gomez-73/+64
Make `suggest_deref_closure_return` more idiomatic/easier to understand The only functional change here really is just making it not use a fresh type variable for upvars. I'll point that out in the code. The rest of the changes are just stylistic, because reading this code was really confusing me (variable names were vague, ways of accessing types were unidiomatic, order of operations was kind of strange, etc). This is stacked on #123989. r? oli-obk since you approved #122213
2024-04-16Rollup merge of #123797 - amandasystems:better-graphviz, r=oli-obkGuillaume Gomez-6/+43
Better graphviz output for SCCs and NLL constraints This PR modifies the output for `-Z dump-mir-graphviz=yes`. Specifically, it changes the output of the files `.-------.nll.0.regioncx.all.dot` and `nll.0.regioncx.scc.dot` to be easier to read and contain some information that helped me during debugging. In particular: - SCC indices are contracted to `SCC(n)` instead of `ConstraintSccIndex(n)` to compress the nodes - SCC regions are in `{}` rather than `[]` (controversial since they are technically ordered by index, but I figured they're more sets than arrays conceptually since they're equivalence classes). - For regions in other universes than the root, also show the region universe (as ?8/U1) - For regions with external names, show the external name in parenthesis - For the region graph where edges are locations, render the All variant of the enum without the file since it's extremely long and often destroys the rendering - For region graph edge annotations for single locations, remove the wrapping around the Location variant and just add its contents since this can be unambiguously done Example output (from the function `foo()` of `tests/ui/error-codes/E0582.rs`) for an SCC graph: ![a graph showing SCCs](https://github.com/rust-lang/rust/assets/102855/0b998338-0379-4829-b99e-d8105c094897) ...and for the constraints: ![a graph showing regions and their constraints](https://github.com/rust-lang/rust/assets/102855/e984c4ca-7aa2-4db2-9878-bf38fe8208d5) This PR also gives `UniverseIndex`es the `is_root()` method since this is now an operation that happens three times in the borrowck crate.
2024-04-16Rollup merge of #123721 - madsmtm:fix-visionos, r=davidtwcoGuillaume Gomez-3/+5
Various visionOS fixes A few small mistakes was introduced in https://github.com/rust-lang/rust/pull/121419, probably after the rename from `xros` to `visionos`. See the commits for details. CC `@agg23` Since you reviewed https://github.com/rust-lang/rust/pull/121419 r? davidtwco
2024-04-16Rollup merge of #123687 - bjorn3:ar_archive_writer_0_2_0, r=oli-obkGuillaume Gomez-9/+2
Update ar_archive_writer to 0.2.0 This adds a whole bunch of tests checking for any difference with llvm's archive writer. It also fixes two mistakes in the porting from C++ to Rust. The first one causes a divergence for Mach-O archives which may or may not be harmless. The second will definitively cause issues, but only applies to thin archives, which rustc currently doesn't create.
2024-04-16Rollup merge of #123491 - gurry:123154-ice-unsized-struct-eval, r=oli-obkGuillaume Gomez-3/+14
Fix ICE in `eval_body_using_ecx` Ensures `TypeckResults` is tainted by failing candidate assembly for types with error Fixes #123154
2024-04-16Rollup merge of #121694 - davidtwco:stabilize-relro-level, r=Mark-SimulacrumGuillaume Gomez-5/+5
sess: stabilize `-Zrelro-level` as `-Crelro-level` Stabilise `-Zrelro-level` as `-Crelro-level`. There's no tracking issue for this flag to close.
2024-04-16Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obkbors-68/+589
Implement syntax for `impl Trait` to specify its captures explicitly (`feature(precise_capturing)`) Implements `impl use<'a, 'b, T, U> Sized` syntax that allows users to explicitly list the captured parameters for an opaque, rather than inferring it from the opaque's bounds (or capturing *all* lifetimes under 2024-edition capture rules). This allows us to exclude some implicit captures, so this syntax may be used as a migration strategy for changes due to #117587. We represent this list of captured params as `PreciseCapturingArg` in AST and HIR, resolving them between `rustc_resolve` and `resolve_bound_vars`. Later on, we validate that the opaques only capture the parameters in this list. We artificially limit the feature to *require* mentioning all type and const parameters, since we don't currently have support for non-lifetime bivariant generics. This can be relaxed in the future. We also may need to limit this to require naming *all* lifetime parameters for RPITIT, since GATs have no variance. I have to investigate this. This can also be relaxed in the future. r? `@oli-obk` Tracking issue: - https://github.com/rust-lang/rust/issues/123432
2024-04-16Fail candidate assembly for erroneous typesGurinder Singh-3/+14
Trait predicates for types which have errors may still evaluate to OK leading to downstream ICEs. Now we return a selection error for such types in candidate assembly and thereby prevent such issues
2024-04-16Move size assertions for `mir::syntax` types into the same fileZalathar-2/+1
A redundant size assertion for `StatementKind` was added in #122937, because the existing assertion was in a different file. This patch cleans that up, and also moves the `TerminatorKind` assertion into the same file where it belongs, to avoid the same thing happening again.
2024-04-15Make suggest_deref_closure_return more idiomatic/easier to understandMichael Goulet-73/+64
2024-04-15Opaque types have no namespaceMichael Goulet-2/+2
2024-04-15Make thir_tree and thir_flat into hooksMichael Goulet-21/+14
2024-04-16Rollup merge of #123989 - compiler-errors:type-dependent-def-id, r=oli-obkLeón Orell Valerian Liehr-53/+21
Just use `type_dependent_def_id` to figure out what the method is for an expr The calls to `lookup_method_for_diagnostic` are overkill. r? oli-obk
2024-04-16Rollup merge of #123926 - compiler-errors:no-ann, r=estebankLeón Orell Valerian Liehr-38/+26
Fix pretty HIR for anon consts in diagnostics This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`. There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh. r? estebank
2024-04-16Rollup merge of #123603 - compiler-errors:no-intrinsic, r=estebankLeón Orell Valerian Liehr-11/+11
Don't even parse an intrinsic unless the feature gate is enabled Don't return true in `tcx.is_intrinsic` if the function is defined locally and `#![feature(intrinsics)]` is not enabled. This is a slightly more general fix than #123526, since #123587 shows that we have simplifying assumptions about intrinsics elsewhere in the compiler. This will make the code ICE again if the user **enables** `#[feature(intrinsics)]`, but I kind of feel like if we want to fix that, we should make the `INTERNAL_FEATURES` lint `Deny` again. Perhaps we could do that on non-nightly compilers. Or we should just stop compilation altogether if they have `#![feature]` enabled on a non-nightly compiler. As for the UX of *real* cases of hitting these ICEs, I believe pretty strongly that if a compiler/stdlib dev is modifying internal intrinsics (intentionally, like when making a change to rustc) we have no guarantee to make the ICE better looking for them. Honestly, *not* spitting out a stack trace is probably a disservice to the people who hit those ICEs in that case. r? `@Nilstrieb` `@estebank`
2024-04-16Rollup merge of #123462 - fmease:rn-mod-sep-to-path-sep, r=nnethercoteLeón Orell Valerian Liehr-40/+42
Cleanup: Rename `ModSep` to `PathSep` `::` is usually referred to as the *path separator* (citation needed). The existing name `ModSep` for *module separator* is a bit misleading since it in fact separates the segments of arbitrary path segments, not only ones resolving to modules. Let me just give a shout-out to associated items (`T::Assoc`, `<Ty as Trait>::function`) and enum variants (`Option::None`). Motivation: Reduce friction for new contributors, prevent potential confusion. cc `@petrochenkov` r? nnethercote or compiler
2024-04-16Rollup merge of #123016 - compiler-errors:no-type-var-origin, r=lcnrLeón Orell Valerian Liehr-407/+206
Remove `TypeVariableOriginKind` and `ConstVariableOriginKind` It's annoying to have to import `TypeVariableOriginKind` just to fill it with `MiscVariable` for almost every use. Every other usage other than `TypeParameterDefinition` wasn't even used -- I can see how it may have been useful once for debugging, but I do quite a lot of typeck debugging and I've never really needed it. So let's just remove it, and keep around the only useful thing which is the `DefId` of the param for `var_for_def`. This is based on #123006, which removed the special use of `TypeVariableOriginKind::OpaqueInference`, which I'm pretty sure I was the one that added. r? lcnr or re-roll to types
2024-04-15Fix pretty hir for anon consts in diagnosticsMichael Goulet-38/+26
2024-04-15Rebase falloutMichael Goulet-8/+8
2024-04-15Just use type_dependent_def_id to figure out what the method is for an exprMichael Goulet-53/+21
2024-04-15nitsMichael Goulet-25/+15
2024-04-15Account for Self params properlyMichael Goulet-20/+19
2024-04-15Remove ConstVariableOriginKindMichael Goulet-63/+26
2024-04-15Remove TypeVariableOriginKindMichael Goulet-305/+152
2024-04-15More polishingMichael Goulet-4/+26
2024-04-15Use a path instead of an ident (and stop manually resolving)Michael Goulet-70/+57
2024-04-15Some ordering and duplication checksMichael Goulet-15/+70
2024-04-15Add hir::Node::PreciseCapturingNonLifetimeArgMichael Goulet-7/+42
2024-04-15Validation and other thingsMichael Goulet-18/+215
2024-04-15Lower and resolve precise captures in HIRMichael Goulet-46/+108
2024-04-15Implement resolution, parse use<Self>Michael Goulet-3/+29
2024-04-15Use dedicated PreciseCapturingArg for representing what goes in use<>Michael Goulet-56/+146
2024-04-15Begin AST lowering for precise capturesMichael Goulet-29/+50
2024-04-15Parsing , pre-lowering support for precise capturesMichael Goulet-15/+41
2024-04-15Rollup merge of #123924 - compiler-errors:tuple-sugg, r=estebankMichael Goulet-130/+81
Fix various bugs in `ty_kind_suggestion` Consolidates two implementations of `ty_kind_suggestion` Fixes some misuse of the empty param-env Fixes a problem where we suggested `(42)` instead of `(42,)` for tuple suggestions Suggest a value when `return;`, making it consistent with `break;` Fixes #123906
2024-04-15Rollup merge of #123900 - compiler-errors:nobound, r=lcnrMichael Goulet-61/+39
Stop using `PolyTraitRef` for closure/coroutine predicates already instantiated w placeholders r? lcnr
2024-04-15PolyTraitRefs -> TraitRefsMichael Goulet-43/+20
2024-04-15Rollup merge of #123941 - Mark-Simulacrum:fix-llvm-ub, r=nikic许杰友 Jieyou Xu (Joe)-6/+29
Fix UB in LLVM FFI when passing zero or >1 bundle Rust passes a `*const &OperandBundleDef` to these APIs, usually from a `Vec<&OperandBundleDef>` or so. Previously we were dereferencing that pointer and passing it to the ArrayRef constructor with some length (N). This meant that if the length was 0, we were dereferencing a pointer to nowhere (if the vector on the Rust side didn't actually get allocated or so), and if the length was >1 then loading the *second* element somewhere in LLVM would've been reading past the end. Since Rust can't hold OperandBundleDef by-value we're forced to indirect through a vector that copies out the OperandBundleDefs from the by-reference list on the Rust side in order to match the LLVM expected API.
2024-04-15Rollup merge of #123934 - WaffleLapkin:graph-mini-refactor, r=fmease许杰友 Jieyou Xu (Joe)-193/+89
`rustc_data_structures::graph` mini refactor Who doesn't love to breathe dust from the ancient times?
2024-04-15Rollup merge of #123933 - RalfJung:large-assignments, r=michaelwoerister许杰友 Jieyou Xu (Joe)-140/+161
move the LargeAssignments lint logic into its own file The collector is a file full of very subtle logic, so let's try to keep that separate from the logic that only serves to implement this lint.
2024-04-15Rollup merge of #123931 - compiler-errors:variance-unnameables, r=fmease许杰友 Jieyou Xu (Joe)-17/+12
Don't leak unnameable types in `-> _` recover Fixes #123899
2024-04-15Rollup merge of #123922 - TDecking:base_n_magic_removal, r=jieyouxu许杰友 Jieyou Xu (Joe)-3/+3
Remove magic constants when using `base_n`. Some use cases of `base_n` use number literals instead of the predefined constants. The latter are more descriptive so it might be better to use those instead.
2024-04-15Rollup merge of #123919 - RalfJung:discriminant, r=compiler-errors许杰友 Jieyou Xu (Joe)-60/+60
builtin-derive: tag → discriminant As far as I can tell, all of this operates on the discriminant, not the tag. After all, with something like `Option<&T>`, the "tag" of the `Some` variant is basically just the reference value, which is never what you want to compare when figuring out which variant the enum is in. See [here](https://rustc-dev-guide.rust-lang.org/appendix/glossary.html) for an explanation of the difference between tag and discriminant.
2024-04-15Rollup merge of #123896 - JeanCASPAR:rustc_resolve-to-session-diagnostic, ↵许杰友 Jieyou Xu (Joe)-278/+795
r=jieyouxu Migrate some diagnostics in `rustc_resolve` to session diagnostic Hello, I migrated some diagnostics in `rustc_resolve` to session diagnostic. r? ``@davidtwco``
2024-04-15Rollup merge of #123864 - oli-obk:define_opaque_types3, r=compiler-errors许杰友 Jieyou Xu (Joe)-36/+6
Remove a HACK by instead inferring opaque types during expected/formal type checking I was wondering why I couldn't come up with a test that hits the code path of the argument check checking the types we inferred from the return type... Turns out we reject those attempts early during fudging. I have absolutely no information for you as to what kind of type inference changes this may incur, but I think we should just land this out of two reasons: * had I found the other place to use opaque type inference on before I added the hack, we'd be using that today and this PR would never have happened * if it is possible to hit this path, it requires some god awful recursive RPIT logic that I doubt anyone would have written without actively trying to write obscure code r? ``@ghost``
2024-04-15Stop using PolyTraitRef for closure/coroutine predicates already ↵Michael Goulet-28/+29
instantiated w placeholders