Auto merge of #55462 - pietroalbini:rollup, r=pietroalbini
Rollup of 9 pull requests Successful merges: - #54965 (update tcp stream documentation) - #55269 (fix typos in various places) - #55384 (Avoid unnecessary allocations in `float_lit` and `integer_lit`.) - #55423 (back out bogus `Ok`-wrapping suggestion on `?` arm type mismatch) - #55426 (Make a bunch of trivial methods of NonNull be `#[inline]`) - #55438 (Avoid directly catching BaseException in bootstrap configure script) - #55439 (Remove unused sys import from generate-deriving-span-tests) - #55440 (Remove unreachable code in hasClass function in Rustdoc) - #55447 (Fix invalid path in generate-deriving-span-tests.py.) Failed merges: r? @ghost
This commit is contained in:
commit
d586d5d2f5
@ -397,7 +397,7 @@ def is_number(value):
|
||||
try:
|
||||
float(value)
|
||||
return True
|
||||
except:
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
# Here we walk through the constructed configuration we have from the parsed
|
||||
|
@ -18,10 +18,10 @@ derives have spans that point to the fields, rather than the
|
||||
sample usage: src/etc/generate-deriving-span-tests.py
|
||||
"""
|
||||
|
||||
import sys, os, datetime, stat, re
|
||||
import os, datetime, stat, re
|
||||
|
||||
TEST_DIR = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), '../test/compile-fail'))
|
||||
os.path.join(os.path.dirname(__file__), '../test/ui/derives/'))
|
||||
|
||||
YEAR = datetime.datetime.now().year
|
||||
|
||||
|
@ -2867,6 +2867,7 @@ impl<T: Sized> NonNull<T> {
|
||||
/// sentinel value. Types that lazily allocate must track initialization by
|
||||
/// some other means.
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
#[inline]
|
||||
pub fn dangling() -> Self {
|
||||
unsafe {
|
||||
let ptr = mem::align_of::<T>() as *mut T;
|
||||
@ -2882,12 +2883,14 @@ impl<T: ?Sized> NonNull<T> {
|
||||
///
|
||||
/// `ptr` must be non-null.
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
#[inline]
|
||||
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
|
||||
NonNull { pointer: NonZero(ptr as _) }
|
||||
}
|
||||
|
||||
/// Creates a new `NonNull` if `ptr` is non-null.
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
#[inline]
|
||||
pub fn new(ptr: *mut T) -> Option<Self> {
|
||||
if !ptr.is_null() {
|
||||
Some(NonNull { pointer: NonZero(ptr as _) })
|
||||
@ -2898,6 +2901,7 @@ impl<T: ?Sized> NonNull<T> {
|
||||
|
||||
/// Acquires the underlying `*mut` pointer.
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
#[inline]
|
||||
pub fn as_ptr(self) -> *mut T {
|
||||
self.pointer.0 as *mut T
|
||||
}
|
||||
@ -2908,6 +2912,7 @@ impl<T: ?Sized> NonNull<T> {
|
||||
/// it were actually an instance of T that is getting borrowed. If a longer
|
||||
/// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`.
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
#[inline]
|
||||
pub unsafe fn as_ref(&self) -> &T {
|
||||
&*self.as_ptr()
|
||||
}
|
||||
@ -2918,12 +2923,14 @@ impl<T: ?Sized> NonNull<T> {
|
||||
/// it were actually an instance of T that is getting borrowed. If a longer
|
||||
/// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`.
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
#[inline]
|
||||
pub unsafe fn as_mut(&mut self) -> &mut T {
|
||||
&mut *self.as_ptr()
|
||||
}
|
||||
|
||||
/// Cast to a pointer of another type
|
||||
#[stable(feature = "nonnull_cast", since = "1.27.0")]
|
||||
#[inline]
|
||||
pub fn cast<U>(self) -> NonNull<U> {
|
||||
unsafe {
|
||||
NonNull::new_unchecked(self.as_ptr() as *mut U)
|
||||
@ -2963,6 +2970,7 @@ impl<T: ?Sized> Eq for NonNull<T> {}
|
||||
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
impl<T: ?Sized> PartialEq for NonNull<T> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.as_ptr() == other.as_ptr()
|
||||
}
|
||||
@ -2970,6 +2978,7 @@ impl<T: ?Sized> PartialEq for NonNull<T> {
|
||||
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
impl<T: ?Sized> Ord for NonNull<T> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.as_ptr().cmp(&other.as_ptr())
|
||||
}
|
||||
@ -2977,6 +2986,7 @@ impl<T: ?Sized> Ord for NonNull<T> {
|
||||
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
impl<T: ?Sized> PartialOrd for NonNull<T> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
self.as_ptr().partial_cmp(&other.as_ptr())
|
||||
}
|
||||
@ -2984,6 +2994,7 @@ impl<T: ?Sized> PartialOrd for NonNull<T> {
|
||||
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
impl<T: ?Sized> hash::Hash for NonNull<T> {
|
||||
#[inline]
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
self.as_ptr().hash(state)
|
||||
}
|
||||
@ -2991,6 +3002,7 @@ impl<T: ?Sized> hash::Hash for NonNull<T> {
|
||||
|
||||
#[unstable(feature = "ptr_internals", issue = "0")]
|
||||
impl<T: ?Sized> From<Unique<T>> for NonNull<T> {
|
||||
#[inline]
|
||||
fn from(unique: Unique<T>) -> Self {
|
||||
NonNull { pointer: unique.pointer }
|
||||
}
|
||||
@ -2998,6 +3010,7 @@ impl<T: ?Sized> From<Unique<T>> for NonNull<T> {
|
||||
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
|
||||
#[inline]
|
||||
fn from(reference: &'a mut T) -> Self {
|
||||
NonNull { pointer: NonZero(reference as _) }
|
||||
}
|
||||
@ -3005,6 +3018,7 @@ impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
|
||||
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
impl<'a, T: ?Sized> From<&'a T> for NonNull<T> {
|
||||
#[inline]
|
||||
fn from(reference: &'a T) -> Self {
|
||||
NonNull { pointer: NonZero(reference as _) }
|
||||
}
|
||||
|
@ -479,17 +479,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
err.span_label(arm_span, msg);
|
||||
}
|
||||
}
|
||||
hir::MatchSource::TryDesugar => {
|
||||
// Issue #51632
|
||||
if let Ok(try_snippet) = self.tcx.sess.source_map().span_to_snippet(arm_span) {
|
||||
err.span_suggestion_with_applicability(
|
||||
arm_span,
|
||||
"try wrapping with a success variant",
|
||||
format!("Ok({})", try_snippet),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
}
|
||||
hir::MatchSource::TryDesugar => {}
|
||||
_ => {
|
||||
let msg = "match arm with an incompatible type";
|
||||
if self.tcx.sess.source_map().is_multiline(arm_span) {
|
||||
|
@ -93,11 +93,6 @@
|
||||
var end = start + className.length;
|
||||
return !(end < elemClass.length && elemClass[end] !== ' ');
|
||||
}
|
||||
if (start > 0 && elemClass[start - 1] !== ' ') {
|
||||
return false;
|
||||
}
|
||||
var end = start + className.length;
|
||||
return !(end < elemClass.length && elemClass[end] !== ' ');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -494,8 +494,17 @@ fn float_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
|
||||
-> Option<ast::LitKind> {
|
||||
debug!("float_lit: {:?}, {:?}", s, suffix);
|
||||
// FIXME #2252: bounds checking float literals is deferred until trans
|
||||
let s = s.chars().filter(|&c| c != '_').collect::<String>();
|
||||
filtered_float_lit(Symbol::intern(&s), suffix, diag)
|
||||
|
||||
// Strip underscores without allocating a new String unless necessary.
|
||||
let s2;
|
||||
let s = if s.chars().any(|c| c == '_') {
|
||||
s2 = s.chars().filter(|&c| c != '_').collect::<String>();
|
||||
&s2
|
||||
} else {
|
||||
s
|
||||
};
|
||||
|
||||
filtered_float_lit(Symbol::intern(s), suffix, diag)
|
||||
}
|
||||
|
||||
/// Parse a string representing a byte literal into its final form. Similar to `char_lit`
|
||||
@ -591,8 +600,14 @@ fn integer_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
|
||||
-> Option<ast::LitKind> {
|
||||
// s can only be ascii, byte indexing is fine
|
||||
|
||||
let s2 = s.chars().filter(|&c| c != '_').collect::<String>();
|
||||
let mut s = &s2[..];
|
||||
// Strip underscores without allocating a new String unless necessary.
|
||||
let s2;
|
||||
let mut s = if s.chars().any(|c| c == '_') {
|
||||
s2 = s.chars().filter(|&c| c != '_').collect::<String>();
|
||||
&s2
|
||||
} else {
|
||||
s
|
||||
};
|
||||
|
||||
debug!("integer_lit: {}, {:?}", s, suffix);
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-rustfix
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn missing_discourses() -> Result<isize, ()> {
|
||||
Ok(1)
|
||||
}
|
||||
|
||||
fn forbidden_narratives() -> Result<isize, ()> {
|
||||
Ok(missing_discourses()?)
|
||||
//~^ ERROR try expression alternatives have incompatible types
|
||||
//~| HELP try wrapping with a success variant
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-rustfix
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn missing_discourses() -> Result<isize, ()> {
|
||||
@ -19,7 +17,6 @@ fn missing_discourses() -> Result<isize, ()> {
|
||||
fn forbidden_narratives() -> Result<isize, ()> {
|
||||
missing_discourses()?
|
||||
//~^ ERROR try expression alternatives have incompatible types
|
||||
//~| HELP try wrapping with a success variant
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,11 +1,8 @@
|
||||
error[E0308]: try expression alternatives have incompatible types
|
||||
--> $DIR/issue-51632-try-desugar-incompatible-types.rs:20:5
|
||||
--> $DIR/issue-51632-try-desugar-incompatible-types.rs:18:5
|
||||
|
|
||||
LL | missing_discourses()?
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected enum `std::result::Result`, found isize
|
||||
| help: try wrapping with a success variant: `Ok(missing_discourses()?)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found isize
|
||||
|
|
||||
= note: expected type `std::result::Result<isize, ()>`
|
||||
found type `isize`
|
||||
|
Loading…
x
Reference in New Issue
Block a user