]> git.lizzy.rs Git - rust.git/log
rust.git
16 months agotweak wording
Esteban Küber [Mon, 23 Jan 2023 14:46:30 +0000 (14:46 +0000)]
tweak wording

16 months agoEnsure suggestion correctness
Esteban Küber [Sun, 8 Jan 2023 19:12:15 +0000 (19:12 +0000)]
Ensure suggestion correctness

16 months agoDo not erase regions
Esteban Küber [Sun, 8 Jan 2023 07:43:24 +0000 (07:43 +0000)]
Do not erase regions

16 months agoAdd call in `emit_type_mismatch_suggestions`
Esteban Küber [Sun, 8 Jan 2023 07:14:17 +0000 (07:14 +0000)]
Add call in `emit_type_mismatch_suggestions`

16 months agoreview comment: use `fcx.infcx`
Esteban Küber [Sun, 8 Jan 2023 07:05:23 +0000 (07:05 +0000)]
review comment: use `fcx.infcx`

16 months agoSuggest coercion of `Result` using `?`
Esteban Küber [Sun, 8 Jan 2023 02:54:59 +0000 (02:54 +0000)]
Suggest coercion of `Result` using `?`

Fix #47560.

16 months agoAuto merge of #106910 - aliemjay:alias-ty-in-regionck, r=oli-obk
bors [Thu, 19 Jan 2023 14:05:07 +0000 (14:05 +0000)]
Auto merge of #106910 - aliemjay:alias-ty-in-regionck, r=oli-obk

even more unify Projection/Opaque handling in region outlives code

edit: This continues ate the same pace as #106829. New changes are described in https://github.com/rust-lang/rust/pull/106910#issuecomment-1383251254.

~This touches `OutlivesBound`, `Component`, `GenericKind` enums.~

r? `@oli-obk` (because of overlap with #95474)

16 months agoadd test for ICE fix
Ali MJ Al-Nasrawy [Sun, 15 Jan 2023 22:35:51 +0000 (01:35 +0300)]
add test for ICE fix

16 months agoeven more unify Projection/Opaque in outlives code
Ali MJ Al-Nasrawy [Sun, 15 Jan 2023 16:38:31 +0000 (19:38 +0300)]
even more unify Projection/Opaque in outlives code

16 months agoAuto merge of #107064 - GuillaumeGomez:rollup-pbgu6r3, r=GuillaumeGomez
bors [Thu, 19 Jan 2023 11:12:31 +0000 (11:12 +0000)]
Auto merge of #107064 - GuillaumeGomez:rollup-pbgu6r3, r=GuillaumeGomez

Rollup of 5 pull requests

Successful merges:

 - #105977 (Transform async `ResumeTy` in generator transform)
 - #106927 (make `CastError::NeedsDeref` create a `MachineApplicable` suggestion)
 - #106931 (document + UI test `E0208` and make its output more user-friendly)
 - #107027 (Remove extra removal from test path)
 - #107037 (Fix Dominators::rank_partial_cmp to match documentation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

16 months agoRollup merge of #107037 - tmiasko:rank, r=oli-obk
Guillaume Gomez [Thu, 19 Jan 2023 10:19:36 +0000 (11:19 +0100)]
Rollup merge of #107037 - tmiasko:rank, r=oli-obk

Fix Dominators::rank_partial_cmp to match documentation

The only use site is also updated accordingly and there is no change in end-to-end behaviour.

16 months agoRollup merge of #107027 - GuillaumeGomez:rm-extra-removal, r=tmiasko
Guillaume Gomez [Thu, 19 Jan 2023 10:19:36 +0000 (11:19 +0100)]
Rollup merge of #107027 - GuillaumeGomez:rm-extra-removal, r=tmiasko

Remove extra removal from test path

I don't know how to describe it shortly so better show what it's doing instead. Currently, there is one extra "rust/" before the test folder when running tests:

```
failures:

---- [rustdoc] rust/tests/rustdoc/redirect.rs stdout ----
```

This is a bit annoying when copying the test path. This is due to the moving of the `tests` folder one level up, meaning we were trimming too much of the `root_path`.

Now it is again displaying the correct path:

```
failures:

---- [rustdoc] tests/rustdoc/redirect.rs stdout ----
```

16 months agoRollup merge of #106931 - Ezrashaw:docs-e0208, r=compiler-errors
Guillaume Gomez [Thu, 19 Jan 2023 10:19:35 +0000 (11:19 +0100)]
Rollup merge of #106931 - Ezrashaw:docs-e0208, r=compiler-errors

document + UI test `E0208` and make its output more user-friendly

Cleans up `E0208`'s output a lot. It could actually be useful for someone learning about variance now. I also added a UI test for it in `tests/ui/error-codes/` and wrote some docs for it.

r? `@GuillaumeGomez` another error code, can't be bothered to find the issue :P. Obviously there's some compiler stuff, so you'll have to hand it off.

Part of https://github.com/rust-lang/rust/issues/61137.

16 months agoRollup merge of #106927 - Ezrashaw:e0606-make-machine-applicable, r=estebank
Guillaume Gomez [Thu, 19 Jan 2023 10:19:34 +0000 (11:19 +0100)]
Rollup merge of #106927 - Ezrashaw:e0606-make-machine-applicable, r=estebank

make `CastError::NeedsDeref` create a `MachineApplicable` suggestion

Fixes #106903

Simple impl for the linked issue. I also made some other small changes:
- `CastError::ErrorGuaranteed` now owns an actual `ErrorGuaranteed`. This better enforces the static guarantees of `ErrorGuaranteed`.
- `CastError::NeedDeref` code simplified a bit, we now just suggest the `*`, instead of the whole expression as well.

16 months agoRollup merge of #105977 - Swatinem:async-mir-context, r=oli-obk
Guillaume Gomez [Thu, 19 Jan 2023 10:19:34 +0000 (11:19 +0100)]
Rollup merge of #105977 - Swatinem:async-mir-context, r=oli-obk

Transform async `ResumeTy` in generator transform

- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.

---

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1330 CC `@bjorn3`

r? `@compiler-errors`

16 months agoAuto merge of #106989 - clubby789:is-zero-num, r=scottmcm
bors [Thu, 19 Jan 2023 08:04:26 +0000 (08:04 +0000)]
Auto merge of #106989 - clubby789:is-zero-num, r=scottmcm

Implement `alloc::vec::IsZero` for `Option<$NUM>` types

Fixes #106911

Mirrors the `NonZero$NUM` implementations with an additional `assert_zero_valid`.
`None::<i32>` doesn't stricly satisfy `IsZero` but for the purpose of allocating we can produce more efficient codegen.

16 months agoTransform async ResumeTy in generator transform
Arpad Borsos [Tue, 20 Dec 2022 14:15:29 +0000 (15:15 +0100)]
Transform async ResumeTy in generator transform

- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.

16 months agoAuto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkov
bors [Thu, 19 Jan 2023 05:23:40 +0000 (05:23 +0000)]
Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkov

Various cleanups around pre-TyCtxt queries and functions

part of #105462

based on https://github.com/rust-lang/rust/pull/106776 (everything starting at [0e2b39f](https://github.com/rust-lang/rust/pull/106810/commits/0e2b39fd1ffde51b50d45ccbe41de52b85136b8b) is new in this PR)

r? `@petrochenkov`

I think this should be most of the uncontroversial part of #105462.

16 months agoAuto merge of #107052 - compiler-errors:rollup-vxr22g5, r=compiler-errors
bors [Thu, 19 Jan 2023 02:09:45 +0000 (02:09 +0000)]
Auto merge of #107052 - compiler-errors:rollup-vxr22g5, r=compiler-errors

Rollup of 8 pull requests

Successful merges:

 - #105796 (rustdoc: simplify JS search routine by not messing with lev distance)
 - #106753 (Make sure that RPITITs are not considered suggestable)
 - #106917 (Encode const mir for closures if they're const)
 - #107004 (Implement some candidates for the new solver (redux))
 - #107023 (Stop using `BREAK` & `CONTINUE` in compiler)
 - #107030 (Correct typo)
 - #107042 (rustdoc: fix corner cases with "?" JS keyboard command)
 - #107045 (rustdoc: remove redundant CSS rule `#settings .setting-line`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

16 months agoRollup merge of #107045 - notriddle:notriddle/settings-css-setting-line, r=GuillaumeGomez
Michael Goulet [Wed, 18 Jan 2023 23:00:31 +0000 (18:00 -0500)]
Rollup merge of #107045 - notriddle:notriddle/settings-css-setting-line, r=GuillaumeGomez

rustdoc: remove redundant CSS rule `#settings .setting-line`

Since the current version of settings.js always nests things below a div with ID `settings`, this rule always overrode the one above.

16 months agoRollup merge of #107042 - notriddle:notriddle/rustdoc-js-question, r=GuillaumeGomez
Michael Goulet [Wed, 18 Jan 2023 23:00:31 +0000 (18:00 -0500)]
Rollup merge of #107042 - notriddle:notriddle/rustdoc-js-question, r=GuillaumeGomez

rustdoc: fix corner cases with "?" JS keyboard command

16 months agoRollup merge of #107030 - albertlarsan68:patch-3, r=lcnr
Michael Goulet [Wed, 18 Jan 2023 23:00:30 +0000 (18:00 -0500)]
Rollup merge of #107030 - albertlarsan68:patch-3, r=lcnr

Correct typo

https://github.com/rust-lang/rust/pull/106718#discussion_r1073508490

16 months agoRollup merge of #107023 - scottmcm:stop-shouting, r=Nilstrieb
Michael Goulet [Wed, 18 Jan 2023 23:00:30 +0000 (18:00 -0500)]
Rollup merge of #107023 - scottmcm:stop-shouting, r=Nilstrieb

Stop using `BREAK` & `CONTINUE` in compiler

Switching them to `Break(())` and `Continue(())` instead.

Entirely search-and-replace, though there's one spot where rustfmt insisted on a reformatting too.

libs-api would like to remove these constants (https://github.com/rust-lang/rust/pull/102697#issuecomment-1385705202), so stop using them in compiler to make the removal PR later smaller.

16 months agoRollup merge of #107004 - compiler-errors:new-solver-new-candidates-2, r=lcnr
Michael Goulet [Wed, 18 Jan 2023 23:00:29 +0000 (18:00 -0500)]
Rollup merge of #107004 - compiler-errors:new-solver-new-candidates-2, r=lcnr

Implement some candidates for the new solver (redux)

Based on #106718, so the diff is hard to read without it. See [here](https://github.com/rust-lang/rust/compare/98700cf481bce946bff316b56836cfffd885127b...compiler-errors:rust:new-solver-new-candidates-2) for an easier view until that one lands.

Of note:
44af916020fb43c12070125c45b6dee4ec303bbc fixes a bug where we need to make the query response *inside* of a probe, or else we make no inference progress (I think)
50daad5acd2f163d03e7ffab942534f09bc36e2e implements `consider_assumption` for traits and predicates. I'm not sure if using `sup` here is necessary or if `eq` is fine.
* We decided that all of the `instantiate_constituent_tys_for_*` functions are verbose but ok, since they need to be exhaustive and the logic between each of them is not similar enough, right?

r? ``@lcnr``

16 months agoRollup merge of #106917 - compiler-errors:const-closure-foreign, r=tmiasko
Michael Goulet [Wed, 18 Jan 2023 23:00:29 +0000 (18:00 -0500)]
Rollup merge of #106917 - compiler-errors:const-closure-foreign, r=tmiasko

Encode const mir for closures if they're const

Fixes #106913

16 months agoRollup merge of #106753 - compiler-errors:rpitit-not-suggestable, r=spastorino
Michael Goulet [Wed, 18 Jan 2023 23:00:28 +0000 (18:00 -0500)]
Rollup merge of #106753 - compiler-errors:rpitit-not-suggestable, r=spastorino

Make sure that RPITITs are not considered suggestable

Makes no sense to suggest `where impl Future<Output = ()>: Send`, for example.

16 months agoRollup merge of #105796 - notriddle:notriddle/rustdoc-search-stop-doing-demerits...
Michael Goulet [Wed, 18 Jan 2023 23:00:28 +0000 (18:00 -0500)]
Rollup merge of #105796 - notriddle:notriddle/rustdoc-search-stop-doing-demerits, r=GuillaumeGomez

rustdoc: simplify JS search routine by not messing with lev distance

Since the sorting function accounts for an `index` field, there's not much reason to also be applying changes to the levenshtein distance. Instead, we can just not treat `lev` as a filter if there's already a non-sentinel value for `index`.

<details>

This change gives slightly more weight to the index and path part, as search criteria, than it used to. This changes some of the test cases, but not in any obviously-"worse" way, and, in particular, substring matches are a bigger deal than levenshtein distances (we're assuming that a typo is less likely than someone just not typing the entire name).

The biggest change is the addition of a `path_lev` field to result items. It's always zero if the search query has no parent path part and for type queries, making the check in the `sortResults` function a no-op. When it's present, it is used to implement different precedence for the parent path and the tail.

Consider the query `hashset::insert`, a test case [that already exists and can be found here](https://github.com/rust-lang/rust/blob/5c6a1681a9a7b815febdd9de2f840da338984e68/src/test/rustdoc-js-std/path-ordering.js). We want the ordering shown in the test case:

```
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_with' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_owned' },
        { 'path': 'std::collections::hash_map::HashMap', 'name': 'insert' },
```

We do not want this ordering, which is the ordering that would occur if substring position took priority over `path_lev`:

```
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' },
        { 'path': 'std::collections::hash_map::HashMap', 'name': 'insert' }, // BAD
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_with' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_owned' },
```

We also do not want `HashSet::iter` to appear before `HashMap::insert`, which is what would happen if `path_lev` took priority over the appearance of any substring match. This is why the `sortResults` function has `path_lev` sandwiched between a `index < 0` check and a `index` comparison check:

```
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_with' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_owned' },
        { 'path': 'std::collections::hash_set::HashSet', 'name': 'iter' }, // BAD
        { 'path': 'std::collections::hash_map::HashMap', 'name': 'insert' },
```

The old code implemented a similar feature by manipulating the `lev` member based on whether a substring match was found and averaging in the path distance (`item.lev = name_lev + path_lev / 10`), so the path lev wound up acting like a tie breaker, but it gives slightly different results for `Vec::new`, [changing the test case](https://github.com/rust-lang/rust/pull/105796/files#diff-b346e2ef72a407915f438063c8c2c04f7a621df98923d441b41c0312211a5b21) because of the slight changes to ordering priority.

</details>

Based on https://github.com/rust-lang/rust/pull/103710#issuecomment-1296894296

Previews:

* https://notriddle.com/notriddle-rustdoc-demos/rustdoc-search-stop-doing-demerits/std/index.html
* https://notriddle.com/notriddle-rustdoc-demos/rustdoc-search-stop-doing-demerits-compiler/index.html

16 months agoAuto merge of #107041 - Nilstrieb:back-to-being-clueless-whether-it-really-is-a-liter...
bors [Wed, 18 Jan 2023 22:58:30 +0000 (22:58 +0000)]
Auto merge of #107041 - Nilstrieb:back-to-being-clueless-whether-it-really-is-a-literal, r=compiler-errors

Revert "Improve heuristics whether `format_args` string is a source literal"

This reverts commit e6c02aad9345925cfed74f86b414c4d0715d381b (from #106195).

Keeps the code improvements from the PR and the test (as a known-bug).

Works around #106408 while a proper fix is discussed more thoroughly in #106505, as proposed by `@tmandry.`

Reopens #106191

r? compiler-errors

16 months agoAuto merge of #105716 - chriswailes:ndk-update-redux, r=pietroalbini
bors [Wed, 18 Jan 2023 19:49:02 +0000 (19:49 +0000)]
Auto merge of #105716 - chriswailes:ndk-update-redux, r=pietroalbini

Ndk update redux

Blocked on https://github.com/rust-lang/blog.rust-lang.org/pull/1055

16 months agorustdoc: add test case for setting-line margin on settings.html
Michael Howell [Wed, 18 Jan 2023 19:48:24 +0000 (12:48 -0700)]
rustdoc: add test case for setting-line margin on settings.html

16 months agorustdoc: remove redundant rule `#settings .setting-line`
Michael Howell [Wed, 18 Jan 2023 19:39:13 +0000 (12:39 -0700)]
rustdoc: remove redundant rule `#settings .setting-line`

Since the current version of settings.js always nests things below
a div with ID `settings`, this rule always overrode the one above.

16 months agoRevert "Improve heuristics whether `format_args` string is a source literal"
Nilstrieb [Wed, 18 Jan 2023 18:47:22 +0000 (19:47 +0100)]
Revert "Improve heuristics whether `format_args` string is a source literal"

This reverts commit e6c02aad9345925cfed74f86b414c4d0715d381b.

Keeps the code improvements from the PR and the test (as a known-bug).

16 months agorustdoc: fix "?" keyboard command when radio button is focused
Michael Howell [Wed, 18 Jan 2023 18:52:31 +0000 (11:52 -0700)]
rustdoc: fix "?" keyboard command when radio button is focused

This extends the special case with checkbox settings to also cover radios.

16 months agorustdoc: put focus on the help link when opening it from keyboard
Michael Howell [Wed, 18 Jan 2023 18:41:34 +0000 (11:41 -0700)]
rustdoc: put focus on the help link when opening it from keyboard

This prevents some strange blur-event-related bugs with the "?" command
by ensuring that the focus remains in the same spot when the settings
area closes.

16 months agoAlso remove `#![feature(control_flow_enum)]` where possible
Scott McMurray [Wed, 18 Jan 2023 18:22:21 +0000 (10:22 -0800)]
Also remove `#![feature(control_flow_enum)]` where possible

16 months agoAuto merge of #106503 - cjgillot:remap-nofilter, r=oli-obk
bors [Wed, 18 Jan 2023 16:37:33 +0000 (16:37 +0000)]
Auto merge of #106503 - cjgillot:remap-nofilter, r=oli-obk

Do not filter substs in `remap_generic_params_to_declaration_params`.

The relevant filtering should have been performed by borrowck.

Fixes https://github.com/rust-lang/rust/issues/105826

r? types

16 months agoFix Dominators::rank_partial_cmp to match documentation
Tomasz Miąsko [Wed, 18 Jan 2023 00:00:00 +0000 (00:00 +0000)]
Fix Dominators::rank_partial_cmp to match documentation

The only use site is also updated accordingly and there is no change in
end-to-end behaviour.

16 months agoUpdate `IsZero` documentation
clubby789 [Wed, 18 Jan 2023 15:48:53 +0000 (15:48 +0000)]
Update `IsZero` documentation

16 months agoImplement `alloc::vec::IsZero` for `Option<$NUM>` types
clubby789 [Tue, 17 Jan 2023 15:42:53 +0000 (15:42 +0000)]
Implement `alloc::vec::IsZero` for `Option<$NUM>` types

16 months agoHandle structural traits more gracefully
Michael Goulet [Wed, 18 Jan 2023 14:56:44 +0000 (14:56 +0000)]
Handle structural traits more gracefully

16 months agono subtyping in the new trait solver
Michael Goulet [Wed, 18 Jan 2023 14:40:16 +0000 (14:40 +0000)]
no subtyping in the new trait solver

16 months agoSized, Copy/Clone
Michael Goulet [Tue, 17 Jan 2023 20:24:58 +0000 (20:24 +0000)]
Sized, Copy/Clone

16 months agoAuto and alias traits
Michael Goulet [Tue, 17 Jan 2023 20:16:30 +0000 (20:16 +0000)]
Auto and alias traits

16 months agoAssemble object bound candidates
Michael Goulet [Tue, 17 Jan 2023 18:19:11 +0000 (18:19 +0000)]
Assemble object bound candidates

16 months agoimplement consider_assumption
Michael Goulet [Tue, 17 Jan 2023 19:50:50 +0000 (19:50 +0000)]
implement consider_assumption

16 months agoCanonicalize trait solver response inside probe
Michael Goulet [Tue, 17 Jan 2023 19:29:52 +0000 (19:29 +0000)]
Canonicalize trait solver response inside probe

16 months agoCorrect typo
Albert Larsan [Wed, 18 Jan 2023 13:08:41 +0000 (14:08 +0100)]
Correct typo

16 months agoRemove extra removal from test path
Guillaume Gomez [Wed, 18 Jan 2023 11:09:15 +0000 (12:09 +0100)]
Remove extra removal from test path

16 months agoAuto merge of #107026 - Dylan-DPC:rollup-4fonvdc, r=Dylan-DPC
bors [Wed, 18 Jan 2023 10:26:12 +0000 (10:26 +0000)]
Auto merge of #107026 - Dylan-DPC:rollup-4fonvdc, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #103702 (Lift `T: Sized` bounds from some `strict_provenance` pointer methods)
 - #106441 (relax reference requirement on SocketAddrExt::from_abstract_name)
 - #106718 (finish trait solver skeleton work)
 - #106950 (Don't do pointer arithmetic on pointers to deallocated memory)
 - #107014 (rustdoc: remove deprecated / unused code from main.js)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

16 months agoRollup merge of #107014 - notriddle:notriddle/js-cleanup, r=GuillaumeGomez
Dylan DPC [Wed, 18 Jan 2023 10:25:39 +0000 (15:55 +0530)]
Rollup merge of #107014 - notriddle:notriddle/js-cleanup, r=GuillaumeGomez

rustdoc: remove deprecated / unused code from main.js

16 months agoRollup merge of #106950 - the8472:fix-splice-miri, r=cuviper
Dylan DPC [Wed, 18 Jan 2023 10:25:38 +0000 (15:55 +0530)]
Rollup merge of #106950 - the8472:fix-splice-miri, r=cuviper

Don't do pointer arithmetic on pointers to deallocated memory

vec::Splice can invalidate the slice::Iter inside vec::Drain. So we replace them with dangling pointers which, unlike ones to deallocated memory, are allowed.

Fixes miri test failures.
Fixes https://github.com/rust-lang/miri/issues/2759

16 months agoRollup merge of #106718 - lcnr:solver-cycles, r=compiler-errors
Dylan DPC [Wed, 18 Jan 2023 10:25:38 +0000 (15:55 +0530)]
Rollup merge of #106718 - lcnr:solver-cycles, r=compiler-errors

finish trait solver skeleton work

### 648d661b4e0fcf55f7082894f577377eb451db4b

The previous implementation didn't remove provisional entries which depended on the current goal if we're forced to rerun in case the provisional result of that entry is different from the new result. For reference, see https://rust-lang.github.io/chalk/book/recursive/search_graph.html.

We should also treat inductive cycles as overflow, not ordinary ambiguity.

### 219a5de2517cebfe20a2c3417bd302f7c12db70c 6a1912be539dd5a3b3c10be669787c4bf0c1868a

These two commits move canonicalization to the start of the queries which simplifies a bunch of stuff. I originally intended to keep stuff canonicalized for a while because I expected us to add a additional caches the trait solver, either for candidate assembly or for projections. We ended up not adding (and expect to not need) any of them so this just ends up being easier to understand.

### d78d5ad0979e965afde6500bccfa119b47063506

adds a special `eq` for the solver which doesn't care about obligations or spans

### 18704e6a78b7703e1bbb3856f015cb76c0a07a06

implements https://rust-lang.zulipchat.com/#narrow/stream/364551-t-types.2Ftrait-system-refactor/topic/projection.20cache

r? `@compiler-errors`

16 months agoRollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
Dylan DPC [Wed, 18 Jan 2023 10:25:37 +0000 (15:55 +0530)]
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett

relax reference requirement on SocketAddrExt::from_abstract_name

Reference: https://github.com/rust-lang/rust/issues/85410#issuecomment-1369544671

16 months agoRollup merge of #103702 - WaffleLapkin:lift-sized-bounds-from-pointer-methods-where...
Dylan DPC [Wed, 18 Jan 2023 10:25:36 +0000 (15:55 +0530)]
Rollup merge of #103702 - WaffleLapkin:lift-sized-bounds-from-pointer-methods-where-applicable, r=m-ou-se

Lift `T: Sized` bounds from some `strict_provenance` pointer methods

This PR removes requirement for `T` (pointee type) to be `Sized` to call `pointer::{addr, expose_addr, with_addr, map_addr}`. These functions don't use `T`'s size, so there is no reason for them to require this. Updated public API:

cc ``@Gankra,`` #95228
r? libs-api

17 months agoremove error code from `#[rustc_variance]` and document its remains
Ezra Shaw [Mon, 16 Jan 2023 10:30:50 +0000 (23:30 +1300)]
remove error code from `#[rustc_variance]` and document its remains

17 months agoStop using `BREAK` & `CONTINUE` in compiler
Scott McMurray [Wed, 18 Jan 2023 07:17:13 +0000 (23:17 -0800)]
Stop using `BREAK` & `CONTINUE` in compiler

Switching them to `Break(())` and `Continue(())` instead.

libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.

17 months agoadd comment
lcnr [Wed, 18 Jan 2023 07:08:58 +0000 (08:08 +0100)]
add comment

17 months agoadd note about indirect cycles
lcnr [Tue, 17 Jan 2023 15:00:00 +0000 (16:00 +0100)]
add note about indirect cycles

17 months agoupdate project to emulate a projection cache
lcnr [Tue, 17 Jan 2023 12:41:12 +0000 (13:41 +0100)]
update project to emulate a projection cache

17 months agoadd `eq` to `InferCtxtExt`
lcnr [Tue, 17 Jan 2023 11:26:28 +0000 (12:26 +0100)]
add `eq` to `InferCtxtExt`

17 months agoremove assembly context and impl a bit more
lcnr [Tue, 17 Jan 2023 10:47:47 +0000 (11:47 +0100)]
remove assembly context and impl a bit more

17 months agoinstantiate canonical vars eagerly
lcnr [Tue, 17 Jan 2023 09:21:30 +0000 (10:21 +0100)]
instantiate canonical vars eagerly

17 months agoupdate cache
lcnr [Wed, 11 Jan 2023 12:39:02 +0000 (13:39 +0100)]
update cache

17 months agoAuto merge of #107021 - matthiaskrgr:rollup-0dzxfyi, r=matthiaskrgr
bors [Wed, 18 Jan 2023 07:08:20 +0000 (07:08 +0000)]
Auto merge of #107021 - matthiaskrgr:rollup-0dzxfyi, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #106244 (Improve Markdown styling in README)
 - #106747 (Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB)
 - #106873 (dont randomly use `_` to print out const generic arguments)
 - #106992 (Remove unused `#![feature(box_syntax)]` in `alloc`)
 - #106995 (bump failing assembly & codegen tests from LLVM 14 to LLVM 15)
 - #106996 (rustdoc: instead of `.setting-name { width: 100% }`, use default div CSS)
 - #106997 (Add heapsort fallback in `select_nth_unstable`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoRollup merge of #106997 - Sp00ph:introselect, r=scottmcm
Matthias Krüger [Wed, 18 Jan 2023 05:59:22 +0000 (06:59 +0100)]
Rollup merge of #106997 - Sp00ph:introselect, r=scottmcm

Add heapsort fallback in `select_nth_unstable`

Addresses #102451 and #106933.

`slice::select_nth_unstable` uses a quick select implementation based on the same pattern defeating quicksort algorithm that `slice::sort_unstable` uses. `slice::sort_unstable` uses a recursion limit and falls back to heapsort if there were too many bad pivot choices, to ensure O(n log n) worst case running time (known as introsort). However, `slice::select_nth_unstable` does not have such a fallback strategy, which leads to it having a worst case running time of O(n²) instead. #102451 links to a playground which generates pathological inputs that show this quadratic behavior. On my machine, a randomly generated slice of length `1 << 19` takes ~200µs to calculate its median, whereas a pathological input of the same length takes over 2.5s. This PR adds an iteration limit to `select_nth_unstable`, falling back to heapsort, which ensures an O(n log n) worst case running time (introselect). With this change, there was no noticable slowdown for the random input, but the same pathological input now takes only ~1.2ms. In the future it might be worth implementing something like Median of Medians or Fast Deterministic Selection instead, which guarantee O(n) running time for all possible inputs. I've left this as a `FIXME` for now and only implemented the heapsort fallback to minimize the needed code changes.

I still think we should clarify in the `select_nth_unstable` docs that the worst case running time isn't currently O(n) (the original reason that #102451 was opened), but I think it's a lot better to be able to guarantee O(n log n) instead of O(n²) for the worst case.

17 months agoRollup merge of #106996 - notriddle:notriddle/settings-line-div, r=GuillaumeGomez
Matthias Krüger [Wed, 18 Jan 2023 05:59:22 +0000 (06:59 +0100)]
Rollup merge of #106996 - notriddle:notriddle/settings-line-div, r=GuillaumeGomez

rustdoc: instead of `.setting-name { width: 100% }`, use default div CSS

This has no discernible change in appearance.

17 months agoRollup merge of #106995 - lukas-code:align_offset_assembly_test, r=cuviper
Matthias Krüger [Wed, 18 Jan 2023 05:59:21 +0000 (06:59 +0100)]
Rollup merge of #106995 - lukas-code:align_offset_assembly_test, r=cuviper

bump failing assembly & codegen tests from LLVM 14 to LLVM 15

These tests need LLVM 15.

Found by ```@Robert-Cunningham``` in https://github.com/rust-lang/rust/pull/100601#issuecomment-1385400008

Passed tests at 006506e93fc80318ebfd7939fe1fd4dc19ecd8cb in https://github.com/rust-lang/rust/actions/runs/3942442730/jobs/6746104740.

17 months agoRollup merge of #106992 - joboet:alloc_remove_box_syntax, r=thomcc
Matthias Krüger [Wed, 18 Jan 2023 05:59:21 +0000 (06:59 +0100)]
Rollup merge of #106992 - joboet:alloc_remove_box_syntax, r=thomcc

Remove unused `#![feature(box_syntax)]` in `alloc`

17 months agoRollup merge of #106873 - BoxyUwU:ty_const_formatting, r=compiler-errors
Matthias Krüger [Wed, 18 Jan 2023 05:59:20 +0000 (06:59 +0100)]
Rollup merge of #106873 - BoxyUwU:ty_const_formatting, r=compiler-errors

dont randomly use `_` to print out const generic arguments

const generics seem to get printed out as `_` for no reason a lot of the time, as someone who spends a lot of time with const generics this has gotten :sparkles: very annoying :sparkles:. Latest example would be #106423 where the ICE messaged formatted a `ty::Const` containing no infer vars, as `_`.

For some reason printing of the const argument on arrays was custom instead of using the existing logic for printing `ty::Const`. Additionally the existing logic for printing `ty::Const` would print out `_` for anon consts that are in a separate crate leading to weird diagnostics (see second commit). There ought to be less cases of consts randomly getting printed as `_` hiding valuable info now.

17 months agoRollup merge of #106747 - yanchen4791:issue-105507-fix, r=estebank
Matthias Krüger [Wed, 18 Jan 2023 05:59:20 +0000 (06:59 +0100)]
Rollup merge of #106747 - yanchen4791:issue-105507-fix, r=estebank

Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB

Fix for issue #105507

The problem:
When generic associated types (GATs) are from higher-ranked trait bounds (HRTB), they are implied 'static requirement (see
[Implied 'static requirement from higher-ranked trait bounds](https://blog.rust-lang.org/2022/10/28/gats-stabilization.html#implied-static-requirement-from-higher-ranked-trait-bounds) for more details). If the user did not explicitly specify the `'static` lifetime when using the GAT, the current error message will only point out the type `does not live long enough` where the type is used, but not where the GAT is specified and how to fix the problem.

The solution:
Add notes at the span where the problematic GATs are specified and suggestions of how to fix the problem by adding `'static` lifetime at the right spans.

17 months agoRollup merge of #106244 - atouchet:readme3, r=workingjubilee
Matthias Krüger [Wed, 18 Jan 2023 05:59:19 +0000 (06:59 +0100)]
Rollup merge of #106244 - atouchet:readme3, r=workingjubilee

Improve Markdown styling in README

Update Readme to use consistent line lengths. Also update some formatting and links. (Followup to https://github.com/rust-lang/rust/pull/105553).

r? ``@workingjubilee``

17 months agoi am free
Boxy [Wed, 18 Jan 2023 04:45:35 +0000 (04:45 +0000)]
i am free

17 months agoactually print out non local anon consts
Boxy [Sat, 14 Jan 2023 19:03:50 +0000 (19:03 +0000)]
actually print out non local anon consts

17 months agotest for non local anon const printing
Boxy [Sat, 14 Jan 2023 19:01:31 +0000 (19:01 +0000)]
test for non local anon const printing

17 months agodefer array len printing to const arg printing
Boxy [Sat, 14 Jan 2023 18:32:17 +0000 (18:32 +0000)]
defer array len printing to const arg printing

17 months agoAuto merge of #106952 - petrochenkov:docglob, r=notriddle,GuillaumeGomez
bors [Wed, 18 Jan 2023 03:54:04 +0000 (03:54 +0000)]
Auto merge of #106952 - petrochenkov:docglob, r=notriddle,GuillaumeGomez

rustdoc: Fix glob import inlining

Filter away names that are not actually imported by the glob, e.g. because they are shadowed by something else.

Fixes the issue found in https://github.com/rust-lang/rust/pull/94857#issuecomment-1382912356.

17 months agorustdoc: stop using deprecated `window.event` when there's an `ev` param
Michael Howell [Wed, 18 Jan 2023 00:54:58 +0000 (17:54 -0700)]
rustdoc: stop using deprecated `window.event` when there's an `ev` param

17 months agoAuto merge of #107010 - weihanglo:update-cargo, r=weihanglo
bors [Wed, 18 Jan 2023 00:23:49 +0000 (00:23 +0000)]
Auto merge of #107010 - weihanglo:update-cargo, r=weihanglo

Update cargo

9 commits in 1cd6d3803dfb0b342272862a8590f5dfc9f72573..a5d47a72595dd6fbe7d4e4f6ec20dc5fe724edd1 2023-01-12 18:40:36 +0000 to 2023-01-16 18:51:50 +0000

- Add network container tests (rust-lang/cargo#11583)
- Show progress of crates.io index update even `net.git-fetch-with-cli` option enabled (rust-lang/cargo#11579)
- `cargo metadata` supports artifact dependencies (rust-lang/cargo#11550)
- fix(docs): add required "inherits" option to example profile (rust-lang/cargo#11504)
- add documentation that SSH markers aren't supported (rust-lang/cargo#11586)
- Fix typo (rust-lang/cargo#11585)
- Enable source_config_env test on Windows (rust-lang/cargo#11582)
- Support `codegen-backend` and `rustflags` in profiles in config file (rust-lang/cargo#11562)
- ci: reflect to clap updates (rust-lang/cargo#11578)

r? `@ghost`

17 months agorustdoc: remove function `handleClick` that's only used once
Michael Howell [Wed, 18 Jan 2023 00:22:05 +0000 (17:22 -0700)]
rustdoc: remove function `handleClick` that's only used once

17 months agospecial case removing `&` suggestion
Ezra Shaw [Wed, 18 Jan 2023 00:14:56 +0000 (13:14 +1300)]
special case removing `&` suggestion

17 months agoUpdate cargo
Weihang Lo [Tue, 17 Jan 2023 22:25:17 +0000 (22:25 +0000)]
Update cargo

9 commits in 1cd6d3803dfb0b342272862a8590f5dfc9f72573..a5d47a72595dd6fbe7d4e4f6ec20dc5fe724edd1
2023-01-12 18:40:36 +0000 to 2023-01-16 18:51:50 +0000

- Add network container tests (rust-lang/cargo#11583)
- Show progress of crates.io index update even `net.git-fetch-with-cli` option enabled (rust-lang/cargo#11579)
- `cargo metadata` supports artifact dependencies (rust-lang/cargo#11550)
- fix(docs): add required "inherits" option to example profile (rust-lang/cargo#11504)
- add documentation that SSH markers aren't supported (rust-lang/cargo#11586)
- Fix typo (rust-lang/cargo#11585)
- Enable source_config_env test on Windows (rust-lang/cargo#11582)
- Support `codegen-backend` and `rustflags` in profiles in config file (rust-lang/cargo#11562)
- ci: reflect to clap updates (rust-lang/cargo#11578)

17 months agoadd miri regression test
The 8472 [Tue, 17 Jan 2023 19:30:47 +0000 (20:30 +0100)]
add miri regression test

17 months agoDon't do pointer arithmetic on pointers to deallocated memory
The 8472 [Mon, 16 Jan 2023 20:39:36 +0000 (21:39 +0100)]
Don't do pointer arithmetic on pointers to deallocated memory

vec::Splice can invalidate the slice::Iter inside vec::Drain.
So we replace them with dangling pointers which, unlike ones to
deallocated memory, are allowed.

17 months agoAuto merge of #106998 - matthiaskrgr:rollup-hmfisji, r=matthiaskrgr
bors [Tue, 17 Jan 2023 20:53:05 +0000 (20:53 +0000)]
Auto merge of #106998 - matthiaskrgr:rollup-hmfisji, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #104505 (Remove double spaces after dots in comments)
 - #106784 (prevent E0512 from emitting [type error] by checking the references_error)
 - #106834 (new trait solver: only consider goal changed if response is not identity)
 - #106889 (Mention the lack of `windows_mut` in `windows`)
 - #106963 (Use `scope_expr_id` from `ProbeCtxt`)
 - #106970 (Switch to `EarlyBinder` for `item_bounds` query)
 - #106980 (Hide `_use_mk_alias_ty_instead` in `<AliasTy as Debug>::fmt`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoAdd 'static lifetime suggestion when GAT implied 'static requirement from HRTB
yanchen4791 [Wed, 11 Jan 2023 08:19:40 +0000 (00:19 -0800)]
Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB

17 months agoRollup merge of #106980 - Nilstrieb:_use_mk_manual_debug_impl_instead, r=lcnr
Matthias Krüger [Tue, 17 Jan 2023 19:21:28 +0000 (20:21 +0100)]
Rollup merge of #106980 - Nilstrieb:_use_mk_manual_debug_impl_instead, r=lcnr

Hide `_use_mk_alias_ty_instead` in `<AliasTy as Debug>::fmt`

17 months agoRollup merge of #106970 - kylematsuda:earlybinder-item-bounds, r=lcnr
Matthias Krüger [Tue, 17 Jan 2023 19:21:28 +0000 (20:21 +0100)]
Rollup merge of #106970 - kylematsuda:earlybinder-item-bounds, r=lcnr

Switch to `EarlyBinder` for `item_bounds` query

Part of the work to finish #105779 (also see https://github.com/rust-lang/types-team/issues/78).

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `item_bounds` query and removes `bound_item_bounds`.

r? `@lcnr`

17 months agoRollup merge of #106963 - compiler-errors:scope-expr-dupe, r=michaelwoerister
Matthias Krüger [Tue, 17 Jan 2023 19:21:27 +0000 (20:21 +0100)]
Rollup merge of #106963 - compiler-errors:scope-expr-dupe, r=michaelwoerister

Use `scope_expr_id` from `ProbeCtxt`

We already store it in the `ProbeCtxt`, so just retrieve it from there.

17 months agoRollup merge of #106889 - scottmcm:windows-mut, r=cuviper
Matthias Krüger [Tue, 17 Jan 2023 19:21:27 +0000 (20:21 +0100)]
Rollup merge of #106889 - scottmcm:windows-mut, r=cuviper

Mention the lack of `windows_mut` in `windows`

This is a common request, going back to at least 2015 (#23783), so mention in the docs that it can't be done and offer a workaround using <https://doc.rust-lang.org/std/cell/struct.Cell.html#method.as_slice_of_cells>.

(See also URLO threads like <https://internals.rust-lang.org/t/a-windows-mut-method-on-slice/16941/10?u=scottmcm>.)

17 months agoRollup merge of #106834 - compiler-errors:new-solver-did-changed, r=lcnr
Matthias Krüger [Tue, 17 Jan 2023 19:21:26 +0000 (20:21 +0100)]
Rollup merge of #106834 - compiler-errors:new-solver-did-changed, r=lcnr

new trait solver: only consider goal changed if response is not identity

I think this is the right way of implementing it..

r? `@lcnr`

17 months agoRollup merge of #106784 - lyming2007:issue-106695-fix, r=WaffleLapkin
Matthias Krüger [Tue, 17 Jan 2023 19:21:26 +0000 (20:21 +0100)]
Rollup merge of #106784 - lyming2007:issue-106695-fix, r=WaffleLapkin

prevent E0512 from emitting [type error] by checking the references_error

but still emit E0512
this will fix #106695

17 months agoRollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Matthias Krüger [Tue, 17 Jan 2023 19:21:25 +0000 (20:21 +0100)]
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726

Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.

17 months agorustdoc: add test cases for settings radio button layout
Michael Howell [Tue, 17 Jan 2023 19:09:38 +0000 (12:09 -0700)]
rustdoc: add test cases for settings radio button layout

17 months agobump failing assembly & codegen tests from LLVM 14 to LLVM 15
Lukas Markeffsky [Tue, 17 Jan 2023 18:35:19 +0000 (19:35 +0100)]
bump failing assembly & codegen tests from LLVM 14 to LLVM 15

17 months agorustdoc: instead of `.setting-name { width: 100% }`, use default div CSS
Michael Howell [Tue, 17 Jan 2023 18:49:36 +0000 (11:49 -0700)]
rustdoc: instead of `.setting-name { width: 100% }`, use default div CSS

17 months agoAdd heapsort fallback in `select_nth_unstable`
Markus Everling [Tue, 17 Jan 2023 18:38:37 +0000 (19:38 +0100)]
Add heapsort fallback in `select_nth_unstable`

17 months agorefactor[alloc]: remove unused box syntax feature
joboet [Tue, 17 Jan 2023 17:55:44 +0000 (18:55 +0100)]
refactor[alloc]: remove unused box syntax feature

17 months agonew trait solver: only consider goal changed if response is not identity
Michael Goulet [Sat, 14 Jan 2023 04:46:23 +0000 (04:46 +0000)]
new trait solver: only consider goal changed if response is not identity

17 months agoAuto merge of #106294 - Nilstrieb:noundef-everything, r=nikic
bors [Tue, 17 Jan 2023 17:39:48 +0000 (17:39 +0000)]
Auto merge of #106294 - Nilstrieb:noundef-everything, r=nikic

Put `noundef` on all scalars that don't allow uninit

Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those.

Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them.

The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. After #99182, this function now doesn't return uninit values anymore, making users of it safe from this change.

The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec). This is hopefully rare enough to not break anything.

cc `@nagisa` `@scottmcm` `@nikic`

17 months agodelay E0512 as a bug by checking the references_error
Yiming Lei [Thu, 12 Jan 2023 20:28:07 +0000 (12:28 -0800)]
delay E0512 as a bug by checking the references_error
fix #106695