about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-08-16rustdoc: box ItemKind::TraitMichael Howell-7/+7
This reduces the memory consumption of ItemKind.
2022-08-16rustdoc: factor Type::QPath out into its own boxMichael Howell-40/+47
This reduces the size of Type.
2022-08-16Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errorsbors-0/+67
Fix #95079 unhelpful error when missing move in nested closure Fix #95079 by adding help for missing move in nested closure
2022-08-16Auto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkovbors-113/+113
Shrink `ast::Attribute`. r? `@ghost`
2022-08-16Rollup merge of #100590 - TaKO8Ki:suggest-adding-array-length, r=compiler-errorsMatthias Krüger-21/+97
Suggest adding an array length if possible fixes #100448
2022-08-16Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisaMatthias Krüger-115/+15
Update the minimum external LLVM to 13 With this change, we'll have stable support for LLVM 13 through 15 (pending release). For reference, the previous increase to LLVM 12 was #90175. r? `@nagisa`
2022-08-16Rollup merge of #100384 - ridwanabdillahi:instr_profile_output, r=wesleywiserMatthias Krüger-8/+37
Add support for generating unique profraw files by default when using `-C instrument-coverage` Currently, enabling the rustc flag `-C instrument-coverage` instruments the given crate and by default uses the naming scheme `default.profraw` for any instrumented profile files generated during the execution of a binary linked against this crate. This leads to multiple binaries being executed overwriting one another and causing only the last executable run to contain actual coverage results. This can be overridden by manually setting the environment variable `LLVM_PROFILE_FILE` to use a unique naming scheme. This PR adds a change to add support for a reasonable default for rustc to use when enabling coverage instrumentation similar to how the Rust compiler treats generating these same `profraw` files when PGO is enabled. The new naming scheme is set to `default_%m_%p.profraw` to ensure the uniqueness of each file being generated using [LLVMs special pattern strings](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program). Today the compiler sets the default for PGO `profraw` files to `default_%m.profraw` to ensure a unique file for each run. The same can be done for the instrumented profile files generated via the `-C instrument-coverage` flag as well which LLVM has API support for. Linked Issue: https://github.com/rust-lang/rust/issues/100381 r? `@wesleywiser`
2022-08-16Rollup merge of #100338 - lyming2007:issue-100285-fix, r=petrochenkovMatthias Krüger-0/+56
when there are 3 or more return statements in the loop emit the first 3 errors and duplicated diagnostic information modified: compiler/rustc_typeck/src/check/coercion.rs new file: src/test/ui/typeck/issue-100285.rs new file: src/test/ui/typeck/issue-100285.stderr
2022-08-16Shrink `ast::Attribute`.Nicholas Nethercote-113/+113
2022-08-15when there are 3 or more return statements in the loopYiming Lei-0/+56
emit the first 3 errors and duplicated diagnostic information using take of iterator for the first third return modified: compiler/rustc_typeck/src/check/coercion.rs new file: src/test/ui/typeck/issue-100285.rs new file: src/test/ui/typeck/issue-100285.stderr
2022-08-16use `span_suggestion` instead of `span_suggestion_verbose`Takayuki Maeda-20/+4
2022-08-15Fix #95079 by adding help and suggestion for missing move in nested closureYan Chen-0/+67
2022-08-15Rollup merge of #100586 - the8472:available_parallelism_2, r=jyn514Matthias Krüger-7/+6
Reland changes replacing num_cpus with available_parallelism Since #97925 added cgroupv1 support the problem in #97549 which lead to the previous revert should be addressed now. Cargo has reapplied the replacement too https://github.com/rust-lang/cargo/pull/10969 Reverts 1ae4b258267462da0b1aae1badcf83578153c799 (part of #97911) Relands #94524
2022-08-15Rollup merge of #100582 - GuillaumeGomez:rustdoc-json-stripped-enum-variant, ↵Matthias Krüger-6/+17
r=notriddle [rustdoc] Fix handling of stripped enum variant in JSON output format Fixes https://github.com/rust-lang/rust/issues/100529. cc ``@aDotInTheVoid`` ``@Enselic`` r? ``@notriddle``
2022-08-15Rollup merge of #100514 - compiler-errors:issue-100191, r=spastorinoMatthias Krüger-0/+59
Delay span bug when failing to normalize negative coherence impl subject due to other malformed impls Fixes #100191 r? ``@spastorino``
2022-08-15Rollup merge of #100458 - compiler-errors:fn-argument-span, r=estebankMatthias Krüger-20/+14
Adjust span of fn argument declaration Span of a fn argument declaration goes from: ``` fn foo(i : i32 , ...) ^^^^^^^^ ``` to: ``` fn foo(i : i32 , ...) ^^^^^^^ ``` That is, we don't include the extra spacing up to the trailing comma, which I think is more correct. cc https://github.com/rust-lang/rust/pull/99646#discussion_r944568074 r? ``@estebank`` --- The two tests that had dramatic changes in their rendering I think actually are improved, though they are kinda poor spans both before and after the changes. :shrug: Thoughts?
2022-08-15Rollup merge of #100377 - est31:fluent_grepability, r=davidtwcoMatthias Krüger-8/+45
Replace - with _ in fluent slugs to improve developer workflows This is a proposal to smoothen the compiler contribution experience in the face of the move to fluent. ## Context The fluent project has introduced a layer of abstraction to compiler errors. Previously, people would write down error messages directly in the same file the code was located to emit them. Now, there is a slug that connects the code in the compiler to the error message in the ftl file. You can look at 7ef610c003f8072ec4ca4ecf195922a9a44e48dd to see an example of the changes: Old: ```Rust let msg = format!( "bounds on `{}` are most likely incorrect, consider instead \ using `{}` to detect whether a type can be trivially dropped", predicate, cx.tcx.def_path_str(needs_drop) ); lint.build(&msg).emit(); ``` New (Rust side): ```Rust lint.build(fluent::lint::drop_trait_constraints) .set_arg("predicate", predicate) .set_arg("needs_drop", cx.tcx.def_path_str(needs_drop)) .emit(); ``` New (Fluent side): ```fluent lint-drop-trait-constraints = bounds on `{$predicate}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped ``` You will note that in the ftl file, the slug is slightly different from the slug in the Rust file: The ftl slug uses `-` (e.g. `lint-drop-trait-constraints`) while the rust slug uses `::` and `_` (e.g. `lint::drop_trait_constraints`). This choice was probably done due to: * Rust not accepting `-` in identifiers (as it is an operator) * fluent not supporting the `:` character in slug names (parse error upon attempts) * all official fluent documentation using `-` instead of `_` ## The problem The two different types of slugs, one with `-`, and one with `_`, cause difficulties for contributors. Imagine you don't have perfect knowledge of where stuff is in the compiler (i would say this is most people), and you encounter an error for which you think there is something you could improve that is not just a rewording. So you want to find out where in the compiler's code that error is being emitted. The best way is via grepping. 1. you grep for the message in the compiler's source code. You discover the ftl file and find out the slug for that error. 2. That slug however contains `-` instead of `_`, so you have to manually translate the `-`'s into `_`s, and furthermore either remove the leading module name, or replace the first `-` with a `::`. 3. you do a second grep to get to the emitting location in the compiler's code. This translation difficulty in step 2 appears also in the other direction when you want to figure out what some code in the compiler is doing and use error messages to help your understanding. Comments and variable names are way less exposed to users so [are more likely going to lie](https://github.com/rust-lang/rust/commit/cc3c5d2700481bae497d6cde825c1d48e79c776a) than error messages. I think that at least the `-`→`_` translation which makes up most of step 2 can be removed at low cost. ## The solution If you look closely, the practice of fluent to use `-` is only a stylistic choice and it is not enforced by fluent implementations, neither the playground nor the one the rust compiler uses, that slugs may not contain `_`. Thus, we can in fact migrate the ftl side to `_`. So now we'll have slugs like `lint_drop_trait_constraints` on the ftl side. You only have to do one replacement now to get to the Rust slug: remove the first `_` and place a `::` in its stead. I would argue that this change is in fact useful as it allows you to control whether you want to look at the rust side of things or the ftl side of things via changing the query string only: with an increased number of translations checked into the repository, grepping for raw slugs will return the slug in many ftl files, so an explicit step to look for the source code is always useful. In the other direction (rust to fluent), you don't need a translation at all any more, as you can just take the final piece of the slug (e.g. `drop_trait_constraints`) and grep for that. The PR also adds enforcement to forbid usage of `_` in slug names. Internal slug names (those leading with a `-`) are exempt from that enforcement. As another workflow that benefits from this change, people who add new errors don't have to do that `-` conversion either. | Before/After | Fluent slug | Rust slug (no change) | |--|--|--| | Before | `lint-drop-trait-constraints` | `lint::drop_trait_constraints`| | After | `lint_drop_trait_constraints` | `lint::drop_trait_constraints`| Note that I've suggested this previously in the translation thread on zulip. I think it's important to think about non-translator contribution impact of fluent. I have certainly plans for more improvements, but this is a good first step. ``@rustbot`` label A-diagnostics
2022-08-15Rollup merge of #100325 - aDotInTheVoid:rdj-import-impl, r=GuillaumeGomezMatthias Krüger-1/+35
Rustdoc-Json: Don't remove impls for items imported from private modules After #99287, items in private modules may still be in the json output, if a public import accesses them. To reflect this, items that are imported need to be marked as retained in the `Stripper` pass, so their impls arn't removed by `ImplStripper`. [More context on zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Populating.20cache.2Eimpls), thanks to @ jyn514 for helping debug this. ``@rustbot`` modify labels: +A-rustdoc-json +T-rustdoc r? ``@GuillaumeGomez`` Fixes #100252 Fixes #100242
2022-08-15Rollup merge of #100031 - GoldsteinE:try-removing-the-field, r=michaelwoeristerMatthias Krüger-0/+56
improve "try ignoring the field" diagnostic Closes #95795
2022-08-15rustdoc: Mark imported items as retainedNixon Enraght-Moony-1/+35
Fixes a bug where impl of items that were imported from a private module would be striped Fixes #100252 Fixes #100242
2022-08-15Auto merge of #100569 - matthiaskrgr:rollup-9450lzs, r=matthiaskrgrbors-69/+156
Rollup of 6 pull requests Successful merges: - #100211 (Refuse to codegen an upstream static.) - #100277 (Simplify format_args builtin macro implementation.) - #100483 (Point to generic or arg if it's the self type of unsatisfied projection predicate) - #100506 (change `InlineAsmCtxt` to not talk about `FnCtxt`) - #100534 (Make code slightly more uniform) - #100566 (Use `create_snapshot_for_diagnostic` instead of `clone` for `Parser`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-16suggest adding an array length if possibleTakayuki Maeda-19/+111
2022-08-15Add regression test for stripped enum variant fieldsGuillaume Gomez-0/+13
2022-08-15Handle correctly stripped enum variant fieldsGuillaume Gomez-6/+4
2022-08-15Revert "Revert "Remove num_cpus dependency from bootstrap, build-manifest ↵The 8472-7/+6
and rustc_session"" This reverts commit 1ae4b258267462da0b1aae1badcf83578153c799.
2022-08-15Auto merge of #98393 - michaelwoerister:new-cpp-like-enum-debuginfo, ↵bors-174/+421
r=wesleywiser debuginfo: Generalize C++-like encoding for enums. The updated encoding should be able to handle niche layouts where more than one variant has fields (as introduced in https://github.com/rust-lang/rust/pull/94075). The new encoding is more uniform as there is no structural difference between direct-tag, niche-tag, and no-tag layouts anymore. The only difference between those cases is that the "dataful" variant in a niche-tag enum will have a `(start, end)` pair denoting the tag range instead of a single value. The new encoding now also supports 128-bit tags, which occur in at least some standard library types. These tags are represented as `u64` pairs so that debuggers (which don't always have support for 128-bit integers) can reliably deal with them. The downside is that this adds quite a bit of complexity to the encoding and especially to the corresponding NatVis. The new encoding seems to increase the size of (x86_64-pc-windows-msvc) debuginfo by 10-15%. The size of binaries is not affected (release builds were built with `-Cdebuginfo=2`, numbers are in kilobytes): EXE | before | after | relative -- | -- | -- | -- cargo (debug) | 40453 | 40450 | +0% ripgrep (debug) | 10275 | 10273 | +0% cargo (release) | 16186 | 16185 | +0% ripgrep (release) | 4727 | 4726 | +0% PDB | before | after | relative -- | -- | -- | -- cargo (debug) | 236524 | 261412 | +11% ripgrep (debug) | 53140 | 59060 | +11% cargo (release) | 148516 | 169620 | +14% ripgrep (release) | 10676 | 11804 | +11% Given that the new encoding is more general, this is to be expected. Only platforms using C++-like debuginfo are affected -- which currently is only `*-pc-windows-msvc`. *TODO* - [x] Properly update documentation - [x] Add regression tests for new optimized enum layouts as introduced by #94075. r? `@wesleywiser`
2022-08-15[debuginfo] Fix msvc-pretty-enums debuginfo test for i686.Michael Woerister-2/+2
2022-08-15Rollup merge of #100483 - compiler-errors:point-to-projection-too, r=jyn514Matthias Krüger-69/+128
Point to generic or arg if it's the self type of unsatisfied projection predicate We do this for `TraitPredicate`s in `point_at_type_arg_instead_of_call_if_possible` and `point_at_arg_instead_of_call_if_possible`, so also do it for `ProjectionPredicate`. Improves spans for a lot of unit tests.
2022-08-15Rollup merge of #100211 - cjgillot:ctfe-mir-available, r=michaelwoeristerMatthias Krüger-0/+28
Refuse to codegen an upstream static. Fixes https://github.com/rust-lang/rust/issues/85401
2022-08-15Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillotbors-13/+1320
Visit attributes in more places. This adds 3 loosely related changes (I can split PRs if desired): - Attribute checking on pattern struct fields. - Attribute checking on struct expression fields. - Lint level visiting on pattern struct fields, struct expression fields, and generic parameters. There are still some lints which ignore lint levels in various positions. This is a consequence of how the lints themselves are implemented. For example, lint levels on associated consts don't work with `unused_braces`.
2022-08-14Update the minimum external LLVM to 13Josh Stone-115/+15
2022-08-14Also do it for genericsMichael Goulet-10/+10
2022-08-14Point to argument if it's self type of unsatisfied projection predicateMichael Goulet-59/+118
2022-08-14Rollup merge of #100526 - Nilstrieb:tests!, r=Mark-SimulacrumMatthias Krüger-0/+145
Add tests for the drop behavior of some control flow constructs In #100513 it was shown that the drop behaviour of let_chains is not correct currently. Since drop behaviour is something pretty subtle, this adds explicit tests for the drop behavior of `if`, `if let` and `match` to make sure that it does not regress in the future. The `println!`s were left in to make debugging easier in case something goes wrong, but they are not required for the test.
2022-08-14Rollup merge of #100524 - ohno418:impl-debug-for-some-rustbuild-structs, ↵Matthias Krüger-1/+2
r=Mark-Simulacrum Impl `Debug` for some structs of rustbuild A small patch to impl `Debug` for some structs of rustbuild to make debugging easier. (I was trying to impl `Debug` for the `Config` struct, but found to have a bit more things to do. So gave up for now.)
2022-08-14Rollup merge of #100523 - GuillaumeGomez:remove-clean-impls, r=Dylan-DPCMatthias Krüger-13/+7
[rustdoc] remove Clean trait Follow-up of https://github.com/rust-lang/rust/pull/99638. This is (finally!) the last part. r? `@Dylan-DPC`
2022-08-14Rollup merge of #100253 - obeis:issue-100197, r=cjgillotMatthias Krüger-0/+20
Recover from mutable variable declaration where `mut` is placed before `let` Closes #100197
2022-08-14Auto merge of #100429 - GuillaumeGomez:merge-html-elements-together, r=notriddlebors-59/+216
rustdoc: Merge source code pages HTML elements together We realized that the HTML generated for the source code pages could be improved quite a lot. This PR is a first pass toward this goal. Some explanations: it merges similar classes elements (even when there are white characters in between). There is an exception to this: if this is an ident, I also merged it with "unclassified" elements. This part is up to debate and can be very easily removed as the check is performed in one place (in the `can_merge` function). EDIT: The `ident` is now only kept in the code for the `span` it contains but it is not rendered into the HTML. So now some numbers: For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others. | file name | before this PR | with this PR | diff | without ident | diff | |-|-|-|-|-|-| | std/lib.rs.html (source link on std crate page) | 3455 | 2776 | 20.7% | 2387 | 31% | | alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 8084 | 26.6% | 6682 | 39.4% | | alloc/string.rs.html (source on String type page) | 10800 | 8214 | 24% | 6712 | 37.9% | | std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2403 | 18.7% | 2139 | 27.6% | You can test it [here](https://rustdoc.crud.net/imperio/merge-html-elements-together/src/std/lib.rs.html). cc `@jsha` r? `@notriddle`
2022-08-14Add tests for the drop behavior of some control flow constructsNilstrieb-0/+145
In #100513 it was shown that the drop behavior of let_chains is not correct currently. Since drop behavior is something pretty subtle, this adds explicit tests for the drop behavior of `if`, `if let` and `match` to make sure that it does not regress in the future. The `println!`s were left in to make debugging easier in case something goes wrong, but they are not required for the test.
2022-08-14Rollup merge of #100487 - tmiasko:assert-safe, r=petrochenkovDylan DPC-6/+6
`assert_{inhabited,zero_valid,uninit_valid}` intrinsics are safe Those intrinsics either panic or do nothing. They are safe.
2022-08-14Rollup merge of #100115 - obeis:issue-99910, r=cjgillotDylan DPC-0/+30
Suggest removing `let` if `const let` or `let const` is used Closes #99910
2022-08-14Rollup merge of #99861 - lcnr:orphan-check-cg, r=jackh726Dylan DPC-0/+29
orphan check: rationalize our handling of constants cc `@rust-lang/types` `@rust-lang/project-const-generics` on whether you agree with this reasoning. r? types
2022-08-14Rollup merge of #99582 - compiler-errors:issue-99566, r=cjgillotDylan DPC-0/+28
Delay a span bug if we see ty/const generic params during writeback Fixes #99566
2022-08-14Update rustdoc testsGuillaume Gomez-40/+41
2022-08-14Impl Debug for some structs of rustbuildohno418-1/+2
2022-08-14Remove the Clean traitGuillaume Gomez-4/+0
2022-08-14remove Clean trait implementation for hir::VariantGuillaume Gomez-9/+7
2022-08-14Don't generate ident elements as DOM nodesGuillaume Gomez-14/+23
2022-08-14Merge HTML elements in highlighting when they can be merged togetherGuillaume Gomez-8/+155
2022-08-14Auto merge of #100516 - compiler-errors:rollup-fgrfeb3, r=compiler-errorsbors-223/+719
Rollup of 8 pull requests Successful merges: - #99646 (Only point out a single function parameter if we have a single arg incompatibility) - #100299 (make `clean::Item::span` return `Option` instead of dummy span) - #100335 (Rustdoc-Json: Add `Path` type for traits.) - #100367 (Suggest the path separator when a dot is used on a trait) - #100431 (Enum variant ctor inherits the stability of the enum variant) - #100446 (Suggest removing a semicolon after impl/trait items) - #100468 (Use an extensionless `x` script for non-Windows) - #100479 (Argument type error improvements) Failed merges: - #100483 (Point to generic or arg if it's the self type of unsatisfied projection predicate) r? `@ghost` `@rustbot` modify labels: rollup