about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-10-13Rollup merge of #102641 - eholk:dyn-star-box, r=compiler-errorsYuki Okushi-0/+17
Support casting boxes to dyn* Boxes have a pointer type at codegen time which LLVM does not allow to be transparently converted to an integer. Work around this by inserting a `ptrtoint` instruction if the argument is a pointer. r? ``@compiler-errors`` Fixes #102427
2022-10-12Auto merge of #101679 - compiler-errors:rpitit-default-body, r=nikomatsakisbors-95/+68
Support default-body trait functions with return-position `impl Trait` in traits Introduce a new `Trait` candidate kind for the `ImplTraitInTrait` projection candidate, which just projects an RPITIT down to its opaque type form. This is a hack until we lower RPITITs to regular associated types, after which we will need to rework how these default bodies are type-checked, so comments are left in a few places for us to clean up later. Fixes #101665
2022-10-12add regression testLukas Markeffsky-0/+20
2022-10-13fix small word dupe typosRageking8-16/+16
2022-10-12Rollup merge of #102927 - compiler-errors:let, r=davidtwcoDylan DPC-6/+70
Fix `let` keyword removal suggestion in structs (1.) Fixes a bug where, given this code: ```rust struct Foo { let x: i32, } ``` We were parsing the field name as `let` instead of `x`, which causes issues later on in the type-checking phase. (2.) Also, suggestions for `let: i32` as a field regressed, displaying this extra `help:` which is removed by this PR ``` help: remove the let, the `let` keyword is not allowed in struct field definitions | 2 - let: i32, 2 + : i32, ``` (3.) Makes the suggestion text a bit more succinct, since we don't need to re-explain that `let` is not allowed in this position (since it's in a note that follows). This causes the suggestion to render inline as well. cc `@gimbles,` this addresses a few nits I mentioned in your PR.
2022-10-12Rollup merge of #102719 - Nilstrieb:tidy-alphabetical, r=jackh726Dylan DPC-22/+22
Enforce alphabetical sorting with tidy We have many places where things are supposed to be sorted alphabetically. For the smaller and more recent size assertions, this is mostly upheld, but in other more... alive places it's very messy. This introduces a new tidy directive to check that a section of code is sorted alphabetically and fixes all places where sorting has gone wrong.
2022-10-12Rollup merge of #102623 - davidtwco:translation-eager, r=compiler-errorsDylan DPC-8/+125
translation: eager translation Part of #100717. See [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20lists!/near/295010720) for additional context. - **Store diagnostic arguments in a `HashMap`**: Eager translation will enable subdiagnostics to be translated multiple times with different arguments - this requires the ability to replace the value of one argument with a new value, which is better suited to a `HashMap` than the previous storage, a `Vec`. - **Add `AddToDiagnostic::add_to_diagnostic_with`**: `AddToDiagnostic::add_to_diagnostic_with` is similar to the previous `AddToDiagnostic::add_to_diagnostic` but takes a function that can be used by the caller to modify diagnostic messages originating from the subdiagnostic (such as performing translation eagerly). `add_to_diagnostic` now just calls `add_to_diagnostic_with` with an empty closure. - **Add `DiagnosticMessage::Eager`**: Add variant of `DiagnosticMessage` for eagerly translated messages (messages in the target language which don't need translated by the emitter during emission). Also adds `eager_subdiagnostic` function which is intended to be invoked by the diagnostic derive for subdiagnostic fields which are marked as needing eager translation. - **Support `#[subdiagnostic(eager)]`**: Add support for `eager` argument to the `subdiagnostic` attribute which generates a call to `eager_subdiagnostic`. - **Finish migrating `rustc_query_system`**: Using eager translation, migrate the remaining repeated cycle stack diagnostic. - **Split formatting initialization and use in diagnostic derives**: Diagnostic derives have previously had to take special care when ordering the generated code so that fields were not used after a move. This is unlikely for most fields because a field is either annotated with a subdiagnostic attribute and is thus likely a `Span` and copiable, or is a argument, in which case it is only used once by `set_arg` anyway. However, format strings for code in suggestions can result in fields being used after being moved if not ordered carefully. As a result, the derive currently puts `set_arg` calls last (just before emission), such as: let diag = { /* create diagnostic */ }; diag.span_suggestion_with_style( span, fluent::crate::slug, format!("{}", __binding_0), Applicability::Unknown, SuggestionStyle::ShowAlways ); /* + other subdiagnostic additions */ diag.set_arg("foo", __binding_0); /* + other `set_arg` calls */ diag.emit(); For eager translation, this doesn't work, as the message being translated eagerly can assume that all arguments are available - so arguments _must_ be set first. Format strings for suggestion code are now separated into two parts - an initialization line that performs the formatting into a variable, and a usage in the subdiagnostic addition. By separating these parts, the initialization can happen before arguments are set, preserving the desired order so that code compiles, while still enabling arguments to be set before subdiagnostics are added. let diag = { /* create diagnostic */ }; let __code_0 = format!("{}", __binding_0); /* + other formatting */ diag.set_arg("foo", __binding_0); /* + other `set_arg` calls */ diag.span_suggestion_with_style( span, fluent::crate::slug, __code_0, Applicability::Unknown, SuggestionStyle::ShowAlways ); /* + other subdiagnostic additions */ diag.emit(); - **Remove field ordering logic in diagnostic derive:** Following the approach taken in earlier commits to separate formatting initialization from use in the subdiagnostic derive, simplify the diagnostic derive by removing the field-ordering logic that previously solved this problem. r? ```@compiler-errors```
2022-10-12Add broken test for AFIT with RPITITMichael Goulet-0/+33
2022-10-12add test for issue 102964Rageking8-0/+29
2022-10-12Use `tidy-alphabetical` in the compilerNilstrieb-22/+22
2022-10-12Auto merge of #102460 - flba-eb:fix_85261_prevent_alloc_after_fork, r=thomccbors-1/+42
Prevent UB in child process after calling libc::fork After calling libc::fork, the child process tried to access a TLS variable when processing a panic. This caused a memory allocation which is UB in the child. To prevent this from happening, the panic handler will not access the TLS variable in case `panic::always_abort` was called before. Fixes #85261 (not only on Android systems, but also on Linux/QNX with TLS disabled, see issue for more details) Main drawbacks of this fix: * Panic messages can incorrectly omit `core::panic::PanicInfo` struct in case several panics (of multiple threads) occur at the same time. The handler cannot distinguish between multiple panics in different threads or recursive ones in the same thread, but the message will contain a hint about the uncertainty. * `panic_count::increase()` will be a bit slower as it has an additional `if`, but this should be irrelevant as it is only called in case of a panic.
2022-10-12fix #102946Takayuki Maeda-0/+33
2022-10-12Rollup merge of #102924 - notriddle:notriddle/sidebar-link-class, ↵Dylan DPC-64/+64
r=GuillaumeGomez rustdoc: remove unused classes from sidebar links Since https://github.com/rust-lang/rust/commit/98f05a0282625a5fda6e90ebf3b05a4bd7608f65 removed separate colors from the currently-selected item, there's no need to have item classes on sidebar links. Preview: https://notriddle.com/notriddle-rustdoc-demos/sidebar-link-class/std/vec/struct.Vec.html While cleaning up the CSS to remove unneeded `.content` selectors, this PR changes the `h1.fqn a` CSS selector to just be `h1 a`, so that the header link color selector is less specific than the typed link at the end. Since https://github.com/rust-lang/rust/pull/89506 made docblocks start at `h2`, the main page link header should be the only h1 in the page now.
2022-10-12Rollup merge of #102890 - camsteffen:adt-sized-representability, r=cjgillotDylan DPC-57/+36
Check representability in adt_sized_constraint Now that representability is a query, we can use it to preemptively avoid a cycle in `adt_sized_constraint`. I moved the representability check into `check_mod_type_wf` to avoid a scenario where rustc quits before checking all the types for representability. This also removes the check from rustdoc, which is alright AFAIK. r? ``@cjgillot``
2022-10-12Rollup merge of #102187 - b-naber:inline-const-source-info, r=eholkDylan DPC-0/+67
Use correct location for type tests in promoted constants Previously we forgot to remap the location in a type test collected when visiting the body of a promoted constant back to the usage location, causing an ICE when trying to get span information for that type test. Fixes https://github.com/rust-lang/rust/issues/102117
2022-10-12Rollup merge of #102110 - CleanCut:migrate_rustc_passes_diagnostics, r=davidtwcoDylan DPC-2/+2
Migrate rustc_passes diagnostics Picks up abandoned work from https://github.com/rust-lang/rust/pull/100870 I would like to do this collaboratively, as there is a lot of work! Here's the process: - Comment below that you are willing to help and I will add you as a collaborator to my `rust` fork (that gives you write access) - Indicate which file/task you would like to work on (so we don't duplicate work) from the list below - Do the work, push up a commit, comment that you're done with that file/task - Repeat until done 😄 ### Files to Migrate (in `compiler/rustc_passes/src/`) - [x] check_attr.rs ``@CleanCut`` - [x] check_const.rs ``@CleanCut`` - [x] dead.rs ``@CleanCut`` - [x] debugger_visualizer.rs ``@CleanCut`` - [x] diagnostic_items.rs ``@CleanCut`` - [x] entry.rs ``@CleanCut`` - [x] lang_items.rs ``@CleanCut`` - [x] layout_test.rs ``@CleanCut`` - [x] lib_features.rs ``@CleanCut`` - [x] ~liveness.rs~ ``@CleanCut`` Nothing to do - [x] loops.rs ``@CleanCut`` - [x] naked_functions.rs ``@CleanCut`` - [x] stability.rs ``@CleanCut`` - [x] weak_lang_items.rs ``@CleanCut`` ### Tasks - [x] Rebase on current `master` ``@CleanCut`` - [x] Review work from [the earlier PR](https://github.com/rust-lang/rust/pull/100870) and make sure it all looks good - [x] compiler/rustc_error_messages/locales/en-US/passes.ftl ``@CleanCut`` - [x] compiler/rustc_passes/src/check_attr.rs ``@CleanCut`` - [x] compiler/rustc_passes/src/errors.rs ``@CleanCut`` - [x] compiler/rustc_passes/src/lang_items.rs ``@CleanCut`` - [x] compiler/rustc_passes/src/lib.rs ``@CleanCut`` - [x] compiler/rustc_passes/src/weak_lang_items.rs ``@CleanCut``
2022-10-12Do not register placeholder region outlives when considering_regions is falseMichael Goulet-0/+61
2022-10-11wip: trying to enable #[track_caller] on async fnEric Holk-0/+1
2022-10-11Fix let removal suggestion in structMichael Goulet-6/+70
2022-10-11Rollup merge of #102893 - TaKO8Ki:fix-102878, r=davidtwcoMatthias Krüger-0/+70
Fix ICE #102878 Fixes #102878
2022-10-11Rollup merge of #100387 - cjgillot:hygiene-trait-impl, r=petrochenkovMatthias Krüger-22/+89
Check uniqueness of impl items by trait item when applicable. When checking uniqueness of item names in impl blocks, we currently use the same definition of hygiene as for toplevel items. This means that a plain item and one generated by a macro 2.0 do not collide. This hygiene rule does not match with how impl items resolve to associated trait items. As a consequence, we misdiagnose the trait impls. This PR proposes to consider that trait impl items are uses of the corresponding trait items during resolution, instead of checking for duplicates later. An error is emitted when a trait impl item is used twice. There should be no stable breakage, since macros 2.0 are still unstable. r? ``@petrochenkov`` cc ``@RalfJung`` Fixes https://github.com/rust-lang/rust/issues/71614.
2022-10-11rustdoc: remove unused classes from sidebarMichael Howell-64/+64
Since 98f05a0282625a5fda6e90ebf3b05a4bd7608f65 removed separate colors from the currently-selected item, there's no need to have item classes on sidebar links.
2022-10-11Rollup merge of #102898 - notriddle:notriddle/sidebar-block, r=GuillaumeGomezYuki Okushi-14/+14
rustdoc: remove unneeded `<div>` wrapper from sidebar DOM When this was added, the sidebar had a bit more complex style. It can be removed, now. Preview: https://notriddle.com/notriddle-rustdoc-demos/sidebar-block/std/index.html
2022-10-11Add GUI test for source code pages highlightingGuillaume Gomez-1/+73
2022-10-11Report duplicate definitions in trait impls during resolution.Camille GILLOT-22/+89
2022-10-11Auto merge of #102724 - pcc:scs-fix-test, r=Mark-Simulacrumbors-3/+3
Fix the sanitizer_scs_attr_check.rs test The test is failing when targeting aarch64 Android. The intent appears to have been to look for a function attributes comment (or the absence of one) on the line preceding the function declaration. But this isn't quite possible with FileCheck and the test as written was looking for a line with `no_scs` after a line with `scs`, which doesn't appear in the output. Instead, match on the function attributes comment on the line following the demangled function name comment.
2022-10-11Auto merge of #102896 - matthiaskrgr:rollup-jg5xawz, r=matthiaskrgrbors-716/+363
Rollup of 6 pull requests Successful merges: - #101360 (Point out incompatible closure bounds) - #101789 (`let`'s not needed in struct field definitions) - #102846 (update to syn-1.0.102) - #102871 (rustdoc: clean up overly complex `.trait-impl` CSS selectors) - #102876 (suggest candidates for unresolved import) - #102888 (Improve rustdoc-gui search-color test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-10Add a test case for #[track_caller] on async fnEric Holk-0/+74
2022-10-10Auto merge of #101720 - GuillaumeGomez:warn-INVALID_HTML_TAGS, r=notriddlebors-14/+79
Change default level of INVALID_HTML_TAGS to warning and stabilize it Fixes of #67799. cc `@Nemo157` r? `@notriddle`
2022-10-10Check representability in adt_sized_constraintCameron Steffen-57/+36
2022-10-10Rollup merge of #102888 - GuillaumeGomez:improve-search-color-check, r=notriddleMatthias Krüger-710/+233
Improve rustdoc-gui search-color test Thanks to the add of "functions" in `browser-ui-test`, we can start to reduce the size of the scripts. It'll be very useful for all color checks. r? `@notriddle`
2022-10-10Rollup merge of #102876 - SparrowLii:import-candidate, r=fee1-deadMatthias Krüger-4/+83
suggest candidates for unresolved import Currently we prompt suggestion of candidates(help notes of `use xxx::yyy`) for names which cannot be resolved, but we don't do that for import statements themselves that couldn't be resolved. It seems reasonable to add candidate help information for these statements as well. Fixes #102711
2022-10-10Rollup merge of #101789 - gimbles:let, r=estebankMatthias Krüger-2/+8
`let`'s not needed in struct field definitions Fixes #101683
2022-10-10Rollup merge of #101360 - compiler-errors:multiple-closure-bounds, ↵Matthias Krüger-0/+39
r=petrochenkov Point out incompatible closure bounds Fixes #100295
2022-10-10Auto merge of #102596 - scottmcm:option-bool-calloc, r=Mark-Simulacrumbors-1/+18
Do the `calloc` optimization for `Option<bool>` Inspired by <https://old.reddit.com/r/rust/comments/xtiqj8/why_is_this_functional_version_faster_than_my_for/iqqy37b/>.
2022-10-10rustdoc: remove unneeded `<div>` wrapper from sidebar DOMMichael Howell-14/+14
When this was added, the sidebar had a bit more complex style. It can be removed, now.
2022-10-11fix #102878Takayuki Maeda-0/+70
2022-10-10Update rustdoc testsGuillaume Gomez-14/+79
2022-10-10Simplify result color checksGuillaume Gomez-710/+233
2022-10-10macros: separate suggestion fmt'ing and emissionDavid Wood-0/+24
Diagnostic derives have previously had to take special care when ordering the generated code so that fields were not used after a move. This is unlikely for most fields because a field is either annotated with a subdiagnostic attribute and is thus likely a `Span` and copiable, or is a argument, in which case it is only used once by `set_arg` anyway. However, format strings for code in suggestions can result in fields being used after being moved if not ordered carefully. As a result, the derive currently puts `set_arg` calls last (just before emission), such as: ```rust let diag = { /* create diagnostic */ }; diag.span_suggestion_with_style( span, fluent::crate::slug, format!("{}", __binding_0), Applicability::Unknown, SuggestionStyle::ShowAlways ); /* + other subdiagnostic additions */ diag.set_arg("foo", __binding_0); /* + other `set_arg` calls */ diag.emit(); ``` For eager translation, this doesn't work, as the message being translated eagerly can assume that all arguments are available - so arguments _must_ be set first. Format strings for suggestion code are now separated into two parts - an initialization line that performs the formatting into a variable, and a usage in the subdiagnostic addition. By separating these parts, the initialization can happen before arguments are set, preserving the desired order so that code compiles, while still enabling arguments to be set before subdiagnostics are added. ```rust let diag = { /* create diagnostic */ }; let __code_0 = format!("{}", __binding_0); /* + other formatting */ diag.set_arg("foo", __binding_0); /* + other `set_arg` calls */ diag.span_suggestion_with_style( span, fluent::crate::slug, __code_0, Applicability::Unknown, SuggestionStyle::ShowAlways ); /* + other subdiagnostic additions */ diag.emit(); ``` Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10macros: `#[subdiagnostic(eager)]`David Wood-1/+88
Add support for `eager` argument to the `subdiagnostic` attribute which generates a call to `eager_subdiagnostic`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10errors: `AddToDiagnostic::add_to_diagnostic_with`David Wood-7/+13
`AddToDiagnostic::add_to_diagnostic_with` is similar to the previous `AddToDiagnostic::add_to_diagnostic` but takes a function that can be used by the caller to modify diagnostic messages originating from the subdiagnostic (such as performing translation eagerly). `add_to_diagnostic` now just calls `add_to_diagnostic_with` with an empty closure. Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10`let` is not allowed in struct field definitionsgimbles-2/+8
Co-authored-by: jyn514 <jyn514@gmail.com> Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-10-10Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8KiDylan DPC-2/+2
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type` Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247
2022-10-10Rollup merge of #102853 - cjgillot:skip-opaque-cast, r=jackh726Dylan DPC-0/+17
Skip chained OpaqueCast when building captures. Fixes https://github.com/rust-lang/rust/issues/102089
2022-10-10Rollup merge of #102055 - c410-f3r:moar-errors, r=petrochenkovDylan DPC-171/+0
Move some tests to more reasonable directories r? ``@petrochenkov``
2022-10-10Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-deadDylan DPC-7/+152
Uplift `clippy::for_loops_over_fallibles` lint into rustc This PR, as the title suggests, uplifts [`clippy::for_loops_over_fallibles`] lint into rustc. This lint warns for code like this: ```rust for _ in Some(1) {} for _ in Ok::<_, ()>(1) {} ``` i.e. directly iterating over `Option` and `Result` using `for` loop. There are a number of suggestions that this PR adds (on top of what clippy suggested): 1. If the argument (? is there a better name for that expression) of a `for` loop is a `.next()` call, then we can suggest removing it (or rather replacing with `.by_ref()` to allow iterator being used later) ```rust for _ in iter.next() {} // turns into for _ in iter.by_ref() {} ``` 2. (otherwise) We can suggest using `while let`, this is useful for non-iterator, iterator-like things like [async] channels ```rust for _ in rx.recv() {} // turns into while let Some(_) = rx.recv() {} ``` 3. If the argument type is `Result<impl IntoIterator, _>` and the body has a `Result<_, _>` type, we can suggest using `?` ```rust for _ in f() {} // turns into for _ in f()? {} ``` 4. To preserve the original behavior and clear intent, we can suggest using `if let` ```rust for _ in f() {} // turns into if let Some(_) = f() {} ``` (P.S. `Some` and `Ok` are interchangeable depending on the type) I still feel that the lint wording/look is somewhat off, so I'll be happy to hear suggestions (on how to improve suggestions :D)! Resolves #99272 [`clippy::for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles
2022-10-10Point out incompatible closure boundsMichael Goulet-0/+39
2022-10-10suggest candidates for unresolved importSparrowLii-4/+83
2022-10-10Rename AssocItemKind::TyAlias to AssocItemKind::TypeMichael Goulet-2/+2