1. 08 3月, 2022 1 次提交
  2. 02 3月, 2022 1 次提交
  3. 25 2月, 2022 1 次提交
    • A
      Fix intra-doc link issues exposed by new macro · 7b7b0f14
      Aaron Hill 提交于
      These links never worked, but the lint was suppressed due to the fact
      that the span was pointing into the macro. With the new macro
      implementation, the span now points directly to the doc comment in the
      macro invocation, so it's no longer suppressed.
      7b7b0f14
  4. 21 2月, 2022 2 次提交
  5. 18 2月, 2022 2 次提交
  6. 16 2月, 2022 1 次提交
  7. 15 2月, 2022 3 次提交
    • D
      Clarify confusing UB statement in MIR · 7fa87f25
      Deadbeef 提交于
      7fa87f25
    • N
      Overhaul `Const`. · a95fb8b1
      Nicholas Nethercote 提交于
      Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as
      this:
      ```
      pub struct Const<'tcx>(&'tcx Interned<ConstS>);
      ```
      This now matches `Ty` and `Predicate` more closely, including using
      pointer-based `eq` and `hash`.
      
      Notable changes:
      - `mk_const` now takes a `ConstS`.
      - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a
        we need separate arena for it, because we can't use the `Dropless` one any
        more.
      - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes
      - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes.
      - Lots of tedious sigil fiddling.
      a95fb8b1
    • N
      Overhaul `TyS` and `Ty`. · e9a0c429
      Nicholas Nethercote 提交于
      Specifically, change `Ty` from this:
      ```
      pub type Ty<'tcx> = &'tcx TyS<'tcx>;
      ```
      to this
      ```
      pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
      ```
      There are two benefits to this.
      - It's now a first class type, so we can define methods on it. This
        means we can move a lot of methods away from `TyS`, leaving `TyS` as a
        barely-used type, which is appropriate given that it's not meant to
        be used directly.
      - The uniqueness requirement is now explicit, via the `Interned` type.
        E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
        than via `TyS`, which wasn't obvious at all.
      
      Much of this commit is boring churn. The interesting changes are in
      these files:
      - compiler/rustc_middle/src/arena.rs
      - compiler/rustc_middle/src/mir/visit.rs
      - compiler/rustc_middle/src/ty/context.rs
      - compiler/rustc_middle/src/ty/mod.rs
      
      Specifically:
      - Most mentions of `TyS` are removed. It's very much a dumb struct now;
        `Ty` has all the smarts.
      - `TyS` now has `crate` visibility instead of `pub`.
      - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
        which just works better with the new structure.
      - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
        of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
        (pointer-based, for the `Equal` case) and partly on `TyS`
        (contents-based, for the other cases).
      - There are many tedious sigil adjustments, i.e. adding or removing `*`
        or `&`. They seem to be unavoidable.
      e9a0c429
  8. 12 2月, 2022 1 次提交
  9. 02 2月, 2022 1 次提交
  10. 22 1月, 2022 1 次提交
    • N
      Make `Decodable` and `Decoder` infallible. · 416399dc
      Nicholas Nethercote 提交于
      `Decoder` has two impls:
      - opaque: this impl is already partly infallible, i.e. in some places it
        currently panics on failure (e.g. if the input is too short, or on a
        bad `Result` discriminant), and in some places it returns an error
        (e.g. on a bad `Option` discriminant). The number of places where
        either happens is surprisingly small, just because the binary
        representation has very little redundancy and a lot of input reading
        can occur even on malformed data.
      - json: this impl is fully fallible, but it's only used (a) for the
        `.rlink` file production, and there's a `FIXME` comment suggesting it
        should change to a binary format, and (b) in a few tests in
        non-fundamental ways. Indeed #85993 is open to remove it entirely.
      
      And the top-level places in the compiler that call into decoding just
      abort on error anyway. So the fallibility is providing little value, and
      getting rid of it leads to some non-trivial performance improvements.
      
      Much of this commit is pretty boring and mechanical. Some notes about
      a few interesting parts:
      - The commit removes `Decoder::{Error,error}`.
      - `InternIteratorElement::intern_with`: the impl for `T` now has the same
        optimization for small counts that the impl for `Result<T, E>` has,
        because it's now much hotter.
      - Decodable impls for SmallVec, LinkedList, VecDeque now all use
        `collect`, which is nice; the one for `Vec` uses unsafe code, because
        that gave better perf on some benchmarks.
      416399dc
  11. 19 1月, 2022 1 次提交
  12. 16 1月, 2022 1 次提交
  13. 15 1月, 2022 1 次提交
  14. 13 1月, 2022 1 次提交
  15. 11 1月, 2022 1 次提交
    • A
      Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef` · 450ef861
      Aaron Hill 提交于
      The field is also renamed from `ident` to `name. In most cases,
      we don't actually need the `Span`. A new `ident` method is added
      to `VariantDef` and `FieldDef`, which constructs the full `Ident`
      using `tcx.def_ident_span()`. This method is used in the cases
      where we actually need an `Ident`.
      
      This makes incremental compilation properly track changes
      to the `Span`, without all of the invalidations caused by storing
      a `Span` directly via an `Ident`.
      450ef861
  16. 02 1月, 2022 1 次提交
    • J
      Stabilize -Z instrument-coverage as -C instrument-coverage · 34106f89
      Josh Triplett 提交于
      Continue supporting -Z instrument-coverage for compatibility for now,
      but show a deprecation warning for it.
      
      Update uses and documentation to use the -C option.
      
      Move the documentation from the unstable book to stable rustc
      documentation.
      34106f89
  17. 23 12月, 2021 1 次提交
    • A
      Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt` · cac431ba
      Aaron Hill 提交于
      The `AggregateKind` enum ends up in the final mir `Body`. Currently,
      any changes to `AdtDef` (regardless of how significant they are)
      will legitimately cause the overall result of `optimized_mir` to change,
      invalidating any codegen re-use involving that mir.
      
      This will get worse once we start hashing the `Span` inside `FieldDef`
      (which is itself contained in `AdtDef`).
      
      To try to reduce these kinds of invalidations, this commit changes
      `AggregateKind::Adt` to store just the `DefId`, instead of the full
      `AdtDef`. This allows the result of `optimized_mir` to be unchanged
      if the `AdtDef` changes in a way that doesn't actually affect any
      of the MIR we build.
      cac431ba
  18. 16 12月, 2021 1 次提交
    • A
      Remove `in_band_lifetimes` from `rustc_middle` · 070bf94a
      Aaron Hill 提交于
      See #91867
      
      This was mostly straightforward. In several places, I take advantage
      of the fact that lifetimes are non-hygenic: a macro declares the
      'tcx' lifetime, which is then used in types passed in as macro
      arguments.
      070bf94a
  19. 15 12月, 2021 2 次提交
  20. 11 12月, 2021 1 次提交
    • N
      Suggest using a temporary variable to fix borrowck errors · e2731526
      Noah Lev 提交于
      In Rust, nesting method calls with both require `&mut` access to `self`
      produces a borrow-check error:
      
          error[E0499]: cannot borrow `*self` as mutable more than once at a time
           --> src/lib.rs:7:14
            |
          7 |     self.foo(self.bar());
            |     ---------^^^^^^^^^^-
            |     |    |   |
            |     |    |   second mutable borrow occurs here
            |     |    first borrow later used by call
            |     first mutable borrow occurs here
      
      That's because Rust has a left-to-right evaluation order, and the method
      receiver is passed first. Thus, the argument to the method cannot then
      mutate `self`.
      
      There's an easy solution to this error: just extract a local variable
      for the inner argument:
      
          let tmp = self.bar();
          self.foo(tmp);
      
      However, the error doesn't give any suggestion of how to solve the
      problem. As a result, new users may assume that it's impossible to
      express their code correctly and get stuck.
      
      This commit adds a (non-structured) suggestion to extract a local
      variable for the inner argument to solve the error. The suggestion uses
      heuristics that eliminate most false positives, though there are a few
      false negatives (cases where the suggestion should be emitted but is
      not). Those other cases can be implemented in a future change.
      e2731526
  21. 03 12月, 2021 3 次提交
  22. 01 12月, 2021 1 次提交
  23. 27 11月, 2021 1 次提交
    • S
      Small mir-opt refactor · b215a32a
      Scott McMurray 提交于
      Hopefully-non-controversial changes from some not-ready-yet work that I'd figured I'd submit on their own.
      b215a32a
  24. 26 11月, 2021 1 次提交
  25. 24 11月, 2021 1 次提交
  26. 07 11月, 2021 2 次提交
  27. 21 10月, 2021 1 次提交
  28. 03 10月, 2021 1 次提交
  29. 25 9月, 2021 1 次提交
  30. 17 9月, 2021 1 次提交
    • A
      Add `ConstraintCategory::Usage` for handling aggregate construction · a41a13f7
      Aaron Hill 提交于
      In some cases, we emit borrowcheck diagnostics pointing
      at a particular field expression in a struct expression
      (e.g. `MyStruct { field: my_expr }`). However, this
      behavior currently relies on us choosing the
      `ConstraintCategory::Boring` with the 'correct' span.
      When adding additional variants to `ConstraintCategory`,
      (or changing existing usages away from `ConstraintCategory::Boring`),
      the current behavior can easily get broken, since a non-boring
      constraint will get chosen over a boring one.
      
      To make the diagnostic output less fragile, this commit
      adds a `ConstraintCategory::Usage` variant. We use this variant
      for the temporary assignments created for each field of
      an aggregate we are constructing.
      
      Using this new variant, we can emit a message mentioning
      "this usage", emphasizing the fact that the error message
      is related to the specific use site (in the struct expression).
      
      This is preparation for additional work on improving NLL error messages
      (see #57374)
      a41a13f7
  31. 13 9月, 2021 1 次提交
  32. 09 9月, 2021 1 次提交