about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-07-27Rollup merge of #114123 - oli-obk:tait_wtf, r=WaffleLapkinGuillaume Gomez-6/+9
Turns out opaque types can have hidden types registered during mir validation See the newly added test's documentation for an explanation. fixes #114121
2023-07-27Rollup merge of #114117 - compiler-errors:return-to-uniq, r=lcnrGuillaume Gomez-12/+15
Restore region uniquification in the new solver 🎉 All of the bugs that were "due" to uniquification have been settled via other means (e.g. bidirectional alias-relate, param-env incompleteness, etc). Firstly, revert the functional changes in #110180. 😸 Secondly, we need to ignore regions when considering if a goal has changed (the "has_changed" boolean returned from `evaluate_goal`) -- otherwise, because we're doing region uniquification, we may perpetually consider a goal to be changed. See the UI test I committed for an explanation.
2023-07-27Rollup merge of #114088 - oli-obk:syn, r=davidtwcoGuillaume Gomez-2/+1
Bump syn dependency r? `@davidtwco` because this affects diagnostics derive diagnostics (yes this sentence is grammatically correct)
2023-07-27Auto merge of #113281 - dayo05:master, r=davidtwcobors-14/+111
Implement diagnostic translation for rustc-errors This is my first PR to rustc yeah~ I'm going to implement diagnostic translation on rustc-errors crate. This PR is WIP, the reason of opening this as draft, I want to show my code to prevent the issue caused by misunderstanding and also I have few questions. Some error messages are processed by `pluralize!` macro which determines to use plural word or not. From now, I make two kinds of keys and combine with enum but I'm not sure is this best method to do it. Is there any prefered method to do this? => This resolved on conversation on PR. I'll remain to perform force-push until my first implementation looks good to me
2023-07-27Turns out opaque types can have hidden types registered during mir validationOli Scherer-6/+9
2023-07-27Auto merge of #114080 - compiler-errors:negative, r=spastorinobors-1/+1
Don't treat negative trait predicates as always knowable We don't need this. It was added in #90104 but I don't really know why. It's not sound afaict -- negative trait predicates need the same coherence-ambiguity/orphan check rules as positive ones. r? `@lcnr` cc `@spastorino,` do you remember why?
2023-07-27Auto merge of #114116 - matthiaskrgr:rollup-dtdfk76, r=matthiaskrgrbors-527/+426
Rollup of 7 pull requests Successful merges: - #113872 (Tweak CGU sorting in a couple of places.) - #114053 (CI: fix CMake installation for 32/64 bit `dist` Linux) - #114075 (inline format!() args from rustc_codegen_llvm to the end (4)) - #114081 (`desugar_doc_comments` cleanups) - #114082 (add stable NullaryOp) - #114098 (replace atty crate with std's IsTerminal) - #114102 (Dont pass `-Zwrite-long-types-to-disk=no` for `ui-fulldeps --stage=1`) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-27Rollup merge of #114098 - klensy:drop-atty, r=fee1-deadMatthias Krüger-4/+4
replace atty crate with std's IsTerminal
2023-07-27Rollup merge of #114082 - ericmarkmartin:smir-nullary-op, r=spastorinoMatthias Krüger-1/+6
add stable NullaryOp r? `@spastorino`
2023-07-27Rollup merge of #114081 - nnethercote:desugar_doc_comments-cleanups, ↵Matthias Krüger-21/+27
r=petrochenkov `desugar_doc_comments` cleanups r? `@petrochenkov`
2023-07-27Rollup merge of #114075 - matthiaskrgr:fmt_args_rustc_3, r=wesleywiserMatthias Krüger-498/+385
inline format!() args from rustc_codegen_llvm to the end (4) r? `@WaffleLapkin`
2023-07-27Rollup merge of #113872 - nnethercote:tweak-cgu-sorting, r=pnkfelixMatthias Krüger-3/+4
Tweak CGU sorting in a couple of places. In `base.rs`, tweak how the CGU size interleaving works. Since #113777, it's much more common to have multiple CGUs with identical sizes. With the existing code these same-sized items ended up in the opposite-to-desired order due to the stable sorting. The code now starts with a reverse sort (like is done in `partitioning.rs`) which gives the behaviour we want. This doesn't matter much for perf, but makes profiles in `samply` look more like what we expect. In `partitioning.rs`, we can use `sort_by_key` instead of `sort_by_cached_key` because `CGU::size_estimate()` is cheap. (There is an identical CGU sort earlier in that function that already uses `sort_by_key`.) r? `@pnkfelix`
2023-07-27Consider a goal as NOT changed if its response is identity modulo regionsMichael Goulet-1/+1
2023-07-27Revert "don't uniquify regions when canonicalizing"Michael Goulet-11/+14
This reverts commit 171f5414705194067557cd7b70bd680308b9cced.
2023-07-27Auto merge of #113708 - rcvalle:rust-cfi-fix-100778, r=compiler-errorsbors-34/+45
CFI: Fix ICE: encode_const: unexpected type [usize Fixes #100778 and #113366, and complements #106547 by adding support for encoding const parameters.
2023-07-26Auto merge of #113843 - wesleywiser:replace_rustc_apfloat, r=pnkfelixbors-7728/+3
Replace in-tree `rustc_apfloat` with the new version of the crate Replace the in-tree version of `rustc_apfloat` with the new version of the crate which has been correctly licensed. The new crate incorporates upstream changes from LLVM since the original port was done including many correctness fixes and has been extensively fuzz tested to validate correctness. Fixes #100233 Fixes #102403 Fixes #113407 Fixes #113409 Fixes #55993 Fixes #93224 Closes #93225 Closes #109573
2023-07-26Rollup merge of #114073 - ehuss:remove-z-diagnostic-width, r=fee1-deadMatthias Krüger-2/+0
Remove -Z diagnostic-width This removes the `-Z diagnostic-width` option since it is ignored and does nothing. `-Z diagnostic-width` was stabilized as `--diagnostic-width` in #95635. It is not entirely clear why the `-Z` flag was kept, but in part its final use was removed in #102216, but the `-Z` flag itself was not removed.
2023-07-26Rollup merge of #114070 - blyxyas:iter_mut_symbol, r=oli-obkMatthias Krüger-0/+2
Add `sym::iter_mut` + `sym::as_mut_ptr` for Clippy We currently have `sym::iter` and `sym::iter_repeat`, this PR adds `sym::iter_mut` as it's useful for https://github.com/rust-lang/rust-clippy/pull/11038 and another Clippy lint, it also adds `sym::as_mut_ptr` as it's useful for https://github.com/rust-lang/rust-clippy/pull/10962.
2023-07-26Rollup merge of #113942 - ehuss:squelch-bad_path_expr_1, r=fee1-deadMatthias Krüger-24/+57
Squelch a noisy rustc_expand unittest The test `rustc_parse::tests::bad_path_expr_1` prints an error message to stderr, circumventing libtest's stderr intercept. This causes noise when running tests, in particular they show up 16 times on the GitHub Actions summary page. The solution here is to not use an error emitter that prints to stderr, and instead check that the correct error is generated.
2023-07-26Rollup merge of #113930 - spastorino:smir-types-6, r=oli-obkMatthias Krüger-2/+34
Add Param and Bound ty to SMIR r? ``@oli-obk``
2023-07-26Auto merge of #113457 - davidtwco:lint-ctypes-issue-113436, r=oli-obkbors-46/+39
lint/ctypes: fix `()` return type checks Fixes #113436. `()` is normally FFI-unsafe, but is FFI-safe when used as a return type. It is also desirable that a transparent newtype for `()` is FFI-safe when used as a return type. In order to support this, when a type was deemed FFI-unsafe, because of a `()` type, and was used in return type - then the type was considered FFI-safe. However, this was the wrong approach - it didn't check that the `()` was part of a transparent newtype! The consequence of this is that the presence of a `()` type in a more complex return type would make it the entire type be considered safe (as long as the `()` type was the first that the lint found) - which is obviously incorrect. Instead, this logic is removed, and after [consultation with t-lang](https://github.com/rust-lang/rust/issues/113436#issuecomment-1640756721), I've fixed the bugs and inconsistencies and made `()` FFI-safe within types. I also refactor a function, but that's not too exciting.
2023-07-26Squelch a noisy rustc_expand unittestEric Huss-24/+57
2023-07-26replace atty crate with std's isTerminalklensy-4/+4
2023-07-26Replace in-tree `rustc_apfloat` with the new version of the crateWesley Wiser-7728/+3
2023-07-26Auto merge of #114071 - RalfJung:interpret-generic-read-write, r=oli-obkbors-246/+278
interpret: make read/write methods generic Instead of always having to call `into()` to convert things to `PlaceTy`/`OpTy`, make the relevant methods generic. This also means that when we read from an `MPlaceTy`, we avoid creating an intermediate `PlaceTy`. This makes it feasible to remove the `Copy` from `MPlaceTy`. All the other `*Ty` interpreter types already had their `Copy` removed a while ago so this is only consistent. (And in fact we had one function that accidentally took `MPlaceTy` instead of `&MPlaceTy`.)
2023-07-26Add Bound ty to SMIRSantiago Pastorino-1/+18
2023-07-26Add Param ty to SMIRSantiago Pastorino-1/+16
2023-07-26Auto merge of #114054 - oli-obk:cleanups, r=estebankbors-86/+45
Split some functions with many arguments into builder pattern functions r? `@estebank` This doesn't resolve all of the ones in rustc, mostly because I need to do other cleanups in order to be able to use some builder derives from crates.io Works around https://github.com/rust-lang/rust/issues/90672 by making `x test rustfmt --bless` format itself instead of testing that it is formatted
2023-07-26valtree: a bit of cleanupRalf Jung-15/+15
2023-07-26Bump syn now that it doesn't affect diagnostics anymoreOli Scherer-2/+1
2023-07-26add stable NullaryOpEric Mark Martin-1/+6
2023-07-26Add a comment to `TokenCursor::desugar_doc_comments`.Nicholas Nethercote-0/+3
Useful information that took me some time to discern.
2023-07-26Remove `desugar_doc_comments` arguments from `TokenCursor::{inlined_,}next`.Nicholas Nethercote-19/+24
Because it's now always `self.desugar_doc_comments`.
2023-07-26Tweak `Parser::look_ahead`.Nicholas Nethercote-1/+1
It doesn't really matter what the `desugar_doc_comments` argument is here, because in practice we never look ahead through doc comments. Changing it to `cursor.desugar_doc_comments` will allow some follow-up simplifications.
2023-07-26Don't treat negative trait predicates as always knowableMichael Goulet-1/+1
2023-07-26Auto merge of #113893 - mdibaiee:type-name-spill-flag, r=compiler-errorsbors-2/+10
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-25Add `sym::iter_mut` + `sym::as_mut_ptr`blyxyas-0/+2
2023-07-26Remove `Parser::desugar_doc_comments`.Nicholas Nethercote-3/+1
It's currently stored twice: once in `Parser`, once in the `TokenStream` within `Parser`. We only need the latter.
2023-07-25Rollup merge of #114044 - ericmarkmartin:more-stable-impls, r=spastorinoMatthias Krüger-55/+110
factor out more stable impls I saw some logic must resembling stable impls and thought it might be nice to factor it out r? `@spastorino`
2023-07-25Rollup merge of #113661 - oli-obk:tait_wtf, r=lcnrMatthias Krüger-9/+186
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-25Rollup merge of #113578 - compiler-errors:uncallable-sig, r=b-naberMatthias Krüger-0/+8
Don't say that a type is uncallable if its fn signature has errors in it This is fallout from #106309, where we don't consider param-env candidates that reference errors because they unify with everything. This means, however, that we don't consider an APIT like `impl Fn(MissingType)` isn't considered to implement `Fn`, for example. We can double-check that with a weaker heuristic [`extract_callable_info`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/fn_ctxt/struct.FnCtxt.html#method.extract_callable_info), and suppress the knock-down error using that. Fixes #113566
2023-07-25Rollup merge of #112995 - strottos:ref-clone-suggestions, r=fee1-deadMatthias Krüger-0/+84
Check for `<&NotClone as Clone>::clone()` calls and suggest to add Clone trait appropriately Added recursive checking back up the HIR to see if a `Clone` suggestion would be helpful. Addresses https://github.com/rust-lang/rust/issues/112857 Largely based on: https://github.com/rust-lang/rust/pull/112977
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-498/+385
r? @WaffleLapkin
2023-07-25Remove -Z diagnostic-widthEric Huss-2/+0
2023-07-25make MPlaceTy non-CopyRalf Jung-16/+16
2023-07-25interpret: make read functions generic over operand typeRalf Jung-83/+85
2023-07-25interpret: make write functions generic over the place typeRalf Jung-139/+169
2023-07-25Auto merge of #114063 - matthiaskrgr:rollup-c90czu6, r=matthiaskrgrbors-69/+140
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-25Rollup merge of #114060 - davidtwco:issue-113279, r=wesleywiserMatthias Krüger-7/+15
abi: unsized field in union - assert to delay bug Fixes #113279. > Unions cannot have unsized fields, and as such, layout computation for unions asserts that each union field is sized (as this would normally have halted compilation earlier). > > However, if a generator ends up with an unsized local - a circumstance in which an error will always have been emitted earlier, for example, if attempting to dereference a `&str` - then the generator transform will produce a union with an unsized field. > > Since https://github.com/rust-lang/rust/pull/110107, later passes will be run, such as constant propagation, and can attempt layout computation on the generator, which will result in layout computation of `str` in the context of it being a field of a union - and so the aforementioned assertion would cause an ICE. > > It didn't seem appropriate to try and detect this case in the MIR body and skip this specific pass; tainting the MIR body or delaying a bug from the generator transform (or elsewhere) wouldn't prevent this either (as neither would prevent the later pass from running); and tainting when the deref of `&str` is reported, if that's possible, would unnecessarily prevent potential other errors from being reported later in compilation, and is very tailored to this specific case of getting a unsized type in a generator. > > Given that this circumstance can only happen when an error should have already been reported, the correct fix appears to be just changing the assert to a delayed bug. This will still assert if there is some circumstance where this occurs and no error has been reported, but it won't crash the compiler in this instance. While debugging this, I noticed a translation ICE in a delayed bug, so I fixed that too: > During borrowck, the `MultiSpan` from a buffered diagnostic is cloned and used to emit a delayed bug indicating a diagnostic was buffered - when the buffered diagnostic is translated, then the cloned `MultiSpan` may contain labels which can only render with the diagnostic's arguments, but the delayed bug being emitted won't have those arguments. Adds a function which clones `MultiSpan` without also cloning the contained labels, and use this function when creating the buffered diagnostic delayed bug.
2023-07-25Rollup merge of #114058 - chenyukang:yukang-fix-113981-crate-arg, ↵Matthias Krüger-2/+20
r=fmease,oli-obk Add help for crate arg when crate name is invalid Fixes #113981