Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #122350

Closed
wants to merge 22 commits into from

Commits on Jan 6, 2024

  1. rustdoc-search: parse and search with ML-style HOF

    Option::map, for example, looks like this:
    
        option<t>, (t -> u) -> option<u>
    
    This syntax searches all of the HOFs in Rust: traits Fn, FnOnce,
    and FnMut, and bare fn primitives.
    notriddle committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    5983db9 View commit details
    Browse the repository at this point in the history
  2. rustdoc: clean up search.js by removing empty sort case

    It's going to be a no-op on the empty list anyway
    (we have plenty of test cases that return nothing)
    so why send extra code?
    notriddle committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    8eac04f View commit details
    Browse the repository at this point in the history
  3. rustdoc: use const for the special type name ids

    Initialize them before the search index is loaded.
    notriddle committed Jan 6, 2024
    Configuration menu
    Copy the full SHA
    df043c4 View commit details
    Browse the repository at this point in the history

Commits on Jan 7, 2024

  1. rustdoc-search: add search query syntax Fn(T) -> U

    This is implemented, in addition to the ML-style one,
    because Rust does it. If we don't, we'll never hear the end of it.
    
    This commit also refactors some duplicate parts of the parser
    into a dedicated function.
    notriddle committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    84d7a2c View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2024

  1. Configuration menu
    Copy the full SHA
    3ab6936 View commit details
    Browse the repository at this point in the history

Commits on Mar 9, 2024

  1. Configuration menu
    Copy the full SHA
    6f1156a View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2024

  1. Configuration menu
    Copy the full SHA
    3af28f0 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2024

  1. Update books

    rustbot committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    b66d7f5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    779ac69 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    aeec0d1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    2a1d4dd View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    0b6b330 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f614eae View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    ba70528 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#115141 - ChrisDenton:windows-support, r=wes…

    …leywiser
    
    Update Windows platform support
    
    This should not be merged until Rust 1.76 but I'm told this may need an fcp in addition to [MCP 651](rust-lang/compiler-team#651).
    
    cc `@rust-lang/compiler` `@rust-lang/release`
    matthiaskrgr authored Mar 11, 2024
    Configuration menu
    Copy the full SHA
    7ec3516 View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#119676 - notriddle:notriddle/rustdoc-search…

    …-hof, r=GuillaumeGomez
    
    rustdoc-search: search types by higher-order functions
    
    This feature extends rustdoc with syntax and search index information for searching function pointers and closures (Higher-Order Functions, or HOF). Part of rust-lang#60485
    
    This PR adds two syntaxes: a high-level one for finding any kind of HOF, and a direct implementation of the parenthesized path syntax that Rust itself uses.
    
    ## Preview pages
    
    | Query | Results |
    |-------|---------|
    | [`option<T>, (fnonce (T) -> bool) -> option<T>`][optionfilter] | `Option::filter` |
    | [`option<T>, (T -> bool) -> option<T>`][optionfilter2] | `Option::filter` |
    
    Updated chapter of the book: https://notriddle.com/rustdoc-html-demo-9/search-hof/rustdoc/read-documentation/search.html
    
    [optionfilter]: https://notriddle.com/rustdoc-html-demo-9/search-hof/std/vec/struct.Vec.html?search=option<T>%2C+(fnonce+(T)+->+bool)+->+option<T>&filter-crate=std
    [optionfilter2]: https://notriddle.com/rustdoc-html-demo-9/search-hof/std/vec/struct.Vec.html?search=option<T>%2C+(T+->+bool)+->+option<T>&filter-crate=std
    
    ## Motivation
    
    When type-based search was first landed, it was directly [described as incomplete][a comment].
    
    [a comment]: rust-lang#23289 (comment)
    
    Filling out the missing functionality is going to mean adding support for more of Rust's [type expression] syntax, such as references, raw pointers, function pointers, and closures. This PR adds function pointers and closures.
    
    [type expression]: https://doc.rust-lang.org/reference/types.html#type-expressions
    
    There's been demand for something "like Hoogle, but for Rust" expressed a few times [1](https://www.reddit.com/r/rust/comments/y8sbid/is_there_a_website_like_haskells_hoogle_for_rust/) [2](https://users.rust-lang.org/t/rust-equivalent-of-haskells-hoogle/102280) [3](https://internals.rust-lang.org/t/std-library-inclusion-policy/6852/2) [4](https://discord.com/channels/442252698964721669/448238009733742612/1109502307495858216). Some of them just don't realize what functionality already exists ([`Duration -> u64`](https://doc.rust-lang.org/nightly/std/?search=duration%20-%3E%20u64) already works), but a lot of them specifically want to search for higher-order functions like option combinators.
    
    ## Guide-level explanation (from the Rustdoc book)
    
    To search for a function that accepts a function as a parameter, like `Iterator::all`, wrap the nested signature in parenthesis, as in [`Iterator<T>, (T -> bool) -> bool`][iterator-all]. You can also search for a specific closure trait, such as `Iterator<T>, (FnMut(T) -> bool) -> bool`, but you need to know which one you want.
    
    [iterator-all]: https://notriddle.com/rustdoc-html-demo-9/search-hof/std/vec/struct.Vec.html?search=Iterator<T>%2C+(T+->+bool)+->+bool&filter-crate=std
    
    ## Reference-level description (also from the Rustdoc book)
    
    ### Primitives with Special Syntax
    
    <table>
    <thead>
      <tr>
        <th>Shorthand</th>
        <th>Explicit names</th>
      </tr>
    </thead>
    <tbody>
      <tr><td colspan="2">Before this PR</td></tr>
      <tr>
        <td><code>[]</code></td>
        <td><code>primitive:slice</code> and/or <code>primitive:array</code></td>
      </tr>
      <tr>
        <td><code>[T]</code></td>
        <td><code>primitive:slice&lt;T&gt;</code> and/or <code>primitive:array&lt;T&gt;</code></td>
      </tr>
      <tr>
        <td><code>!</code></td>
        <td><code>primitive:never</code></td>
      </tr>
      <tr>
        <td><code>()</code></td>
        <td><code>primitive:unit</code> and/or <code>primitive:tuple</code></td>
      </tr>
      <tr>
        <td><code>(T)</code></td>
        <td><code>T</code></td>
      </tr>
      <tr>
        <td><code>(T,)</code></td>
        <td><code>primitive:tuple&lt;T&gt;</code></td>
      </tr>
      <tr><td colspan="2">After this PR</td></tr>
      <tr>
        <td><code>(T, U -> V, W)</code></td>
        <td><code>fn(T, U) -> (V, W)</code>, Fn, FnMut, and FnOnce</td>
      </tr>
    </tbody>
    </table>
    
    The `->` operator has lower precedence than comma. If it's not wrapped in brackets, it delimits the return value for the function being searched for. To search for functions that take functions as parameters, use parenthesis.
    
    ### Search query grammar
    
    ```ebnf
    ident = *(ALPHA / DIGIT / "_")
    path = ident *(DOUBLE-COLON ident) [BANG]
    slice-like = OPEN-SQUARE-BRACKET [ nonempty-arg-list ] CLOSE-SQUARE-BRACKET
    tuple-like = OPEN-PAREN [ nonempty-arg-list ] CLOSE-PAREN
    arg = [type-filter *WS COLON *WS] (path [generics] / slice-like / tuple-like)
    type-sep = COMMA/WS *(COMMA/WS)
    nonempty-arg-list = *(type-sep) arg *(type-sep arg) *(type-sep) [ return-args ]
    generic-arg-list = *(type-sep) arg [ EQUAL arg ] *(type-sep arg [ EQUAL arg ]) *(type-sep)
    normal-generics = OPEN-ANGLE-BRACKET [ generic-arg-list ] *(type-sep)
                CLOSE-ANGLE-BRACKET
    fn-like-generics = OPEN-PAREN [ nonempty-arg-list ] CLOSE-PAREN [ RETURN-ARROW arg ]
    generics = normal-generics / fn-like-generics
    return-args = RETURN-ARROW *(type-sep) nonempty-arg-list
    
    exact-search = [type-filter *WS COLON] [ RETURN-ARROW ] *WS QUOTE ident QUOTE [ generics ]
    type-search = [ nonempty-arg-list ]
    
    query = *WS (exact-search / type-search) *WS
    
    ; unchanged parts of the grammar, like the full list of type filters, are omitted
    ```
    
    ## Future direction
    
    ### The remaining type expression grammar
    
    As described in rust-lang#118194, this is another step in the type expression grammar: BareFunction, and the function-like mode of TypePath, are now supported.
    
    * RawPointerType and ReferenceType actually are a priority.
    * ImplTraitType and TraitObjectType (and ImplTraitTypeOneBound and TraitObjectTypeOneBound) aren't as much of a priority, since they desugar pretty easily.
    
    ### Search subtyping and traits
    
    This is the other major factor that makes it less useful than it should be.
    
    * `iterator<result<t>> -> result<t>` doesn't find `Result::from_iter`. You have to search [`intoiterator<result<t>> -> result<t>`](https://notriddle.com/rustdoc-html-demo-9/search-hof/std/vec/struct.Vec.html?search=intoiterator%3Cresult%3Ct%3E%3E%20-%3E%20result%3Ct%3E&filter-crate=std). Nobody's going to search for IntoIterator unless they basically already know about it and don't need the search engine anyway.
    
    * Iterator combinators are usually structs that happen to implement Iterator, like `std::iter::Map`.
    
    To solve these cases, it needs to look at trait implementations, knowing that Iterator is a "subtype of" IntoIterator, and Map is a "subtype of" Iterator, so `iterator -> result` is a subtype of `intoiterator -> result` and `iterator<t>, (t -> u) -> iterator<u>` is a subtype of [`iterator<t>, (t -> u) -> map<t -> u>`](https://notriddle.com/rustdoc-html-demo-9/search-hof/std/vec/struct.Vec.html?search=iterator%3Ct%3E%2C%20(t%20-%3E%20u)%20-%3E%20map%3Ct%20-%3E%20u%3E&filter-crate=std).
    matthiaskrgr authored Mar 11, 2024
    Configuration menu
    Copy the full SHA
    c87410e View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#121865 - Kirandevraj:unnamed-fields-fileche…

    …ck, r=oli-obk
    
    Add FileCheck annotations to MIR-opt unnamed-fields tests
    
    Part of rust-lang#116971
    Adds filecheck annotations to unnamed-fields mir-opt tests in `tests/mir-opt/unnamed-fields`
    matthiaskrgr authored Mar 11, 2024
    Configuration menu
    Copy the full SHA
    8fb5cda View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#122000 - erer1243:issue-121868, r=nikic

    Fix 32-bit overflows in LLVM composite constants
    
    Inspired by rust-lang#121868. Fixes unsoundness created when constructing constant arrays, strings, and structs with 2^32 or more elements on x86_64. This introduces copies of a few LLVM functions that have their signatures updated to use size_t in place of unsigned int. Alternatively we could just add overflow checks and just disallow huge composite constants. That introduces less code, but maybe a huge static block of memory is useful in embedded/no-os situations?
    matthiaskrgr authored Mar 11, 2024
    Configuration menu
    Copy the full SHA
    7a27bd3 View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#122319 - compiler-errors:next-solver-normal…

    …izing-self-constrains-args, r=lcnr
    
    Don't ICE when non-self part of trait goal is constrained in new solver
    
    Self-explanatory. See test for example when this can happen.
    matthiaskrgr authored Mar 11, 2024
    Configuration menu
    Copy the full SHA
    92e9023 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#122339 - rustbot:docs-update, r=ehuss

    Update books
    
    ## rust-lang/reference
    
    3 commits in 3417f866932cb1c09c6be0f31d2a02ee01b4b95d..5afb503a4c1ea3c84370f8f4c08a1cddd1cdf6ad
    2024-03-06 21:29:54 UTC to 2024-02-28 04:06:45 UTC
    
    - Input format (rust-lang/reference#1459)
    - Lexer: say that lifetime-like tokens can't be immediately followed by ' (rust-lang/reference#1479)
    - Patterns and enums (rust-lang/reference#1460)
    
    ## rust-lang/rust-by-example
    
    2 commits in 57f1e708f5d5850562bc385aaf610e6af14d6ec8..e093099709456e6fd74fecd2505fdf49a2471c10
    2024-03-08 23:30:57 UTC to 2024-02-26 21:10:20 UTC
    
    - While-Let Unable to compile code example on page (rust-lang/rust-by-example#1819)
    - Update new_types.md wording (rust-lang/rust-by-example#1823)
    
    ## rust-lang/rustc-dev-guide
    
    14 commits in 7b0ef5b0bea5e3ce3b9764aa5754a60e2cc05c52..8a5d647f19b08998612146b1cb2ca47083db63e0
    2024-03-11 10:37:18 UTC to 2024-02-29 09:46:28 UTC
    
    - update rustc-driver-interacting-with-the-ast.md (rust-lang/rustc-dev-guide#1930)
    - Update rustc-driver-getting-diagnostics.md (rust-lang/rustc-dev-guide#1931)
    - Document that test names cannot contain dots (rust-lang/rustc-dev-guide#1927)
    - Update overview.md (rust-lang/rustc-dev-guide#1898)
    - actually need to fix two occurances (rust-lang/rustc-dev-guide#1925)
    - fix broken links (rust-lang/rustc-dev-guide#1924)
    - next-solver: document caching (rust-lang/rustc-dev-guide#1923)
    - Add compiletest docs for FileCheck prefixes and `//@ filecheck-flags:` (rust-lang/rustc-dev-guide#1914)
    - Use different type in an example (rust-lang/rustc-dev-guide#1908)
    - Update run-make test description (rust-lang/rustc-dev-guide#1920)
    - Add some more details on feature gating (rust-lang/rustc-dev-guide#1891)
    - make shell.nix better (rust-lang/rustc-dev-guide#1858)
    - opaque types in new solver (rust-lang/rustc-dev-guide#1918)
    - add implied bounds doc (rust-lang/rustc-dev-guide#1915)
    matthiaskrgr authored Mar 11, 2024
    Configuration menu
    Copy the full SHA
    60d7ef8 View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#122342 - ChrisDenton:defautlib, r=petrochenkov

    Update /NODEFAUTLIB comment for msvc
    
    I've tried to explain a bit more about the effects of `/NODEFAULTLIB` when using msvc link.exe (or compatible) as they're different from `-nodefaultlib` on gnu.
    
    I also removed the part about licensing as I'm not sure licensing is an issue? Or rather, it's no more or less of an issue no matter how you link msvc libraries. The license is the one you get if using VS at all and even dynamic linking includes static code (e.g. startup/shutdown code, etc).
    
    r? petrochenkov
    matthiaskrgr authored Mar 11, 2024
    Configuration menu
    Copy the full SHA
    2b344e3 View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#122343 - compiler-errors:rando, r=fmease

    Remove some unnecessary `allow(incomplete_features)` in the test suite
    
    A useless change, but I like things to be clean.
    matthiaskrgr authored Mar 11, 2024
    Configuration menu
    Copy the full SHA
    2336a89 View commit details
    Browse the repository at this point in the history