Auto merge of #93534 - ehuss:rollup-9ecozo9, r=ehuss
Rollup of 9 pull requests Successful merges: - #91343 (Fix suggestion to slice if scrutinee is a `Result` or `Option`) - #93019 (If an integer is entered with an upper-case base prefix (0Xbeef, 0O755, 0B1010), suggest to make it lowercase) - #93090 (`impl Display for io::ErrorKind`) - #93456 (Remove an unnecessary transmute from opaque::Encoder) - #93492 (Hide failed command unless in verbose mode) - #93504 (kmc-solid: Increase the default stack size) - #93513 (Allow any pretty printed line to have at least 60 chars) - #93532 (Update books) - #93533 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
93e8201ca7
24 changed files with 467 additions and 44 deletions
10
Cargo.lock
10
Cargo.lock
|
@ -337,7 +337,7 @@ dependencies = [
|
|||
"cargo-test-macro",
|
||||
"cargo-test-support",
|
||||
"cargo-util",
|
||||
"clap 3.0.10",
|
||||
"clap 3.0.13",
|
||||
"crates-io",
|
||||
"crossbeam-utils",
|
||||
"curl",
|
||||
|
@ -627,9 +627,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.0.10"
|
||||
version = "3.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375"
|
||||
checksum = "08799f92c961c7a1cf0cc398a9073da99e21ce388b46372c37f3191f2f3eed3e"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
|
@ -5233,9 +5233,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.13.0"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b80ac5e1b91e3378c63dab121962472b5ca20cf9ab1975e3d588548717807a8"
|
||||
checksum = "744e9ed5b352340aa47ce033716991b5589e23781acb97cad37d4ea70560f55b"
|
||||
dependencies = [
|
||||
"combine",
|
||||
"indexmap",
|
||||
|
|
|
@ -136,6 +136,7 @@ mod ring;
|
|||
|
||||
use ring::RingBuffer;
|
||||
use std::borrow::Cow;
|
||||
use std::cmp;
|
||||
use std::collections::VecDeque;
|
||||
use std::iter;
|
||||
|
||||
|
@ -199,10 +200,13 @@ enum PrintFrame {
|
|||
|
||||
const SIZE_INFINITY: isize = 0xffff;
|
||||
|
||||
/// Target line width.
|
||||
const MARGIN: isize = 78;
|
||||
/// Every line is allowed at least this much space, even if highly indented.
|
||||
const MIN_SPACE: isize = 60;
|
||||
|
||||
pub struct Printer {
|
||||
out: String,
|
||||
/// Width of lines we're constrained to
|
||||
margin: isize,
|
||||
/// Number of spaces left on line
|
||||
space: isize,
|
||||
/// Ring-buffer of tokens and calculated sizes
|
||||
|
@ -237,11 +241,9 @@ struct BufEntry {
|
|||
|
||||
impl Printer {
|
||||
pub fn new() -> Self {
|
||||
let linewidth = 78;
|
||||
Printer {
|
||||
out: String::new(),
|
||||
margin: linewidth as isize,
|
||||
space: linewidth as isize,
|
||||
space: MARGIN,
|
||||
buf: RingBuffer::new(),
|
||||
left_total: 0,
|
||||
right_total: 0,
|
||||
|
@ -395,7 +397,7 @@ impl Printer {
|
|||
self.print_stack.push(PrintFrame::Broken { indent: self.indent, breaks: token.breaks });
|
||||
self.indent = match token.indent {
|
||||
IndentStyle::Block { offset } => (self.indent as isize + offset) as usize,
|
||||
IndentStyle::Visual => (self.margin - self.space) as usize,
|
||||
IndentStyle::Visual => (MARGIN - self.space) as usize,
|
||||
};
|
||||
} else {
|
||||
self.print_stack.push(PrintFrame::Fits);
|
||||
|
@ -421,7 +423,7 @@ impl Printer {
|
|||
self.out.push('\n');
|
||||
let indent = self.indent as isize + token.offset;
|
||||
self.pending_indentation = indent;
|
||||
self.space = self.margin - indent;
|
||||
self.space = cmp::max(MARGIN - indent, MIN_SPACE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1700,6 +1700,19 @@ impl<'a> Parser<'a> {
|
|||
s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit())
|
||||
}
|
||||
|
||||
// Try to lowercase the prefix if it's a valid base prefix.
|
||||
fn fix_base_capitalisation(s: &str) -> Option<String> {
|
||||
if let Some(stripped) = s.strip_prefix("B") {
|
||||
Some(format!("0b{stripped}"))
|
||||
} else if let Some(stripped) = s.strip_prefix("O") {
|
||||
Some(format!("0o{stripped}"))
|
||||
} else if let Some(stripped) = s.strip_prefix("X") {
|
||||
Some(format!("0x{stripped}"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
let token::Lit { kind, suffix, .. } = lit;
|
||||
match err {
|
||||
// `NotLiteral` is not an error by itself, so we don't report
|
||||
|
@ -1724,6 +1737,18 @@ impl<'a> Parser<'a> {
|
|||
self.struct_span_err(span, &msg)
|
||||
.help("valid widths are 8, 16, 32, 64 and 128")
|
||||
.emit();
|
||||
} else if let Some(fixed) = fix_base_capitalisation(suf) {
|
||||
let msg = "invalid base prefix for number literal";
|
||||
|
||||
self.struct_span_err(span, &msg)
|
||||
.note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")
|
||||
.span_suggestion(
|
||||
span,
|
||||
"try making the prefix lowercase",
|
||||
fixed,
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
.emit();
|
||||
} else {
|
||||
let msg = format!("invalid suffix `{}` for number literal", suf);
|
||||
self.struct_span_err(span, &msg)
|
||||
|
|
|
@ -130,8 +130,7 @@ impl serialize::Encoder for Encoder {
|
|||
|
||||
#[inline]
|
||||
fn emit_i8(&mut self, v: i8) -> EncodeResult {
|
||||
let as_u8: u8 = unsafe { std::mem::transmute(v) };
|
||||
self.emit_u8(as_u8)
|
||||
self.emit_u8(v as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -629,9 +628,9 @@ impl<'a> serialize::Decoder for Decoder<'a> {
|
|||
|
||||
#[inline]
|
||||
fn read_i8(&mut self) -> i8 {
|
||||
let as_u8 = self.data[self.position];
|
||||
let value = self.data[self.position];
|
||||
self.position += 1;
|
||||
unsafe { ::std::mem::transmute(as_u8) }
|
||||
value as i8
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -15,7 +15,7 @@ use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
|
|||
use rustc_span::hygiene::DesugaringKind;
|
||||
use rustc_span::lev_distance::find_best_match_for_name;
|
||||
use rustc_span::source_map::{Span, Spanned};
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::symbol::{sym, Ident};
|
||||
use rustc_span::{BytePos, MultiSpan, DUMMY_SP};
|
||||
use rustc_trait_selection::autoderef::Autoderef;
|
||||
use rustc_trait_selection::traits::{ObligationCause, Pattern};
|
||||
|
@ -2033,12 +2033,39 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
{
|
||||
if let (Some(span), true) = (ti.span, ti.origin_expr) {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
err.span_suggestion(
|
||||
span,
|
||||
"consider slicing here",
|
||||
format!("{}[..]", snippet),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
let applicability = match self.resolve_vars_if_possible(ti.expected).kind() {
|
||||
ty::Adt(adt_def, _)
|
||||
if self.tcx.is_diagnostic_item(sym::Option, adt_def.did)
|
||||
|| self.tcx.is_diagnostic_item(sym::Result, adt_def.did) =>
|
||||
{
|
||||
// Slicing won't work here, but `.as_deref()` might (issue #91328).
|
||||
err.span_suggestion(
|
||||
span,
|
||||
"consider using `as_deref` here",
|
||||
format!("{}.as_deref()", snippet),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
None
|
||||
}
|
||||
// FIXME: instead of checking for Vec only, we could check whether the
|
||||
// type implements `Deref<Target=X>`; see
|
||||
// https://github.com/rust-lang/rust/pull/91343#discussion_r761466979
|
||||
ty::Adt(adt_def, _)
|
||||
if self.tcx.is_diagnostic_item(sym::Vec, adt_def.did) =>
|
||||
{
|
||||
Some(Applicability::MachineApplicable)
|
||||
}
|
||||
_ => Some(Applicability::MaybeIncorrect),
|
||||
};
|
||||
|
||||
if let Some(applicability) = applicability {
|
||||
err.span_suggestion(
|
||||
span,
|
||||
"consider slicing here",
|
||||
format!("{}[..]", snippet),
|
||||
applicability,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -361,13 +361,29 @@ impl ErrorKind {
|
|||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "io_errorkind_display", since = "1.60.0")]
|
||||
impl fmt::Display for ErrorKind {
|
||||
/// Shows a human-readable description of the `ErrorKind`.
|
||||
///
|
||||
/// This is similar to `impl Display for Error`, but doesn't require first converting to Error.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use std::io::ErrorKind;
|
||||
/// assert_eq!("entity not found", ErrorKind::NotFound.to_string());
|
||||
/// ```
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.write_str(self.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
/// Intended for use for errors not exposed to the user, where allocating onto
|
||||
/// the heap (for normal construction via Error::new) is too costly.
|
||||
#[stable(feature = "io_error_from_errorkind", since = "1.14.0")]
|
||||
impl From<ErrorKind> for Error {
|
||||
/// Converts an [`ErrorKind`] into an [`Error`].
|
||||
///
|
||||
/// This conversion allocates a new error with a simple representation of error kind.
|
||||
/// This conversion creates a new error with a simple representation of error kind.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -77,7 +77,8 @@ const LIFECYCLE_DETACHED_OR_JOINED: usize = usize::MAX;
|
|||
const LIFECYCLE_EXITED_OR_FINISHED_OR_JOIN_FINALIZE: usize = usize::MAX;
|
||||
// there's no single value for `JOINING`
|
||||
|
||||
pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * crate::mem::size_of::<usize>();
|
||||
// 64KiB for 32-bit ISAs, 128KiB for 64-bit ISAs.
|
||||
pub const DEFAULT_MIN_STACK_SIZE: usize = 0x4000 * crate::mem::size_of::<usize>();
|
||||
|
||||
impl Thread {
|
||||
/// # Safety
|
||||
|
|
|
@ -851,7 +851,7 @@ impl Build {
|
|||
return;
|
||||
}
|
||||
self.verbose(&format!("running: {:?}", cmd));
|
||||
run(cmd)
|
||||
run(cmd, self.is_verbose())
|
||||
}
|
||||
|
||||
/// Runs a command, printing out nice contextual information if it fails.
|
||||
|
@ -871,7 +871,7 @@ impl Build {
|
|||
return true;
|
||||
}
|
||||
self.verbose(&format!("running: {:?}", cmd));
|
||||
try_run(cmd)
|
||||
try_run(cmd, self.is_verbose())
|
||||
}
|
||||
|
||||
/// Runs a command, printing out nice contextual information if it fails.
|
||||
|
|
|
@ -55,18 +55,18 @@ pub fn restore_library_path() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn run(cmd: &mut Command) {
|
||||
if !try_run(cmd) {
|
||||
pub fn run(cmd: &mut Command, print_cmd_on_fail: bool) {
|
||||
if !try_run(cmd, print_cmd_on_fail) {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_run(cmd: &mut Command) -> bool {
|
||||
pub fn try_run(cmd: &mut Command, print_cmd_on_fail: bool) -> bool {
|
||||
let status = match cmd.status() {
|
||||
Ok(status) => status,
|
||||
Err(e) => fail(&format!("failed to execute command: {:?}\nerror: {}", cmd, e)),
|
||||
};
|
||||
if !status.success() {
|
||||
if !status.success() && print_cmd_on_fail {
|
||||
println!(
|
||||
"\n\ncommand did not execute successfully: {:?}\n\
|
||||
expected success, got: {}\n\n",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f17df27fc14696912c48b8b7a7a8fa49e648088d
|
||||
Subproject commit 98904efaa4fc968db8ff59cf2744d9f7ed158166
|
|
@ -1 +1 @@
|
|||
Subproject commit 8c395bdd8073deb20ca67e1ed4b14a3a7e315a37
|
||||
Subproject commit d5fc1bce3f8eb398f9c25f1b15e0257d7537cd41
|
|
@ -1 +1 @@
|
|||
Subproject commit 66d097d3d80e8f88c288c6879c7c2b909ecf8ad4
|
||||
Subproject commit 9493715a6280a1f74be759c7e1ef9999b5d13e6f
|
|
@ -1 +1 @@
|
|||
Subproject commit 4dee6eb63d728ffb9e7a2ed443e9ada9275c69d2
|
||||
Subproject commit 411c2f0d5cebf48453ae2d136ad0c5e611d39aec
|
|
@ -1 +1 @@
|
|||
Subproject commit 78dd6a4684cf8d6b72275fab6d0429ea40b66338
|
||||
Subproject commit 8763adb62c712df69b1d39ea3e692b6d696cc4d9
|
|
@ -35,8 +35,7 @@ pub fn bar() ({
|
|||
for<'r> fn(Arguments<'r>) -> String {format})(((::core::fmt::Arguments::new_v1
|
||||
as
|
||||
fn(&[&'static str], &[ArgumentV1]) -> Arguments {Arguments::new_v1})((&([("test"
|
||||
as &str)] as [&str; 1]) as
|
||||
&[&str; 1]),
|
||||
as &str)] as [&str; 1]) as &[&str; 1]),
|
||||
(&([] as [ArgumentV1; 0]) as &[ArgumentV1; 0])) as
|
||||
Arguments)) as String);
|
||||
(res as String)
|
||||
|
|
|
@ -11,7 +11,6 @@ pub fn main() ({
|
|||
({ } as
|
||||
()) else if (let Some(a) =
|
||||
((Some as
|
||||
fn(i32) -> Option<i32> {Option::<i32>::Some})((3
|
||||
as i32)) as Option<i32>) as bool) ({ } as ())
|
||||
as ())
|
||||
fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as
|
||||
Option<i32>) as bool) ({ } as ()) as ())
|
||||
} as ())
|
||||
|
|
77
src/test/ui/numeric/uppercase-base-prefix.fixed
Normal file
77
src/test/ui/numeric/uppercase-base-prefix.fixed
Normal file
|
@ -0,0 +1,77 @@
|
|||
// run-rustfix
|
||||
// Checks that integers with an uppercase base prefix (0B, 0X, 0O) have a nice error
|
||||
#![allow(unused_variables)]
|
||||
|
||||
fn main() {
|
||||
let a = 0xABCDEF;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0xABCDEF
|
||||
|
||||
let b = 0o755;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0o755
|
||||
|
||||
let c = 0b10101010;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0b10101010
|
||||
|
||||
let d = 0xABC_DEF;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0xABC_DEF
|
||||
|
||||
let e = 0o7_55;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0o7_55
|
||||
|
||||
let f = 0b1010_1010;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0b1010_1010
|
||||
|
||||
let g = 0xABC_DEF_u64;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0xABC_DEF_u64
|
||||
|
||||
let h = 0o7_55_u32;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0o7_55_u32
|
||||
|
||||
let i = 0b1010_1010_u8;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0b1010_1010_u8
|
||||
//
|
||||
let j = 0xABCDEFu64;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0xABCDEFu64
|
||||
|
||||
let k = 0o755u32;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0o755u32
|
||||
|
||||
let l = 0b10101010u8;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0b10101010u8
|
||||
}
|
77
src/test/ui/numeric/uppercase-base-prefix.rs
Normal file
77
src/test/ui/numeric/uppercase-base-prefix.rs
Normal file
|
@ -0,0 +1,77 @@
|
|||
// run-rustfix
|
||||
// Checks that integers with an uppercase base prefix (0B, 0X, 0O) have a nice error
|
||||
#![allow(unused_variables)]
|
||||
|
||||
fn main() {
|
||||
let a = 0XABCDEF;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0xABCDEF
|
||||
|
||||
let b = 0O755;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0o755
|
||||
|
||||
let c = 0B10101010;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0b10101010
|
||||
|
||||
let d = 0XABC_DEF;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0xABC_DEF
|
||||
|
||||
let e = 0O7_55;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0o7_55
|
||||
|
||||
let f = 0B1010_1010;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0b1010_1010
|
||||
|
||||
let g = 0XABC_DEF_u64;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0xABC_DEF_u64
|
||||
|
||||
let h = 0O7_55_u32;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0o7_55_u32
|
||||
|
||||
let i = 0B1010_1010_u8;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0b1010_1010_u8
|
||||
//
|
||||
let j = 0XABCDEFu64;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0xABCDEFu64
|
||||
|
||||
let k = 0O755u32;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0o755u32
|
||||
|
||||
let l = 0B10101010u8;
|
||||
//~^ ERROR invalid base prefix for number literal
|
||||
//~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
//~| HELP try making the prefix lowercase
|
||||
//~| SUGGESTION 0b10101010u8
|
||||
}
|
98
src/test/ui/numeric/uppercase-base-prefix.stderr
Normal file
98
src/test/ui/numeric/uppercase-base-prefix.stderr
Normal file
|
@ -0,0 +1,98 @@
|
|||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:6:13
|
||||
|
|
||||
LL | let a = 0XABCDEF;
|
||||
| ^^^^^^^^ help: try making the prefix lowercase (notice the capitalization): `0xABCDEF`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:12:13
|
||||
|
|
||||
LL | let b = 0O755;
|
||||
| ^^^^^ help: try making the prefix lowercase (notice the capitalization): `0o755`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:18:13
|
||||
|
|
||||
LL | let c = 0B10101010;
|
||||
| ^^^^^^^^^^ help: try making the prefix lowercase: `0b10101010`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:24:13
|
||||
|
|
||||
LL | let d = 0XABC_DEF;
|
||||
| ^^^^^^^^^ help: try making the prefix lowercase (notice the capitalization): `0xABC_DEF`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:30:13
|
||||
|
|
||||
LL | let e = 0O7_55;
|
||||
| ^^^^^^ help: try making the prefix lowercase (notice the capitalization): `0o7_55`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:36:13
|
||||
|
|
||||
LL | let f = 0B1010_1010;
|
||||
| ^^^^^^^^^^^ help: try making the prefix lowercase: `0b1010_1010`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:42:13
|
||||
|
|
||||
LL | let g = 0XABC_DEF_u64;
|
||||
| ^^^^^^^^^^^^^ help: try making the prefix lowercase (notice the capitalization): `0xABC_DEF_u64`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:48:13
|
||||
|
|
||||
LL | let h = 0O7_55_u32;
|
||||
| ^^^^^^^^^^ help: try making the prefix lowercase (notice the capitalization): `0o7_55_u32`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:54:13
|
||||
|
|
||||
LL | let i = 0B1010_1010_u8;
|
||||
| ^^^^^^^^^^^^^^ help: try making the prefix lowercase: `0b1010_1010_u8`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:60:13
|
||||
|
|
||||
LL | let j = 0XABCDEFu64;
|
||||
| ^^^^^^^^^^^ help: try making the prefix lowercase (notice the capitalization): `0xABCDEFu64`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:66:13
|
||||
|
|
||||
LL | let k = 0O755u32;
|
||||
| ^^^^^^^^ help: try making the prefix lowercase (notice the capitalization): `0o755u32`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: invalid base prefix for number literal
|
||||
--> $DIR/uppercase-base-prefix.rs:72:13
|
||||
|
|
||||
LL | let l = 0B10101010u8;
|
||||
| ^^^^^^^^^^^^ help: try making the prefix lowercase: `0b10101010u8`
|
||||
|
|
||||
= note: base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
|
@ -27,8 +27,7 @@ fn main() {
|
|||
crate::TokenStream::from(crate::TokenTree::Literal({
|
||||
let mut iter =
|
||||
"\"world\"".parse::<crate::TokenStream>().unwrap().into_iter();
|
||||
if let (Some(crate::TokenTree::Literal(mut lit)),
|
||||
None) =
|
||||
if let (Some(crate::TokenTree::Literal(mut lit)), None) =
|
||||
(iter.next(), iter.next()) {
|
||||
lit.set_span(crate::Span::recover_proc_macro_span(2));
|
||||
lit
|
||||
|
|
37
src/test/ui/typeck/issue-91328.fixed
Normal file
37
src/test/ui/typeck/issue-91328.fixed
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Regression test for issue #91328.
|
||||
|
||||
// run-rustfix
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn foo(r: Result<Vec<i32>, i32>) -> i32 {
|
||||
match r.as_deref() {
|
||||
//~^ HELP: consider using `as_deref` here
|
||||
Ok([a, b]) => a + b,
|
||||
//~^ ERROR: expected an array or slice
|
||||
//~| NOTE: pattern cannot match with input type
|
||||
_ => 42,
|
||||
}
|
||||
}
|
||||
|
||||
fn bar(o: Option<Vec<i32>>) -> i32 {
|
||||
match o.as_deref() {
|
||||
//~^ HELP: consider using `as_deref` here
|
||||
Some([a, b]) => a + b,
|
||||
//~^ ERROR: expected an array or slice
|
||||
//~| NOTE: pattern cannot match with input type
|
||||
_ => 42,
|
||||
}
|
||||
}
|
||||
|
||||
fn baz(v: Vec<i32>) -> i32 {
|
||||
match v[..] {
|
||||
//~^ HELP: consider slicing here
|
||||
[a, b] => a + b,
|
||||
//~^ ERROR: expected an array or slice
|
||||
//~| NOTE: pattern cannot match with input type
|
||||
_ => 42,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
37
src/test/ui/typeck/issue-91328.rs
Normal file
37
src/test/ui/typeck/issue-91328.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Regression test for issue #91328.
|
||||
|
||||
// run-rustfix
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn foo(r: Result<Vec<i32>, i32>) -> i32 {
|
||||
match r {
|
||||
//~^ HELP: consider using `as_deref` here
|
||||
Ok([a, b]) => a + b,
|
||||
//~^ ERROR: expected an array or slice
|
||||
//~| NOTE: pattern cannot match with input type
|
||||
_ => 42,
|
||||
}
|
||||
}
|
||||
|
||||
fn bar(o: Option<Vec<i32>>) -> i32 {
|
||||
match o {
|
||||
//~^ HELP: consider using `as_deref` here
|
||||
Some([a, b]) => a + b,
|
||||
//~^ ERROR: expected an array or slice
|
||||
//~| NOTE: pattern cannot match with input type
|
||||
_ => 42,
|
||||
}
|
||||
}
|
||||
|
||||
fn baz(v: Vec<i32>) -> i32 {
|
||||
match v {
|
||||
//~^ HELP: consider slicing here
|
||||
[a, b] => a + b,
|
||||
//~^ ERROR: expected an array or slice
|
||||
//~| NOTE: pattern cannot match with input type
|
||||
_ => 42,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
30
src/test/ui/typeck/issue-91328.stderr
Normal file
30
src/test/ui/typeck/issue-91328.stderr
Normal file
|
@ -0,0 +1,30 @@
|
|||
error[E0529]: expected an array or slice, found `Vec<i32>`
|
||||
--> $DIR/issue-91328.rs:10:12
|
||||
|
|
||||
LL | match r {
|
||||
| - help: consider using `as_deref` here: `r.as_deref()`
|
||||
LL |
|
||||
LL | Ok([a, b]) => a + b,
|
||||
| ^^^^^^ pattern cannot match with input type `Vec<i32>`
|
||||
|
||||
error[E0529]: expected an array or slice, found `Vec<i32>`
|
||||
--> $DIR/issue-91328.rs:20:14
|
||||
|
|
||||
LL | match o {
|
||||
| - help: consider using `as_deref` here: `o.as_deref()`
|
||||
LL |
|
||||
LL | Some([a, b]) => a + b,
|
||||
| ^^^^^^ pattern cannot match with input type `Vec<i32>`
|
||||
|
||||
error[E0529]: expected an array or slice, found `Vec<i32>`
|
||||
--> $DIR/issue-91328.rs:30:9
|
||||
|
|
||||
LL | match v {
|
||||
| - help: consider slicing here: `v[..]`
|
||||
LL |
|
||||
LL | [a, b] => a + b,
|
||||
| ^^^^^^ pattern cannot match with input type `Vec<i32>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0529`.
|
|
@ -1 +1 @@
|
|||
Subproject commit 1c034752de0df744fcd7788fcbca158830b8bf85
|
||||
Subproject commit 25fcb135d02ea897ce894b67ae021f48107d522b
|
Loading…
Add table
Reference in a new issue