diff options
| author | bors <bors@rust-lang.org> | 2022-06-16 23:50:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-16 23:50:20 +0000 |
| commit | 349bda2051e94b7aefb33d6541f48f561bf06dbc (patch) | |
| tree | 53b5320c033a44c0e0ed2f23b2ad5b194f083d2c /compiler | |
| parent | cacc75c82ebe15cf63d31034fcf7f1016cddf0e2 (diff) | |
| parent | 6ac93185f4daacacb537d5b61e900eb9d58edcd1 (diff) | |
Auto merge of #98181 - JohnTitor:rollup-65ztwnz, r=JohnTitor
Rollup of 5 pull requests Successful merges: - #97377 (Do not suggest adding semicolon/changing delimiters for macros in item position that originates in macros) - #97675 (Make `std::mem::needs_drop` accept `?Sized`) - #98118 (Test NLL fix of bad lifetime inference for reference captured in closure.) - #98166 (Add rustdoc-json regression test for #98009) - #98169 (Keyword docs: Link to wikipedia article for dynamic dispatch) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler')
5 files changed, 41 insertions, 23 deletions
diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index 8da705e0cb0..489259d1a6b 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -567,7 +567,7 @@ pub mod intrinsics { pub fn copy<T>(src: *const T, dst: *mut T, count: usize); pub fn transmute<T, U>(e: T) -> U; pub fn ctlz_nonzero<T>(x: T) -> T; - pub fn needs_drop<T>() -> bool; + pub fn needs_drop<T: ?::Sized>() -> bool; pub fn bitreverse<T>(x: T) -> T; pub fn bswap<T>(x: T) -> T; pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize); diff --git a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs index 85ca908d0a2..0f1245c2758 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs @@ -55,6 +55,11 @@ struct NoisyDrop { inner: NoisyDropInner, } +struct NoisyDropUnsized { + inner: NoisyDropInner, + text: str, +} + struct NoisyDropInner; impl Drop for NoisyDrop { @@ -170,7 +175,9 @@ fn main() { assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8); assert!(!intrinsics::needs_drop::<u8>()); + assert!(!intrinsics::needs_drop::<[u8]>()); assert!(intrinsics::needs_drop::<NoisyDrop>()); + assert!(intrinsics::needs_drop::<NoisyDropUnsized>()); Unique { pointer: NonNull(1 as *mut &str), diff --git a/compiler/rustc_codegen_gcc/example/mini_core.rs b/compiler/rustc_codegen_gcc/example/mini_core.rs index a8435287d9f..ddcbb0d9fc7 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core.rs @@ -514,7 +514,7 @@ pub mod intrinsics { pub fn copy<T>(src: *const T, dst: *mut T, count: usize); pub fn transmute<T, U>(e: T) -> U; pub fn ctlz_nonzero<T>(x: T) -> T; - pub fn needs_drop<T>() -> bool; + pub fn needs_drop<T: ?::Sized>() -> bool; pub fn bitreverse<T>(x: T) -> T; pub fn bswap<T>(x: T) -> T; pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize); diff --git a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs index 69d591565ac..14fd9eeffa6 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs @@ -47,6 +47,11 @@ struct NoisyDrop { inner: NoisyDropInner, } +struct NoisyDropUnsized { + inner: NoisyDropInner, + text: str, +} + struct NoisyDropInner; impl Drop for NoisyDrop { @@ -184,7 +189,9 @@ fn main() { assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8); assert!(!intrinsics::needs_drop::<u8>()); + assert!(!intrinsics::needs_drop::<[u8]>()); assert!(intrinsics::needs_drop::<NoisyDrop>()); + assert!(intrinsics::needs_drop::<NoisyDropUnsized>()); Unique { pointer: 0 as *const &str, diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 1d50ce767af..bf685aa8cad 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1775,30 +1775,34 @@ impl<'a> Parser<'a> { span, "macros that expand to items must be delimited with braces or followed by a semicolon", ); - if self.unclosed_delims.is_empty() { - let DelimSpan { open, close } = match args { - MacArgs::Empty | MacArgs::Eq(..) => unreachable!(), - MacArgs::Delimited(dspan, ..) => *dspan, - }; - err.multipart_suggestion( - "change the delimiters to curly braces", - vec![(open, "{".to_string()), (close, '}'.to_string())], - Applicability::MaybeIncorrect, - ); - } else { + // FIXME: This will make us not emit the help even for declarative + // macros within the same crate (that we can fix), which is sad. + if !span.from_expansion() { + if self.unclosed_delims.is_empty() { + let DelimSpan { open, close } = match args { + MacArgs::Empty | MacArgs::Eq(..) => unreachable!(), + MacArgs::Delimited(dspan, ..) => *dspan, + }; + err.multipart_suggestion( + "change the delimiters to curly braces", + vec![(open, "{".to_string()), (close, '}'.to_string())], + Applicability::MaybeIncorrect, + ); + } else { + err.span_suggestion( + span, + "change the delimiters to curly braces", + " { /* items */ }", + Applicability::HasPlaceholders, + ); + } err.span_suggestion( - span, - "change the delimiters to curly braces", - " { /* items */ }", - Applicability::HasPlaceholders, + span.shrink_to_hi(), + "add a semicolon", + ';', + Applicability::MaybeIncorrect, ); } - err.span_suggestion( - span.shrink_to_hi(), - "add a semicolon", - ';', - Applicability::MaybeIncorrect, - ); err.emit(); } |
