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

Fix rustdoc handling of primitive items #87073

Merged
merged 5 commits into from
Sep 12, 2021
Merged

Commits on Sep 12, 2021

  1. Add primitive documentation to libcore

    This works by doing two things:
    - Adding links that are specific to the crate. Since not all primitive
      items are defined in `core` (due to lang_items), these need to use
      relative links and not intra-doc links.
    - Duplicating `primitive_docs` in both core and std. This allows not needing CARGO_PKG_NAME to build the standard library. It also adds a tidy check to make sure they stay the same.
    jyn514 committed Sep 12, 2021
    Configuration menu
    Copy the full SHA
    69fe39e View commit details
    Browse the repository at this point in the history
  2. downgrade some logging

    jyn514 committed Sep 12, 2021
    Configuration menu
    Copy the full SHA
    f78acae View commit details
    Browse the repository at this point in the history
  3. Fix broken handling of primitive items

    - Fix broken handling of primitive associated items
    - Remove fragment hack
    
      Fixes 83083
    
    - more logging
    - Update CrateNum hacks
    
      The CrateNum has no relation to where in the dependency tree the crate
      is, only when it's loaded. Explicitly special-case core instead of
      assuming it will be the first DefId.
    
    - Update and add tests
    - Cache calculation of primitive locations
    
      This could possibly be avoided by passing a Cache into
      collect_intra_doc_links; but that's a much larger change, and doesn't
      seem valuable other than for this.
    jyn514 committed Sep 12, 2021
    Configuration menu
    Copy the full SHA
    cb7e527 View commit details
    Browse the repository at this point in the history
  4. Fix linkcheck issues

    Most of these are because alloc uses `#[lang_item]` to define methods,
    but core documents primitives before those methods are available.
    
    - Fix rustdoc-js-std test
    
      For some reason this change made CStr not show up in the results for
      `str,u8`. Since it still shows up for str, and since it wasn't a great
      match for that query anyway, I think this is ok to let slide.
    
    - Add test that all primitives can be linked to
    - Enable `doc(primitive)` in `core` as well
    - Add linkcheck exception specifically for Windows
    
      Ideally this would be done automatically by the linkchecker by
      replacing `\\` with forward slashes, but this PR is already a ton of
      work ...
    
    - Don't forcibly fail linkchecking if there's a broken intra-doc link on Windows
    
      Previously, it would exit with a hard error if a missing file had `::`
      in it. This changes it to report a missing file instead, which allows
      adding an exception.
    jyn514 committed Sep 12, 2021
    Configuration menu
    Copy the full SHA
    7b46920 View commit details
    Browse the repository at this point in the history
  5. Fix no_core and no_std rustdoc tests on Windows

    This prevents the following (very strange) errors:
    
    ```
    error: linking with `link.exe` failed: exit code: 1120
      |
      = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x86\\link.exe" "/DEF:C:\\Users\\runneradmin\\AppData\\Local\\Temp\\rustcJih4fa\\lib.def" "/NOLOGO" "/LARGEADDRESSAWARE" "/SAFESEH" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue-15318.issue_15318.0a2a8554-cgu.0.rcgu.o" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue-15318.1na9aylmt25n6w3f.rcgu.o" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\native\\rust-test-helpers" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "vcruntime.lib" "ucrt.lib" "/WHOLEARCHIVE:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_core-78744e1360284b1e.rlib" "/WHOLEARCHIVE:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcore-a900fa3d16956226.rlib" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcompiler_builtins-eb97e6b4dfd2f421.rlib" "/NXCOMPAT" "/LIBPATH:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "/OUT:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue_15318.dll" "/OPT:REF,ICF" "/DLL" "/IMPLIB:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\rustdoc\\issue-15318-2\\auxiliary\\issue_15318.dll.lib" "/DEBUG" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\stage2\\lib\\rustlib\\etc\\libstd.natvis"
      = note: LINK : warning LNK4216: Exported entry point __DllMainCRTStartup@12
                 Creating library D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll.lib and object D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll.exp
              libcore-a900fa3d16956226.rlib(core-a900fa3d16956226.core.95dedc69-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol __aulldiv referenced in function __ZN4core3num7dec2flt7decimal7Decimal10left_shift17hfb9b6c23d6ff0383E
              libcompiler_builtins-eb97e6b4dfd2f421.rlib(compiler_builtins-eb97e6b4dfd2f421.compiler_builtins.a5ef280a-cgu.51.rcgu.o) : error LNK2001: unresolved external symbol __aulldiv
              libcore-a900fa3d16956226.rlib(core-a900fa3d16956226.core.95dedc69-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol __aullrem referenced in function __ZN4core3fmt3num14parse_u64_into17h90eb20517ec3bd86E
              D:\a\rust\rust\build\i686-pc-windows-msvc\test\rustdoc\issue-15318-2\auxiliary\issue_15318.dll : fatal error LNK1120: 2 unresolved externals
    
    ```
    GuillaumeGomez authored and jyn514 committed Sep 12, 2021
    Configuration menu
    Copy the full SHA
    86fd250 View commit details
    Browse the repository at this point in the history