Skip to content

Commit d586d5d

Browse files
committed
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
2 parents 4e88b73 + eb00b47 commit d586d5d

File tree

9 files changed

+39
-56
lines changed

9 files changed

+39
-56
lines changed

src/bootstrap/configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def is_number(value):
397397
try:
398398
float(value)
399399
return True
400-
except:
400+
except ValueError:
401401
return False
402402

403403
# Here we walk through the constructed configuration we have from the parsed

src/etc/generate-deriving-span-tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
sample usage: src/etc/generate-deriving-span-tests.py
1919
"""
2020

21-
import sys, os, datetime, stat, re
21+
import os, datetime, stat, re
2222

2323
TEST_DIR = os.path.abspath(
24-
os.path.join(os.path.dirname(__file__), '../test/compile-fail'))
24+
os.path.join(os.path.dirname(__file__), '../test/ui/derives/'))
2525

2626
YEAR = datetime.datetime.now().year
2727

src/libcore/ptr.rs

+14
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,7 @@ impl<T: Sized> NonNull<T> {
28672867
/// sentinel value. Types that lazily allocate must track initialization by
28682868
/// some other means.
28692869
#[stable(feature = "nonnull", since = "1.25.0")]
2870+
#[inline]
28702871
pub fn dangling() -> Self {
28712872
unsafe {
28722873
let ptr = mem::align_of::<T>() as *mut T;
@@ -2882,12 +2883,14 @@ impl<T: ?Sized> NonNull<T> {
28822883
///
28832884
/// `ptr` must be non-null.
28842885
#[stable(feature = "nonnull", since = "1.25.0")]
2886+
#[inline]
28852887
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
28862888
NonNull { pointer: NonZero(ptr as _) }
28872889
}
28882890

28892891
/// Creates a new `NonNull` if `ptr` is non-null.
28902892
#[stable(feature = "nonnull", since = "1.25.0")]
2893+
#[inline]
28912894
pub fn new(ptr: *mut T) -> Option<Self> {
28922895
if !ptr.is_null() {
28932896
Some(NonNull { pointer: NonZero(ptr as _) })
@@ -2898,6 +2901,7 @@ impl<T: ?Sized> NonNull<T> {
28982901

28992902
/// Acquires the underlying `*mut` pointer.
29002903
#[stable(feature = "nonnull", since = "1.25.0")]
2904+
#[inline]
29012905
pub fn as_ptr(self) -> *mut T {
29022906
self.pointer.0 as *mut T
29032907
}
@@ -2908,6 +2912,7 @@ impl<T: ?Sized> NonNull<T> {
29082912
/// it were actually an instance of T that is getting borrowed. If a longer
29092913
/// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`.
29102914
#[stable(feature = "nonnull", since = "1.25.0")]
2915+
#[inline]
29112916
pub unsafe fn as_ref(&self) -> &T {
29122917
&*self.as_ptr()
29132918
}
@@ -2918,12 +2923,14 @@ impl<T: ?Sized> NonNull<T> {
29182923
/// it were actually an instance of T that is getting borrowed. If a longer
29192924
/// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`.
29202925
#[stable(feature = "nonnull", since = "1.25.0")]
2926+
#[inline]
29212927
pub unsafe fn as_mut(&mut self) -> &mut T {
29222928
&mut *self.as_ptr()
29232929
}
29242930

29252931
/// Cast to a pointer of another type
29262932
#[stable(feature = "nonnull_cast", since = "1.27.0")]
2933+
#[inline]
29272934
pub fn cast<U>(self) -> NonNull<U> {
29282935
unsafe {
29292936
NonNull::new_unchecked(self.as_ptr() as *mut U)
@@ -2963,48 +2970,55 @@ impl<T: ?Sized> Eq for NonNull<T> {}
29632970

29642971
#[stable(feature = "nonnull", since = "1.25.0")]
29652972
impl<T: ?Sized> PartialEq for NonNull<T> {
2973+
#[inline]
29662974
fn eq(&self, other: &Self) -> bool {
29672975
self.as_ptr() == other.as_ptr()
29682976
}
29692977
}
29702978

29712979
#[stable(feature = "nonnull", since = "1.25.0")]
29722980
impl<T: ?Sized> Ord for NonNull<T> {
2981+
#[inline]
29732982
fn cmp(&self, other: &Self) -> Ordering {
29742983
self.as_ptr().cmp(&other.as_ptr())
29752984
}
29762985
}
29772986

29782987
#[stable(feature = "nonnull", since = "1.25.0")]
29792988
impl<T: ?Sized> PartialOrd for NonNull<T> {
2989+
#[inline]
29802990
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
29812991
self.as_ptr().partial_cmp(&other.as_ptr())
29822992
}
29832993
}
29842994

29852995
#[stable(feature = "nonnull", since = "1.25.0")]
29862996
impl<T: ?Sized> hash::Hash for NonNull<T> {
2997+
#[inline]
29872998
fn hash<H: hash::Hasher>(&self, state: &mut H) {
29882999
self.as_ptr().hash(state)
29893000
}
29903001
}
29913002

29923003
#[unstable(feature = "ptr_internals", issue = "0")]
29933004
impl<T: ?Sized> From<Unique<T>> for NonNull<T> {
3005+
#[inline]
29943006
fn from(unique: Unique<T>) -> Self {
29953007
NonNull { pointer: unique.pointer }
29963008
}
29973009
}
29983010

29993011
#[stable(feature = "nonnull", since = "1.25.0")]
30003012
impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
3013+
#[inline]
30013014
fn from(reference: &'a mut T) -> Self {
30023015
NonNull { pointer: NonZero(reference as _) }
30033016
}
30043017
}
30053018

30063019
#[stable(feature = "nonnull", since = "1.25.0")]
30073020
impl<'a, T: ?Sized> From<&'a T> for NonNull<T> {
3021+
#[inline]
30083022
fn from(reference: &'a T) -> Self {
30093023
NonNull { pointer: NonZero(reference as _) }
30103024
}

src/librustc/infer/error_reporting/mod.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
479479
err.span_label(arm_span, msg);
480480
}
481481
}
482-
hir::MatchSource::TryDesugar => {
483-
// Issue #51632
484-
if let Ok(try_snippet) = self.tcx.sess.source_map().span_to_snippet(arm_span) {
485-
err.span_suggestion_with_applicability(
486-
arm_span,
487-
"try wrapping with a success variant",
488-
format!("Ok({})", try_snippet),
489-
Applicability::MachineApplicable,
490-
);
491-
}
492-
}
482+
hir::MatchSource::TryDesugar => {}
493483
_ => {
494484
let msg = "match arm with an incompatible type";
495485
if self.tcx.sess.source_map().is_multiline(arm_span) {

src/librustdoc/html/static/main.js

-5
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@
9393
var end = start + className.length;
9494
return !(end < elemClass.length && elemClass[end] !== ' ');
9595
}
96-
if (start > 0 && elemClass[start - 1] !== ' ') {
97-
return false;
98-
}
99-
var end = start + className.length;
100-
return !(end < elemClass.length && elemClass[end] !== ' ');
10196
}
10297
return false;
10398
}

src/libsyntax/parse/mod.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,17 @@ fn float_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
494494
-> Option<ast::LitKind> {
495495
debug!("float_lit: {:?}, {:?}", s, suffix);
496496
// FIXME #2252: bounds checking float literals is deferred until trans
497-
let s = s.chars().filter(|&c| c != '_').collect::<String>();
498-
filtered_float_lit(Symbol::intern(&s), suffix, diag)
497+
498+
// Strip underscores without allocating a new String unless necessary.
499+
let s2;
500+
let s = if s.chars().any(|c| c == '_') {
501+
s2 = s.chars().filter(|&c| c != '_').collect::<String>();
502+
&s2
503+
} else {
504+
s
505+
};
506+
507+
filtered_float_lit(Symbol::intern(s), suffix, diag)
499508
}
500509

501510
/// 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)>)
591600
-> Option<ast::LitKind> {
592601
// s can only be ascii, byte indexing is fine
593602

594-
let s2 = s.chars().filter(|&c| c != '_').collect::<String>();
595-
let mut s = &s2[..];
603+
// Strip underscores without allocating a new String unless necessary.
604+
let s2;
605+
let mut s = if s.chars().any(|c| c == '_') {
606+
s2 = s.chars().filter(|&c| c != '_').collect::<String>();
607+
&s2
608+
} else {
609+
s
610+
};
596611

597612
debug!("integer_lit: {}, {:?}", s, suffix);
598613

src/test/ui/issues/issue-51632-try-desugar-incompatible-types.fixed

-25
This file was deleted.

src/test/ui/issues/issue-51632-try-desugar-incompatible-types.rs

-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// run-rustfix
12-
1311
#![allow(dead_code)]
1412

1513
fn missing_discourses() -> Result<isize, ()> {
@@ -19,7 +17,6 @@ fn missing_discourses() -> Result<isize, ()> {
1917
fn forbidden_narratives() -> Result<isize, ()> {
2018
missing_discourses()?
2119
//~^ ERROR try expression alternatives have incompatible types
22-
//~| HELP try wrapping with a success variant
2320
}
2421

2522
fn main() {}

src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
error[E0308]: try expression alternatives have incompatible types
2-
--> $DIR/issue-51632-try-desugar-incompatible-types.rs:20:5
2+
--> $DIR/issue-51632-try-desugar-incompatible-types.rs:18:5
33
|
44
LL | missing_discourses()?
5-
| ^^^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| expected enum `std::result::Result`, found isize
8-
| help: try wrapping with a success variant: `Ok(missing_discourses()?)`
5+
| ^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found isize
96
|
107
= note: expected type `std::result::Result<isize, ()>`
118
found type `isize`

0 commit comments

Comments
 (0)