Improve span of shared struct Drop error

This commit is contained in:
David Tolnay 2021-02-11 21:48:17 -08:00
parent 894ad11042
commit da9f1b9471
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 9 additions and 9 deletions

View File

@ -274,9 +274,11 @@ fn expand_struct_operators(strct: &Struct) -> TokenStream {
fn expand_struct_forbid_drop(strct: &Struct) -> TokenStream {
let ident = &strct.name.rust;
let generics = &strct.generics;
let span = ident.span();
let impl_token = Token![impl](strct.visibility.span);
quote! {
impl #generics self::Drop for super::#ident #generics {}
quote_spanned! {span=>
#impl_token #generics self::Drop for super::#ident #generics {}
}
}

View File

@ -1,10 +1,8 @@
error[E0119]: conflicting implementations of trait `ffi::_::forbid::Drop` for type `ffi::Shared`:
--> $DIR/drop_shared.rs:1:1
--> $DIR/drop_shared.rs:3:5
|
1 | #[cxx::bridge]
| ^^^^^^^^^^^^^^
| |
| first implementation here
| conflicting implementation for `ffi::Shared`
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
| -------------- first implementation here
2 | mod ffi {
3 | struct Shared {
| ^^^^^^^^^^^^^ conflicting implementation for `ffi::Shared`