about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-09-21reviewlcnr-78/+75
2023-09-21wlcnr-1/+1
2023-09-21slight refactor, add commentlcnr-11/+20
2023-09-21HACK: avoid hang in structurally_normalizelcnr-3/+9
2023-09-21proof trees: use for `intercrate_ambiguity_causes`lcnr-221/+757
2023-09-21Auto merge of #115549 - saethlin:include-bytes-resilient, r=jackh726bors-2/+58
Fall back to the unoptimized implementation in read_binary_file if File::metadata lies Fixes https://github.com/rust-lang/rust/issues/115458 r? `@jackh726` because you approved the previous PR
2023-09-20Add unit tests based on files that return odd sizes to statBen Kimock-0/+27
2023-09-20Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkinbors-214/+113
Simplify/Optimize FileEncoder FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing. So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written. The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small. Fixes https://github.com/rust-lang/rust/issues/115298 Fixes https://github.com/rust-lang/rust/issues/114671 Fixes https://github.com/rust-lang/rust/issues/114045 Fixes https://github.com/rust-lang/rust/issues/108100 Fixes https://github.com/rust-lang/rust/issues/106787
2023-09-20PR feedbackBen Kimock-36/+55
2023-09-20Auto merge of #115987 - loongarch-rs:fix-transparent-union-abi, r=bjorn3bors-0/+11
rustc_target/loongarch: Fix passing of transparent unions with only one non-ZST member This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function. Fixes https://github.com/rust-lang/rust/issues/115509 r? `@bjorn3`
2023-09-20Auto merge of #115870 - RalfJung:const-value-slice, r=oli-obkbors-62/+74
adjust ConstValue::Slice to work for arbitrary slice types valtrees have already been assuming that this works; this PR makes it a reality. Also further restrict `ConstValue::Slice` to what it is actually used for; this even shrinks `ConstValue` from 32 to 24 bytes which is a nice win. :) The alternative to this approach is to make `ConstValue::Slice` work really only for `&str`/`&[u8]` literals, and never return it in `op_to_const`. That would make `op_to_const` very clean. We could then even remove the `meta` field; the length would always be `data.inner().len()`. We could *almost* just use a `Symbol` instead of a `ConstAllocation`, but we have to support byte strings and there doesn't seem to be an interned representation of them (or rather, `ConstAllocation` *is* their interned representation). In this world, valtrees of slice reference types would then become noticeably more expensive to turn into a `ConstValue` -- but does that matter? Specifically for `&str`/`&[u8]` we could still use the optimized representation if we wanted. If byte strings were already interned somewhere I'd gravitate towards the alternative, but the way things stand, we need a `ConstAllocation` case anyway to support byte strings, and then we might as well support arbitrary slices. (Or we say that byte strings don't get an optimized representation at all. Such a performance cliff between `str` and byte strings is probably unexpected, though due to the lack of interning for byte strings I think there might already be a performance cliff there.)
2023-09-20Rollup merge of #115962 - Zalathar:debug, r=oli-obkGuillaume Gomez-1048/+38
coverage: Remove debug code from the instrumentor The coverage instrumentor has an entire module full of complex code that is only used for debugging. And as I continue to work on coverage, I keep finding that this debug code is constantly causing more trouble than it's worth. It's deeply entangled with current implementation details, such that making any non-trivial change to the instrumentor usually requires major changes to the debug code. And so far I have personally not found any of this debug code to be *useful*. In light of that situation, I'd like to try just ripping all of it out. If I spend any more time dealing with coverage debug code, I want it to be because I'm writing new and useful tools, not dutifully maintaining a boat-anchor that quite plausibly isn't being used by anyone at all. --- r? `@ghost` `@rustbot` label +A-code-coverage --- [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Removing.20debug.20code.20from.20the.20coverage.20instrumentor)
2023-09-20Rollup merge of #115566 - ↵Guillaume Gomez-58/+23
zirconium-n:issue-107250-clean-up-unused-to-predicate, r=oli-obk clean up unneeded `ToPredicate` impls Part of #107250. Removed all totally unused impls. And inlined two impls not need to satisify trait bound. r? `@oli-obk`
2023-09-20Auto merge of #115827 - eduardosm:miri-sse-reduce-code-dup, r=RalfJungbors-4/+18
miri: reduce code duplication in some SSE/SSE2 intrinsics Reduces code duplication in the Miri implementation of some SSE and SSE2 using generics and rustc_const_eval helper functions. There are also some other minor changes. r? `@RalfJung`
2023-09-20Rollup merge of #115983 - eopb:confusing-if-chain-indent, r=compiler-errorsMatthias Krüger-3/+3
fix confusing let chain indentation in rustc_resolve Sorry for opening a PR for such a minor style fix. This just felt sufficiently misleading to warrant fixing.
2023-09-20coverage: Remove vestigial counter/expression debug labelsZalathar-22/+5
2023-09-20coverage: Remove vestigial `format_counter` methodsZalathar-40/+20
2023-09-20coverage: Remove debug code from the instrumentorZalathar-991/+18
2023-09-20Auto merge of #115486 - compiler-errors:dont-capture-late-pls, r=cjgillotbors-30/+73
Correctly deny late-bound lifetimes from parent in anon consts and TAITs Reuse the `AnonConstBoundary` scope (introduced in #108553, renamed in this PR to `LateBoundary`) to deny late-bound vars of *all* kinds (ty/const/lifetime) in anon consts and TAITs. Side-note, but I would like to consolidate this with the error reporting for RPITs (E0657): https://github.com/rust-lang/rust/blob/c4f25777a08cd64b710e8a9a6159e67cbb35e6f5/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs#L733-L754 but the semantics about what we're allowed to capture there are slightly different, so I'm leaving that untouched. Fixes #115474
2023-09-20rustc_target/loongarch: Fix passing of transparent unions with only one ↵WANG Rui-0/+11
non-ZST member This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function. Fixes https://github.com/rust-lang/rust/issues/115509
2023-09-19Auto merge of #113955 - cjgillot:name-apit, r=WaffleLapkinbors-11/+8
Pretty-print argument-position impl trait to name it. This removes a corner case. RPIT and TAIT keep having no name, and it would be wrong to use the one in HIR (Ident::empty), so I make this case ICE.
2023-09-19fix confusing let chain indentation in rustc_resolveEthan Brierley-3/+3
2023-09-20remove `impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for ↵Ziru Niu-26/+23
PolyProjectionPredicate<'tcx>`
2023-09-20remove unneeded `ToPredicate` implsZiru Niu-32/+0
2023-09-19Auto merge of #115979 - GuillaumeGomez:rollup-06ujzgh, r=GuillaumeGomezbors-1/+48
Rollup of 6 pull requests Successful merges: - #113383 (style-guide: Add section on bugs, and resolving bugs) - #115499 (rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member) - #115801 (Detect cycle errors hidden by opaques during monomorphization) - #115947 (Custom code classes in docs warning) - #115957 (fix mismatched symbols) - #115958 (explain mysterious addition in float minimum/maximum) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-19Rollup merge of #115801 - compiler-errors:async-cycle-mono, r=oli-obkGuillaume Gomez-1/+25
Detect cycle errors hidden by opaques during monomorphization Opaque types may reveal to projections, which themselves normalize to opaques. We don't currently normalize when checking that opaques are cyclical, and we may also not know that the opaque is cyclical until monomorphization (see `tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs`). Detect cycle errors in `normalize_projection_ty` and report a fatal overflow (in the old solver). Luckily, this is already detected as a fatal overflow in the new solver. Fixes #112047
2023-09-19Rollup merge of #115499 - msizanoen1:riscv-fix-transparent-union-abi, r=bjorn3Guillaume Gomez-0/+23
rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function. Fixes https://github.com/rust-lang/rust/issues/115481. r? `@RalfJung`
2023-09-19adjust constValue::Slice to work for arbitrary slice typesRalf Jung-62/+74
2023-09-19Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-sebors-26/+54
Don't modify libstd to dump rustc ICEs Do a much simpler thing and just dump a `std::backtrace::Backtrace` to file. r? `@estebank` `@oli-obk` Fixes #115610
2023-09-19Auto merge of #115865 - RalfJung:mir-mod, r=oli-obkbors-2197/+2253
move things out of mir/mod.rs This moves a bunch of things out of `mir/mod.rs`: - all const-related stuff to a new file consts.rs - all statement/place/operand-related stuff to a new file statement.rs - all pretty-printing related stuff to pretty.rs `mod.rs` started out with 3100 lines and ends up with 1600. :) Also there was some pretty-printing stuff in terminator.rs, that also got moved to pretty.rs, and I reordered things in pretty.rs so that it can be grouped by functionality. Only the commit "use pretty_print_const_value from MIR constant 'extra' printing" has any behavior changes; it resolves the issue of having a fancy and a very crude pretty-printer for `ConstValue`. r? `@oli-obk`
2023-09-19rustc_target/riscv: Fix passing of transparent unions with only one non-ZST ↵msizanoen-0/+23
member This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function. Fixes https://github.com/rust-lang/rust/issues/115481.
2023-09-19Rollup merge of #115924 - compiler-errors:non-exhaustive-1-zst, r=RalfJungGuillaume Gomez-19/+29
Don't complain on a single non-exhaustive 1-ZST r? RalfJung, though you mentioned being busy, so feel free to reassign. This doesn't actually attempt to make the diagnostic better, so when we have two non-exhaustive 1-ZSTs in a struct, we still just point to one. 🤷 Fixes #115922
2023-09-19Rollup merge of #115625 - compiler-errors:hrtb-infer-err, r=b-naberGuillaume Gomez-0/+75
Explain HRTB + infer limitations of old solver Add a helpful message when we hit the limitation of the old trait solver where we don't properly normalize GATs with infer vars + bound vars, leading to too-eagerly reporting trait errors that would be later satisfied due to inference.
2023-09-19Rollup merge of #114941 - compiler-errors:inline-shadowed-by-dyn, r=lcnrGuillaume Gomez-1/+51
Don't resolve generic impls that may be shadowed by dyn built-in impls **NOTE:** This is a hack. This is not trying to be a general fix for the issue that we've allowed overlapping built-in trait object impls and user-written impls for quite a long time, and traits like `Any` rely on this (#57893) -- this PR specifically aims to mitigate a new unsoundness that is uncovered by the MIR inliner (#114928) that interacts with this pre-existing issue. Builtin `dyn Trait` impls may overlap with user-provided blanket impls (`impl<T: ?Sized> Trait for T`) in generic contexts. This leads to bugs when instances are resolved in polymorphic contexts, since we typically prefer object candidates over impl candidates. This PR implements a (hacky) heuristic to `resolve_associated_item` to account for that unfortunate hole in the type system -- we now bail with ambiguity if we try to resolve a non-rigid instance whose self type is not known to be sized. This makes sure we can still inline instances like `impl<T: Sized> Trait for T`, which can never overlap with `dyn Trait`'s built-in impl, but we avoid inlining an impl that may be shadowed by a `dyn Trait`. Fixes #114928
2023-09-19comment on the difference between mir::ConstantKind::Unevaluated and ↵Ralf Jung-0/+5
mir::ConstantKind::Ty(ty::ConstKind::Unevaluated)
2023-09-19move ConstValue into mirRalf Jung-247/+239
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-19organize mir pretty.rs and move more things into it; move statement-related ↵Ralf Jung-1371/+1393
things out of mir/mod.rs
2023-09-19use pretty_print_const_value from MIR constant 'extra' printingRalf Jung-128/+153
2023-09-19move some MIR const pretty-printing into pretty.rsRalf Jung-177/+176
2023-09-19more MIR const types to separate fileRalf Jung-409/+422
2023-09-19Don't complain on a single non-exhaustive 1-zstMichael Goulet-19/+29
2023-09-19Don't resolve generic instances if they may be shadowed by dynMichael Goulet-1/+51
2023-09-19Explain HRTB + infer limitations of old solverMichael Goulet-0/+75
2023-09-19Auto merge of #115289 - compiler-errors:adjust-comments, r=estebankbors-32/+34
Add some needed comments in `adjust_fulfillment_errors.rs` r? `@estebank`
2023-09-19Auto merge of #115644 - danakj:catalyst-asan, r=cjgillot,thomccbors-2/+4
Enable ASAN/LSAN/TSAN for *-apple-ios-macabi The -macabi targets are iOS running on MacOS, and they use the runtime libraries for MacOS, thus they have the same sanitizers available as the *-apple-darwin targets. This is based on the work of https://github.com/rust-lang/rust/commit/aacf3213b142f074999429eab767ef7b53c3a1a5. Closes #113935.
2023-09-19Rollup merge of #115930 - Zalathar:spans-bug, r=compiler-errorsMatthias Krüger-34/+20
coverage: Fix an unstable-sort inconsistency in coverage spans This code was calling `sort_unstable_by`, but failed to impose a total order on the initial spans. That resulted in unpredictable handling of closure spans, producing inconsistencies in the coverage maps and in user-visible coverage reports. This PR fixes the problem by always sorting closure spans before otherwise-identical non-closure spans, and also switches to a stable sort in case the ordering is still not total. --- In addition to the fix itself, this PR also contains a cleanup to the comparison function that I was working on when I discovered the bug.
2023-09-19Rollup merge of #115879 - clubby789:migrate-hir-typeck-cast, r=compiler-errorsMatthias Krüger-182/+313
Migrate diagnostics in `hir_typeck/src/cast.rs`
2023-09-19Rollup merge of #115873 - BoxyUwU:tykind_adt_debug, r=oli-obkMatthias Krüger-2/+22
Make `TyKind::Adt`'s `Debug` impl be more pretty Currently `{:?}` on `Ty` for a `TyKind::Adt` would print as `Adt(Foo, [])`. This PR changes it to be `Foo` when there are no generics or `Foo<T>`/`Foo<T, U>` when there _are_ generics. Example from debug log: `├─0ms DEBUG rustc_hir_analysis::astconv return=Bar<T/#0, U/#1>` I should have done this in my initial PR for a prettier TyKind: Debug impl but I thought I would need to be accessing generics_of to figure out where in the "path" the generics would have to go??? but no, adts literally only have a single place the generics can go (on the end). Feel a bit silly about this :) r? `@oli-obk`
2023-09-19Rollup merge of #115869 - ferrocene:pa-fix-tests-cargo-remap, r=compiler-errorsMatthias Krüger-7/+49
Avoid blessing cargo deps's source code in ui tests Before this PR, the source code of dependencies was included in UI test error messages whenever possible. Unfortunately, "whenever possible" means in some cases the source code wouldn't be injected, resulting in a test failure. One such case is when `$CARGO_HOME` is remapped to something that is not present on disk [^1]. As the remapped path doesn't exist on disk, the source code wouldn't be showed in `tests/ui/issues/issue-21763.rs`: ```diff = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send` note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>` --> $HASHBROWN_SRC_LOCATION - | -LL | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> { - | ^^^^^^^ note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>` --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL note: required by a bound in `foo` ``` This PR fixes the problem by always hiding dependencies source code in the error messages generated during UI tests. This is implemented with a new internal flag, `-Z ignore-directory-in-diagnostics-source-blocks=$path`, which compiletest passes during UI tests. Once this is merged, remapping the Cargo home will be supported. This PR is best reviewed commit-by-commit. [^1]: After being puzzled for a bit, I discovered why this never impacted `rust-lang/rust`: we don't remap `$CARGO_HOME` :sweat_smile:. Instead, we set `$CARGO_HOME` to `/cargo` in CI, which sort-of-but-not-really achieves the same effect.
2023-09-18Auto merge of #115940 - matthiaskrgr:rollup-5ps9ln1, r=matthiaskrgrbors-114/+45
Rollup of 6 pull requests Successful merges: - #109409 (Add `minmax{,_by,_by_key}` functions to `core::cmp`) - #115494 (get rid of duplicate primitive_docs) - #115663 (ci: actions/checkout@v3 to actions/checkout@v4) - #115762 (Explain revealing of opaque types in layout_of ParamEnv) - #115891 (simplify inject_impl_of_structural_trait) - #115932 (Expand infra-ci reviewer list) r? `@ghost` `@rustbot` modify labels: rollup