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 6 pull requests #107642

Merged
merged 19 commits into from
Feb 3, 2023
Merged

Rollup of 6 pull requests #107642

merged 19 commits into from
Feb 3, 2023

Commits on Feb 1, 2023

  1. Configuration menu
    Copy the full SHA
    5fd4f5b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    de50a86 View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2023

  1. Configuration menu
    Copy the full SHA
    64f5293 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c3a71ed View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    745d60c View commit details
    Browse the repository at this point in the history
  4. Improve doc comment desugaring.

    Sometimes the parser needs to desugar a doc comment into `#[doc =
    r"foo"]`. Currently it does this in a hacky way: by pushing a "fake" new
    frame (one without a delimiter) onto the `TokenCursor` stack.
    
    This commit changes things so that the token stream itself is modified
    in place. The nice thing about this is that it means
    `TokenCursorFrame::delim_sp` is now only `None` for the outermost frame.
    nnethercote committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    af1d16e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b23f272 View commit details
    Browse the repository at this point in the history
  6. Remove TokenCursorFrame.

    The motivation here is to eliminate the `Option<(Delimiter,
    DelimSpan)>`, which is `None` for the outermost token stream and `Some`
    for all other token streams.
    
    We are already treating the innermost frame specially -- this is the
    `frame` vs `stack` distinction in `TokenCursor`. We can push that
    further so that `frame` only contains the cursor, and `stack` elements
    contain the delimiters for their children. When we are in the outermost
    token stream `stack` is empty, so there are no stored delimiters, which
    is what we want because the outermost token stream *has* no delimiters.
    
    This change also shrinks `TokenCursor`, which shrinks `Parser` and
    `LazyAttrTokenStreamImpl`, which is nice.
    nnethercote committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    b5ecbbb View commit details
    Browse the repository at this point in the history
  7. Rename Cursor/CursorRef as TokenTreeCursor/RefTokenTreeCursor.

    This makes it clear they return token trees, and makes for a nice
    comparison against `TokenCursor` which returns tokens.
    nnethercote committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    a86fc72 View commit details
    Browse the repository at this point in the history

Commits on Feb 3, 2023

  1. Use new helper inside probe

    detrumi committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    f29000e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f874f67 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9e1c600 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4501d3a View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#107082 - dtolnay:autotraits, r=lcnr

    Autotrait bounds on dyn-safe trait methods
    
    This PR is a successor to rust-lang#106604 implementing the approach encouraged by rust-lang#106604 (comment).
    
    **I propose making it legal to use autotraits as trait bounds on the `Self` type of trait methods in a trait object.** rust-lang#51443 (comment) justifies why this use case is particularly important in the context of the async-trait crate.
    
    ```rust
    #![feature(auto_traits)]
    #![deny(where_clauses_object_safety)]
    
    auto trait AutoTrait {}
    
    trait MyTrait {
        fn f(&self) where Self: AutoTrait;
    }
    
    fn main() {
        let _: &dyn MyTrait;
    }
    ```
    
    Previously this would fail with:
    
    ```console
    error: the trait `MyTrait` cannot be made into an object
     --> src/main.rs:7:8
      |
    7 |     fn f(&self) where Self: AutoTrait;
      |        ^
      |
      = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
      = note: for more information, see issue rust-lang#51443 <rust-lang#51443>
    note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
     --> src/main.rs:7:8
      |
    6 | trait MyTrait {
      |       ------- this trait cannot be made into an object...
    7 |     fn f(&self) where Self: AutoTrait;
      |        ^ ...because method `f` references the `Self` type in its `where` clause
      = help: consider moving `f` to another trait
    ```
    
    In order for this to be sound without hitting rust-lang#50781, **I further propose that we disallow handwritten autotrait impls that apply to trait objects.** Both of the following were previously allowed (_on nightly_) and no longer allowed in my proposal:
    
    ```rust
    auto trait AutoTrait {}
    
    trait MyTrait {}
    impl AutoTrait for dyn MyTrait {}  // NOT ALLOWED
    
    impl<T: ?Sized> AutoTrait for T {}  // NOT ALLOWED
    ```
    
    (`impl<T> AutoTrait for T {}` remains allowed.)
    
    After this change, traits with a default impl are implemented for a trait object **if and only if** the autotrait is one of the trait object's trait bounds (or a supertrait of a bound). In other words `dyn Trait + AutoTrait` always implements AutoTrait while `dyn Trait` never implements AutoTrait.
    
    Fixes dtolnay/async-trait#228.
    
    r? `@lcnr`
    Dylan-DPC committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    7221383 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#107427 - detrumi:builtin-impl-candidates, r…

    …=compiler-errors
    
    Add candidates for DiscriminantKind builtin
    
    Part of rust-lang#107379
    Dylan-DPC committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    e1bf3a1 View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#107539 - PossiblyAShrub:unused-parens-in-in…

    …dex, r=lcnr
    
    Emit warnings on unused parens in index expressions
    
    Fixes: rust-lang#96606.
    
    I am not sure what the best term for "index expression" is. Is there a better term we could use?
    Dylan-DPC committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    d9db357 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#107544 - nnethercote:improve-TokenCursor, r…

    …=petrochenkov
    
    Improve `TokenCursor`.
    
    Some small improvements, for things that were bugging me.
    
    Best reviewed one commit at a time.
    
    r? ``@petrochenkov``
    Dylan-DPC committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    815dc9c View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#107585 - compiler-errors:fndef-sig-cycle, r…

    …=oli-obk
    
    Don't cause a cycle when formatting query description that references a FnDef
    
    When a function returns `-> _`, we use typeck to compute what the resulting type of the body _should_ be. If we call another query inside of typeck and hit a cycle error, we attempt to report the cycle error which requires us to compute all of the query descriptions for the stack.
    
    However, if one of the queries in that cycle has a query description that references this function as a FnDef type, we'll cause a *second* cycle error from within the cycle error reporting code, since rendering a FnDef requires us to compute its signature. This causes an unwrap to ICE, since during the *second* cycle reporting code, we try to look for a job that isn't in the active jobs list.
    
    We can avoid this by using `with_no_queries!` when computing these query descriptions.
    
    Fixes rust-lang#107089
    
    The only drawback is that the rendering of opaque types in cycles regresses a bit :| I'm open to alternate suggestions about how we may handle this...
    Dylan-DPC committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    d6f0c51 View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#107633 - clubby789:option-string-coerce-fix…

    …, r=Nilstrieb
    
    Fix suggestion for coercing Option<&String> to Option<&str>
    
    Fixes rust-lang#107604
    
    This also makes the diagnostic `MachineApplicable`, and runs `rustfix` to check we're not producing incorrect code.
    
    ``@rustbot`` label +A-diagnostics
    Dylan-DPC committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    c927027 View commit details
    Browse the repository at this point in the history