Auto merge of #35951 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests - Successful merges: #35910, #35912, #35913, #35936, #35939, #35949 - Failed merges: #35395
This commit is contained in:
commit
a66fa96d18
@ -662,7 +662,7 @@ Here are some common macros you’ll see in Rust code.
|
||||
This macro causes the current thread to panic. You can give it a message
|
||||
to panic with:
|
||||
|
||||
```rust,no_run
|
||||
```rust,should_panic
|
||||
panic!("oh no!");
|
||||
```
|
||||
|
||||
@ -688,7 +688,7 @@ These two macros are used in tests. `assert!` takes a boolean. `assert_eq!`
|
||||
takes two values and checks them for equality. `true` passes, `false` `panic!`s.
|
||||
Like this:
|
||||
|
||||
```rust,no_run
|
||||
```rust,should_panic
|
||||
// A-ok!
|
||||
|
||||
assert!(true);
|
||||
|
@ -38,7 +38,6 @@ use marker::Sized;
|
||||
/// bar: f32,
|
||||
/// }
|
||||
///
|
||||
///
|
||||
/// fn main() {
|
||||
/// let options: SomeOptions = Default::default();
|
||||
/// }
|
||||
|
@ -421,25 +421,68 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// A trivial implementation of `Div`. When `Foo / Foo` happens, it ends up
|
||||
/// calling `div`, and therefore, `main` prints `Dividing!`.
|
||||
/// Implementing a `Div`idable rational number struct:
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Div;
|
||||
///
|
||||
/// struct Foo;
|
||||
/// // The uniqueness of rational numbers in lowest terms is a consequence of
|
||||
/// // the fundamental theorem of arithmetic.
|
||||
/// #[derive(Eq)]
|
||||
/// #[derive(PartialEq, Debug)]
|
||||
/// struct Rational {
|
||||
/// nominator: usize,
|
||||
/// denominator: usize,
|
||||
/// }
|
||||
///
|
||||
/// impl Div for Foo {
|
||||
/// type Output = Foo;
|
||||
/// impl Rational {
|
||||
/// fn new(nominator: usize, denominator: usize) -> Self {
|
||||
/// if denominator == 0 {
|
||||
/// panic!("Zero is an invalid denominator!");
|
||||
/// }
|
||||
///
|
||||
/// fn div(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Dividing!");
|
||||
/// self
|
||||
/// // Reduce to lowest terms by dividing by the greatest common
|
||||
/// // divisor.
|
||||
/// let gcd = gcd(nominator, denominator);
|
||||
/// Rational {
|
||||
/// nominator: nominator / gcd,
|
||||
/// denominator: denominator / gcd,
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl Div for Rational {
|
||||
/// // The division of rational numbers is a closed operation.
|
||||
/// type Output = Self;
|
||||
///
|
||||
/// fn div(self, rhs: Self) -> Self {
|
||||
/// if rhs.nominator == 0 {
|
||||
/// panic!("Cannot divide by zero-valued `Rational`!");
|
||||
/// }
|
||||
///
|
||||
/// let nominator = self.nominator * rhs.denominator;
|
||||
/// let denominator = self.denominator * rhs.nominator;
|
||||
/// Rational::new(nominator, denominator)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// // Euclid's two-thousand-year-old algorithm for finding the greatest common
|
||||
/// // divisor.
|
||||
/// fn gcd(x: usize, y: usize) -> usize {
|
||||
/// let mut x = x;
|
||||
/// let mut y = y;
|
||||
/// while y != 0 {
|
||||
/// let t = y;
|
||||
/// y = x % y;
|
||||
/// x = t;
|
||||
/// }
|
||||
/// x
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo / Foo;
|
||||
/// assert_eq!(Rational::new(1, 2), Rational::new(2, 4));
|
||||
/// assert_eq!(Rational::new(1, 2) / Rational::new(3, 4),
|
||||
/// Rational::new(2, 3));
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
@ -388,8 +388,9 @@ pub fn next_code_point<'a, I: Iterator<Item = &'a u8>>(bytes: &mut I) -> Option<
|
||||
/// Reads the last code point out of a byte iterator (assuming a
|
||||
/// UTF-8-like encoding).
|
||||
#[inline]
|
||||
fn next_code_point_reverse<'a,
|
||||
I: DoubleEndedIterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> {
|
||||
fn next_code_point_reverse<'a, I>(bytes: &mut I) -> Option<u32>
|
||||
where I: DoubleEndedIterator<Item = &'a u8>,
|
||||
{
|
||||
// Decode UTF-8
|
||||
let w = match bytes.next_back() {
|
||||
None => return None,
|
||||
|
@ -469,10 +469,11 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
// are zero. Since I don't quite know how to phrase things at
|
||||
// the moment, give a kind of vague error message.
|
||||
if trait_params.len() != impl_params.len() {
|
||||
span_err!(ccx.tcx.sess, span, E0195,
|
||||
struct_span_err!(ccx.tcx.sess, span, E0195,
|
||||
"lifetime parameters or bounds on method `{}` do \
|
||||
not match the trait declaration",
|
||||
impl_m.name);
|
||||
not match the trait declaration",impl_m.name)
|
||||
.span_label(span, &format!("lifetimes do not match trait"))
|
||||
.emit();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c37d3747da75c280237dc2d6b925078e69555499
|
||||
Subproject commit 755bc3db4ff795865ea31b5b4f38ac920d8acacb
|
@ -16,6 +16,7 @@ struct Foo;
|
||||
|
||||
impl Trait for Foo {
|
||||
fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195
|
||||
//~^ lifetimes do not match trait
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ impl<'a> Test<'a> for Foo<'a> {
|
||||
impl<'a> NoLifetime for Foo<'a> {
|
||||
fn get<'p, T : Test<'a>>(&self) -> T {
|
||||
//~^ ERROR E0195
|
||||
//~| lifetimes do not match trait
|
||||
return *self as T;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user