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 #104176

Closed
wants to merge 23 commits into from
Closed

Commits on Oct 25, 2022

  1. Fix rust-lang#103451, find_width_of_character_at_span return width wi…

    …th 1 when reaching end
    chenyukang committed Oct 25, 2022
    Configuration menu
    Copy the full SHA
    6d45529 View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2022

  1. Add test case

    wesleywiser committed Nov 3, 2022
    Configuration menu
    Copy the full SHA
    cf6efe8 View commit details
    Browse the repository at this point in the history
  2. Fix Access Violation when using lld & ThinLTO on windows-msvc

    Users report an AV at runtime of the compiled binary when using lld and
    ThinLTO on windows-msvc. The AV occurs when accessing a static value
    which is defined in one crate but used in another. Based on the
    disassembly of the cross-crate use, it appears that the use is not
    correctly linked with the definition and is instead assigned a garbage
    pointer value.
    
    If we look at the symbol tables for each crates' obj file, we can see
    what is happening:
    
    *lib.obj*:
    
    ```
    COFF SYMBOL TABLE
    ...
    00E 00000000 SECT2  notype       External     | _ZN10reproducer7memrchr2FN17h612b61ca0e168901E
    ...
    ```
    
    *bin.obj*:
    
    ```
    COFF SYMBOL TABLE
    ...
    010 00000000 UNDEF  notype       External     | __imp__ZN10reproducer7memrchr2FN17h612b61ca0e168901E
    ...
    ```
    
    The use of the symbol has the "import" style symbol name but the
    declaration doesn't generate any symbol with the same name. As a result,
    linking the files generates a warning from lld:
    
    > rust-lld: warning: bin.obj: locally defined symbol imported: reproducer::memrchr::FN::h612b61ca0e168901 (defined in lib.obj) [LNK4217]
    
    and the symbol reference remains undefined at runtime leading to the AV.
    
    To fix this, we just need to detect that we are performing ThinLTO (and
    thus, static linking) and omit the `dllimport` attribute on the extern
    item in LLVM IR.
    wesleywiser committed Nov 3, 2022
    Configuration menu
    Copy the full SHA
    296489c View commit details
    Browse the repository at this point in the history

Commits on Nov 4, 2022

  1. Configuration menu
    Copy the full SHA
    f8e2cef View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    57b2290 View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2022

  1. Update several crates for improved support of the new targets

    This helps with `*-windows-gnullvm` targets
    mati865 committed Nov 5, 2022
    Configuration menu
    Copy the full SHA
    d5899ef View commit details
    Browse the repository at this point in the history
  2. first move on a nested span_label

    Apply suggestions from code review
    
    Co-authored-by: David Wood <[email protected]>
    AndyJado and davidtwco committed Nov 5, 2022
    Configuration menu
    Copy the full SHA
    e49d10d View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2022

  1. fixyfixfix

    BoxyUwU committed Nov 6, 2022
    Configuration menu
    Copy the full SHA
    c0889a6 View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2022

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

Commits on Nov 8, 2022

  1. Configuration menu
    Copy the full SHA
    303653e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a45151e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    667b15b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9e7d228 View commit details
    Browse the repository at this point in the history
  5. comment

    BoxyUwU committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    49be827 View commit details
    Browse the repository at this point in the history
  6. tests

    BoxyUwU committed Nov 8, 2022
    Configuration menu
    Copy the full SHA
    983a90d View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#100508 - BoxyUwU:make_less_things_late_boun…

    …d, r=nikomatsakis
    
    avoid making substs of type aliases late bound when used as fn args
    
    fixes rust-lang#47511
    fixes rust-lang#85533
    (although I did not know theses issues existed when i was working on this 🙃)
    
    currently `Alias<...>` is treated the same as `Struct<...>` when deciding if generics should be late bound or early bound but this is not correct as `Alias` might normalize to a projection which does not constrain the generics.
    
    I think this needs more tests before merging
    more explanation of PR [here](https://hackmd.io/v44a-QVjTIqqhK9uretyQg?view)
    
    Hackmd inline for future readers:
    ---
    
    This assumes reader is familiar with the concept of early/late bound lifetimes. There's a section on rustc-dev-guide if not (although i think some details are a bit out of date)
    
    ## problem & background
    
    Not all lifetimes on a fn can be late bound:
    ```rust
    fn foo<'a>() -> &'a ();
    impl<'a> Fn<()> for FooFnDef {
        type Output = &'a (); // uh oh unconstrained lifetime
    }
    ```
    so we make make them early bound
    ```rust
    fn foo<'a>() -> &'a ();
    impl<'a> Fn<()> for FooFnDef<'a> {// wow look at all that lifetimey
         type Output = &'a ();
    }
    ```
    (Closures have the same constraint however it is not enforced leading to soundness bugs, [rust-lang#84385](rust-lang#84385) implements this "downgrading late bound to early bound" for closures)
    
    lifetimes on fn items are only late bound when they are "constrained" by the fn args:
    ```rust
    fn foo<'a>(_: &'a ()) -> &'a ();
    //               late bound, not present on `FooFnItem`
    //               vv
    impl<'a> Trait<(&'a (),)> for FooFnItem {
        type Output = &'a ();
    }
    
    // projections do not constrain inputs
    fn bar<'a, T: Trait>(_: <T as Trait<'a>>::Assoc) -> &'a (); //  early bound
                                                                //  vv
    impl<'a, T: Trait> Fn<(<T as Trait<'a>>::Assoc,)> for BarFnItem<'a, T> {
        type Output = &'a ();
    }
    ```
    
    current logic for determining if inputs "constrain" a lifetime works off of HIR so does not normalize aliases. It also assumes that any path with no self type constrains all its substs (i.e. `Foo<'a, u32>` has no self type but `T::Assoc` does). This falls apart for top level type aliases (see linked issues):
    
    ```rust
    type Alias<'a, T> = <T as Trait<'a>>::Assoc;
    //                      wow look its a path with no self type uwu
    //                      i bet that constrains `'a` so it should be latebound
    //                      vvvvvvvvvvv
    fn foo<'a, T: Trait>(_: Alias<'a, T>) -> &'a ();
    //                     `Alias` normalized to make things clearer
    //                     vvvvvvvvvvvvvvvvvvvvvvv
    impl<'a, T: Trait> Fn<(<T as Trait<'a>>::Assoc,)> for FooFnDef<T> {
        type Output = &'a ();
        // oh no `'a` isnt constrained wah wah waaaah *trumbone noises*
        // i think, idk what musical instrument that is
    }
    ```
    
    ## solution
    
    The PR solves this by having the hir visitor that checks for lifetimes in constraining uses check if the path is a `DefKind::Alias`. If it is we ""normalize"" it by calling `type_of` and walking the returned type. This is a bit hacky as it requires a mapping between the substs on the path in hir, and the generics of the `type Alias<...>` which is on the ty layer.
    
    Alternative solutions may involve calculating the "late boundness" of lifetimes after/during astconv rather than relying on hir at all. We already have code to determine whether a lifetime SHOULD be late bound or not as this is currently how the error for `fn foo<'a, T: Trait>(_: Alias<'a, T>) -> &'a ();` gets emitted.
    
    It is probably not possible to do this right now, late boundness is used by `generics_of` and `gather_explicit_predicates_of` as we currently do not put late bound lifetimes in `Generics`. Although this seems sus to me as the long term goal is to make all generics late bound which would result in `generics_of(function)` being empty? [rust-lang#103448](rust-lang#103448) places all lifetimes in `Generics` regardless of late boundness so that may be a good step towards making this possible.
    Manishearth authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    9d8ac54 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#103353 - wesleywiser:fix_lld_thinlto_msvc, …

    …r=michaelwoerister
    
    Fix Access Violation when using lld & ThinLTO on windows-msvc
    
    Users report an AV at runtime of the compiled binary when using lld and ThinLTO on windows-msvc. The AV occurs when accessing a static value which is defined in one crate but used in another. Based on the disassembly of the cross-crate use, it appears that the use is not correctly linked with the definition and is instead assigned a garbage pointer value.
    
    If we look at the symbol tables for each crates' obj file, we can see what is happening:
    
    *lib.obj*:
    
    ```
    COFF SYMBOL TABLE
    ...
    00E 00000000 SECT2  notype       External     | _ZN10reproducer7memrchr2FN17h612b61ca0e168901E
    ...
    ```
    
    *bin.obj*:
    
    ```
    COFF SYMBOL TABLE
    ...
    010 00000000 UNDEF  notype       External     | __imp__ZN10reproducer7memrchr2FN17h612b61ca0e168901E
    ...
    ```
    
    The use of the symbol has the "import" style symbol name but the declaration doesn't generate any symbol with the same name. As a result, linking the files generates a warning from lld:
    
    > rust-lld: warning: bin.obj: locally defined symbol imported: reproducer::memrchr::FN::h612b61ca0e168901 (defined in lib.obj) [LNK4217]
    
    and the symbol reference remains undefined at runtime leading to the AV.
    
    To fix this, we just need to detect that we are performing ThinLTO (and thus, static linking) and omit the `dllimport` attribute on the extern item in LLVM IR.
    
    Fixes rust-lang#81408
    Manishearth authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    c70e035 View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#103521 - chenyukang:yukang/fix-103451-avoid…

    …-hang, r=jackh726,wesleywiser
    
    Avoid possible infinite  loop when next_point reaching the end of file
    
    Fixes rust-lang#103451
    If we return a span with `lo` = `hi`, `span_to_snippet` will always get `Ok("")`, which may introduce infinite loop if we don't care.
    
    This PR make `find_width_of_character_at_span` return `width` with 1, so that `span_to_snippet` will get an `Err`.
    Manishearth authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    3779222 View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#103559 - AndyJado:var_span_label, r=davidtwco

    first move on a nested span_label
    
    trying not to be smart this time.
    Manishearth authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    6138215 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#103636 - chenyukang:yukang/fix-103587-sugg-…

    …if-let, r=jackh276,davidtwco
    
    Recover from common if let syntax mistakes/typos
    
    Fixes rust-lang#103587
    Manishearth authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    c4526d8 View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#103778 - mati865:update-deps, r=Mark-Simula…

    …crum
    
    Update several crates for improved support of the new targets
    
    This helps with `*-windows-gnullvm` targets by reducing amount of patching.
    Manishearth authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    a95763e View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#103952 - ehuss:dont-intra-linkcheck-referen…

    …ce, r=Mark-Simulacrum
    
    Don't intra linkcheck reference
    
    This removes the reference from the intra-doc link checks. This causes problems if any of the reference content needs to change, it causes the linkchecker to break. The reference has its own broken link check (https://github.com/rust-lang/reference/tree/master/style-check) which uses pulldown-cmark on the source to find actual broken links (instead of false-positives like this regex does).
    
    I think the intra-doc link check could potentially be removed completely, since I think rustdoc is now checking for them well enough. However, it may serve as a decent regression check.
    Manishearth authored Nov 8, 2022
    Configuration menu
    Copy the full SHA
    ec84bb0 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    4cd7c67 View commit details
    Browse the repository at this point in the history