From 54d1c50c7e7b4c4c7dca6c85c6965c886922b449 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 25 Feb 2020 16:41:40 +1100 Subject: [PATCH 01/14] Remove `sip::Hasher::short_write`. `sip::Hasher::short_write` is currently unused. It is called by `sip::Hasher::write_{u8,usize}`, but those methods are also unused, because `DefaultHasher`, `SipHasher` and `SipHasher13` don't implement any of the `write_xyz` methods, so all their write operations end up calling `sip::Hasher::write`. (I confirmed this by inserting a `panic!` in `sip::Hasher::short_write` and running the tests -- they all passed.) The alternative would be to add all the missing `write_xyz` methods. This does give some significant speed-ups, but it hurts compile times a little in some cases. See #69152 for details. This commit does the conservative thing and doesn't change existing behaviour. --- src/libcore/hash/sip.rs | 53 ++++++----------------------------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index c4fbd9dbadaea..c3d0c024e1b3f 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -220,37 +220,6 @@ impl Hasher { self.state.v3 = self.k1 ^ 0x7465646279746573; self.ntail = 0; } - - // Specialized write function that is only valid for buffers with len <= 8. - // It's used to force inlining of write_u8 and write_usize, those would normally be inlined - // except for composite types (that includes slices and str hashing because of delimiter). - // Without this extra push the compiler is very reluctant to inline delimiter writes, - // degrading performance substantially for the most common use cases. - #[inline] - fn short_write(&mut self, msg: &[u8]) { - debug_assert!(msg.len() <= 8); - let length = msg.len(); - self.length += length; - - let needed = 8 - self.ntail; - let fill = cmp::min(length, needed); - if fill == 8 { - self.tail = unsafe { load_int_le!(msg, 0, u64) }; - } else { - self.tail |= unsafe { u8to64_le(msg, 0, fill) } << (8 * self.ntail); - if length < needed { - self.ntail += length; - return; - } - } - self.state.v3 ^= self.tail; - S::c_rounds(&mut self.state); - self.state.v0 ^= self.tail; - - // Buffered tail is now flushed, process new input. - self.ntail = length - needed; - self.tail = unsafe { u8to64_le(msg, needed, self.ntail) }; - } } #[stable(feature = "rust1", since = "1.0.0")] @@ -280,21 +249,13 @@ impl super::Hasher for SipHasher13 { } impl super::Hasher for Hasher { - // see short_write comment for explanation - #[inline] - fn write_usize(&mut self, i: usize) { - let bytes = unsafe { - crate::slice::from_raw_parts(&i as *const usize as *const u8, mem::size_of::()) - }; - self.short_write(bytes); - } - - // see short_write comment for explanation - #[inline] - fn write_u8(&mut self, i: u8) { - self.short_write(&[i]); - } - + // Note: no integer hashing methods (`write_u*`, `write_i*`) are defined + // for this type. We could add them, copy the `short_write` implementation + // in librustc_data_structures/sip128.rs, and add `write_u*`/`write_i*` + // methods to `SipHasher`, `SipHasher13`, and `DefaultHasher`. This would + // greatly speed up integer hashing by those hashers, at the cost of + // slightly slowing down compile speeds on some benchmarks. See #69152 for + // details. #[inline] fn write(&mut self, msg: &[u8]) { let length = msg.len(); From 3ba89e87503e25aece0318a9851f8dba5ccd94a2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 13 Feb 2020 00:11:16 -0800 Subject: [PATCH 02/14] Remove quotes around unknown fn placeholder in backtrace --- src/libstd/backtrace.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index 97db0ff3791d7..b14486471ffd7 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -193,7 +193,7 @@ impl fmt::Debug for BacktraceSymbol { if let Some(fn_name) = self.name.as_ref().map(|b| backtrace::SymbolName::new(b)) { write!(fmt, "fn: \"{:#}\"", fn_name)?; } else { - write!(fmt, "fn: \"\"")?; + write!(fmt, "fn: ")?; } if let Some(fname) = self.filename.as_ref() { From db75b6a91f67008ec789d9934f8a73e09fd0d472 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 13 Feb 2020 00:11:52 -0800 Subject: [PATCH 03/14] Add quotes around filename in Backtrace debug --- src/libstd/backtrace.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index b14486471ffd7..cc842ebd5894c 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -197,7 +197,7 @@ impl fmt::Debug for BacktraceSymbol { } if let Some(fname) = self.filename.as_ref() { - write!(fmt, ", file: {:?}", fname)?; + write!(fmt, ", file: \"{:?}\"", fname)?; } if let Some(line) = self.lineno.as_ref() { From 1f1ca877b7002e3ac45916df5415fde1584775ab Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 13 Feb 2020 00:12:26 -0800 Subject: [PATCH 04/14] Change disabled and unsupported backtraces to print using placeholder style --- src/libstd/backtrace.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index cc842ebd5894c..c64eb9f8e409b 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -162,8 +162,8 @@ enum BytesOrWide { impl fmt::Debug for Backtrace { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut capture = match &self.inner { - Inner::Unsupported => return fmt.write_str("unsupported backtrace"), - Inner::Disabled => return fmt.write_str("disabled backtrace"), + Inner::Unsupported => return fmt.write_str(""), + Inner::Disabled => return fmt.write_str(""), Inner::Captured(c) => c.lock().unwrap(), }; capture.resolve(); From a9cc010c4883bafba1304f6fd581343f5b1b3ba2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 13 Feb 2020 00:13:48 -0800 Subject: [PATCH 05/14] Make it possible to instantiate hardcoded Backtrace from test --- src/libstd/backtrace.rs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index c64eb9f8e409b..04fd80ecbdb23 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -92,6 +92,7 @@ // a backtrace or actually symbolizing it. use crate::env; +use crate::ffi::c_void; use crate::fmt; use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst}; use crate::sync::Mutex; @@ -144,10 +145,16 @@ fn _assert_send_sync() { } struct BacktraceFrame { - frame: backtrace::Frame, + frame: RawFrame, symbols: Vec, } +enum RawFrame { + Actual(backtrace::Frame), + #[cfg(test)] + Fake, +} + struct BacktraceSymbol { name: Option>, filename: Option, @@ -293,7 +300,10 @@ impl Backtrace { let mut actual_start = None; unsafe { backtrace::trace_unsynchronized(|frame| { - frames.push(BacktraceFrame { frame: frame.clone(), symbols: Vec::new() }); + frames.push(BacktraceFrame { + frame: RawFrame::Actual(frame.clone()), + symbols: Vec::new(), + }); if frame.symbol_address() as usize == ip && actual_start.is_none() { actual_start = Some(frames.len()); } @@ -393,8 +403,13 @@ impl Capture { let _lock = lock(); for frame in self.frames.iter_mut() { let symbols = &mut frame.symbols; + let frame = match &frame.frame { + RawFrame::Actual(frame) => frame, + #[cfg(test)] + RawFrame::Fake => unimplemented!(), + }; unsafe { - backtrace::resolve_frame_unsynchronized(&frame.frame, |symbol| { + backtrace::resolve_frame_unsynchronized(frame, |symbol| { symbols.push(BacktraceSymbol { name: symbol.name().map(|m| m.as_bytes().to_vec()), filename: symbol.filename_raw().map(|b| match b { @@ -408,3 +423,13 @@ impl Capture { } } } + +impl RawFrame { + fn ip(&self) -> *mut c_void { + match self { + RawFrame::Actual(frame) => frame.ip(), + #[cfg(test)] + RawFrame::Fake => 1 as *mut c_void, + } + } +} From 33600e4d2d7a61f7dcb1b278bb1ccb8f04690db3 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 13 Feb 2020 00:16:28 -0800 Subject: [PATCH 06/14] Add test of Debug representation of Backtrace --- src/libstd/backtrace.rs | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index 04fd80ecbdb23..f3dd7a62fcbb8 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -433,3 +433,55 @@ impl RawFrame { } } } + +#[test] +fn test_debug() { + let backtrace = Backtrace { + inner: Inner::Captured(Mutex::new(Capture { + actual_start: 1, + resolved: true, + frames: vec![ + BacktraceFrame { + frame: RawFrame::Fake, + symbols: vec![BacktraceSymbol { + name: Some(b"std::backtrace::Backtrace::create".to_vec()), + filename: Some(BytesOrWide::Bytes(b"/rust/backtrace.rs".to_vec())), + lineno: Some(100), + }], + }, + BacktraceFrame { + frame: RawFrame::Fake, + symbols: vec![BacktraceSymbol { + name: Some(b"__rust_maybe_catch_panic".to_vec()), + filename: None, + lineno: None, + }], + }, + BacktraceFrame { + frame: RawFrame::Fake, + symbols: vec![ + BacktraceSymbol { + name: Some(b"std::rt::lang_start_internal".to_vec()), + filename: Some(BytesOrWide::Bytes(b"/rust/rt.rs".to_vec())), + lineno: Some(300), + }, + BacktraceSymbol { + name: Some(b"std::rt::lang_start".to_vec()), + filename: Some(BytesOrWide::Bytes(b"/rust/rt.rs".to_vec())), + lineno: Some(400), + }, + ], + }, + ], + })), + }; + + #[rustfmt::skip] + let expected = "Backtrace [\ + \n { fn: \"__rust_maybe_catch_panic\" },\ + \n { fn: \"std::rt::lang_start_internal\", file: \"/rust/rt.rs\", line: 300 },\ + \n { fn: \"std::rt::lang_start\", file: \"/rust/rt.rs\", line: 400 },\ + \n]"; + + assert_eq!(format!("{:#?}", backtrace), expected); +} From a2364dc85fb505487c272988b8c5073a3f6fef2a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 9 Mar 2020 12:23:19 -0700 Subject: [PATCH 07/14] Write backtrace fmt test using relative paths For some reason the absolute paths were formatted differently on the armhf-gnu target. thread '' panicked at 'assertion failed: `(left == right)` left: `"Backtrace [\n { fn: \"__rust_maybe_catch_panic\" },\n { fn: \"std::rt::lang_start_internal\", file: \"./rust/rt.rs\", line: 300 },\n { fn: \"std::rt::lang_start\", file: \"./rust/rt.rs\", line: 400 },\n]"`, right: `"Backtrace [\n { fn: \"__rust_maybe_catch_panic\" },\n { fn: \"std::rt::lang_start_internal\", file: \"/rust/rt.rs\", line: 300 },\n { fn: \"std::rt::lang_start\", file: \"/rust/rt.rs\", line: 400 },\n]"`', src/libstd/backtrace.rs:486:5 --- src/libstd/backtrace.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index f3dd7a62fcbb8..34317c7a2ee3d 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -445,7 +445,7 @@ fn test_debug() { frame: RawFrame::Fake, symbols: vec![BacktraceSymbol { name: Some(b"std::backtrace::Backtrace::create".to_vec()), - filename: Some(BytesOrWide::Bytes(b"/rust/backtrace.rs".to_vec())), + filename: Some(BytesOrWide::Bytes(b"rust/backtrace.rs".to_vec())), lineno: Some(100), }], }, @@ -462,12 +462,12 @@ fn test_debug() { symbols: vec![ BacktraceSymbol { name: Some(b"std::rt::lang_start_internal".to_vec()), - filename: Some(BytesOrWide::Bytes(b"/rust/rt.rs".to_vec())), + filename: Some(BytesOrWide::Bytes(b"rust/rt.rs".to_vec())), lineno: Some(300), }, BacktraceSymbol { name: Some(b"std::rt::lang_start".to_vec()), - filename: Some(BytesOrWide::Bytes(b"/rust/rt.rs".to_vec())), + filename: Some(BytesOrWide::Bytes(b"rust/rt.rs".to_vec())), lineno: Some(400), }, ], @@ -479,8 +479,8 @@ fn test_debug() { #[rustfmt::skip] let expected = "Backtrace [\ \n { fn: \"__rust_maybe_catch_panic\" },\ - \n { fn: \"std::rt::lang_start_internal\", file: \"/rust/rt.rs\", line: 300 },\ - \n { fn: \"std::rt::lang_start\", file: \"/rust/rt.rs\", line: 400 },\ + \n { fn: \"std::rt::lang_start_internal\", file: \"rust/rt.rs\", line: 300 },\ + \n { fn: \"std::rt::lang_start\", file: \"rust/rt.rs\", line: 400 },\ \n]"; assert_eq!(format!("{:#?}", backtrace), expected); From cdc730457e9030feaf8c4376a668a9ef61c7f189 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 6 Mar 2020 11:20:27 +0100 Subject: [PATCH 08/14] Compute the correct layout for variants of uninhabited enums and readd a long lost assertion This reverts part of commit 9712fa405944cb8d5416556ac4b1f26365a10658. --- src/librustc/ty/layout.rs | 14 +++++++++++--- src/librustc_mir/interpret/operand.rs | 2 +- src/librustc_mir/interpret/place.rs | 8 -------- src/librustc_target/abi/mod.rs | 6 +++++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index dedb3035cedb3..f616d81603775 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -782,8 +782,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { present_first @ Some(_) => present_first, // Uninhabited because it has no variants, or only absent ones. None if def.is_enum() => return tcx.layout_raw(param_env.and(tcx.types.never)), - // if it's a struct, still compute a layout so that we can still compute the - // field offsets + // If it's a struct, still compute a layout so that we can still compute the + // field offsets. None => Some(VariantIdx::new(0)), }; @@ -1990,7 +1990,15 @@ where { fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> { let details = match this.variants { - Variants::Single { index } if index == variant_index => this.details, + Variants::Single { index } + // If all variants but one are uninhabited, the variant layout is the enum layout. + if index == variant_index && + // Don't confuse variants of uninhabited enums with the enum itself. + // For more details see https://github.com/rust-lang/rust/issues/69763. + this.fields != FieldPlacement::Union(0) => + { + this.details + } Variants::Single { index } => { // Deny calling for_variant more than once for non-Single enums. diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 22b1a7b7137d9..5d035bbeb27c7 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -356,7 +356,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> { let base = match op.try_as_mplace(self) { Ok(mplace) => { - // The easy case + // We can reuse the mplace field computation logic for indirect operands let field = self.mplace_field(mplace, field)?; return Ok(field.into()); } diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index a4815b9696ebb..856c654980ab7 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -410,14 +410,6 @@ where stride * field } layout::FieldPlacement::Union(count) => { - // This is a narrow bug-fix for rust-lang/rust#69191: if we are - // trying to access absent field of uninhabited variant, then - // signal UB (but don't ICE the compiler). - // FIXME temporary hack to work around incoherence between - // layout computation and MIR building - if field >= count as u64 && base.layout.abi == layout::Abi::Uninhabited { - throw_ub!(Unreachable); - } assert!( field < count as u64, "Tried to access field {} of union {:#?} with {} fields", diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 2f8bbd66c322b..681326b0f150a 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -660,7 +660,11 @@ impl FieldPlacement { pub fn offset(&self, i: usize) -> Size { match *self { - FieldPlacement::Union(_) => Size::ZERO, + FieldPlacement::Union(count) => { + assert!(i < count, + "Tried to access field {} of union with {} fields", i, count); + Size::ZERO + }, FieldPlacement::Array { stride, count } => { let i = i as u64; assert!(i < count); From ec88ffa38cee51fa7290aa6c99d928ffe346ca6c Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 11 Mar 2020 13:57:54 +0100 Subject: [PATCH 09/14] Comment nits Co-Authored-By: Ralf Jung --- src/librustc_mir/interpret/operand.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 5d035bbeb27c7..07c0f76e03a7e 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -356,7 +356,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> { let base = match op.try_as_mplace(self) { Ok(mplace) => { - // We can reuse the mplace field computation logic for indirect operands + // We can reuse the mplace field computation logic for indirect operands. let field = self.mplace_field(mplace, field)?; return Ok(field.into()); } From 74608c7f206171cb72c020a03800b2d9035a35fa Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 11 Mar 2020 14:31:07 +0100 Subject: [PATCH 10/14] Rustfmt and adjust capitalization --- src/librustc_target/abi/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 681326b0f150a..afa30e7e632a7 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -661,10 +661,9 @@ impl FieldPlacement { pub fn offset(&self, i: usize) -> Size { match *self { FieldPlacement::Union(count) => { - assert!(i < count, - "Tried to access field {} of union with {} fields", i, count); + assert!(i < count, "tried to access field {} of union with {} fields", i, count); Size::ZERO - }, + } FieldPlacement::Array { stride, count } => { let i = i as u64; assert!(i < count); From 543832b06c7fccd570a85e2f30a447303fd58602 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 11 Mar 2020 09:19:59 -0700 Subject: [PATCH 11/14] Regenerate tables for Unicode 13.0.0 --- src/libcore/unicode/printable.rs | 173 ++++--- src/libcore/unicode/unicode_data.rs | 734 ++++++++++++++-------------- 2 files changed, 462 insertions(+), 445 deletions(-) diff --git a/src/libcore/unicode/printable.rs b/src/libcore/unicode/printable.rs index eee9ea52ef0d2..9680aa14d3b54 100644 --- a/src/libcore/unicode/printable.rs +++ b/src/libcore/unicode/printable.rs @@ -44,7 +44,7 @@ pub(crate) fn is_printable(x: char) -> bool { } else if x < 0x20000 { check(lower, SINGLETONS1U, SINGLETONS1L, NORMAL1) } else { - if 0x2a6d7 <= x && x < 0x2a700 { + if 0x2a6de <= x && x < 0x2a700 { return false; } if 0x2b735 <= x && x < 0x2b740 { @@ -59,7 +59,10 @@ pub(crate) fn is_printable(x: char) -> bool { if 0x2ebe1 <= x && x < 0x2f800 { return false; } - if 0x2fa1e <= x && x < 0xe0100 { + if 0x2fa1e <= x && x < 0x30000 { + return false; + } + if 0x3134b <= x && x < 0xe0100 { return false; } if 0xe01f0 <= x && x < 0x110000 { @@ -81,7 +84,7 @@ const SINGLETONS0U: &[(u8, u8)] = &[ (0x0a, 28), (0x0b, 25), (0x0c, 20), - (0x0d, 18), + (0x0d, 16), (0x0e, 13), (0x0f, 4), (0x10, 3), @@ -96,7 +99,7 @@ const SINGLETONS0U: &[(u8, u8)] = &[ (0x1d, 1), (0x1f, 22), (0x20, 3), - (0x2b, 4), + (0x2b, 3), (0x2c, 2), (0x2d, 11), (0x2e, 1), @@ -129,29 +132,29 @@ const SINGLETONS0L: &[u8] = &[ 0x4a, 0x5e, 0x64, 0x65, 0x84, 0x91, 0x9b, 0x9d, 0xc9, 0xce, 0xcf, 0x0d, 0x11, 0x29, 0x45, 0x49, 0x57, 0x64, 0x65, 0x8d, 0x91, 0xa9, 0xb4, 0xba, - 0xbb, 0xc5, 0xc9, 0xdf, 0xe4, 0xe5, 0xf0, 0x04, - 0x0d, 0x11, 0x45, 0x49, 0x64, 0x65, 0x80, 0x81, - 0x84, 0xb2, 0xbc, 0xbe, 0xbf, 0xd5, 0xd7, 0xf0, - 0xf1, 0x83, 0x85, 0x8b, 0xa4, 0xa6, 0xbe, 0xbf, - 0xc5, 0xc7, 0xce, 0xcf, 0xda, 0xdb, 0x48, 0x98, - 0xbd, 0xcd, 0xc6, 0xce, 0xcf, 0x49, 0x4e, 0x4f, - 0x57, 0x59, 0x5e, 0x5f, 0x89, 0x8e, 0x8f, 0xb1, - 0xb6, 0xb7, 0xbf, 0xc1, 0xc6, 0xc7, 0xd7, 0x11, - 0x16, 0x17, 0x5b, 0x5c, 0xf6, 0xf7, 0xfe, 0xff, - 0x80, 0x0d, 0x6d, 0x71, 0xde, 0xdf, 0x0e, 0x0f, - 0x1f, 0x6e, 0x6f, 0x1c, 0x1d, 0x5f, 0x7d, 0x7e, - 0xae, 0xaf, 0xbb, 0xbc, 0xfa, 0x16, 0x17, 0x1e, - 0x1f, 0x46, 0x47, 0x4e, 0x4f, 0x58, 0x5a, 0x5c, - 0x5e, 0x7e, 0x7f, 0xb5, 0xc5, 0xd4, 0xd5, 0xdc, - 0xf0, 0xf1, 0xf5, 0x72, 0x73, 0x8f, 0x74, 0x75, - 0x96, 0x97, 0x2f, 0x5f, 0x26, 0x2e, 0x2f, 0xa7, - 0xaf, 0xb7, 0xbf, 0xc7, 0xcf, 0xd7, 0xdf, 0x9a, - 0x40, 0x97, 0x98, 0x30, 0x8f, 0x1f, 0xc0, 0xc1, - 0xce, 0xff, 0x4e, 0x4f, 0x5a, 0x5b, 0x07, 0x08, - 0x0f, 0x10, 0x27, 0x2f, 0xee, 0xef, 0x6e, 0x6f, - 0x37, 0x3d, 0x3f, 0x42, 0x45, 0x90, 0x91, 0xfe, - 0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9, 0xd0, 0xd1, - 0xd8, 0xd9, 0xe7, 0xfe, 0xff, + 0xbb, 0xc5, 0xc9, 0xdf, 0xe4, 0xe5, 0xf0, 0x0d, + 0x11, 0x45, 0x49, 0x64, 0x65, 0x80, 0x84, 0xb2, + 0xbc, 0xbe, 0xbf, 0xd5, 0xd7, 0xf0, 0xf1, 0x83, + 0x85, 0x8b, 0xa4, 0xa6, 0xbe, 0xbf, 0xc5, 0xc7, + 0xce, 0xcf, 0xda, 0xdb, 0x48, 0x98, 0xbd, 0xcd, + 0xc6, 0xce, 0xcf, 0x49, 0x4e, 0x4f, 0x57, 0x59, + 0x5e, 0x5f, 0x89, 0x8e, 0x8f, 0xb1, 0xb6, 0xb7, + 0xbf, 0xc1, 0xc6, 0xc7, 0xd7, 0x11, 0x16, 0x17, + 0x5b, 0x5c, 0xf6, 0xf7, 0xfe, 0xff, 0x80, 0x0d, + 0x6d, 0x71, 0xde, 0xdf, 0x0e, 0x0f, 0x1f, 0x6e, + 0x6f, 0x1c, 0x1d, 0x5f, 0x7d, 0x7e, 0xae, 0xaf, + 0xbb, 0xbc, 0xfa, 0x16, 0x17, 0x1e, 0x1f, 0x46, + 0x47, 0x4e, 0x4f, 0x58, 0x5a, 0x5c, 0x5e, 0x7e, + 0x7f, 0xb5, 0xc5, 0xd4, 0xd5, 0xdc, 0xf0, 0xf1, + 0xf5, 0x72, 0x73, 0x8f, 0x74, 0x75, 0x96, 0x2f, + 0x5f, 0x26, 0x2e, 0x2f, 0xa7, 0xaf, 0xb7, 0xbf, + 0xc7, 0xcf, 0xd7, 0xdf, 0x9a, 0x40, 0x97, 0x98, + 0x30, 0x8f, 0x1f, 0xc0, 0xc1, 0xce, 0xff, 0x4e, + 0x4f, 0x5a, 0x5b, 0x07, 0x08, 0x0f, 0x10, 0x27, + 0x2f, 0xee, 0xef, 0x6e, 0x6f, 0x37, 0x3d, 0x3f, + 0x42, 0x45, 0x90, 0x91, 0xfe, 0xff, 0x53, 0x67, + 0x75, 0xc8, 0xc9, 0xd0, 0xd1, 0xd8, 0xd9, 0xe7, + 0xfe, 0xff, ]; #[rustfmt::skip] const SINGLETONS1U: &[(u8, u8)] = &[ @@ -163,14 +166,15 @@ const SINGLETONS1U: &[(u8, u8)] = &[ (0x09, 2), (0x0a, 5), (0x0b, 2), + (0x0e, 4), (0x10, 1), - (0x11, 4), + (0x11, 2), (0x12, 5), (0x13, 17), - (0x14, 2), + (0x14, 1), (0x15, 2), (0x17, 2), - (0x19, 4), + (0x19, 13), (0x1c, 5), (0x1d, 8), (0x24, 1), @@ -188,32 +192,35 @@ const SINGLETONS1U: &[(u8, u8)] = &[ (0xe8, 2), (0xee, 32), (0xf0, 4), - (0xf9, 6), + (0xf8, 2), + (0xf9, 2), (0xfa, 2), + (0xfb, 1), ]; #[rustfmt::skip] const SINGLETONS1L: &[u8] = &[ 0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e, 0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e, 0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18, 0x36, - 0x37, 0x56, 0x57, 0xbd, 0x35, 0xce, 0xcf, 0xe0, - 0x12, 0x87, 0x89, 0x8e, 0x9e, 0x04, 0x0d, 0x0e, - 0x11, 0x12, 0x29, 0x31, 0x34, 0x3a, 0x45, 0x46, - 0x49, 0x4a, 0x4e, 0x4f, 0x64, 0x65, 0x5a, 0x5c, - 0xb6, 0xb7, 0x1b, 0x1c, 0xa8, 0xa9, 0xd8, 0xd9, - 0x09, 0x37, 0x90, 0x91, 0xa8, 0x07, 0x0a, 0x3b, - 0x3e, 0x66, 0x69, 0x8f, 0x92, 0x6f, 0x5f, 0xee, - 0xef, 0x5a, 0x62, 0x9a, 0x9b, 0x27, 0x28, 0x55, - 0x9d, 0xa0, 0xa1, 0xa3, 0xa4, 0xa7, 0xa8, 0xad, - 0xba, 0xbc, 0xc4, 0x06, 0x0b, 0x0c, 0x15, 0x1d, - 0x3a, 0x3f, 0x45, 0x51, 0xa6, 0xa7, 0xcc, 0xcd, - 0xa0, 0x07, 0x19, 0x1a, 0x22, 0x25, 0x3e, 0x3f, - 0xc5, 0xc6, 0x04, 0x20, 0x23, 0x25, 0x26, 0x28, - 0x33, 0x38, 0x3a, 0x48, 0x4a, 0x4c, 0x50, 0x53, - 0x55, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x63, - 0x65, 0x66, 0x6b, 0x73, 0x78, 0x7d, 0x7f, 0x8a, - 0xa4, 0xaa, 0xaf, 0xb0, 0xc0, 0xd0, 0x0c, 0x72, - 0xa3, 0xa4, 0xcb, 0xcc, 0x6e, 0x6f, + 0x37, 0x56, 0x57, 0x7f, 0xaa, 0xae, 0xaf, 0xbd, + 0x35, 0xe0, 0x12, 0x87, 0x89, 0x8e, 0x9e, 0x04, + 0x0d, 0x0e, 0x11, 0x12, 0x29, 0x31, 0x34, 0x3a, + 0x45, 0x46, 0x49, 0x4a, 0x4e, 0x4f, 0x64, 0x65, + 0x5c, 0xb6, 0xb7, 0x1b, 0x1c, 0x07, 0x08, 0x0a, + 0x0b, 0x14, 0x17, 0x36, 0x39, 0x3a, 0xa8, 0xa9, + 0xd8, 0xd9, 0x09, 0x37, 0x90, 0x91, 0xa8, 0x07, + 0x0a, 0x3b, 0x3e, 0x66, 0x69, 0x8f, 0x92, 0x6f, + 0x5f, 0xee, 0xef, 0x5a, 0x62, 0x9a, 0x9b, 0x27, + 0x28, 0x55, 0x9d, 0xa0, 0xa1, 0xa3, 0xa4, 0xa7, + 0xa8, 0xad, 0xba, 0xbc, 0xc4, 0x06, 0x0b, 0x0c, + 0x15, 0x1d, 0x3a, 0x3f, 0x45, 0x51, 0xa6, 0xa7, + 0xcc, 0xcd, 0xa0, 0x07, 0x19, 0x1a, 0x22, 0x25, + 0x3e, 0x3f, 0xc5, 0xc6, 0x04, 0x20, 0x23, 0x25, + 0x26, 0x28, 0x33, 0x38, 0x3a, 0x48, 0x4a, 0x4c, + 0x50, 0x53, 0x55, 0x56, 0x58, 0x5a, 0x5c, 0x5e, + 0x60, 0x63, 0x65, 0x66, 0x6b, 0x73, 0x78, 0x7d, + 0x7f, 0x8a, 0xa4, 0xaa, 0xaf, 0xb0, 0xc0, 0xd0, + 0xae, 0xaf, 0x79, 0xcc, 0x6e, 0x6f, 0x93, ]; #[rustfmt::skip] const NORMAL0: &[u8] = &[ @@ -225,7 +232,7 @@ const NORMAL0: &[u8] = &[ 0x06, 0x11, 0x81, 0xac, 0x0e, 0x80, 0xab, 0x35, - 0x1e, 0x15, + 0x28, 0x0b, 0x80, 0xe0, 0x03, 0x19, 0x08, 0x01, 0x04, @@ -237,8 +244,8 @@ const NORMAL0: &[u8] = &[ 0x11, 0x0a, 0x50, 0x0f, 0x12, 0x07, - 0x55, 0x08, - 0x02, 0x04, + 0x55, 0x07, + 0x03, 0x04, 0x1c, 0x0a, 0x09, 0x03, 0x08, 0x03, @@ -292,7 +299,7 @@ const NORMAL0: &[u8] = &[ 0x0b, 0x03, 0x80, 0xac, 0x06, 0x0a, 0x06, - 0x1f, 0x41, + 0x21, 0x3f, 0x4c, 0x04, 0x2d, 0x03, 0x74, 0x08, @@ -315,21 +322,19 @@ const NORMAL0: &[u8] = &[ 0x3b, 0x07, 0x02, 0x0e, 0x18, 0x09, - 0x80, 0xb0, 0x30, + 0x80, 0xb3, 0x2d, 0x74, 0x0c, 0x80, 0xd6, 0x1a, 0x0c, 0x05, 0x80, 0xff, 0x05, - 0x80, 0xb6, 0x05, - 0x24, 0x0c, - 0x9b, 0xc6, 0x0a, - 0xd2, 0x30, 0x10, + 0x80, 0xdf, 0x0c, + 0xee, 0x0d, 0x03, 0x84, 0x8d, 0x03, 0x37, 0x09, 0x81, 0x5c, 0x14, 0x80, 0xb8, 0x08, - 0x80, 0xc7, 0x30, - 0x35, 0x04, + 0x80, 0xcb, 0x2a, + 0x38, 0x03, 0x0a, 0x06, 0x38, 0x08, 0x46, 0x08, @@ -341,7 +346,7 @@ const NORMAL0: &[u8] = &[ 0x80, 0x83, 0x18, 0x1c, 0x0a, 0x16, 0x09, - 0x48, 0x08, + 0x4c, 0x04, 0x80, 0x8a, 0x06, 0xab, 0xa4, 0x0c, 0x17, 0x04, @@ -365,7 +370,7 @@ const NORMAL1: &[u8] = &[ 0x7b, 0x05, 0x03, 0x04, 0x2d, 0x03, - 0x65, 0x04, + 0x66, 0x03, 0x01, 0x2f, 0x2e, 0x80, 0x82, 0x1d, 0x03, @@ -410,16 +415,17 @@ const NORMAL1: &[u8] = &[ 0x33, 0x07, 0x2e, 0x08, 0x0a, 0x81, 0x26, - 0x1f, 0x80, 0x81, + 0x52, 0x4e, 0x28, 0x08, - 0x2a, 0x80, 0x86, + 0x2a, 0x56, + 0x1c, 0x14, 0x17, 0x09, 0x4e, 0x04, 0x1e, 0x0f, 0x43, 0x0e, 0x19, 0x07, 0x0a, 0x06, - 0x47, 0x09, + 0x48, 0x08, 0x27, 0x09, 0x75, 0x0b, 0x3f, 0x41, @@ -430,7 +436,7 @@ const NORMAL1: &[u8] = &[ 0x01, 0x05, 0x10, 0x03, 0x05, 0x80, 0x8b, - 0x60, 0x20, + 0x62, 0x1e, 0x48, 0x08, 0x0a, 0x80, 0xa6, 0x5e, 0x22, @@ -443,7 +449,8 @@ const NORMAL1: &[u8] = &[ 0x10, 0x80, 0xc0, 0x3c, 0x64, 0x53, 0x0c, - 0x01, 0x80, 0xa0, + 0x48, 0x09, + 0x0a, 0x46, 0x45, 0x1b, 0x48, 0x08, 0x53, 0x1d, @@ -456,7 +463,8 @@ const NORMAL1: &[u8] = &[ 0x0a, 0x06, 0x39, 0x07, 0x0a, 0x81, 0x36, - 0x19, 0x80, 0xc7, + 0x19, 0x80, 0xb7, + 0x01, 0x0f, 0x32, 0x0d, 0x83, 0x9b, 0x66, 0x75, 0x0b, @@ -474,9 +482,11 @@ const NORMAL1: &[u8] = &[ 0x4b, 0x04, 0x39, 0x07, 0x11, 0x40, - 0x04, 0x1c, + 0x05, 0x0b, + 0x02, 0x0e, 0x97, 0xf8, 0x08, - 0x82, 0xf3, 0xa5, 0x0d, + 0x84, 0xd6, 0x2a, + 0x09, 0xa2, 0xf7, 0x81, 0x1f, 0x31, 0x03, 0x11, 0x04, 0x08, @@ -515,17 +525,15 @@ const NORMAL1: &[u8] = &[ 0x2c, 0x04, 0x64, 0x0c, 0x56, 0x0a, - 0x0d, 0x03, - 0x5d, 0x03, - 0x3d, 0x39, + 0x80, 0xae, 0x38, 0x1d, 0x0d, 0x2c, 0x04, 0x09, 0x07, 0x02, 0x0e, 0x06, 0x80, 0x9a, - 0x83, 0xd6, 0x0a, + 0x83, 0xd8, 0x08, + 0x0d, 0x03, 0x0d, 0x03, - 0x0b, 0x05, 0x74, 0x0c, 0x59, 0x07, 0x0c, 0x14, @@ -533,12 +541,15 @@ const NORMAL1: &[u8] = &[ 0x38, 0x08, 0x0a, 0x06, 0x28, 0x08, - 0x1e, 0x52, - 0x77, 0x03, - 0x31, 0x03, - 0x80, 0xa6, 0x0c, - 0x14, 0x04, + 0x22, 0x4e, + 0x81, 0x54, 0x0c, + 0x15, 0x03, 0x03, 0x05, + 0x07, 0x09, + 0x19, 0x07, + 0x07, 0x09, 0x03, 0x0d, - 0x06, 0x85, 0x6a, + 0x07, 0x29, + 0x80, 0xcb, 0x25, + 0x0a, 0x84, 0x06, ]; diff --git a/src/libcore/unicode/unicode_data.rs b/src/libcore/unicode/unicode_data.rs index da4cd4e9b1da1..3e90028613ce1 100644 --- a/src/libcore/unicode/unicode_data.rs +++ b/src/libcore/unicode/unicode_data.rs @@ -1,128 +1,130 @@ ///! This file is generated by src/tools/unicode-table-generator; do not edit manually! use super::range_search; -pub const UNICODE_VERSION: (u32, u32, u32) = (12, 1, 0); +pub const UNICODE_VERSION: (u32, u32, u32) = (13, 0, 0); #[rustfmt::skip] pub mod alphabetic { - static BITSET_LAST_CHUNK_MAP: (u16, u8) = (190, 37); - static BITSET_CHUNKS_MAP: [u8; 187] = [ - 6, 32, 10, 18, 19, 23, 21, 12, 7, 5, 0, 20, 14, 49, 49, 49, 49, 49, 49, 36, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 47, 49, 30, 8, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 45, 0, 0, 0, 0, 0, 0, 0, 0, 4, 35, 17, 31, 16, 25, 24, 26, 13, 15, - 44, 27, 0, 0, 49, 11, 0, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0, 0, 38, 1, 49, 49, 49, 49, 49, 48, - 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 28, 0, 0, 0, 0, 0, 29, 0, 0, 9, 0, 33, 2, 3, 0, 0, - 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 41, 49, 49, 49, - 43, 22, 49, 49, 49, 49, 40, 49, 49, 49, 49, 49, 49, 46, + static BITSET_LAST_CHUNK_MAP: (u16, u8) = (196, 44); + static BITSET_CHUNKS_MAP: [u8; 196] = [ + 6, 32, 10, 18, 19, 23, 21, 12, 7, 5, 0, 20, 14, 50, 50, 50, 50, 50, 50, 37, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 49, 50, 30, 8, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 46, 0, 0, 0, 0, 0, 0, 0, 0, 4, 36, 17, 31, 16, 25, 24, 26, 13, 15, + 45, 27, 0, 0, 50, 11, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 39, 1, 50, 50, 50, 50, 50, 48, + 50, 34, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 28, 0, 0, 0, 0, 0, 29, 0, 0, 9, 0, 33, 2, 3, 0, 0, + 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 42, 50, 50, 50, + 43, 22, 50, 50, 50, 50, 41, 50, 50, 50, 50, 50, 50, 47, 0, 0, 0, 38, 0, 50, 50, 50, 50, ]; - static BITSET_INDEX_CHUNKS: [[u8; 16]; 50] = [ + static BITSET_INDEX_CHUNKS: [[u8; 16]; 51] = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 0, 0, 248, 241, 38, 40], - [0, 0, 0, 0, 0, 0, 0, 0, 108, 133, 110, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 190, 200, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 248, 248, 248, 248, 248, 205, 248, 23, 134, 245, 68, 237], - [0, 0, 179, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 103, 99, 176, 248, 248, 248, 248, 248, 248, 248, 61, 0, 151, 217, 178], - [0, 145, 28, 0, 168, 221, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [48, 77, 248, 165, 201, 120, 184, 137, 91, 175, 143, 83, 206, 196, 248, 56], - [53, 0, 0, 0, 126, 15, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0], - [59, 54, 127, 199, 167, 186, 157, 114, 154, 84, 160, 115, 158, 66, 155, 21], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 0, 0, 254, 247, 39, 68], + [0, 0, 0, 0, 0, 0, 0, 0, 111, 135, 113, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 195, 205, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 254, 254, 254, 254, 254, 210, 254, 25, 136, 251, 71, 243], + [0, 0, 182, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 107, 103, 180, 254, 254, 254, 254, 254, 254, 254, 61, 0, 155, 222, 181], + [0, 148, 30, 0, 172, 226, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [48, 80, 254, 169, 206, 123, 189, 139, 95, 179, 145, 86, 211, 204, 254, 56], + [53, 0, 0, 0, 129, 17, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0], + [59, 54, 185, 203, 171, 191, 161, 117, 158, 87, 164, 118, 162, 67, 159, 23], [62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [91, 129, 164, 101, 248, 248, 248, 79, 248, 248, 248, 248, 230, 128, 135, 117], - [97, 0, 220, 144, 0, 0, 212, 44, 142, 240, 30, 97, 0, 0, 0, 0], - [116, 247, 219, 171, 188, 248, 104, 190, 0, 0, 0, 0, 0, 0, 0, 0], - [141, 185, 88, 0, 149, 213, 22, 0, 0, 0, 0, 89, 0, 0, 0, 0], - [147, 90, 35, 82, 98, 0, 153, 0, 85, 119, 29, 45, 86, 71, 18, 0], - [150, 32, 248, 107, 0, 81, 0, 0, 0, 0, 227, 17, 211, 105, 231, 19], - [162, 41, 161, 69, 163, 173, 123, 73, 106, 14, 124, 37, 1, 187, 121, 0], - [172, 240, 228, 170, 248, 248, 248, 248, 248, 229, 138, 235, 234, 24, 222, 125], - [208, 233, 248, 74, 204, 64, 140, 232, 63, 0, 0, 0, 0, 0, 0, 0], - [220, 97, 202, 86, 94, 78, 203, 9, 226, 80, 46, 0, 183, 11, 174, 67], - [231, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248], - [247, 248, 248, 248, 248, 248, 248, 248, 248, 209, 225, 95, 76, 75, 180, 25], - [248, 5, 96, 50, 72, 87, 248, 26, 132, 0, 198, 51, 159, 42, 0, 0], - [248, 8, 72, 72, 49, 0, 0, 0, 0, 0, 0, 0, 194, 5, 0, 89], - [248, 36, 248, 7, 0, 0, 139, 31, 143, 3, 93, 0, 55, 0, 0, 0], - [248, 62, 248, 248, 248, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [248, 118, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [248, 236, 166, 246, 136, 239, 248, 248, 248, 248, 215, 169, 182, 207, 214, 12], - [248, 248, 13, 130, 248, 248, 248, 248, 57, 146, 248, 65, 218, 248, 243, 177], - [248, 248, 191, 111, 197, 43, 0, 0, 248, 248, 248, 248, 91, 47, 0, 0], - [248, 248, 244, 248, 189, 223, 152, 70, 224, 210, 248, 148, 240, 242, 68, 100], - [248, 248, 248, 4, 248, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [248, 248, 248, 248, 35, 195, 248, 248, 248, 248, 248, 113, 0, 0, 0, 0], - [248, 248, 248, 248, 131, 240, 238, 109, 0, 181, 248, 122, 102, 216, 143, 27], - [248, 248, 248, 248, 248, 248, 86, 0, 248, 248, 248, 248, 248, 248, 248, 248], - [248, 248, 248, 248, 248, 248, 248, 248, 33, 0, 0, 0, 0, 0, 0, 0], - [248, 248, 248, 248, 248, 248, 248, 248, 97, 35, 0, 60, 65, 156, 16, 0], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 6, 0, 0, 0, 0, 0, 0], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 192, 248, 248, 248, 248, 248], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 20, 248, 248, 248, 248], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 72, 0, 0, 0, 0], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 81, 248, 248, 248], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 23, 0], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 193, 112], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 39], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 65], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 92], - [248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248], + [95, 131, 168, 105, 254, 254, 254, 82, 254, 254, 254, 254, 236, 130, 137, 120], + [101, 0, 225, 146, 151, 2, 217, 45, 144, 246, 32, 101, 0, 0, 0, 0], + [119, 253, 224, 175, 193, 254, 227, 195, 0, 0, 0, 0, 0, 0, 0, 0], + [143, 190, 91, 0, 153, 218, 24, 0, 0, 0, 0, 92, 0, 0, 66, 0], + [150, 94, 37, 85, 102, 0, 157, 0, 88, 122, 31, 46, 89, 74, 20, 0], + [154, 34, 254, 110, 0, 84, 0, 0, 0, 0, 233, 19, 216, 108, 237, 21], + [166, 42, 165, 72, 167, 177, 126, 76, 109, 16, 127, 38, 1, 192, 124, 0], + [176, 246, 234, 174, 254, 254, 254, 254, 254, 235, 140, 241, 240, 26, 228, 128], + [213, 239, 254, 77, 209, 64, 142, 238, 63, 0, 0, 0, 0, 0, 0, 0], + [225, 101, 207, 89, 98, 81, 208, 10, 232, 83, 147, 1, 188, 13, 178, 70], + [237, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254], + [253, 254, 254, 254, 254, 254, 254, 254, 254, 214, 231, 99, 79, 78, 183, 27], + [254, 6, 100, 50, 75, 90, 254, 28, 134, 0, 202, 51, 163, 43, 0, 0], + [254, 9, 75, 75, 49, 0, 0, 0, 0, 0, 69, 0, 199, 6, 195, 93], + [254, 41, 254, 8, 0, 0, 141, 33, 145, 4, 97, 0, 55, 0, 0, 0], + [254, 62, 254, 254, 254, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [254, 121, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [254, 242, 170, 252, 138, 245, 254, 254, 254, 254, 220, 173, 186, 212, 219, 14], + [254, 254, 15, 132, 254, 254, 254, 254, 57, 149, 254, 65, 223, 254, 249, 187], + [254, 254, 196, 114, 201, 44, 0, 0, 254, 254, 254, 254, 95, 47, 0, 0], + [254, 254, 250, 254, 194, 229, 156, 73, 230, 215, 254, 152, 246, 248, 71, 104], + [254, 254, 254, 5, 254, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [254, 254, 254, 22, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [254, 254, 254, 254, 37, 200, 254, 254, 254, 254, 254, 116, 0, 0, 0, 0], + [254, 254, 254, 254, 133, 246, 244, 112, 0, 184, 254, 125, 106, 221, 145, 29], + [254, 254, 254, 254, 254, 254, 254, 0, 254, 254, 254, 254, 254, 254, 254, 254], + [254, 254, 254, 254, 254, 254, 254, 254, 35, 0, 0, 0, 0, 0, 0, 0], + [254, 254, 254, 254, 254, 254, 254, 254, 101, 37, 0, 60, 65, 160, 18, 0], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 7, 0, 0, 0, 0, 0, 0], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 197, 254, 254, 254, 254, 254], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 35, 254, 254, 254, 254], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 84, 254, 254, 254], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 11, 0, 0], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 25, 0], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 198, 115], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 40], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 96], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 125], + [254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254], ]; - static BITSET: [u64; 249] = [ - 0, 1, 15, 17, 31, 63, 127, 179, 511, 1023, 2191, 4079, 4087, 8191, 8319, 16384, 65535, - 131071, 262143, 4128527, 8388607, 8461767, 24870911, 67108863, 134217727, 276824575, - 335544350, 486341884, 536805376, 536870911, 553648127, 1056964608, 1073692671, 1073741823, - 1140785663, 2147483647, 2147485627, 4026540127, 4294934783, 8589934591, 47244640256, - 64548249055, 68191066527, 68719476735, 115913785343, 137438953215, 549755813888, - 1095220854783, 1099511627711, 1099511627775, 2199023190016, 2199023255551, 4398046511103, - 8641373536127, 8791831609343, 8795690369023, 8796093022207, 13198434443263, 17592186044415, - 35184321757183, 70368744112128, 88094074470339, 140737488355327, 140737488355328, - 141836999983103, 281474976710655, 563017343310239, 1125625028935679, 1125899906842623, - 1688915364814303, 2119858418286774, 2251795522912255, 2251799813685247, 3377704004976767, - 3509778554814463, 3905461007941631, 4503595333443583, 4503599627370495, 8796093022142464, - 9006649498927104, 9007192812290047, 9007199254740991, 15762594400829440, 17169970223906821, - 17732925109967239, 18014398491652207, 18014398509481983, 20266198323101808, - 36027697507139583, 36028792723996672, 36028792728190975, 36028797018963967, - 72057594037927935, 90071992547409919, 143851303137705983, 144053615424700415, - 144115188075855868, 144115188075855871, 288230371860938751, 297241973452963840, - 301749971126844416, 319718190147960832, 576460743713488896, 576460743847706622, - 576460748008488959, 576460752303359999, 576460752303423486, 576460752303423487, - 790380184120328175, 1152640029630136575, 1152917029519358975, 1152921504591118335, - 1152921504606845055, 1152921504606846975, 1153765996922689951, 2161727885562420159, - 2251241253188403424, 2295745090394464220, 2305570330330005503, 2305843004918726656, - 2305843004919250943, 2305843009196916483, 2305843009213693951, 3457638613854978028, - 4323455298678290390, 4557642822898941951, 4575692405780512767, 4602678814877679616, - 4611686017001275199, 4611686018360336384, 4611686018427322368, 4611686018427387903, - 4656722014700830719, 6843210385291930244, 6881498031078244479, 6908521828386340863, - 8935141660164089791, 8935423131384840192, 9168765891372858879, 9169328841326329855, - 9187201948305063935, 9187343239835811327, 9216616637413720063, 9223372036854775807, - 9223372041149743103, 9223934986808197120, 10371930679322607615, 10502394331027995967, - 11241233151490523135, 13006395723845991295, 13258596753222922239, 13609596598936928288, - 13834776580305453567, 13907115649320091647, 14082190885810440174, 14123225865944680428, - 16212958624174047247, 16412803692974677999, 16424062692043104238, 16424062692043104239, - 16424062692043243502, 16424625641996804079, 16429129241624174575, 16717361816799141871, - 16717361816799216127, 16788293510930366511, 17005555242810474495, 17293822569102704639, - 17581979622616071300, 17870283321271910397, 17870283321406070975, 17870283321406128127, - 17978369712463020031, 18158513764145585631, 18158781978395017215, 18194542490281852927, - 18410715276682199039, 18410715276690587772, 18428729675200069631, 18428729675200069632, - 18433233274827440127, 18437455399478099968, 18437736874452713471, 18442240474082181119, + static BITSET: [u64; 255] = [ + 0, 1, 7, 15, 17, 31, 63, 127, 179, 511, 1023, 2047, 2191, 4079, 4087, 8191, 8319, 16384, + 65535, 131071, 262143, 4128527, 4194303, 8461767, 24870911, 67108863, 134217727, 276824575, + 335593502, 486341884, 536805376, 536870911, 553648127, 1056964608, 1073692671, 1073741823, + 1140785663, 2147483647, 4026540127, 4294934783, 8589934591, 15032387515, 64548249055, + 68191066527, 68719476735, 115913785343, 137438953215, 1095220854783, 1099511627711, + 1099511627775, 2199023190016, 2199023255551, 4398046511103, 8641373536127, 8791831609343, + 8795690369023, 8796093022207, 13198434443263, 17592186044415, 35184321757183, + 70368744112128, 88094074470339, 140737488355327, 140737488355328, 141836999983103, + 281474976710655, 281474976710656, 563017343310239, 844472174772224, 875211255709695, + 1125625028935679, 1125899906842623, 1688915364814303, 2119858418286774, 2251795522912255, + 2251799813685247, 3377704004976767, 3509778554814463, 3905461007941631, 4503595333443583, + 4503599627370495, 8796093022142464, 9006649498927104, 9007192812290047, 9007199254740991, + 15762594400829440, 17169970223906821, 17732925109967239, 18014398491652207, + 18014398509481983, 20266198323101936, 36027697507139583, 36028792723996672, + 36028792723996703, 36028792728190975, 36028797018963967, 72057594037927935, + 90071992547409919, 143851303137705983, 144053615424700415, 144115188075855868, + 144115188075855871, 288230371860938751, 297241973452963840, 301749971126844416, + 319718190147960832, 576460743713488896, 576460743847706622, 576460752303359999, + 576460752303423486, 576460752303423487, 790380184120328175, 1152640029630136575, + 1152917029519358975, 1152921504591118335, 1152921504606845055, 1152921504606846975, + 1153765996922689951, 2161727885562420159, 2251241253188403424, 2295745090394464220, + 2305570330330005503, 2305843004918726656, 2305843004919250943, 2305843009196916483, + 2305843009213693951, 3457638613854978030, 4323455298678290390, 4557642822898941951, + 4575692405780512767, 4611686017001275199, 4611686018360336384, 4611686018427322368, + 4611686018427387903, 4656722014700830719, 6843210385291930244, 6881498031078244479, + 6908521828386340863, 8935141660164089791, 8935423131384840192, 9168765891372858879, + 9169328841326329855, 9187201948305063935, 9187343239835811327, 9216616637413720063, + 9223372036854775807, 9223372041149743103, 9223372586610589696, 9223934986808197120, + 10371930679322607615, 10502394331027995967, 11078855083321979519, 11241233151490523135, + 13006395723845991295, 13258596753222922239, 13609596598936928288, 13834776580305453567, + 13907115649320091647, 14082190885810440174, 14123225865944680428, 16212958624174047247, + 16412803692974677999, 16424062692043104238, 16424062692043104239, 16424062692043243502, + 16424625641996804079, 16429129241624174575, 16717361816799141887, 16717361816799216127, + 16788293510930366511, 17005555242810474495, 17293822569102704639, 17581979622616071300, + 17870283321271910397, 17870283321406070975, 17870283321406128127, 17978369712463020031, + 18158513764145585631, 18158781978395017215, 18194542490281852927, 18410715276682199039, + 18428729675200069631, 18428729675200069632, 18433233274827440127, 18437455399478099968, + 18437736870159843328, 18437736874452713471, 18437736874454812668, 18442240474082181119, 18444492273895866367, 18445618173802708993, 18446181192473632767, 18446216308128218879, 18446462598732840928, 18446462598732840959, 18446462598732840960, 18446462599806582783, 18446462615912710143, 18446462667452317695, 18446463149025525759, 18446463629525450752, - 18446463698110251007, 18446463698244468735, 18446464796682337663, 18446466966713532416, + 18446463698244468735, 18446464796682337663, 18446466966713532671, 18446466996645134335, 18446466996779287551, 18446471394825862144, 18446471394825863167, 18446480190918885375, 18446498607738650623, 18446532967477018623, 18446602782178705022, 18446603336221163519, 18446603336221196287, 18446638520593285119, 18446673709243564031, 18446708893632430079, 18446740770879700992, 18446741595513422027, 18446741874686295551, 18446743249075830783, 18446743798965862398, 18446744056529672000, 18446744060816261120, 18446744068886102015, - 18446744069414584320, 18446744069414601696, 18446744069414649855, 18446744069456527359, - 18446744069548736512, 18446744069548802046, 18446744069683019775, 18446744069951455231, - 18446744070421282815, 18446744070446333439, 18446744070475743231, 18446744070488326143, - 18446744071553646463, 18446744071562067967, 18446744073696837631, 18446744073701162813, - 18446744073707454463, 18446744073709027328, 18446744073709355007, 18446744073709419615, - 18446744073709486080, 18446744073709520895, 18446744073709543424, 18446744073709550079, - 18446744073709550595, 18446744073709551579, 18446744073709551599, 18446744073709551614, - 18446744073709551615, + 18446744069414584320, 18446744069414601696, 18446744069414617087, 18446744069414649855, + 18446744069456527359, 18446744069548736512, 18446744069548802046, 18446744069683019775, + 18446744069951455231, 18446744070421282815, 18446744070446333439, 18446744070475743231, + 18446744070488326143, 18446744071553646463, 18446744071562067967, 18446744073696837631, + 18446744073701162813, 18446744073707454463, 18446744073709027328, 18446744073709355007, + 18446744073709419615, 18446744073709486080, 18446744073709520895, 18446744073709543424, + 18446744073709550079, 18446744073709550595, 18446744073709551579, 18446744073709551599, + 18446744073709551614, 18446744073709551615, ]; pub fn lookup(c: char) -> bool { @@ -141,82 +143,83 @@ pub mod case_ignorable { static BITSET_LAST_CHUNK_MAP: (u16, u8) = (896, 33); static BITSET_CHUNKS_MAP: [u8; 125] = [ 25, 14, 21, 30, 28, 4, 17, 23, 22, 0, 0, 16, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 13, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 13, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 9, 0, 7, 11, 32, 31, 26, 29, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, - 10, 0, 8, 0, 20, 0, 12, 0, 1, + 10, 0, 8, 0, 19, 0, 12, 0, 1, ]; static BITSET_INDEX_CHUNKS: [[u8; 16]; 34] = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 164], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 47, 52], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 171, 2], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 88, 134, 38], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 94, 102, 6, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 76, 26, 0, 146, 136, 79, 43, 117], - [0, 0, 0, 0, 0, 0, 0, 0, 152, 0, 0, 58, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 165, 97, 75, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 48, 0, 114, 0, 0], - [0, 0, 0, 0, 0, 170, 68, 0, 0, 7, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0], - [0, 0, 0, 28, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 133, 0, 0, 0, 0, 15, 160, 45, 84, 51, 78, 12, 109], - [0, 0, 11, 0, 0, 30, 161, 90, 35, 80, 0, 69, 173, 13, 81, 129], - [0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 131, 0, 85, 0, 148, 0, 175, 73, 0, 0, 0, 0, 0, 0, 0], - [20, 4, 62, 0, 118, 0, 0, 0, 32, 154, 145, 0, 124, 89, 67, 86], - [25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [59, 0, 0, 150, 70, 24, 132, 60, 100, 122, 163, 99, 0, 46, 0, 66], - [63, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 74, 0, 0, 0, 0], - [71, 33, 0, 178, 123, 83, 120, 137, 121, 98, 121, 167, 153, 55, 3, 18], - [72, 149, 36, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [104, 133, 0, 110, 174, 105, 177, 166, 0, 0, 0, 0, 0, 0, 155, 139], - [107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [111, 50, 106, 0, 0, 0, 0, 0, 0, 0, 172, 179, 179, 112, 9, 0], - [113, 0, 0, 0, 0, 0, 0, 49, 142, 34, 31, 0, 0, 0, 0, 0], - [116, 0, 42, 141, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [140, 93, 37, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0], - [159, 0, 101, 0, 158, 10, 29, 0, 0, 0, 0, 91, 0, 0, 0, 0], - [162, 56, 153, 54, 125, 53, 0, 27, 115, 21, 126, 19, 108, 144, 127, 8], - [168, 41, 151, 5, 0, 0, 157, 39, 156, 1, 103, 0, 65, 0, 0, 0], - [169, 147, 130, 17, 96, 87, 143, 16, 138, 0, 0, 64, 125, 95, 0, 0], - [176, 179, 0, 0, 179, 179, 179, 77, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 47, 57], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 173, 3], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 94, 90, 136, 38], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 104, 7, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 78, 27, 0, 148, 138, 81, 44, 119], + [0, 0, 0, 0, 0, 0, 0, 0, 154, 0, 0, 58, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 167, 99, 77, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 130, 0, 0, 0, 48, 0, 116, 0, 0], + [0, 0, 0, 0, 0, 172, 70, 0, 0, 8, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 67, 0, 0, 24, 0, 0], + [0, 0, 0, 29, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 135, 0, 0, 0, 0, 16, 162, 46, 86, 51, 80, 13, 111], + [0, 0, 12, 0, 0, 43, 163, 92, 35, 82, 0, 71, 175, 14, 83, 131], + [0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 133, 0, 87, 0, 150, 0, 178, 75, 0, 0, 0, 0, 0, 0, 0], + [20, 5, 61, 0, 120, 0, 0, 0, 32, 156, 176, 1, 126, 91, 69, 88], + [26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [62, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 76, 0, 0, 0, 0], + [66, 0, 0, 152, 72, 25, 134, 59, 102, 124, 165, 101, 0, 64, 0, 68], + [73, 33, 0, 181, 125, 85, 122, 139, 123, 100, 123, 169, 155, 54, 4, 18], + [74, 151, 36, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [106, 135, 0, 112, 177, 107, 180, 168, 0, 0, 0, 0, 0, 0, 157, 142], + [109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [113, 50, 108, 0, 0, 0, 0, 0, 0, 0, 174, 182, 182, 114, 10, 0], + [115, 0, 0, 0, 141, 5, 0, 49, 145, 34, 31, 0, 0, 0, 0, 0], + [118, 0, 42, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [143, 95, 37, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0], + [161, 0, 103, 0, 160, 11, 30, 0, 0, 0, 0, 93, 0, 0, 0, 0], + [164, 55, 155, 53, 127, 52, 2, 28, 117, 21, 128, 19, 110, 147, 129, 9], + [170, 41, 153, 6, 0, 0, 159, 39, 158, 1, 105, 0, 65, 0, 0, 0], + [171, 149, 132, 17, 98, 89, 146, 23, 140, 0, 0, 63, 127, 97, 0, 0], + [179, 182, 0, 0, 182, 182, 182, 79, 0, 0, 0, 0, 0, 0, 0, 0], ]; - static BITSET: [u64; 180] = [ - 0, 1, 3, 4, 8, 13, 15, 28, 64, 176, 191, 1016, 1792, 2047, 4080, 4096, 7680, 8192, 8193, - 16192, 30720, 32704, 32768, 131008, 262016, 2097152, 2359296, 6030336, 8323072, 10682368, - 33554432, 58719232, 159383552, 234881024, 243138688, 402587711, 536805376, 536879204, - 546307648, 805306369, 1073741824, 1073741916, 2113929216, 3221225472, 3758096384, - 4026531840, 4160749568, 4294934528, 4294967296, 4512022528, 5368709120, 17179869183, - 47244640256, 51539615774, 51539619904, 51543810078, 51545914817, 66035122176, 412316860416, - 412316862532, 412316893184, 1030792151040, 2199023255648, 8641373536127, 8763880767488, - 17303886364672, 36421322670080, 65128884076547, 65970697670631, 68168642985984, - 70093866270720, 70368739983360, 136957967529984, 140737488355328, 263882790666240, - 281470547525648, 281470682333183, 281474976710655, 281474976710656, 281474976710657, - 281479271675905, 562675075514368, 562949953355776, 563001509683710, 844424930131968, - 985162418487296, 1023920203366400, 2251799813685248, 3377699721314304, 4494803534348292, - 4503599627370678, 6755399441055744, 7881299349733376, 8444256867844096, 8725724278030336, - 8760633772212225, 8989057312882695, 9042383626829823, 9851624185018758, 24822575045541890, - 28848986089586688, 30958948903026688, 35747322042253312, 53805701016846336, - 58529202969772032, 72066390130950143, 112767012056334336, 143833713099145216, - 189151184399892480, 216172782113783808, 220713756545974272, 288301294651703296, - 302022650010533887, 504262420777140224, 558446353793941504, 572520102629474304, - 593978171557150752, 1008806350890729472, 1009933895770046464, 1152921504606846976, - 1152921504606846978, 1152921504606846982, 1153202979583561736, 1441151880758558727, - 1715871458028158991, 1729382256910270467, 2301902359539744768, 2305843009196908767, - 2305843009213693952, 2612078987781865472, 2771965570646540291, 3458764513820540928, - 3731232291276455943, 4539628424389459968, 4589168020290535424, 4611404543450677248, - 4611686018494513280, 4611686069967003678, 4671217976001691648, 6917775322003857411, - 7421334051581067264, 8070450532247928832, 8788774672813524990, 9205357638345293827, - 9222809086901354496, 9223091111633879040, 9223372036854775808, 9223372036854775935, - 9223512774343131136, 9224216320050987008, 9224497932466651184, 9653465801268658176, - 9727775195120332910, 10376293541461622786, 11526998316797657088, 11529215046068469760, - 12103423998558208000, 12699025049277956096, 13005832773892571136, 13798747783286489088, - 13832665517980123136, 13835058055282032640, 13835058055282163729, 13951307220663664640, - 17870283321406128128, 17906312118425092095, 18158513697557839871, 18158513749097456062, - 18374686479671623680, 18374686479671623682, 18444496122186563584, 18445618173802708992, - 18446462598732840960, 18446462598733004800, 18446726481523507200, 18446744069414584320, - 18446744069414584322, 18446744073575333888, 18446744073709027328, 18446744073709551615, + static BITSET: [u64; 183] = [ + 0, 1, 2, 3, 4, 8, 13, 15, 28, 64, 176, 191, 1016, 1792, 2047, 4080, 4096, 8192, 8193, + 16192, 30720, 32704, 32768, 40448, 131008, 262016, 2097152, 2359296, 6030336, 8323072, + 10682368, 58719232, 159383552, 234881024, 243138688, 402587711, 536805376, 536879204, + 546307648, 805306369, 1073741824, 1073741916, 2113929216, 2181038080, 3221225472, + 3758096384, 4026531840, 4294934528, 4294967296, 4512022528, 5368709120, 17179869183, + 51539615774, 51539619904, 51545907230, 51545914817, 66035122176, 115964116992, 412316860416, + 412316893184, 1030792151040, 2199023255648, 8641373536127, 8763880767488, 15397323538432, + 17303886364672, 18004502906948, 26388279066624, 36421322670080, 65128884076547, + 65970697670631, 68168642985984, 70093866270720, 70368739983360, 136957967529984, + 140737488355328, 263882790666240, 281470547525648, 281470682333183, 281474976710655, + 281474976710656, 281474976710657, 281479271675905, 562675075514368, 562949953355776, + 563001509683710, 844424930131968, 985162418487296, 1023920203366400, 2251799813685248, + 3377699721314304, 4494803534348292, 4503599627370678, 6755399441055744, 7881299349733376, + 8444256867844096, 8725724278030336, 8760633772212225, 8989057312882695, 9042383626829823, + 9851624185018758, 24822575045541890, 28848986089586688, 30958948903026688, + 35747322042253312, 53805701016846336, 58529202969772032, 72066390130950143, + 112767012056334336, 143833713099145216, 189151184399892480, 216172782113783808, + 220713756545974272, 288301294651703296, 302022650010533887, 504262420777140224, + 558446353793941504, 572520102629474304, 593978171557150752, 1008806350890729472, + 1009933895770046464, 1152921504606846976, 1152921504606846978, 1152921504606846982, + 1153202979583561736, 1441151880758558727, 1715871458028158991, 1729382256910270467, + 2301902359539744768, 2305843009196908767, 2305843009213693952, 2612078987781865472, + 2771965570646540291, 3458764513820540928, 3731232291276455943, 4539628424389459968, + 4589168020290535424, 4611404543450677248, 4611686018494513280, 4611686069967003678, + 4671217976001691648, 6341068275337658368, 6917775322003857411, 7421334051581067264, + 8070450532247928832, 8788774672813524990, 9205357638345293827, 9222809086901354496, + 9223372036854775808, 9223372036854775935, 9223512774343131136, 9224216320050987008, + 9224497932466651184, 9653465801268658176, 9727775195120332910, 10376293541461622786, + 11526998316797657088, 11529215046068469760, 12103423998558208000, 12699025049277956096, + 13005832773892571136, 13798747783286489088, 13832665517980123136, 13835058055282032640, + 13835058055282163729, 13951307220663664640, 17870283321406128128, 17906312118425092095, + 18158513697557839871, 18158513749097456062, 18374686479671623680, 18374686479671623682, + 18444496122186563584, 18445618173802708992, 18446462598732840960, 18446462598733004800, + 18446463148488654848, 18446726481523507200, 18446744069414584320, 18446744069414584322, + 18446744073575333888, 18446744073709027328, 18446744073709551615, ]; pub fn lookup(c: char) -> bool { @@ -264,13 +267,13 @@ pub mod cased { static BITSET: [u64; 63] = [ 0, 15, 24, 511, 1023, 4087, 65535, 16253055, 134217726, 536805376, 1073741823, 4294967295, 133143986179, 4398046511103, 36009005809663, 70368744177663, 2251799813685247, - 3509778554814463, 144115188074807295, 297241973452963840, 504403158265495676, + 3509778554814463, 144115188074807295, 297241973452963840, 531424756029720572, 576460743713488896, 576460743847706622, 1152921504591118335, 2295745090394464220, 4557642822898941951, 4611686017001275199, 6908521828386340863, 8935141660164089791, 9223934986808197120, 13605092999309557792, 16717361816799216127, 16717361816799223999, 17005555242810474495, 17446871633794956420, 17870283321271910397, 17870283321406128127, 18410715276682199039, 18428729675200069631, 18428729675200069632, 18437736874452713471, - 18446462598732840959, 18446462598732840960, 18446463698110251007, 18446466996779287551, + 18446462598732840959, 18446462598732840960, 18446464797621878783, 18446466996779287551, 18446603336221163519, 18446603336221196287, 18446741874686295551, 18446743249075830783, 18446744056529672000, 18446744056529682432, 18446744069414584320, 18446744069414601696, 18446744069422972927, 18446744070475743231, 18446744071562067967, 18446744073707454463, @@ -317,72 +320,72 @@ pub mod grapheme_extend { static BITSET_LAST_CHUNK_MAP: (u16, u8) = (896, 30); static BITSET_CHUNKS_MAP: [u8; 123] = [ 4, 15, 21, 27, 25, 3, 18, 23, 17, 0, 0, 14, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, 10, 0, 8, 12, 29, 28, 24, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, - 11, 0, 9, 0, 20, 0, 13, + 11, 0, 9, 0, 19, 0, 13, ]; static BITSET_INDEX_CHUNKS: [[u8; 16]; 31] = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 18, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 70, 102, 29], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 62, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 83, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 35, 66, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 61, 0, 0, 0, 0, 0, 35, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, 45, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 130, 78, 60, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 99, 0, 0, 0, 37, 0, 90, 0, 0], - [0, 0, 0, 0, 0, 129, 54, 0, 0, 3, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0], - [0, 0, 0, 19, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 67, 0, 114, 0, 137, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 7, 0, 0, 0, 125, 5, 24, 63, 0, 55, 135, 9, 64, 100], - [0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [10, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [12, 0, 48, 0, 92, 0, 0, 0, 25, 119, 113, 0, 96, 71, 53, 68], - [46, 0, 0, 116, 57, 17, 101, 44, 81, 94, 127, 80, 0, 0, 0, 52], - [49, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0], - [56, 26, 0, 136, 95, 43, 107, 105, 93, 79, 93, 132, 128, 42, 104, 20], - [59, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [85, 0, 0, 87, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 0], - [89, 0, 0, 0, 0, 0, 0, 38, 110, 27, 22, 0, 0, 0, 0, 0], - [109, 74, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0], - [124, 0, 82, 0, 123, 6, 21, 0, 0, 0, 0, 72, 0, 0, 0, 0], - [126, 40, 118, 39, 108, 41, 0, 34, 91, 14, 97, 13, 86, 112, 98, 4], - [133, 32, 120, 2, 0, 0, 122, 30, 121, 1, 84, 0, 51, 0, 0, 0], - [134, 115, 88, 0, 77, 69, 111, 11, 106, 0, 0, 50, 108, 76, 0, 0], - [137, 138, 0, 0, 138, 138, 138, 62, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 20, 46], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 74, 106, 31], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, 66, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 87, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 37, 70, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 37, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 121, 0, 0, 48, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 134, 82, 64, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 103, 0, 0, 0, 39, 0, 94, 0, 0], + [0, 0, 0, 0, 0, 133, 58, 0, 0, 5, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 55, 0, 0, 18, 0, 0], + [0, 0, 0, 21, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 71, 0, 118, 0, 142, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 9, 0, 0, 0, 129, 7, 26, 67, 0, 59, 140, 11, 68, 104], + [0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [12, 0, 0, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [13, 0, 50, 0, 96, 0, 0, 0, 27, 123, 139, 1, 100, 75, 57, 72], + [51, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 0], + [54, 0, 0, 120, 61, 19, 105, 47, 85, 98, 131, 84, 0, 0, 0, 56], + [60, 28, 0, 141, 99, 45, 111, 109, 97, 83, 97, 136, 132, 44, 108, 22], + [63, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [89, 0, 0, 91, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0], + [93, 0, 0, 0, 113, 3, 0, 40, 115, 29, 24, 0, 0, 0, 0, 0], + [114, 78, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 0, 0], + [128, 0, 86, 0, 127, 8, 23, 0, 0, 0, 0, 76, 0, 0, 0, 0], + [130, 42, 122, 41, 112, 43, 2, 36, 95, 15, 101, 14, 90, 117, 102, 6], + [137, 34, 124, 4, 0, 0, 126, 32, 125, 1, 88, 0, 53, 0, 0, 0], + [138, 119, 92, 0, 81, 73, 116, 17, 110, 0, 0, 52, 112, 80, 0, 0], + [142, 143, 0, 0, 143, 143, 143, 66, 0, 0, 0, 0, 0, 0, 0, 0], ]; - static BITSET: [u64; 139] = [ - 0, 1, 13, 28, 64, 182, 191, 1016, 2032, 2047, 4096, 7680, 14336, 16128, 32640, 32768, - 131008, 262016, 491520, 8323072, 8396801, 10682368, 58719232, 100663296, 134152192, + static BITSET: [u64; 144] = [ + 0, 1, 2, 8, 13, 28, 64, 182, 191, 1016, 2032, 2047, 4096, 14336, 16128, 32640, 32768, + 40448, 131008, 262016, 491520, 8323072, 8396801, 10682368, 58719232, 100663296, 134152192, 159383552, 234881024, 243138688, 536879204, 537919040, 805306369, 1073741824, 1073741916, 1610612736, 2153546752, 3221225472, 3758096384, 4294967296, 4512022528, 51545911364, - 51545914817, 51548004382, 51552198686, 51556262398, 137438953472, 412316860416, - 412316862532, 1030792151040, 2199023255648, 8641373536127, 8763880767488, 17303886364672, - 36421322670080, 65128884076547, 65970697670631, 67755789254656, 69200441769984, - 70093866270720, 263882790666240, 277076930199552, 281470547525648, 281470681808895, - 281474976710655, 281479271675904, 562675075514368, 562949953355776, 844424930131968, - 985162418487296, 1023920203366400, 2251799813685248, 3377699721314304, 4494803534348292, - 6755399441055744, 7881299349733376, 8444256867844096, 8725724278030336, 8760633780600833, - 8989057312882695, 9042383626829823, 9851624185018758, 18067175067615234, 28848986089586688, - 30958948903026688, 35747322042253312, 53805701016846336, 58529202969772032, - 189151184399892480, 220713756545974272, 466122561432846339, 504262420777140224, - 558446353793941504, 572520102629474304, 1009933895770046464, 1152921504606846982, - 1152921504606851080, 1441151880758558727, 1724878657282899983, 2301902359539744768, - 2305843009196908767, 2305843009213693952, 2310337812748042240, 3731232291276455943, - 4589168020290535424, 4609293481125347328, 4611686018427387908, 4611686069975392286, - 4671217976001691648, 5764607523034234882, 6341068275337658371, 7421334051581067264, - 8788774672813524990, 9205357638345293827, 9222809086901354496, 9223090561878065152, - 9223372036854775808, 9223372036854775935, 9224497932466651184, 9727775195120332910, - 10376293541461622786, 11526998316797657088, 11959590285459062784, 12103423998558208000, - 12699165786766311424, 13005832773892571136, 13798747783286489088, 13835058055282032640, - 13835058055282163729, 13951307220663664640, 14987979559889010690, 17872468738205286400, - 17906312118425092095, 18158513697557839871, 18158513749097456062, 18374686479671623680, - 18374686479671623682, 18446462598732972032, 18446744056529158144, 18446744069414584320, - 18446744073709551615, + 51545914817, 51548004382, 51554295838, 51556262398, 68719476736, 137438953472, 412316860416, + 1030792151040, 2199023255648, 8641373536127, 8763880767488, 17303886364672, 18004502906948, + 26388279066624, 36421322670080, 65128884076547, 65970697670631, 67755789254656, + 69200441769984, 70093866270720, 263882790666240, 277076930199552, 281470547525648, + 281470681808895, 281474976710655, 281479271675904, 562675075514368, 562949953355776, + 844424930131968, 985162418487296, 1023920203366400, 2251799813685248, 3377699721314304, + 4494803534348292, 6755399441055744, 7881299349733376, 8444256867844096, 8725724278030336, + 8760633780600833, 8989057312882695, 9042383626829823, 9851624185018758, 18067175067615234, + 28848986089586688, 30958948903026688, 35747322042253312, 53805701016846336, + 58529202969772032, 189151184399892480, 220713756545974272, 466122561432846339, + 504262420777140224, 558446353793941504, 572520102629474304, 1009933895770046464, + 1152921504606846982, 1152921504606851080, 1441151880758558727, 1724878657282899983, + 2301902359539744768, 2305843009196908767, 2305843009213693952, 2310337812748042240, + 3731232291276455943, 4589168020290535424, 4609293481125347328, 4611686018427387908, + 4611686069975392286, 4671217976001691648, 5764607523034234882, 6341068275337658371, + 6341349750314369024, 7421334051581067264, 8788774672813524990, 9205357638345293827, + 9222809086901354496, 9223372036854775808, 9223372036854775935, 9224497932466651184, + 9727775195120332910, 10376293541461622786, 11526998316797657088, 11959590285459062784, + 12103423998558208000, 12699165786766311424, 13005832773892571136, 13798747783286489088, + 13835058055282032640, 13835058055282163729, 13951307220663664640, 14987979559889010690, + 17872468738205286400, 17906312118425092095, 18158513697557839871, 18158513749097456062, + 18374686479671623680, 18374686479671623682, 18446462598732840960, 18446462598732972032, + 18446744056529158144, 18446744069414584320, 18446744073709551615, ]; pub fn lookup(c: char) -> bool { @@ -430,7 +433,7 @@ pub mod lowercase { 133143986179, 274877905920, 1099509514240, 4398046445568, 17592185782272, 36009005809663, 46912496118442, 187649984473770, 281474972516352, 2251799813685247, 2339875276368554, 4503599560261632, 61925590106570972, 71777214282006783, 72057592964186127, - 144115188074807295, 297241973452963840, 504403158265495560, 576460743713488896, + 144115188074807295, 297241973452963840, 522417556774978824, 576460743713488896, 1152921487426978047, 1152921504590069760, 1814856824841797631, 3607524039012697088, 4362299189061746720, 4539628424389459968, 4601013482110844927, 4611405638684049471, 4674456033467236607, 6172933889249159850, 9223934986808197120, 10663022717737544362, @@ -439,7 +442,7 @@ pub mod lowercase { 12298110845996498944, 15324248332066007893, 16596095761559859497, 16717361816799215616, 16987577794709946364, 17293822586148356092, 18158513701852807104, 18410715274543104000, 18428729675466407935, 18446462598732840960, 18446462598732858304, 18446462598737002495, - 18446463698110251007, 18446673704966422527, 18446726481523572736, 18446739675663105535, + 18446464797621878783, 18446673704966422527, 18446726481523572736, 18446739675663105535, 18446739675663106031, 18446742974197923840, 18446744056529682432, 18446744069414584320, 18446744073709529733, 18446744073709551615, ]; @@ -457,56 +460,57 @@ pub mod lowercase { #[rustfmt::skip] pub mod n { - static BITSET_LAST_CHUNK_MAP: (u16, u8) = (124, 11); - static BITSET_CHUNKS_MAP: [u8; 124] = [ - 30, 7, 10, 24, 18, 3, 28, 20, 23, 27, 0, 15, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 2, 12, 17, 25, 16, 22, 19, 14, 21, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 1, 0, 0, 9, 0, 13, 26, + static BITSET_LAST_CHUNK_MAP: (u16, u8) = (127, 0); + static BITSET_CHUNKS_MAP: [u8; 127] = [ + 31, 8, 11, 25, 19, 4, 29, 21, 24, 28, 0, 16, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, 13, 18, 26, 17, 23, 20, 15, 22, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 7, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 5, 2, 0, 0, 10, 0, 14, 27, 12, 0, 1, ]; - static BITSET_INDEX_CHUNKS: [[u8; 16]; 33] = [ + static BITSET_INDEX_CHUNKS: [[u8; 16]; 34] = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 48], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 42, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 21, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 46, 0, 0, 0, 2], - [0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 30, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 30, 0, 44, 0, 30, 0, 30, 0, 40, 0, 33], - [0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 36, 43, 4, 0, 0, 0, 0, 51, 22, 3, 0, 12], - [0, 0, 0, 6, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 61, 46, 0, 0, 0, 0, 59, 0, 0, 23, 9, 0, 0], - [0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 2, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0], - [0, 14, 0, 14, 0, 0, 0, 0, 0, 14, 0, 2, 50, 0, 0, 0], - [0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 25, 0, 0, 0, 14, 24, 0, 0, 0, 0, 0, 0, 0, 0, 10], - [0, 31, 0, 46, 64, 0, 0, 38, 0, 0, 0, 46, 0, 0, 0, 0], - [0, 45, 2, 0, 0, 70, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 58, 0, 30, 0, 41, 0, 30, 0, 14, 0, 14, 35, 0, 0, 0], - [0, 62, 29, 60, 17, 0, 54, 69, 0, 56, 19, 27, 0, 63, 28, 0], - [0, 65, 37, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 68, 18, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 8, 0], - [14, 0, 0, 0, 0, 7, 0, 16, 0, 0, 15, 0, 0, 14, 46, 0], - [39, 0, 0, 14, 2, 0, 0, 47, 0, 14, 0, 0, 0, 0, 0, 46], - [46, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [49, 0, 0, 0, 0, 0, 11, 0, 24, 20, 66, 0, 0, 0, 0, 0], - [72, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 49], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 43, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 22, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 47, 0, 0, 0, 2], + [0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 31, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 47, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 31, 0, 45, 0, 31, 0, 31, 0, 41, 0, 34], + [0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 37, 44, 4, 0, 0, 0, 0, 52, 23, 3, 0, 13], + [0, 0, 0, 7, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 35, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 62, 47, 0, 0, 0, 0, 60, 0, 0, 24, 10, 0, 5], + [0, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 2, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0], + [0, 15, 0, 15, 0, 0, 0, 0, 0, 15, 0, 2, 51, 0, 0, 0], + [0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 26, 0, 0, 0, 15, 25, 0, 0, 0, 0, 0, 0, 0, 0, 11], + [0, 32, 0, 47, 65, 0, 0, 39, 0, 0, 0, 47, 0, 0, 0, 0], + [0, 46, 2, 0, 0, 71, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 59, 0, 31, 0, 42, 0, 31, 0, 15, 0, 15, 36, 0, 0, 0], + [0, 63, 30, 61, 18, 0, 55, 70, 0, 57, 20, 28, 0, 64, 29, 0], + [0, 66, 38, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 69, 19, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 9, 0], + [15, 0, 0, 0, 0, 8, 0, 17, 0, 0, 16, 0, 0, 15, 47, 0], + [40, 0, 0, 15, 2, 0, 0, 48, 0, 15, 0, 0, 0, 0, 0, 47], + [47, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [50, 0, 0, 0, 0, 0, 12, 0, 25, 21, 67, 0, 0, 0, 0, 0], + [73, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ]; - static BITSET: [u64; 73] = [ - 0, 999, 1023, 1026, 3072, 8191, 65408, 65472, 1048575, 1966080, 2097151, 3932160, 4063232, - 8388607, 67043328, 67044351, 134152192, 264241152, 268435455, 3758096384, 4294901504, - 17112694784, 64424509440, 549218942976, 4393751543808, 35184372023296, 140737488355327, - 272678883688448, 279275953455104, 280925220896768, 281200098803712, 281474976448512, - 492581209243648, 2251524935778304, 2251795518717952, 4503595332403200, 4503599627370368, - 8708132091985919, 9007190731849728, 17732923532771328, 71212894229889024, + static BITSET: [u64; 74] = [ + 0, 999, 1023, 1026, 3072, 4064, 8191, 65408, 65472, 1048575, 1966080, 2097151, 3932160, + 4063232, 8388607, 67043328, 67044351, 134152192, 264241152, 268435455, 3758096384, + 4294901504, 17112694784, 64424509440, 549218942976, 4393751543808, 35184372023296, + 140737488355327, 272678883688448, 279275953455104, 280925220896768, 281200098803712, + 281474976448512, 492581209243648, 2251524935778304, 2251795518717952, 4503595332403200, + 4503599627370368, 8708132091985919, 9007190731849728, 17732923532771328, 71212894229889024, 144114915328655360, 144115183780888576, 144115188075855871, 284007976623144960, 284008251501051904, 287948901175001088, 287948901242044416, 287953294926544896, 504407547722072192, 1152640029630136320, 1152921496016912384, 2305840810190438400, @@ -541,28 +545,28 @@ pub mod uppercase { static BITSET_INDEX_CHUNKS: [[u8; 16]; 17] = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 10, 0, 38, 46, 44, 2], - [0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 51, 24, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 60, 62, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 54, 0, 0, 0, 0, 0, 43, 43, 40, 43, 56, 23, 34, 35], - [0, 0, 57, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 9, 0, 38, 46, 44, 28], + [0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 51, 23, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 60, 62, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 54, 0, 0, 0, 0, 0, 43, 43, 40, 43, 56, 22, 34, 35], + [0, 0, 57, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 66, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 30], - [0, 11, 0, 12, 50, 37, 36, 45, 47, 6, 0, 0, 0, 49, 18, 53], - [15, 0, 60, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [22, 52, 43, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [25, 39, 42, 41, 59, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [58, 65, 29, 17, 48, 63, 31, 20, 55, 61, 64, 32, 28, 21, 16, 4], + [0, 0, 66, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 30], + [0, 10, 0, 11, 50, 37, 36, 45, 47, 5, 0, 0, 0, 49, 17, 53], + [14, 0, 60, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [21, 52, 43, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [24, 39, 42, 41, 59, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [58, 65, 29, 16, 48, 63, 31, 19, 55, 61, 64, 32, 27, 20, 15, 3], ]; static BITSET: [u64; 67] = [ - 0, 8, 116, 1023, 1024, 8383, 21882, 65535, 1048575, 8388607, 89478485, 134217726, - 2139095039, 4294967295, 17179869183, 1099511627775, 2199023190016, 4398046445568, - 17575006099264, 23456248059221, 70368743129088, 140737484161024, 140737488355327, - 280378317225728, 281470681743392, 281474976710655, 1169903278445909, 2251799813685247, - 9007198986305536, 17977448100528131, 18014398509481983, 288230371856744511, + 0, 8, 1023, 1024, 8383, 21882, 65535, 1048575, 8388607, 89478485, 134217726, 2139095039, + 4294967295, 17179869183, 1099511627775, 2199023190016, 4398046445568, 17575006099264, + 23456248059221, 70368743129088, 140737484161024, 140737488355327, 280378317225728, + 281470681743392, 281474976710655, 1169903278445909, 2251799813685247, 9007198986305536, + 9007199254741748, 17977448100528131, 18014398509481983, 288230371856744511, 576460735123554305, 576460743713488896, 1080863910568919040, 1080897995681042176, 1274187559846268630, 3122495741643543722, 6148633210533183488, 6148914689804861440, 6148914690880001365, 6148914691236506283, 6148914691236516865, 6148914691236517205, @@ -1202,20 +1206,21 @@ pub mod conversions { ('\u{a7ba}', ['\u{a7bb}', '\u{0}', '\u{0}']), ('\u{a7bc}', ['\u{a7bd}', '\u{0}', '\u{0}']), ('\u{a7be}', ['\u{a7bf}', '\u{0}', '\u{0}']), ('\u{a7c2}', ['\u{a7c3}', '\u{0}', '\u{0}']), ('\u{a7c4}', ['\u{a794}', '\u{0}', '\u{0}']), ('\u{a7c5}', ['\u{282}', '\u{0}', '\u{0}']), - ('\u{a7c6}', ['\u{1d8e}', '\u{0}', '\u{0}']), ('\u{ff21}', ['\u{ff41}', '\u{0}', '\u{0}']), - ('\u{ff22}', ['\u{ff42}', '\u{0}', '\u{0}']), ('\u{ff23}', ['\u{ff43}', '\u{0}', '\u{0}']), - ('\u{ff24}', ['\u{ff44}', '\u{0}', '\u{0}']), ('\u{ff25}', ['\u{ff45}', '\u{0}', '\u{0}']), - ('\u{ff26}', ['\u{ff46}', '\u{0}', '\u{0}']), ('\u{ff27}', ['\u{ff47}', '\u{0}', '\u{0}']), - ('\u{ff28}', ['\u{ff48}', '\u{0}', '\u{0}']), ('\u{ff29}', ['\u{ff49}', '\u{0}', '\u{0}']), - ('\u{ff2a}', ['\u{ff4a}', '\u{0}', '\u{0}']), ('\u{ff2b}', ['\u{ff4b}', '\u{0}', '\u{0}']), - ('\u{ff2c}', ['\u{ff4c}', '\u{0}', '\u{0}']), ('\u{ff2d}', ['\u{ff4d}', '\u{0}', '\u{0}']), - ('\u{ff2e}', ['\u{ff4e}', '\u{0}', '\u{0}']), ('\u{ff2f}', ['\u{ff4f}', '\u{0}', '\u{0}']), - ('\u{ff30}', ['\u{ff50}', '\u{0}', '\u{0}']), ('\u{ff31}', ['\u{ff51}', '\u{0}', '\u{0}']), - ('\u{ff32}', ['\u{ff52}', '\u{0}', '\u{0}']), ('\u{ff33}', ['\u{ff53}', '\u{0}', '\u{0}']), - ('\u{ff34}', ['\u{ff54}', '\u{0}', '\u{0}']), ('\u{ff35}', ['\u{ff55}', '\u{0}', '\u{0}']), - ('\u{ff36}', ['\u{ff56}', '\u{0}', '\u{0}']), ('\u{ff37}', ['\u{ff57}', '\u{0}', '\u{0}']), - ('\u{ff38}', ['\u{ff58}', '\u{0}', '\u{0}']), ('\u{ff39}', ['\u{ff59}', '\u{0}', '\u{0}']), - ('\u{ff3a}', ['\u{ff5a}', '\u{0}', '\u{0}']), + ('\u{a7c6}', ['\u{1d8e}', '\u{0}', '\u{0}']), ('\u{a7c7}', ['\u{a7c8}', '\u{0}', '\u{0}']), + ('\u{a7c9}', ['\u{a7ca}', '\u{0}', '\u{0}']), ('\u{a7f5}', ['\u{a7f6}', '\u{0}', '\u{0}']), + ('\u{ff21}', ['\u{ff41}', '\u{0}', '\u{0}']), ('\u{ff22}', ['\u{ff42}', '\u{0}', '\u{0}']), + ('\u{ff23}', ['\u{ff43}', '\u{0}', '\u{0}']), ('\u{ff24}', ['\u{ff44}', '\u{0}', '\u{0}']), + ('\u{ff25}', ['\u{ff45}', '\u{0}', '\u{0}']), ('\u{ff26}', ['\u{ff46}', '\u{0}', '\u{0}']), + ('\u{ff27}', ['\u{ff47}', '\u{0}', '\u{0}']), ('\u{ff28}', ['\u{ff48}', '\u{0}', '\u{0}']), + ('\u{ff29}', ['\u{ff49}', '\u{0}', '\u{0}']), ('\u{ff2a}', ['\u{ff4a}', '\u{0}', '\u{0}']), + ('\u{ff2b}', ['\u{ff4b}', '\u{0}', '\u{0}']), ('\u{ff2c}', ['\u{ff4c}', '\u{0}', '\u{0}']), + ('\u{ff2d}', ['\u{ff4d}', '\u{0}', '\u{0}']), ('\u{ff2e}', ['\u{ff4e}', '\u{0}', '\u{0}']), + ('\u{ff2f}', ['\u{ff4f}', '\u{0}', '\u{0}']), ('\u{ff30}', ['\u{ff50}', '\u{0}', '\u{0}']), + ('\u{ff31}', ['\u{ff51}', '\u{0}', '\u{0}']), ('\u{ff32}', ['\u{ff52}', '\u{0}', '\u{0}']), + ('\u{ff33}', ['\u{ff53}', '\u{0}', '\u{0}']), ('\u{ff34}', ['\u{ff54}', '\u{0}', '\u{0}']), + ('\u{ff35}', ['\u{ff55}', '\u{0}', '\u{0}']), ('\u{ff36}', ['\u{ff56}', '\u{0}', '\u{0}']), + ('\u{ff37}', ['\u{ff57}', '\u{0}', '\u{0}']), ('\u{ff38}', ['\u{ff58}', '\u{0}', '\u{0}']), + ('\u{ff39}', ['\u{ff59}', '\u{0}', '\u{0}']), ('\u{ff3a}', ['\u{ff5a}', '\u{0}', '\u{0}']), ('\u{10400}', ['\u{10428}', '\u{0}', '\u{0}']), ('\u{10401}', ['\u{10429}', '\u{0}', '\u{0}']), ('\u{10402}', ['\u{1042a}', '\u{0}', '\u{0}']), @@ -2052,51 +2057,52 @@ pub mod conversions { ('\u{a7b7}', ['\u{a7b6}', '\u{0}', '\u{0}']), ('\u{a7b9}', ['\u{a7b8}', '\u{0}', '\u{0}']), ('\u{a7bb}', ['\u{a7ba}', '\u{0}', '\u{0}']), ('\u{a7bd}', ['\u{a7bc}', '\u{0}', '\u{0}']), ('\u{a7bf}', ['\u{a7be}', '\u{0}', '\u{0}']), ('\u{a7c3}', ['\u{a7c2}', '\u{0}', '\u{0}']), - ('\u{ab53}', ['\u{a7b3}', '\u{0}', '\u{0}']), ('\u{ab70}', ['\u{13a0}', '\u{0}', '\u{0}']), - ('\u{ab71}', ['\u{13a1}', '\u{0}', '\u{0}']), ('\u{ab72}', ['\u{13a2}', '\u{0}', '\u{0}']), - ('\u{ab73}', ['\u{13a3}', '\u{0}', '\u{0}']), ('\u{ab74}', ['\u{13a4}', '\u{0}', '\u{0}']), - ('\u{ab75}', ['\u{13a5}', '\u{0}', '\u{0}']), ('\u{ab76}', ['\u{13a6}', '\u{0}', '\u{0}']), - ('\u{ab77}', ['\u{13a7}', '\u{0}', '\u{0}']), ('\u{ab78}', ['\u{13a8}', '\u{0}', '\u{0}']), - ('\u{ab79}', ['\u{13a9}', '\u{0}', '\u{0}']), ('\u{ab7a}', ['\u{13aa}', '\u{0}', '\u{0}']), - ('\u{ab7b}', ['\u{13ab}', '\u{0}', '\u{0}']), ('\u{ab7c}', ['\u{13ac}', '\u{0}', '\u{0}']), - ('\u{ab7d}', ['\u{13ad}', '\u{0}', '\u{0}']), ('\u{ab7e}', ['\u{13ae}', '\u{0}', '\u{0}']), - ('\u{ab7f}', ['\u{13af}', '\u{0}', '\u{0}']), ('\u{ab80}', ['\u{13b0}', '\u{0}', '\u{0}']), - ('\u{ab81}', ['\u{13b1}', '\u{0}', '\u{0}']), ('\u{ab82}', ['\u{13b2}', '\u{0}', '\u{0}']), - ('\u{ab83}', ['\u{13b3}', '\u{0}', '\u{0}']), ('\u{ab84}', ['\u{13b4}', '\u{0}', '\u{0}']), - ('\u{ab85}', ['\u{13b5}', '\u{0}', '\u{0}']), ('\u{ab86}', ['\u{13b6}', '\u{0}', '\u{0}']), - ('\u{ab87}', ['\u{13b7}', '\u{0}', '\u{0}']), ('\u{ab88}', ['\u{13b8}', '\u{0}', '\u{0}']), - ('\u{ab89}', ['\u{13b9}', '\u{0}', '\u{0}']), ('\u{ab8a}', ['\u{13ba}', '\u{0}', '\u{0}']), - ('\u{ab8b}', ['\u{13bb}', '\u{0}', '\u{0}']), ('\u{ab8c}', ['\u{13bc}', '\u{0}', '\u{0}']), - ('\u{ab8d}', ['\u{13bd}', '\u{0}', '\u{0}']), ('\u{ab8e}', ['\u{13be}', '\u{0}', '\u{0}']), - ('\u{ab8f}', ['\u{13bf}', '\u{0}', '\u{0}']), ('\u{ab90}', ['\u{13c0}', '\u{0}', '\u{0}']), - ('\u{ab91}', ['\u{13c1}', '\u{0}', '\u{0}']), ('\u{ab92}', ['\u{13c2}', '\u{0}', '\u{0}']), - ('\u{ab93}', ['\u{13c3}', '\u{0}', '\u{0}']), ('\u{ab94}', ['\u{13c4}', '\u{0}', '\u{0}']), - ('\u{ab95}', ['\u{13c5}', '\u{0}', '\u{0}']), ('\u{ab96}', ['\u{13c6}', '\u{0}', '\u{0}']), - ('\u{ab97}', ['\u{13c7}', '\u{0}', '\u{0}']), ('\u{ab98}', ['\u{13c8}', '\u{0}', '\u{0}']), - ('\u{ab99}', ['\u{13c9}', '\u{0}', '\u{0}']), ('\u{ab9a}', ['\u{13ca}', '\u{0}', '\u{0}']), - ('\u{ab9b}', ['\u{13cb}', '\u{0}', '\u{0}']), ('\u{ab9c}', ['\u{13cc}', '\u{0}', '\u{0}']), - ('\u{ab9d}', ['\u{13cd}', '\u{0}', '\u{0}']), ('\u{ab9e}', ['\u{13ce}', '\u{0}', '\u{0}']), - ('\u{ab9f}', ['\u{13cf}', '\u{0}', '\u{0}']), ('\u{aba0}', ['\u{13d0}', '\u{0}', '\u{0}']), - ('\u{aba1}', ['\u{13d1}', '\u{0}', '\u{0}']), ('\u{aba2}', ['\u{13d2}', '\u{0}', '\u{0}']), - ('\u{aba3}', ['\u{13d3}', '\u{0}', '\u{0}']), ('\u{aba4}', ['\u{13d4}', '\u{0}', '\u{0}']), - ('\u{aba5}', ['\u{13d5}', '\u{0}', '\u{0}']), ('\u{aba6}', ['\u{13d6}', '\u{0}', '\u{0}']), - ('\u{aba7}', ['\u{13d7}', '\u{0}', '\u{0}']), ('\u{aba8}', ['\u{13d8}', '\u{0}', '\u{0}']), - ('\u{aba9}', ['\u{13d9}', '\u{0}', '\u{0}']), ('\u{abaa}', ['\u{13da}', '\u{0}', '\u{0}']), - ('\u{abab}', ['\u{13db}', '\u{0}', '\u{0}']), ('\u{abac}', ['\u{13dc}', '\u{0}', '\u{0}']), - ('\u{abad}', ['\u{13dd}', '\u{0}', '\u{0}']), ('\u{abae}', ['\u{13de}', '\u{0}', '\u{0}']), - ('\u{abaf}', ['\u{13df}', '\u{0}', '\u{0}']), ('\u{abb0}', ['\u{13e0}', '\u{0}', '\u{0}']), - ('\u{abb1}', ['\u{13e1}', '\u{0}', '\u{0}']), ('\u{abb2}', ['\u{13e2}', '\u{0}', '\u{0}']), - ('\u{abb3}', ['\u{13e3}', '\u{0}', '\u{0}']), ('\u{abb4}', ['\u{13e4}', '\u{0}', '\u{0}']), - ('\u{abb5}', ['\u{13e5}', '\u{0}', '\u{0}']), ('\u{abb6}', ['\u{13e6}', '\u{0}', '\u{0}']), - ('\u{abb7}', ['\u{13e7}', '\u{0}', '\u{0}']), ('\u{abb8}', ['\u{13e8}', '\u{0}', '\u{0}']), - ('\u{abb9}', ['\u{13e9}', '\u{0}', '\u{0}']), ('\u{abba}', ['\u{13ea}', '\u{0}', '\u{0}']), - ('\u{abbb}', ['\u{13eb}', '\u{0}', '\u{0}']), ('\u{abbc}', ['\u{13ec}', '\u{0}', '\u{0}']), - ('\u{abbd}', ['\u{13ed}', '\u{0}', '\u{0}']), ('\u{abbe}', ['\u{13ee}', '\u{0}', '\u{0}']), - ('\u{abbf}', ['\u{13ef}', '\u{0}', '\u{0}']), ('\u{fb00}', ['F', 'F', '\u{0}']), - ('\u{fb01}', ['F', 'I', '\u{0}']), ('\u{fb02}', ['F', 'L', '\u{0}']), - ('\u{fb03}', ['F', 'F', 'I']), ('\u{fb04}', ['F', 'F', 'L']), - ('\u{fb05}', ['S', 'T', '\u{0}']), ('\u{fb06}', ['S', 'T', '\u{0}']), - ('\u{fb13}', ['\u{544}', '\u{546}', '\u{0}']), + ('\u{a7c8}', ['\u{a7c7}', '\u{0}', '\u{0}']), ('\u{a7ca}', ['\u{a7c9}', '\u{0}', '\u{0}']), + ('\u{a7f6}', ['\u{a7f5}', '\u{0}', '\u{0}']), ('\u{ab53}', ['\u{a7b3}', '\u{0}', '\u{0}']), + ('\u{ab70}', ['\u{13a0}', '\u{0}', '\u{0}']), ('\u{ab71}', ['\u{13a1}', '\u{0}', '\u{0}']), + ('\u{ab72}', ['\u{13a2}', '\u{0}', '\u{0}']), ('\u{ab73}', ['\u{13a3}', '\u{0}', '\u{0}']), + ('\u{ab74}', ['\u{13a4}', '\u{0}', '\u{0}']), ('\u{ab75}', ['\u{13a5}', '\u{0}', '\u{0}']), + ('\u{ab76}', ['\u{13a6}', '\u{0}', '\u{0}']), ('\u{ab77}', ['\u{13a7}', '\u{0}', '\u{0}']), + ('\u{ab78}', ['\u{13a8}', '\u{0}', '\u{0}']), ('\u{ab79}', ['\u{13a9}', '\u{0}', '\u{0}']), + ('\u{ab7a}', ['\u{13aa}', '\u{0}', '\u{0}']), ('\u{ab7b}', ['\u{13ab}', '\u{0}', '\u{0}']), + ('\u{ab7c}', ['\u{13ac}', '\u{0}', '\u{0}']), ('\u{ab7d}', ['\u{13ad}', '\u{0}', '\u{0}']), + ('\u{ab7e}', ['\u{13ae}', '\u{0}', '\u{0}']), ('\u{ab7f}', ['\u{13af}', '\u{0}', '\u{0}']), + ('\u{ab80}', ['\u{13b0}', '\u{0}', '\u{0}']), ('\u{ab81}', ['\u{13b1}', '\u{0}', '\u{0}']), + ('\u{ab82}', ['\u{13b2}', '\u{0}', '\u{0}']), ('\u{ab83}', ['\u{13b3}', '\u{0}', '\u{0}']), + ('\u{ab84}', ['\u{13b4}', '\u{0}', '\u{0}']), ('\u{ab85}', ['\u{13b5}', '\u{0}', '\u{0}']), + ('\u{ab86}', ['\u{13b6}', '\u{0}', '\u{0}']), ('\u{ab87}', ['\u{13b7}', '\u{0}', '\u{0}']), + ('\u{ab88}', ['\u{13b8}', '\u{0}', '\u{0}']), ('\u{ab89}', ['\u{13b9}', '\u{0}', '\u{0}']), + ('\u{ab8a}', ['\u{13ba}', '\u{0}', '\u{0}']), ('\u{ab8b}', ['\u{13bb}', '\u{0}', '\u{0}']), + ('\u{ab8c}', ['\u{13bc}', '\u{0}', '\u{0}']), ('\u{ab8d}', ['\u{13bd}', '\u{0}', '\u{0}']), + ('\u{ab8e}', ['\u{13be}', '\u{0}', '\u{0}']), ('\u{ab8f}', ['\u{13bf}', '\u{0}', '\u{0}']), + ('\u{ab90}', ['\u{13c0}', '\u{0}', '\u{0}']), ('\u{ab91}', ['\u{13c1}', '\u{0}', '\u{0}']), + ('\u{ab92}', ['\u{13c2}', '\u{0}', '\u{0}']), ('\u{ab93}', ['\u{13c3}', '\u{0}', '\u{0}']), + ('\u{ab94}', ['\u{13c4}', '\u{0}', '\u{0}']), ('\u{ab95}', ['\u{13c5}', '\u{0}', '\u{0}']), + ('\u{ab96}', ['\u{13c6}', '\u{0}', '\u{0}']), ('\u{ab97}', ['\u{13c7}', '\u{0}', '\u{0}']), + ('\u{ab98}', ['\u{13c8}', '\u{0}', '\u{0}']), ('\u{ab99}', ['\u{13c9}', '\u{0}', '\u{0}']), + ('\u{ab9a}', ['\u{13ca}', '\u{0}', '\u{0}']), ('\u{ab9b}', ['\u{13cb}', '\u{0}', '\u{0}']), + ('\u{ab9c}', ['\u{13cc}', '\u{0}', '\u{0}']), ('\u{ab9d}', ['\u{13cd}', '\u{0}', '\u{0}']), + ('\u{ab9e}', ['\u{13ce}', '\u{0}', '\u{0}']), ('\u{ab9f}', ['\u{13cf}', '\u{0}', '\u{0}']), + ('\u{aba0}', ['\u{13d0}', '\u{0}', '\u{0}']), ('\u{aba1}', ['\u{13d1}', '\u{0}', '\u{0}']), + ('\u{aba2}', ['\u{13d2}', '\u{0}', '\u{0}']), ('\u{aba3}', ['\u{13d3}', '\u{0}', '\u{0}']), + ('\u{aba4}', ['\u{13d4}', '\u{0}', '\u{0}']), ('\u{aba5}', ['\u{13d5}', '\u{0}', '\u{0}']), + ('\u{aba6}', ['\u{13d6}', '\u{0}', '\u{0}']), ('\u{aba7}', ['\u{13d7}', '\u{0}', '\u{0}']), + ('\u{aba8}', ['\u{13d8}', '\u{0}', '\u{0}']), ('\u{aba9}', ['\u{13d9}', '\u{0}', '\u{0}']), + ('\u{abaa}', ['\u{13da}', '\u{0}', '\u{0}']), ('\u{abab}', ['\u{13db}', '\u{0}', '\u{0}']), + ('\u{abac}', ['\u{13dc}', '\u{0}', '\u{0}']), ('\u{abad}', ['\u{13dd}', '\u{0}', '\u{0}']), + ('\u{abae}', ['\u{13de}', '\u{0}', '\u{0}']), ('\u{abaf}', ['\u{13df}', '\u{0}', '\u{0}']), + ('\u{abb0}', ['\u{13e0}', '\u{0}', '\u{0}']), ('\u{abb1}', ['\u{13e1}', '\u{0}', '\u{0}']), + ('\u{abb2}', ['\u{13e2}', '\u{0}', '\u{0}']), ('\u{abb3}', ['\u{13e3}', '\u{0}', '\u{0}']), + ('\u{abb4}', ['\u{13e4}', '\u{0}', '\u{0}']), ('\u{abb5}', ['\u{13e5}', '\u{0}', '\u{0}']), + ('\u{abb6}', ['\u{13e6}', '\u{0}', '\u{0}']), ('\u{abb7}', ['\u{13e7}', '\u{0}', '\u{0}']), + ('\u{abb8}', ['\u{13e8}', '\u{0}', '\u{0}']), ('\u{abb9}', ['\u{13e9}', '\u{0}', '\u{0}']), + ('\u{abba}', ['\u{13ea}', '\u{0}', '\u{0}']), ('\u{abbb}', ['\u{13eb}', '\u{0}', '\u{0}']), + ('\u{abbc}', ['\u{13ec}', '\u{0}', '\u{0}']), ('\u{abbd}', ['\u{13ed}', '\u{0}', '\u{0}']), + ('\u{abbe}', ['\u{13ee}', '\u{0}', '\u{0}']), ('\u{abbf}', ['\u{13ef}', '\u{0}', '\u{0}']), + ('\u{fb00}', ['F', 'F', '\u{0}']), ('\u{fb01}', ['F', 'I', '\u{0}']), + ('\u{fb02}', ['F', 'L', '\u{0}']), ('\u{fb03}', ['F', 'F', 'I']), + ('\u{fb04}', ['F', 'F', 'L']), ('\u{fb05}', ['S', 'T', '\u{0}']), + ('\u{fb06}', ['S', 'T', '\u{0}']), ('\u{fb13}', ['\u{544}', '\u{546}', '\u{0}']), ('\u{fb14}', ['\u{544}', '\u{535}', '\u{0}']), ('\u{fb15}', ['\u{544}', '\u{53b}', '\u{0}']), ('\u{fb16}', ['\u{54e}', '\u{546}', '\u{0}']), From 7995a08d7cb1a3d0c365be59874590c164a01543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 11 Mar 2020 20:38:21 -0700 Subject: [PATCH 12/14] Increase verbosity when suggesting subtle code changes --- .../infer/error_reporting/need_type_info.rs | 17 +- .../traits/error_reporting/mod.rs | 13 +- .../traits/error_reporting/suggestions.rs | 24 +-- src/librustc_typeck/check/method/mod.rs | 28 ++-- src/librustc_typeck/check/mod.rs | 16 +- src/librustc_typeck/check/pat.rs | 24 +-- src/test/ui/error-codes/E0615.stderr | 7 +- .../ui/extern/extern-types-unsized.stderr | 8 +- src/test/ui/implicit-method-bind.stderr | 7 +- src/test/ui/issues/issue-13853-2.stderr | 7 +- src/test/ui/issues/issue-26472.stderr | 9 +- src/test/ui/issues/issue-35241.stderr | 10 +- .../ui/methods/method-missing-call.stderr | 14 +- src/test/ui/question-mark-type-infer.stderr | 9 +- src/test/ui/reify-intrinsic.stderr | 10 +- src/test/ui/resolve/privacy-enum-ctor.stderr | 30 ++-- .../span/type-annotations-needed-expr.stderr | 9 +- src/test/ui/str/str-mut-idx.stderr | 8 +- src/test/ui/substs-ppaux.normal.stderr | 40 +++-- src/test/ui/substs-ppaux.verbose.stderr | 40 +++-- ...rg-where-it-should-have-been-called.stderr | 20 ++- .../ui/suggestions/const-in-struct-pat.stderr | 6 +- ...rg-where-it-should-have-been-called.stderr | 20 ++- .../fn-or-tuple-struct-without-args.stderr | 154 +++++++++++------- .../imm-ref-trait-object-literal.stderr | 9 +- .../method-missing-parentheses.stderr | 9 +- .../or_else-multiple-type-params.stderr | 10 +- src/test/ui/type-inference/sort_by_key.stderr | 9 +- .../ui/type/type-annotation-needed.stderr | 9 +- src/test/ui/union/union-suggest-field.rs | 2 +- src/test/ui/union/union-suggest-field.stderr | 7 +- src/test/ui/unsized3.stderr | 16 +- 32 files changed, 361 insertions(+), 240 deletions(-) diff --git a/src/librustc_infer/infer/error_reporting/need_type_info.rs b/src/librustc_infer/infer/error_reporting/need_type_info.rs index 285f0c9cf51a9..668c73b62775c 100644 --- a/src/librustc_infer/infer/error_reporting/need_type_info.rs +++ b/src/librustc_infer/infer/error_reporting/need_type_info.rs @@ -3,7 +3,7 @@ use crate::infer::InferCtxt; use rustc::hir::map::Map; use rustc::ty::print::Print; use rustc::ty::{self, DefIdTree, Infer, Ty, TyVar}; -use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; @@ -462,24 +462,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { e: &Expr<'_>, err: &mut DiagnosticBuilder<'_>, ) { - if let (Ok(snippet), Some(tables), None) = ( - self.tcx.sess.source_map().span_to_snippet(segment.ident.span), - self.in_progress_tables, - &segment.args, - ) { + if let (Some(tables), None) = (self.in_progress_tables, &segment.args) { let borrow = tables.borrow(); if let Some((DefKind::Method, did)) = borrow.type_dependent_def(e.hir_id) { let generics = self.tcx.generics_of(did); if !generics.params.is_empty() { - err.span_suggestion( - segment.ident.span, + err.span_suggestion_verbose( + segment.ident.span.shrink_to_hi(), &format!( "consider specifying the type argument{} in the method call", - if generics.params.len() > 1 { "s" } else { "" }, + pluralize!(generics.params.len()), ), format!( - "{}::<{}>", - snippet, + "::<{}>", generics .params .iter() diff --git a/src/librustc_infer/traits/error_reporting/mod.rs b/src/librustc_infer/traits/error_reporting/mod.rs index 10143ae015f2f..0f848802d8a47 100644 --- a/src/librustc_infer/traits/error_reporting/mod.rs +++ b/src/librustc_infer/traits/error_reporting/mod.rs @@ -23,7 +23,7 @@ use rustc::ty::{ }; use rustc_ast::ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::{QPath, TyKind, WhereBoundPredicate, WherePredicate}; @@ -1186,15 +1186,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // | // = note: cannot resolve `_: Tt` - err.span_suggestion( - span, + err.span_suggestion_verbose( + span.shrink_to_hi(), &format!( "consider specifying the type argument{} in the function call", - if generics.params.len() > 1 { "s" } else { "" }, + pluralize!(generics.params.len()), ), format!( - "{}::<{}>", - snippet, + "::<{}>", generics .params .iter() @@ -1356,7 +1355,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { [] => (span.shrink_to_hi(), ":"), [.., bound] => (bound.span().shrink_to_hi(), " + "), }; - err.span_suggestion( + err.span_suggestion_verbose( span, "consider relaxing the implicit `Sized` restriction", format!("{} ?Sized", separator), diff --git a/src/librustc_infer/traits/error_reporting/suggestions.rs b/src/librustc_infer/traits/error_reporting/suggestions.rs index d05955fb858c0..0094ba82d902b 100644 --- a/src/librustc_infer/traits/error_reporting/suggestions.rs +++ b/src/librustc_infer/traits/error_reporting/suggestions.rs @@ -265,7 +265,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } let hir = self.tcx.hir(); // Get the name of the callable and the arguments to be used in the suggestion. - let snippet = match hir.get_if_local(def_id) { + let (snippet, sugg) = match hir.get_if_local(def_id) { Some(hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, _, span, ..), .. @@ -276,7 +276,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { None => return, }; let args = decl.inputs.iter().map(|_| "_").collect::>().join(", "); - format!("{}({})", name, args) + let sugg = format!("({})", args); + (format!("{}{}", name, sugg), sugg) } Some(hir::Node::Item(hir::Item { ident, @@ -297,7 +298,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }) .collect::>() .join(", "); - format!("{}({})", ident, args) + let sugg = format!("({})", args); + (format!("{}{}", ident, sugg), sugg) } _ => return, }; @@ -306,10 +308,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // an argument, the `obligation.cause.span` points at the expression // of the argument, so we can provide a suggestion. This is signaled // by `points_at_arg`. Otherwise, we give a more general note. - err.span_suggestion( - obligation.cause.span, + err.span_suggestion_verbose( + obligation.cause.span.shrink_to_hi(), &msg, - snippet, + sugg, Applicability::HasPlaceholders, ); } else { @@ -494,7 +496,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .source_map() .span_take_while(span, |c| c.is_whitespace() || *c == '&'); if points_at_arg && mutability == hir::Mutability::Not && refs_number > 0 { - err.span_suggestion( + err.span_suggestion_verbose( sp, "consider changing this borrow's mutability", "&mut ".to_string(), @@ -898,11 +900,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // For example, if `expected_args_length` is 2, suggest `|_, _|`. if found_args.is_empty() && is_closure { let underscores = vec!["_"; expected_args.len()].join(", "); - err.span_suggestion( + err.span_suggestion_verbose( pipe_span, &format!( "consider changing the closure to take and ignore the expected argument{}", - if expected_args.len() < 2 { "" } else { "s" } + pluralize!(expected_args.len()) ), format!("|{}|", underscores), Applicability::MachineApplicable, @@ -916,7 +918,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .map(|(name, _)| name.to_owned()) .collect::>() .join(", "); - err.span_suggestion( + err.span_suggestion_verbose( found_span, "change the closure to take multiple arguments instead of a single tuple", format!("|{}|", sugg), @@ -953,7 +955,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { String::new() }, ); - err.span_suggestion( + err.span_suggestion_verbose( found_span, "change the closure to accept a tuple instead of individual arguments", sugg, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 542a1ac4536c1..3bcc598491b50 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -136,7 +136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self_ty: Ty<'tcx>, call_expr: &hir::Expr<'_>, ) { - let has_params = self + let params = self .probe_for_name( method_name.span, probe::Mode::MethodCall, @@ -146,26 +146,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { call_expr.hir_id, ProbeScope::TraitsInScope, ) - .and_then(|pick| { + .map(|pick| { let sig = self.tcx.fn_sig(pick.item.def_id); - Ok(sig.inputs().skip_binder().len() > 1) - }); + sig.inputs().skip_binder().len().saturating_sub(1) + }) + .unwrap_or(0); // Account for `foo.bar`; - let sugg_span = method_name.span.with_hi(call_expr.span.hi()); - let snippet = self - .tcx - .sess - .source_map() - .span_to_snippet(sugg_span) - .unwrap_or_else(|_| method_name.to_string()); - let (suggestion, applicability) = if has_params.unwrap_or_default() { - (format!("{}(...)", snippet), Applicability::HasPlaceholders) - } else { - (format!("{}()", snippet), Applicability::MaybeIncorrect) - }; + let sugg_span = call_expr.span.shrink_to_hi(); + let (suggestion, applicability) = ( + format!("({})", (0..params).map(|_| "_").collect::>().join(", ")), + if params > 0 { Applicability::HasPlaceholders } else { Applicability::MaybeIncorrect }, + ); - err.span_suggestion(sugg_span, msg, suggestion, applicability); + err.span_suggestion_verbose(sugg_span, msg, suggestion, applicability); } /// Performs method lookup. If lookup is successful, it will return the callee diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b34c6ddab3902..439c9853a14ea 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4951,15 +4951,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } _ => {} } - if let Ok(code) = self.sess().source_map().span_to_snippet(expr.span) { - err.span_suggestion( - expr.span, - &format!("use parentheses to {}", msg), - format!("{}({})", code, sugg_call), - applicability, - ); - return true; - } + err.span_suggestion_verbose( + expr.span.shrink_to_hi(), + &format!("use parentheses to {}", msg), + format!("({})", sugg_call), + applicability, + ); + return true; } false } diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 84854dff85165..886ac2cc5655d 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -752,17 +752,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { res.descr(), ), ); - let (msg, sugg) = match parent_pat { - Some(Pat { kind: hir::PatKind::Struct(..), .. }) => ( - "bind the struct field to a different name instead", - format!("{}: other_{}", ident, ident.as_str().to_lowercase()), - ), - _ => ( - "introduce a new binding instead", - format!("other_{}", ident.as_str().to_lowercase()), - ), + match parent_pat { + Some(Pat { kind: hir::PatKind::Struct(..), .. }) => { + e.span_suggestion_verbose( + ident.span.shrink_to_hi(), + "bind the struct field to a different name instead", + format!(": other_{}", ident.as_str().to_lowercase()), + Applicability::HasPlaceholders, + ); + } + _ => { + let msg = "introduce a new binding instead"; + let sugg = format!("other_{}", ident.as_str().to_lowercase()); + e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders); + } }; - e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders); } } e.emit(); diff --git a/src/test/ui/error-codes/E0615.stderr b/src/test/ui/error-codes/E0615.stderr index 772058719ae04..039d736673c08 100644 --- a/src/test/ui/error-codes/E0615.stderr +++ b/src/test/ui/error-codes/E0615.stderr @@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `method` on type `Foo` --> $DIR/E0615.rs:11:7 | LL | f.method; - | ^^^^^^ help: use parentheses to call the method: `method()` + | ^^^^^^ + | +help: use parentheses to call the method + | +LL | f.method(); + | ^^ error: aborting due to previous error diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 0c9165fd9585d..871757ec7b0c6 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -2,15 +2,17 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:22:20 | LL | fn assert_sized() { } - | ------------ -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized` - | | - | required by this bound in `assert_sized` + | ------------ - required by this bound in `assert_sized` ... LL | assert_sized::(); | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `A` = note: to learn more, visit +help: consider relaxing the implicit `Sized` restriction + | +LL | fn assert_sized() { } + | ^^^^^^^^ error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/extern-types-unsized.rs:25:5 diff --git a/src/test/ui/implicit-method-bind.stderr b/src/test/ui/implicit-method-bind.stderr index 968272d4d2c19..e9616f8317f91 100644 --- a/src/test/ui/implicit-method-bind.stderr +++ b/src/test/ui/implicit-method-bind.stderr @@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `abs` on type `i32` --> $DIR/implicit-method-bind.rs:2:20 | LL | let _f = 10i32.abs; - | ^^^ help: use parentheses to call the method: `abs()` + | ^^^ + | +help: use parentheses to call the method + | +LL | let _f = 10i32.abs(); + | ^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-13853-2.stderr b/src/test/ui/issues/issue-13853-2.stderr index ea3b38940cf01..264faa0da333b 100644 --- a/src/test/ui/issues/issue-13853-2.stderr +++ b/src/test/ui/issues/issue-13853-2.stderr @@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `get` on type `std::boxed::Box<( --> $DIR/issue-13853-2.rs:5:43 | LL | fn foo(res : Box) { res.get } - | ^^^ help: use parentheses to call the method: `get()` + | ^^^ + | +help: use parentheses to call the method + | +LL | fn foo(res : Box) { res.get() } + | ^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-26472.stderr b/src/test/ui/issues/issue-26472.stderr index 245ebeaf972ed..9073bfed8948e 100644 --- a/src/test/ui/issues/issue-26472.stderr +++ b/src/test/ui/issues/issue-26472.stderr @@ -2,9 +2,12 @@ error[E0616]: field `len` of struct `sub::S` is private --> $DIR/issue-26472.rs:11:13 | LL | let v = s.len; - | ^^--- - | | - | help: a method `len` also exists, call it with parentheses: `len()` + | ^^^^^ + | +help: a method `len` also exists, call it with parentheses + | +LL | let v = s.len(); + | ^^ error[E0616]: field `len` of struct `sub::S` is private --> $DIR/issue-26472.rs:12:5 diff --git a/src/test/ui/issues/issue-35241.stderr b/src/test/ui/issues/issue-35241.stderr index 4a52a292ef30a..b6045c993a958 100644 --- a/src/test/ui/issues/issue-35241.stderr +++ b/src/test/ui/issues/issue-35241.stderr @@ -5,14 +5,16 @@ LL | struct Foo(u32); | ---------------- fn(u32) -> Foo {Foo} defined here LL | LL | fn test() -> Foo { Foo } - | --- ^^^ - | | | - | | expected struct `Foo`, found fn item - | | help: use parentheses to instantiate this tuple struct: `Foo(_)` + | --- ^^^ expected struct `Foo`, found fn item + | | | expected `Foo` because of return type | = note: expected struct `Foo` found fn item `fn(u32) -> Foo {Foo}` +help: use parentheses to instantiate this tuple struct + | +LL | fn test() -> Foo { Foo(_) } + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/methods/method-missing-call.stderr b/src/test/ui/methods/method-missing-call.stderr index 3ab5f66a0c3f6..23f8970e9e790 100644 --- a/src/test/ui/methods/method-missing-call.stderr +++ b/src/test/ui/methods/method-missing-call.stderr @@ -2,13 +2,23 @@ error[E0615]: attempted to take value of method `get_x` on type `Point` --> $DIR/method-missing-call.rs:22:26 | LL | .get_x; - | ^^^^^ help: use parentheses to call the method: `get_x()` + | ^^^^^ + | +help: use parentheses to call the method + | +LL | .get_x(); + | ^^ error[E0615]: attempted to take value of method `filter_map` on type `std::iter::Filter, [closure@$DIR/method-missing-call.rs:27:20: 27:25]>, [closure@$DIR/method-missing-call.rs:28:23: 28:35]>` --> $DIR/method-missing-call.rs:29:16 | LL | .filter_map; - | ^^^^^^^^^^ help: use parentheses to call the method: `filter_map(...)` + | ^^^^^^^^^^ + | +help: use parentheses to call the method + | +LL | .filter_map(_); + | ^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/question-mark-type-infer.stderr b/src/test/ui/question-mark-type-infer.stderr index 7911701946cd3..262344fba5999 100644 --- a/src/test/ui/question-mark-type-infer.stderr +++ b/src/test/ui/question-mark-type-infer.stderr @@ -2,12 +2,13 @@ error[E0284]: type annotations needed --> $DIR/question-mark-type-infer.rs:12:21 | LL | l.iter().map(f).collect()? - | ^^^^^^^ - | | - | cannot infer type - | help: consider specifying the type argument in the method call: `collect::` + | ^^^^^^^ cannot infer type | = note: cannot resolve `<_ as std::ops::Try>::Ok == _` +help: consider specifying the type argument in the method call + | +LL | l.iter().map(f).collect::()? + | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/reify-intrinsic.stderr b/src/test/ui/reify-intrinsic.stderr index 4defe12b1b37b..c4eee0f466119 100644 --- a/src/test/ui/reify-intrinsic.stderr +++ b/src/test/ui/reify-intrinsic.stderr @@ -2,14 +2,16 @@ error[E0308]: cannot coerce intrinsics to function pointers --> $DIR/reify-intrinsic.rs:6:64 | LL | let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute; - | ------------------------------------------------- ^^^^^^^^^^^^^^^^^^^ - | | | - | | cannot coerce intrinsics to function pointers - | | help: use parentheses to call this function: `std::mem::transmute(...)` + | ------------------------------------------------- ^^^^^^^^^^^^^^^^^^^ cannot coerce intrinsics to function pointers + | | | expected due to this | = note: expected fn pointer `unsafe extern "rust-intrinsic" fn(isize) -> usize` found fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` +help: use parentheses to call this function + | +LL | let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute(...); + | ^^^^^ error[E0606]: casting `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid --> $DIR/reify-intrinsic.rs:11:13 diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index 08a1d790197a6..bf24cfc4d7377 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -304,14 +304,16 @@ LL | Fn(u8), | ------ fn(u8) -> m::n::Z {m::n::Z::Fn} defined here ... LL | let _: Z = Z::Fn; - | - ^^^^^ - | | | - | | expected enum `m::n::Z`, found fn item - | | help: use parentheses to instantiate this tuple variant: `Z::Fn(_)` + | - ^^^^^ expected enum `m::n::Z`, found fn item + | | | expected due to this | = note: expected enum `m::n::Z` found fn item `fn(u8) -> m::n::Z {m::n::Z::Fn}` +help: use parentheses to instantiate this tuple variant + | +LL | let _: Z = Z::Fn(_); + | ^^^ error[E0618]: expected function, found enum variant `Z::Unit` --> $DIR/privacy-enum-ctor.rs:31:17 @@ -336,14 +338,16 @@ LL | Fn(u8), | ------ fn(u8) -> m::E {m::E::Fn} defined here ... LL | let _: E = m::E::Fn; - | - ^^^^^^^^ - | | | - | | expected enum `m::E`, found fn item - | | help: use parentheses to instantiate this tuple variant: `m::E::Fn(_)` + | - ^^^^^^^^ expected enum `m::E`, found fn item + | | | expected due to this | = note: expected enum `m::E` found fn item `fn(u8) -> m::E {m::E::Fn}` +help: use parentheses to instantiate this tuple variant + | +LL | let _: E = m::E::Fn(_); + | ^^^ error[E0618]: expected function, found enum variant `m::E::Unit` --> $DIR/privacy-enum-ctor.rs:47:16 @@ -368,14 +372,16 @@ LL | Fn(u8), | ------ fn(u8) -> m::E {m::E::Fn} defined here ... LL | let _: E = E::Fn; - | - ^^^^^ - | | | - | | expected enum `m::E`, found fn item - | | help: use parentheses to instantiate this tuple variant: `E::Fn(_)` + | - ^^^^^ expected enum `m::E`, found fn item + | | | expected due to this | = note: expected enum `m::E` found fn item `fn(u8) -> m::E {m::E::Fn}` +help: use parentheses to instantiate this tuple variant + | +LL | let _: E = E::Fn(_); + | ^^^ error[E0618]: expected function, found enum variant `E::Unit` --> $DIR/privacy-enum-ctor.rs:55:16 diff --git a/src/test/ui/span/type-annotations-needed-expr.stderr b/src/test/ui/span/type-annotations-needed-expr.stderr index 2b92f9b93bff2..13bd938389ed5 100644 --- a/src/test/ui/span/type-annotations-needed-expr.stderr +++ b/src/test/ui/span/type-annotations-needed-expr.stderr @@ -2,12 +2,13 @@ error[E0282]: type annotations needed --> $DIR/type-annotations-needed-expr.rs:2:39 | LL | let _ = (vec![1,2,3]).into_iter().sum() as f64; - | ^^^ - | | - | cannot infer type for type parameter `S` declared on the method `sum` - | help: consider specifying the type argument in the method call: `sum::` + | ^^^ cannot infer type for type parameter `S` declared on the method `sum` | = note: type must be known at this point +help: consider specifying the type argument in the method call + | +LL | let _ = (vec![1,2,3]).into_iter().sum::() as f64; + | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index a9ec6b9c02fe8..d0afb2ae7af74 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -2,15 +2,17 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t --> $DIR/str-mut-idx.rs:4:15 | LL | fn bot() -> T { loop {} } - | --- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized` - | | - | required by this bound in `bot` + | --- - required by this bound in `bot` ... LL | s[1..2] = bot(); | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit +help: consider relaxing the implicit `Sized` restriction + | +LL | fn bot() -> T { loop {} } + | ^^^^^^^^ error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/str-mut-idx.rs:4:5 diff --git a/src/test/ui/substs-ppaux.normal.stderr b/src/test/ui/substs-ppaux.normal.stderr index 4423f3c130e2a..3ad2a1414f969 100644 --- a/src/test/ui/substs-ppaux.normal.stderr +++ b/src/test/ui/substs-ppaux.normal.stderr @@ -5,14 +5,16 @@ LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::<'static, char>} defined here ... LL | let x: () = >::bar::<'static, char>; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `()`, found fn item - | | help: use parentheses to call this function: `>::bar::<'static, char>()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item + | | | expected due to this | = note: expected unit type `()` found fn item `fn() {>::bar::<'static, char>}` +help: use parentheses to call this function + | +LL | let x: () = >::bar::<'static, char>(); + | ^^ error[E0308]: mismatched types --> $DIR/substs-ppaux.rs:25:17 @@ -21,14 +23,16 @@ LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::<'static, char>} defined here ... LL | let x: () = >::bar::<'static, char>; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `()`, found fn item - | | help: use parentheses to call this function: `>::bar::<'static, char>()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item + | | | expected due to this | = note: expected unit type `()` found fn item `fn() {>::bar::<'static, char>}` +help: use parentheses to call this function + | +LL | let x: () = >::bar::<'static, char>(); + | ^^ error[E0308]: mismatched types --> $DIR/substs-ppaux.rs:33:17 @@ -37,14 +41,16 @@ LL | fn baz() {} | -------- fn() {>::baz} defined here ... LL | let x: () = >::baz; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `()`, found fn item - | | help: use parentheses to call this function: `>::baz()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item + | | | expected due to this | = note: expected unit type `()` found fn item `fn() {>::baz}` +help: use parentheses to call this function + | +LL | let x: () = >::baz(); + | ^^ error[E0308]: mismatched types --> $DIR/substs-ppaux.rs:41:17 @@ -53,14 +59,16 @@ LL | fn foo<'z>() where &'z (): Sized { | -------------------------------- fn() {foo::<'static>} defined here ... LL | let x: () = foo::<'static>; - | -- ^^^^^^^^^^^^^^ - | | | - | | expected `()`, found fn item - | | help: use parentheses to call this function: `foo::<'static>()` + | -- ^^^^^^^^^^^^^^ expected `()`, found fn item + | | | expected due to this | = note: expected unit type `()` found fn item `fn() {foo::<'static>}` +help: use parentheses to call this function + | +LL | let x: () = foo::<'static>(); + | ^^ error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/substs-ppaux.rs:49:5 diff --git a/src/test/ui/substs-ppaux.verbose.stderr b/src/test/ui/substs-ppaux.verbose.stderr index 2aebdebee72c1..e23f06a3ef590 100644 --- a/src/test/ui/substs-ppaux.verbose.stderr +++ b/src/test/ui/substs-ppaux.verbose.stderr @@ -5,14 +5,16 @@ LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::} defined here ... LL | let x: () = >::bar::<'static, char>; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `()`, found fn item - | | help: use parentheses to call this function: `>::bar::<'static, char>()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item + | | | expected due to this | = note: expected unit type `()` found fn item `fn() {>::bar::}` +help: use parentheses to call this function + | +LL | let x: () = >::bar::<'static, char>(); + | ^^ error[E0308]: mismatched types --> $DIR/substs-ppaux.rs:25:17 @@ -21,14 +23,16 @@ LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::} defined here ... LL | let x: () = >::bar::<'static, char>; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `()`, found fn item - | | help: use parentheses to call this function: `>::bar::<'static, char>()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item + | | | expected due to this | = note: expected unit type `()` found fn item `fn() {>::bar::}` +help: use parentheses to call this function + | +LL | let x: () = >::bar::<'static, char>(); + | ^^ error[E0308]: mismatched types --> $DIR/substs-ppaux.rs:33:17 @@ -37,14 +41,16 @@ LL | fn baz() {} | -------- fn() {>::baz} defined here ... LL | let x: () = >::baz; - | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `()`, found fn item - | | help: use parentheses to call this function: `>::baz()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item + | | | expected due to this | = note: expected unit type `()` found fn item `fn() {>::baz}` +help: use parentheses to call this function + | +LL | let x: () = >::baz(); + | ^^ error[E0308]: mismatched types --> $DIR/substs-ppaux.rs:41:17 @@ -53,14 +59,16 @@ LL | fn foo<'z>() where &'z (): Sized { | -------------------------------- fn() {foo::} defined here ... LL | let x: () = foo::<'static>; - | -- ^^^^^^^^^^^^^^ - | | | - | | expected `()`, found fn item - | | help: use parentheses to call this function: `foo::<'static>()` + | -- ^^^^^^^^^^^^^^ expected `()`, found fn item + | | | expected due to this | = note: expected unit type `()` found fn item `fn() {foo::}` +help: use parentheses to call this function + | +LL | let x: () = foo::<'static>(); + | ^^ error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/substs-ppaux.rs:49:5 diff --git a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index 05583876a066c..638d504d7feab 100644 --- a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -8,10 +8,12 @@ LL | fn bar(f: impl Future) {} | --- ----------------- required by this bound in `bar` ... LL | bar(foo); - | ^^^ - | | - | the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}` - | help: use parentheses to call the function: `foo()` + | ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}` + | +help: use parentheses to call the function + | +LL | bar(foo()); + | ^^ error[E0277]: the trait bound `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]: std::future::Future` is not satisfied --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9 @@ -22,10 +24,12 @@ LL | fn bar(f: impl Future) {} LL | let async_closure = async || (); | -------- consider calling this closure LL | bar(async_closure); - | ^^^^^^^^^^^^^ - | | - | the trait `std::future::Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]` - | help: use parentheses to call the closure: `async_closure()` + | ^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]` + | +help: use parentheses to call the closure + | +LL | bar(async_closure()); + | ^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/suggestions/const-in-struct-pat.stderr b/src/test/ui/suggestions/const-in-struct-pat.stderr index 0a010dcab4c26..ab336b14d2948 100644 --- a/src/test/ui/suggestions/const-in-struct-pat.stderr +++ b/src/test/ui/suggestions/const-in-struct-pat.stderr @@ -9,7 +9,11 @@ LL | let Thing { foo } = t; | | | expected struct `std::string::String`, found struct `foo` | `foo` is interpreted as a unit struct, not a new binding - | help: bind the struct field to a different name instead: `foo: other_foo` + | +help: bind the struct field to a different name instead + | +LL | let Thing { foo: other_foo } = t; + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index 91f60e8f426c4..ed4a0b8487dff 100644 --- a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -8,10 +8,12 @@ LL | fn bar(f: impl T) {} | --- ------- required by this bound in `bar` ... LL | bar(foo); - | ^^^ - | | - | the trait `T` is not implemented for `fn() -> impl T {foo}` - | help: use parentheses to call the function: `foo()` + | ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}` + | +help: use parentheses to call the function + | +LL | bar(foo()); + | ^^ error[E0277]: the trait bound `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]: T` is not satisfied --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9 @@ -22,10 +24,12 @@ LL | fn bar(f: impl T) {} LL | let closure = || S; | -- consider calling this closure LL | bar(closure); - | ^^^^^^^ - | | - | the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]` - | help: use parentheses to call the closure: `closure()` + | ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]` + | +help: use parentheses to call the closure + | +LL | bar(closure()); + | ^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr index 232e54b5d37b2..69aef0853cec3 100644 --- a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -19,14 +19,16 @@ LL | fn foo(a: usize, b: usize) -> usize { a } | ----------------------------------- fn(usize, usize) -> usize {foo} defined here ... LL | let _: usize = foo; - | ----- ^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `foo(a, b)` + | ----- ^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `fn(usize, usize) -> usize {foo}` +help: use parentheses to call this function + | +LL | let _: usize = foo(a, b); + | ^^^^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:30:16 @@ -35,14 +37,16 @@ LL | struct S(usize, usize); | ----------------------- fn(usize, usize) -> S {S} defined here ... LL | let _: S = S; - | - ^ - | | | - | | expected struct `S`, found fn item - | | help: use parentheses to instantiate this tuple struct: `S(_, _)` + | - ^ expected struct `S`, found fn item + | | | expected due to this | = note: expected struct `S` found fn item `fn(usize, usize) -> S {S}` +help: use parentheses to instantiate this tuple struct + | +LL | let _: S = S(_, _); + | ^^^^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:31:20 @@ -51,14 +55,16 @@ LL | fn bar() -> usize { 42 } | ----------------- fn() -> usize {bar} defined here ... LL | let _: usize = bar; - | ----- ^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `bar()` + | ----- ^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `fn() -> usize {bar}` +help: use parentheses to call this function + | +LL | let _: usize = bar(); + | ^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:32:16 @@ -67,14 +73,16 @@ LL | struct V(); | ----------- fn() -> V {V} defined here ... LL | let _: V = V; - | - ^ - | | | - | | expected struct `V`, found fn item - | | help: use parentheses to instantiate this tuple struct: `V()` + | - ^ expected struct `V`, found fn item + | | | expected due to this | = note: expected struct `V` found fn item `fn() -> V {V}` +help: use parentheses to instantiate this tuple struct + | +LL | let _: V = V(); + | ^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:33:20 @@ -83,14 +91,16 @@ LL | fn baz(x: usize, y: usize) -> usize { x } | ----------------------------------- fn(usize, usize) -> usize {<_ as T>::baz} defined here ... LL | let _: usize = T::baz; - | ----- ^^^^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `T::baz(x, y)` + | ----- ^^^^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `fn(usize, usize) -> usize {<_ as T>::baz}` +help: use parentheses to call this function + | +LL | let _: usize = T::baz(x, y); + | ^^^^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:34:20 @@ -99,14 +109,16 @@ LL | fn bat(x: usize) -> usize { 42 } | ------------------------- fn(usize) -> usize {<_ as T>::bat} defined here ... LL | let _: usize = T::bat; - | ----- ^^^^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `T::bat(x)` + | ----- ^^^^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `fn(usize) -> usize {<_ as T>::bat}` +help: use parentheses to call this function + | +LL | let _: usize = T::bat(x); + | ^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:35:16 @@ -115,14 +127,16 @@ LL | A(usize), | -------- fn(usize) -> E {E::A} defined here ... LL | let _: E = E::A; - | - ^^^^ - | | | - | | expected enum `E`, found fn item - | | help: use parentheses to instantiate this tuple variant: `E::A(_)` + | - ^^^^ expected enum `E`, found fn item + | | | expected due to this | = note: expected enum `E` found fn item `fn(usize) -> E {E::A}` +help: use parentheses to instantiate this tuple variant + | +LL | let _: E = E::A(_); + | ^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:37:20 @@ -131,14 +145,16 @@ LL | fn baz(x: usize, y: usize) -> usize { x } | ----------------------------------- fn(usize, usize) -> usize {::baz} defined here ... LL | let _: usize = X::baz; - | ----- ^^^^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `X::baz(x, y)` + | ----- ^^^^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `fn(usize, usize) -> usize {::baz}` +help: use parentheses to call this function + | +LL | let _: usize = X::baz(x, y); + | ^^^^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:38:20 @@ -147,14 +163,16 @@ LL | fn bat(x: usize) -> usize { 42 } | ------------------------- fn(usize) -> usize {::bat} defined here ... LL | let _: usize = X::bat; - | ----- ^^^^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `X::bat(x)` + | ----- ^^^^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `fn(usize) -> usize {::bat}` +help: use parentheses to call this function + | +LL | let _: usize = X::bat(x); + | ^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:39:20 @@ -163,14 +181,16 @@ LL | fn bax(x: usize) -> usize { 42 } | ------------------------- fn(usize) -> usize {::bax} defined here ... LL | let _: usize = X::bax; - | ----- ^^^^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `X::bax(x)` + | ----- ^^^^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `fn(usize) -> usize {::bax}` +help: use parentheses to call this function + | +LL | let _: usize = X::bax(x); + | ^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:40:20 @@ -179,14 +199,16 @@ LL | fn bach(x: usize) -> usize; | --------------------------- fn(usize) -> usize {::bach} defined here ... LL | let _: usize = X::bach; - | ----- ^^^^^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `X::bach(x)` + | ----- ^^^^^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `fn(usize) -> usize {::bach}` +help: use parentheses to call this function + | +LL | let _: usize = X::bach(x); + | ^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:41:20 @@ -195,14 +217,16 @@ LL | fn ban(&self) -> usize { 42 } | ---------------------- for<'r> fn(&'r X) -> usize {::ban} defined here ... LL | let _: usize = X::ban; - | ----- ^^^^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `X::ban(_)` + | ----- ^^^^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `for<'r> fn(&'r X) -> usize {::ban}` +help: use parentheses to call this function + | +LL | let _: usize = X::ban(_); + | ^^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:42:20 @@ -211,26 +235,38 @@ LL | fn bal(&self) -> usize; | ----------------------- for<'r> fn(&'r X) -> usize {::bal} defined here ... LL | let _: usize = X::bal; - | ----- ^^^^^^ - | | | - | | expected `usize`, found fn item - | | help: use parentheses to call this function: `X::bal(_)` + | ----- ^^^^^^ expected `usize`, found fn item + | | | expected due to this | = note: expected type `usize` found fn item `for<'r> fn(&'r X) -> usize {::bal}` +help: use parentheses to call this function + | +LL | let _: usize = X::bal(_); + | ^^^ error[E0615]: attempted to take value of method `ban` on type `X` --> $DIR/fn-or-tuple-struct-without-args.rs:43:22 | LL | let _: usize = X.ban; - | ^^^ help: use parentheses to call the method: `ban()` + | ^^^ + | +help: use parentheses to call the method + | +LL | let _: usize = X.ban(); + | ^^ error[E0615]: attempted to take value of method `bal` on type `X` --> $DIR/fn-or-tuple-struct-without-args.rs:44:22 | LL | let _: usize = X.bal; - | ^^^ help: use parentheses to call the method: `bal()` + | ^^^ + | +help: use parentheses to call the method + | +LL | let _: usize = X.bal(); + | ^^ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:46:20 @@ -238,14 +274,16 @@ error[E0308]: mismatched types LL | let closure = || 42; | ----- the found closure LL | let _: usize = closure; - | ----- ^^^^^^^ - | | | - | | expected `usize`, found closure - | | help: use parentheses to call this closure: `closure()` + | ----- ^^^^^^^ expected `usize`, found closure + | | | expected due to this | = note: expected type `usize` found closure `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]` +help: use parentheses to call this closure + | +LL | let _: usize = closure(); + | ^^ error: aborting due to 17 previous errors diff --git a/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr b/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr index ccaceefacd739..84ba935191b48 100644 --- a/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr +++ b/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr @@ -5,13 +5,14 @@ LL | fn foo(_: X) {} | --- ----- required by this bound in `foo` ... LL | foo(&s); - | -^ - | | - | the trait `Trait` is not implemented for `&S` - | help: consider changing this borrow's mutability: `&mut` + | ^^ the trait `Trait` is not implemented for `&S` | = help: the following implementations were found: <&'a mut S as Trait> +help: consider changing this borrow's mutability + | +LL | foo(&mut s); + | ^^^^ error[E0277]: the trait bound `S: Trait` is not satisfied --> $DIR/imm-ref-trait-object-literal.rs:13:7 diff --git a/src/test/ui/suggestions/method-missing-parentheses.stderr b/src/test/ui/suggestions/method-missing-parentheses.stderr index 6e4f7a84724bf..75a6091d56e93 100644 --- a/src/test/ui/suggestions/method-missing-parentheses.stderr +++ b/src/test/ui/suggestions/method-missing-parentheses.stderr @@ -8,9 +8,12 @@ error[E0615]: attempted to take value of method `collect` on type `std::vec::Int --> $DIR/method-missing-parentheses.rs:2:32 | LL | let _ = vec![].into_iter().collect::; - | ^^^^^^^--------- - | | - | help: use parentheses to call the method: `collect::()` + | ^^^^^^^ + | +help: use parentheses to call the method + | +LL | let _ = vec![].into_iter().collect::(); + | ^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/type-inference/or_else-multiple-type-params.stderr b/src/test/ui/type-inference/or_else-multiple-type-params.stderr index b9258b20f5add..b468eedf1eef2 100644 --- a/src/test/ui/type-inference/or_else-multiple-type-params.stderr +++ b/src/test/ui/type-inference/or_else-multiple-type-params.stderr @@ -2,10 +2,12 @@ error[E0282]: type annotations needed --> $DIR/or_else-multiple-type-params.rs:7:10 | LL | .or_else(|err| { - | ^^^^^^^ - | | - | cannot infer type for type parameter `F` declared on the method `or_else` - | help: consider specifying the type arguments in the method call: `or_else::` + | ^^^^^^^ cannot infer type for type parameter `F` declared on the method `or_else` + | +help: consider specifying the type arguments in the method call + | +LL | .or_else::(|err| { + | ^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type-inference/sort_by_key.stderr b/src/test/ui/type-inference/sort_by_key.stderr index e74c0dfa5e20c..127283417cc2a 100644 --- a/src/test/ui/type-inference/sort_by_key.stderr +++ b/src/test/ui/type-inference/sort_by_key.stderr @@ -2,9 +2,12 @@ error[E0282]: type annotations needed --> $DIR/sort_by_key.rs:3:9 | LL | lst.sort_by_key(|&(v, _)| v.iter().sum()); - | ^^^^^^^^^^^ --- help: consider specifying the type argument in the method call: `sum::` - | | - | cannot infer type for type parameter `K` declared on the method `sort_by_key` + | ^^^^^^^^^^^ cannot infer type for type parameter `K` declared on the method `sort_by_key` + | +help: consider specifying the type argument in the method call + | +LL | lst.sort_by_key(|&(v, _)| v.iter().sum::()); + | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type/type-annotation-needed.stderr b/src/test/ui/type/type-annotation-needed.stderr index c6a811e836342..df7d73d7a7c1d 100644 --- a/src/test/ui/type/type-annotation-needed.stderr +++ b/src/test/ui/type/type-annotation-needed.stderr @@ -5,12 +5,13 @@ LL | fn foo>(x: i32) {} | --- ------------ required by this bound in `foo` ... LL | foo(42); - | ^^^ - | | - | cannot infer type for type parameter `T` declared on the function `foo` - | help: consider specifying the type argument in the function call: `foo::` + | ^^^ cannot infer type for type parameter `T` declared on the function `foo` | = note: cannot resolve `_: std::convert::Into` +help: consider specifying the type argument in the function call + | +LL | foo::(42); + | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/union/union-suggest-field.rs b/src/test/ui/union/union-suggest-field.rs index d84a22cee5ab2..71b93e873c220 100644 --- a/src/test/ui/union/union-suggest-field.rs +++ b/src/test/ui/union/union-suggest-field.rs @@ -17,5 +17,5 @@ fn main() { let y = u.calculate; //~ ERROR attempted to take value of method `calculate` on type `U` //~| HELP use parentheses to call the method - //~| SUGGESTION calculate() + //~| SUGGESTION () } diff --git a/src/test/ui/union/union-suggest-field.stderr b/src/test/ui/union/union-suggest-field.stderr index 5050e4a986499..6ab84c4836af1 100644 --- a/src/test/ui/union/union-suggest-field.stderr +++ b/src/test/ui/union/union-suggest-field.stderr @@ -14,7 +14,12 @@ error[E0615]: attempted to take value of method `calculate` on type `U` --> $DIR/union-suggest-field.rs:18:15 | LL | let y = u.calculate; - | ^^^^^^^^^ help: use parentheses to call the method: `calculate()` + | ^^^^^^^^^ + | +help: use parentheses to call the method + | +LL | let y = u.calculate(); + | ^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr index e97d00fc4741d..083c74ba1e05d 100644 --- a/src/test/ui/unsized3.stderr +++ b/src/test/ui/unsized3.stderr @@ -7,12 +7,14 @@ LL | f2::(x); | ^ doesn't have a size known at compile-time ... LL | fn f2(x: &X) { - | -- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized` - | | - | required by this bound in `f2` + | -- - required by this bound in `f2` | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit +help: consider relaxing the implicit `Sized` restriction + | +LL | fn f2(x: &X) { + | ^^^^^^^^ error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized3.rs:18:13 @@ -23,12 +25,14 @@ LL | f4::(x); | ^ doesn't have a size known at compile-time ... LL | fn f4(x: &X) { - | -- - - help: consider relaxing the implicit `Sized` restriction: `+ ?Sized` - | | - | required by this bound in `f4` + | -- - required by this bound in `f4` | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit +help: consider relaxing the implicit `Sized` restriction + | +LL | fn f4(x: &X) { + | ^^^^^^^^^ error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized3.rs:33:8 From 40ffcc2911ef0a1d32395481338d60ad9d81afaa Mon Sep 17 00:00:00 2001 From: "KRAAI, MATTHEW [VISUS]" Date: Fri, 13 Mar 2020 12:01:41 -0700 Subject: [PATCH 13/14] Add self to .mailmap --- .mailmap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.mailmap b/.mailmap index ea8ef0eebf9a1..78c3c3019af50 100644 --- a/.mailmap +++ b/.mailmap @@ -172,6 +172,9 @@ Mateusz Mikuła Mateusz Mikuła Matt Brubeck Matthew Auld +Matthew Kraai +Matthew Kraai +Matthew Kraai Matthew McPherrin Matthijs Hofstra Melody Horn From c274e0721b122b5fa58f06560f994ac00bca2948 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 12 Mar 2020 11:39:30 -0700 Subject: [PATCH 14/14] Fix abort-on-eprintln during process shutdown This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations. --- src/libstd/io/stdio.rs | 49 +++++++----- src/libstd/sys/cloudabi/mutex.rs | 8 +- src/libstd/sys/hermit/mutex.rs | 6 +- src/libstd/sys/sgx/mutex.rs | 2 +- src/libstd/sys/unix/mutex.rs | 4 +- src/libstd/sys/vxworks/mutex.rs | 4 +- src/libstd/sys/wasm/mutex.rs | 4 +- src/libstd/sys/wasm/mutex_atomics.rs | 4 +- src/libstd/sys/windows/mutex.rs | 6 +- src/libstd/sys_common/remutex.rs | 114 ++++++++++++--------------- src/test/ui/eprint-on-tls-drop.rs | 43 ++++++++++ 11 files changed, 144 insertions(+), 100 deletions(-) create mode 100644 src/test/ui/eprint-on-tls-drop.rs diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index d410faca30d9e..0ac928817184d 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -6,7 +6,7 @@ use crate::cell::RefCell; use crate::fmt; use crate::io::lazy::Lazy; use crate::io::{self, BufReader, Initializer, IoSlice, IoSliceMut, LineWriter}; -use crate::sync::{Arc, Mutex, MutexGuard}; +use crate::sync::{Arc, Mutex, MutexGuard, Once}; use crate::sys::stdio; use crate::sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; use crate::thread::LocalKey; @@ -493,7 +493,11 @@ pub fn stdout() -> Stdout { Ok(stdout) => Maybe::Real(stdout), _ => Maybe::Fake, }; - Arc::new(ReentrantMutex::new(RefCell::new(LineWriter::new(stdout)))) + unsafe { + let ret = Arc::new(ReentrantMutex::new(RefCell::new(LineWriter::new(stdout)))); + ret.init(); + return ret; + } } } @@ -520,7 +524,7 @@ impl Stdout { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn lock(&self) -> StdoutLock<'_> { - StdoutLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) } + StdoutLock { inner: self.inner.lock() } } } @@ -581,7 +585,7 @@ impl fmt::Debug for StdoutLock<'_> { /// an error. #[stable(feature = "rust1", since = "1.0.0")] pub struct Stderr { - inner: Arc>>>, + inner: &'static ReentrantMutex>>, } /// A locked reference to the `Stderr` handle. @@ -639,19 +643,28 @@ pub struct StderrLock<'a> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn stderr() -> Stderr { - static INSTANCE: Lazy>>> = Lazy::new(); - return Stderr { - inner: unsafe { INSTANCE.get(stderr_init).expect("cannot access stderr during shutdown") }, - }; - - fn stderr_init() -> Arc>>> { - // This must not reentrantly access `INSTANCE` - let stderr = match stderr_raw() { - Ok(stderr) => Maybe::Real(stderr), - _ => Maybe::Fake, - }; - Arc::new(ReentrantMutex::new(RefCell::new(stderr))) - } + // Note that unlike `stdout()` we don't use `Lazy` here which registers a + // destructor. Stderr is not buffered nor does the `stderr_raw` type consume + // any owned resources, so there's no need to run any destructors at some + // point in the future. + // + // This has the added benefit of allowing `stderr` to be usable during + // process shutdown as well! + static INSTANCE: ReentrantMutex>> = + unsafe { ReentrantMutex::new(RefCell::new(Maybe::Fake)) }; + + // When accessing stderr we need one-time initialization of the reentrant + // mutex, followed by one-time detection of whether we actually have a + // stderr handle or not. Afterwards we can just always use the now-filled-in + // `INSTANCE` value. + static INIT: Once = Once::new(); + INIT.call_once(|| unsafe { + INSTANCE.init(); + if let Ok(stderr) = stderr_raw() { + *INSTANCE.lock().borrow_mut() = Maybe::Real(stderr); + } + }); + return Stderr { inner: &INSTANCE }; } impl Stderr { @@ -677,7 +690,7 @@ impl Stderr { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn lock(&self) -> StderrLock<'_> { - StderrLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) } + StderrLock { inner: self.inner.lock() } } } diff --git a/src/libstd/sys/cloudabi/mutex.rs b/src/libstd/sys/cloudabi/mutex.rs index 4aa25e2505271..580ab0e8ad863 100644 --- a/src/libstd/sys/cloudabi/mutex.rs +++ b/src/libstd/sys/cloudabi/mutex.rs @@ -53,16 +53,16 @@ pub struct ReentrantMutex { } impl ReentrantMutex { - pub unsafe fn uninitialized() -> ReentrantMutex { + pub const unsafe fn uninitialized() -> ReentrantMutex { ReentrantMutex { lock: UnsafeCell::new(MaybeUninit::uninit()), recursion: UnsafeCell::new(MaybeUninit::uninit()), } } - pub unsafe fn init(&mut self) { - self.lock = UnsafeCell::new(MaybeUninit::new(AtomicU32::new(abi::LOCK_UNLOCKED.0))); - self.recursion = UnsafeCell::new(MaybeUninit::new(0)); + pub unsafe fn init(&self) { + *self.lock.get() = MaybeUninit::new(AtomicU32::new(abi::LOCK_UNLOCKED.0)); + *self.recursion.get() = MaybeUninit::new(0); } pub unsafe fn try_lock(&self) -> bool { diff --git a/src/libstd/sys/hermit/mutex.rs b/src/libstd/sys/hermit/mutex.rs index b5c75f738d228..3d4813209cbc4 100644 --- a/src/libstd/sys/hermit/mutex.rs +++ b/src/libstd/sys/hermit/mutex.rs @@ -46,13 +46,13 @@ pub struct ReentrantMutex { } impl ReentrantMutex { - pub unsafe fn uninitialized() -> ReentrantMutex { + pub const unsafe fn uninitialized() -> ReentrantMutex { ReentrantMutex { inner: ptr::null() } } #[inline] - pub unsafe fn init(&mut self) { - let _ = abi::recmutex_init(&mut self.inner as *mut *const c_void); + pub unsafe fn init(&self) { + let _ = abi::recmutex_init(&self.inner as *const *const c_void as *mut _); } #[inline] diff --git a/src/libstd/sys/sgx/mutex.rs b/src/libstd/sys/sgx/mutex.rs index eebbea1b285ba..4911c2f538769 100644 --- a/src/libstd/sys/sgx/mutex.rs +++ b/src/libstd/sys/sgx/mutex.rs @@ -75,7 +75,7 @@ impl ReentrantMutex { } #[inline] - pub unsafe fn init(&mut self) {} + pub unsafe fn init(&self) {} #[inline] pub unsafe fn lock(&self) { diff --git a/src/libstd/sys/unix/mutex.rs b/src/libstd/sys/unix/mutex.rs index b38375a2e03c5..103d87e3d2f91 100644 --- a/src/libstd/sys/unix/mutex.rs +++ b/src/libstd/sys/unix/mutex.rs @@ -92,11 +92,11 @@ unsafe impl Send for ReentrantMutex {} unsafe impl Sync for ReentrantMutex {} impl ReentrantMutex { - pub unsafe fn uninitialized() -> ReentrantMutex { + pub const unsafe fn uninitialized() -> ReentrantMutex { ReentrantMutex { inner: UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER) } } - pub unsafe fn init(&mut self) { + pub unsafe fn init(&self) { let mut attr = MaybeUninit::::uninit(); let result = libc::pthread_mutexattr_init(attr.as_mut_ptr()); debug_assert_eq!(result, 0); diff --git a/src/libstd/sys/vxworks/mutex.rs b/src/libstd/sys/vxworks/mutex.rs index b38375a2e03c5..103d87e3d2f91 100644 --- a/src/libstd/sys/vxworks/mutex.rs +++ b/src/libstd/sys/vxworks/mutex.rs @@ -92,11 +92,11 @@ unsafe impl Send for ReentrantMutex {} unsafe impl Sync for ReentrantMutex {} impl ReentrantMutex { - pub unsafe fn uninitialized() -> ReentrantMutex { + pub const unsafe fn uninitialized() -> ReentrantMutex { ReentrantMutex { inner: UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER) } } - pub unsafe fn init(&mut self) { + pub unsafe fn init(&self) { let mut attr = MaybeUninit::::uninit(); let result = libc::pthread_mutexattr_init(attr.as_mut_ptr()); debug_assert_eq!(result, 0); diff --git a/src/libstd/sys/wasm/mutex.rs b/src/libstd/sys/wasm/mutex.rs index 07238d087308f..7aaf1b3a343b6 100644 --- a/src/libstd/sys/wasm/mutex.rs +++ b/src/libstd/sys/wasm/mutex.rs @@ -47,11 +47,11 @@ impl Mutex { pub struct ReentrantMutex {} impl ReentrantMutex { - pub unsafe fn uninitialized() -> ReentrantMutex { + pub const unsafe fn uninitialized() -> ReentrantMutex { ReentrantMutex {} } - pub unsafe fn init(&mut self) {} + pub unsafe fn init(&self) {} pub unsafe fn lock(&self) {} diff --git a/src/libstd/sys/wasm/mutex_atomics.rs b/src/libstd/sys/wasm/mutex_atomics.rs index 90c628a19c22e..268a53bb5641c 100644 --- a/src/libstd/sys/wasm/mutex_atomics.rs +++ b/src/libstd/sys/wasm/mutex_atomics.rs @@ -80,11 +80,11 @@ unsafe impl Sync for ReentrantMutex {} // released when this recursion counter reaches 0. impl ReentrantMutex { - pub unsafe fn uninitialized() -> ReentrantMutex { + pub const unsafe fn uninitialized() -> ReentrantMutex { ReentrantMutex { owner: AtomicU32::new(0), recursions: UnsafeCell::new(0) } } - pub unsafe fn init(&mut self) { + pub unsafe fn init(&self) { // nothing to do... } diff --git a/src/libstd/sys/windows/mutex.rs b/src/libstd/sys/windows/mutex.rs index 281eb294c65d8..63dfc640908e9 100644 --- a/src/libstd/sys/windows/mutex.rs +++ b/src/libstd/sys/windows/mutex.rs @@ -109,7 +109,7 @@ impl Mutex { 0 => {} n => return n as *mut _, } - let mut re = box ReentrantMutex::uninitialized(); + let re = box ReentrantMutex::uninitialized(); re.init(); let re = Box::into_raw(re); match self.lock.compare_and_swap(0, re as usize, Ordering::SeqCst) { @@ -157,11 +157,11 @@ unsafe impl Send for ReentrantMutex {} unsafe impl Sync for ReentrantMutex {} impl ReentrantMutex { - pub fn uninitialized() -> ReentrantMutex { + pub const fn uninitialized() -> ReentrantMutex { ReentrantMutex { inner: UnsafeCell::new(MaybeUninit::uninit()) } } - pub unsafe fn init(&mut self) { + pub unsafe fn init(&self) { c::InitializeCriticalSection((&mut *self.inner.get()).as_mut_ptr()); } diff --git a/src/libstd/sys_common/remutex.rs b/src/libstd/sys_common/remutex.rs index a1ad44a3666ed..4f19bbc467f33 100644 --- a/src/libstd/sys_common/remutex.rs +++ b/src/libstd/sys_common/remutex.rs @@ -3,7 +3,6 @@ use crate::marker; use crate::ops::Deref; use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::sys::mutex as sys; -use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult}; /// A re-entrant mutual exclusion /// @@ -11,8 +10,7 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult}; /// available. The thread which has already locked the mutex can lock it /// multiple times without blocking, preventing a common source of deadlocks. pub struct ReentrantMutex { - inner: Box, - poison: poison::Flag, + inner: sys::ReentrantMutex, data: T, } @@ -39,23 +37,30 @@ pub struct ReentrantMutexGuard<'a, T: 'a> { // funny underscores due to how Deref currently works (it disregards field // privacy). __lock: &'a ReentrantMutex, - __poison: poison::Guard, } impl !marker::Send for ReentrantMutexGuard<'_, T> {} impl ReentrantMutex { /// Creates a new reentrant mutex in an unlocked state. - pub fn new(t: T) -> ReentrantMutex { - unsafe { - let mut mutex = ReentrantMutex { - inner: box sys::ReentrantMutex::uninitialized(), - poison: poison::Flag::new(), - data: t, - }; - mutex.inner.init(); - mutex - } + /// + /// # Unsafety + /// + /// This function is unsafe because it is required that `init` is called + /// once this mutex is in its final resting place, and only then are the + /// lock/unlock methods safe. + pub const unsafe fn new(t: T) -> ReentrantMutex { + ReentrantMutex { inner: sys::ReentrantMutex::uninitialized(), data: t } + } + + /// Initializes this mutex so it's ready for use. + /// + /// # Unsafety + /// + /// Unsafe to call more than once, and must be called after this will no + /// longer move in memory. + pub unsafe fn init(&self) { + self.inner.init(); } /// Acquires a mutex, blocking the current thread until it is able to do so. @@ -70,7 +75,7 @@ impl ReentrantMutex { /// If another user of this mutex panicked while holding the mutex, then /// this call will return failure if the mutex would otherwise be /// acquired. - pub fn lock(&self) -> LockResult> { + pub fn lock(&self) -> ReentrantMutexGuard<'_, T> { unsafe { self.inner.lock() } ReentrantMutexGuard::new(&self) } @@ -87,12 +92,8 @@ impl ReentrantMutex { /// If another user of this mutex panicked while holding the mutex, then /// this call will return failure if the mutex would otherwise be /// acquired. - pub fn try_lock(&self) -> TryLockResult> { - if unsafe { self.inner.try_lock() } { - Ok(ReentrantMutexGuard::new(&self)?) - } else { - Err(TryLockError::WouldBlock) - } + pub fn try_lock(&self) -> Option> { + if unsafe { self.inner.try_lock() } { Some(ReentrantMutexGuard::new(&self)) } else { None } } } @@ -108,11 +109,8 @@ impl Drop for ReentrantMutex { impl fmt::Debug for ReentrantMutex { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.try_lock() { - Ok(guard) => f.debug_struct("ReentrantMutex").field("data", &*guard).finish(), - Err(TryLockError::Poisoned(err)) => { - f.debug_struct("ReentrantMutex").field("data", &**err.get_ref()).finish() - } - Err(TryLockError::WouldBlock) => { + Some(guard) => f.debug_struct("ReentrantMutex").field("data", &*guard).finish(), + None => { struct LockedPlaceholder; impl fmt::Debug for LockedPlaceholder { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -127,11 +125,8 @@ impl fmt::Debug for ReentrantMutex { } impl<'mutex, T> ReentrantMutexGuard<'mutex, T> { - fn new(lock: &'mutex ReentrantMutex) -> LockResult> { - poison::map_result(lock.poison.borrow(), |guard| ReentrantMutexGuard { - __lock: lock, - __poison: guard, - }) + fn new(lock: &'mutex ReentrantMutex) -> ReentrantMutexGuard<'mutex, T> { + ReentrantMutexGuard { __lock: lock } } } @@ -147,7 +142,6 @@ impl Drop for ReentrantMutexGuard<'_, T> { #[inline] fn drop(&mut self) { unsafe { - self.__lock.poison.done(&self.__poison); self.__lock.inner.unlock(); } } @@ -162,13 +156,17 @@ mod tests { #[test] fn smoke() { - let m = ReentrantMutex::new(()); + let m = unsafe { + let m = ReentrantMutex::new(()); + m.init(); + m + }; { - let a = m.lock().unwrap(); + let a = m.lock(); { - let b = m.lock().unwrap(); + let b = m.lock(); { - let c = m.lock().unwrap(); + let c = m.lock(); assert_eq!(*c, ()); } assert_eq!(*b, ()); @@ -179,15 +177,19 @@ mod tests { #[test] fn is_mutex() { - let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); + let m = unsafe { + let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); + m.init(); + m + }; let m2 = m.clone(); - let lock = m.lock().unwrap(); + let lock = m.lock(); let child = thread::spawn(move || { - let lock = m2.lock().unwrap(); + let lock = m2.lock(); assert_eq!(*lock.borrow(), 4950); }); for i in 0..100 { - let lock = m.lock().unwrap(); + let lock = m.lock(); *lock.borrow_mut() += i; } drop(lock); @@ -196,17 +198,21 @@ mod tests { #[test] fn trylock_works() { - let m = Arc::new(ReentrantMutex::new(())); + let m = unsafe { + let m = Arc::new(ReentrantMutex::new(())); + m.init(); + m + }; let m2 = m.clone(); - let _lock = m.try_lock().unwrap(); - let _lock2 = m.try_lock().unwrap(); + let _lock = m.try_lock(); + let _lock2 = m.try_lock(); thread::spawn(move || { let lock = m2.try_lock(); - assert!(lock.is_err()); + assert!(lock.is_none()); }) .join() .unwrap(); - let _lock3 = m.try_lock().unwrap(); + let _lock3 = m.try_lock(); } pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell>); @@ -215,22 +221,4 @@ mod tests { *self.0.borrow_mut() = 42; } } - - #[test] - fn poison_works() { - let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); - let mc = m.clone(); - let result = thread::spawn(move || { - let lock = mc.lock().unwrap(); - *lock.borrow_mut() = 1; - let lock2 = mc.lock().unwrap(); - *lock.borrow_mut() = 2; - let _answer = Answer(lock2); - panic!("What the answer to my lifetimes dilemma is?"); - }) - .join(); - assert!(result.is_err()); - let r = m.lock().err().unwrap().into_inner(); - assert_eq!(*r.borrow(), 42); - } } diff --git a/src/test/ui/eprint-on-tls-drop.rs b/src/test/ui/eprint-on-tls-drop.rs new file mode 100644 index 0000000000000..26b3add990e15 --- /dev/null +++ b/src/test/ui/eprint-on-tls-drop.rs @@ -0,0 +1,43 @@ +// run-pass + +use std::cell::RefCell; +use std::env; +use std::process::Command; + +fn main() { + let name = "YOU_ARE_THE_TEST"; + if env::var(name).is_ok() { + TLS.with(|f| f.borrow().ensure()); + } else { + let me = env::current_exe().unwrap(); + let output = Command::new(&me).env(name, "1").output().unwrap(); + println!("{:?}", output); + assert!(output.status.success()); + let stderr = String::from_utf8(output.stderr).unwrap(); + assert!(stderr.contains("hello new\n")); + assert!(stderr.contains("hello drop\n")); + } +} + +struct Stuff { + _x: usize, +} + +impl Stuff { + fn new() -> Self { + eprintln!("hello new"); + Self { _x: 0 } + } + + fn ensure(&self) {} +} + +impl Drop for Stuff { + fn drop(&mut self) { + eprintln!("hello drop"); + } +} + +thread_local! { + static TLS: RefCell = RefCell::new(Stuff::new()); +}