Commit Graph

215304 Commits

Author SHA1 Message Date
bors
705a96d39b 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.
2023-01-19 08:04:26 +00:00
bors
65d2f2a5f9 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](0e2b39fd1f) is new in this PR)

r? `@petrochenkov`

I think this should be most of the uncontroversial part of #105462.
2023-01-19 05:23:40 +00:00
bors
6ba6d22bdf 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
2023-01-19 02:09:45 +00:00
Michael Goulet
e12c6b277f
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.
2023-01-18 18:00:31 -05:00
Michael Goulet
6595127e66
Rollup merge of #107042 - notriddle:notriddle/rustdoc-js-question, r=GuillaumeGomez
rustdoc: fix corner cases with "?" JS keyboard command
2023-01-18 18:00:31 -05:00
Michael Goulet
5d562be33d
Rollup merge of #107030 - albertlarsan68:patch-3, r=lcnr
Correct typo

https://github.com/rust-lang/rust/pull/106718#discussion_r1073508490
2023-01-18 18:00:30 -05:00
Michael Goulet
2eef516b30
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.
2023-01-18 18:00:30 -05:00
Michael Goulet
cf5068bd62
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](98700cf481...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``
2023-01-18 18:00:29 -05:00
Michael Goulet
a637e2a950
Rollup merge of #106917 - compiler-errors:const-closure-foreign, r=tmiasko
Encode const mir for closures if they're const

Fixes #106913
2023-01-18 18:00:29 -05:00
Michael Goulet
685c77305c
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.
2023-01-18 18:00:28 -05:00
Michael Goulet
f7066f79d7
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](5c6a1681a9/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
2023-01-18 18:00:28 -05:00
bors
8b11574ca0 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 e6c02aad93 (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
2023-01-18 22:58:30 +00:00
bors
333ee6c466 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
2023-01-18 19:49:02 +00:00
Michael Howell
34d595dda1 rustdoc: add test case for setting-line margin on settings.html 2023-01-18 12:48:24 -07:00
Michael Howell
9ee4df0e9c 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.
2023-01-18 12:39:13 -07:00
Nilstrieb
a8086cf9df Revert "Improve heuristics whether format_args string is a source literal"
This reverts commit e6c02aad93.

Keeps the code improvements from the PR and the test (as a known-bug).
2023-01-18 20:33:17 +01:00
Michael Howell
bb5fb53b30 rustdoc: fix "?" keyboard command when radio button is focused
This extends the special case with checkbox settings to also cover radios.
2023-01-18 12:14:00 -07:00
Michael Howell
deb05758c8 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.
2023-01-18 12:14:00 -07:00
Scott McMurray
7d57685682 Also remove #![feature(control_flow_enum)] where possible 2023-01-18 10:22:21 -08:00
bors
6d46b1ec87 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
2023-01-18 16:37:33 +00:00
clubby789
50e9f2e6e8 Update IsZero documentation 2023-01-18 15:48:53 +00:00
clubby789
b94a29a25f Implement alloc::vec::IsZero for Option<$NUM> types 2023-01-18 15:15:15 +00:00
Michael Goulet
f672436f04 Handle structural traits more gracefully 2023-01-18 14:59:15 +00:00
Michael Goulet
34127c5080 no subtyping in the new trait solver 2023-01-18 14:59:15 +00:00
Michael Goulet
685c32fd85 Sized, Copy/Clone 2023-01-18 14:59:15 +00:00
Michael Goulet
45aa5c0f90 Auto and alias traits 2023-01-18 14:59:15 +00:00
Michael Goulet
3d87a8e848 Assemble object bound candidates 2023-01-18 14:28:14 +00:00
Michael Goulet
f99b273d57 implement consider_assumption 2023-01-18 14:28:14 +00:00
Michael Goulet
b84b1da2db Canonicalize trait solver response inside probe 2023-01-18 14:28:14 +00:00
Albert Larsan
5a685a10ec
Correct typo 2023-01-18 14:08:41 +01:00
bors
1f72129ffe 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
2023-01-18 10:26:12 +00:00
Dylan DPC
43b1e732db
Rollup merge of #107014 - notriddle:notriddle/js-cleanup, r=GuillaumeGomez
rustdoc: remove deprecated / unused code from main.js
2023-01-18 15:55:39 +05:30
Dylan DPC
1ff4a1259d
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
2023-01-18 15:55:38 +05:30
Dylan DPC
6f5c3c9cdb
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`
2023-01-18 15:55:38 +05:30
Dylan DPC
548ae602fc
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
2023-01-18 15:55:37 +05:30
Dylan DPC
d6ea99d2ed
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
2023-01-18 15:55:36 +05:30
Scott McMurray
925dc37313 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.
2023-01-17 23:17:51 -08:00
lcnr
369f9aa099 add comment 2023-01-18 08:11:15 +01:00
lcnr
415aa663a2 add note about indirect cycles 2023-01-18 08:11:15 +01:00
lcnr
31ac29d989 update project to emulate a projection cache 2023-01-18 08:11:15 +01:00
lcnr
9a757d6ee4 add eq to InferCtxtExt 2023-01-18 08:11:15 +01:00
lcnr
660c28391c remove assembly context and impl a bit more 2023-01-18 08:11:15 +01:00
lcnr
bf7dbff921 instantiate canonical vars eagerly 2023-01-18 08:11:13 +01:00
lcnr
b738b06160 update cache 2023-01-18 08:09:01 +01:00
bors
74c1ad5d35 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
2023-01-18 07:08:20 +00:00
Matthias Krüger
788671c1c6
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.
2023-01-18 06:59:22 +01:00
Matthias Krüger
f547bb5715
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.
2023-01-18 06:59:22 +01:00
Matthias Krüger
c96dac16c3
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.
2023-01-18 06:59:21 +01:00
Matthias Krüger
47ccca0c86
Rollup merge of #106992 - joboet:alloc_remove_box_syntax, r=thomcc
Remove unused `#![feature(box_syntax)]` in `alloc`
2023-01-18 06:59:21 +01:00
Matthias Krüger
9e46c24a90
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  very annoying . 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.
2023-01-18 06:59:20 +01:00