]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #54859 - pietroalbini:rollup, r=pietroalbini
authorbors <bors@rust-lang.org>
Sat, 6 Oct 2018 00:44:11 +0000 (00:44 +0000)
committerbors <bors@rust-lang.org>
Sat, 6 Oct 2018 00:44:11 +0000 (00:44 +0000)
Rollup of 11 pull requests

Successful merges:

 - #54078 (Expand the documentation for the `std::sync` module)
 - #54717 (Cleanup rustc/ty part 1)
 - #54781 (Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs)
 - #54787 (Only warn about unused `mut` in user-written code)
 - #54804 (add suggestion for inverted function parameters)
 - #54812 (Regression test for #32382.)
 - #54833 (make `Parser::parse_foreign_item()` return a foreign item or error)
 - #54834 (rustdoc: overflow:auto doesn't work nicely on small screens)
 - #54838 (Fix typo in src/libsyntax/parse/parser.rs)
 - #54851 (Fix a regression in 1.30 by reverting #53564)
 - #54853 (Remove unneccessary error from test, revealing NLL error.)

Failed merges:

r? @ghost

1  2 
src/librustc/ty/sty.rs

diff --combined src/librustc/ty/sty.rs
index 8a3e853a822d7fb2e562cd81ae586cfab77f7c77,71940196a64c630b76fffefb3d75f297a3a4820a..145c122e75d681070cfa2f1616b2c2185dcef61f
@@@ -126,10 -126,25 +126,25 @@@ pub enum TyKind<'tcx> 
      Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability),
  
      /// The anonymous type of a function declaration/definition. Each
-     /// function has a unique type.
+     /// function has a unique type, which is output (for a function
+     /// named `foo` returning an `i32`) as `fn() -> i32 {foo}`.
+     ///
+     /// For example the type of `bar` here:
+     ///
+     /// ```rust
+     /// fn foo() -> i32 { 1 }
+     /// let bar = foo; // bar: fn() -> i32 {foo}
+     /// ```
      FnDef(DefId, &'tcx Substs<'tcx>),
  
      /// A pointer to a function.  Written as `fn() -> i32`.
+     ///
+     /// For example the type of `bar` here:
+     ///
+     /// ```rust
+     /// fn foo() -> i32 { 1 }
+     /// let bar: fn() -> i32 = foo;
+     /// ```
      FnPtr(PolyFnSig<'tcx>),
  
      /// A trait, defined with `trait`.
@@@ -992,7 -1007,11 +1007,7 @@@ impl<'a, 'gcx, 'tcx> ParamTy 
          // FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere,
          // but this should only be possible when using `-Z continue-parse-after-error` like
          // `compile-fail/issue-36638.rs`.
 -        if self.name == keywords::SelfType.name().as_str() && self.idx == 0 {
 -            true
 -        } else {
 -            false
 -        }
 +        self.name == keywords::SelfType.name().as_str() && self.idx == 0
      }
  }
  
@@@ -2039,14 -2058,18 +2054,14 @@@ impl<'tcx> Const<'tcx> 
          tcx: TyCtxt<'_, '_, '_>,
          ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
      ) -> u128 {
 -        match self.assert_bits(tcx, ty) {
 -            Some(val) => val,
 -            None => bug!("expected bits of {}, got {:#?}", ty.value, self),
 -        }
 +        self.assert_bits(tcx, ty).unwrap_or_else(||
 +            bug!("expected bits of {}, got {:#?}", ty.value, self))
      }
  
      #[inline]
      pub fn unwrap_usize(&self, tcx: TyCtxt<'_, '_, '_>) -> u64 {
 -        match self.assert_usize(tcx) {
 -            Some(val) => val,
 -            None => bug!("expected constant usize, got {:#?}", self),
 -        }
 +        self.assert_usize(tcx).unwrap_or_else(||
 +            bug!("expected constant usize, got {:#?}", self))
      }
  }