-// aux-build:doc_unsafe_macros.rs
+//@aux-build:proc_macros.rs
-#[macro_use]
-extern crate doc_unsafe_macros;
+#![allow(clippy::let_unit_value)]
+
+extern crate proc_macros;
+use proc_macros::external;
/// This is not sufficiently documented
pub unsafe fn destroy_the_planet() {
pub use private_mod::republished;
-pub trait UnsafeTrait {
+pub trait SafeTraitUnsafeMethods {
unsafe fn woefully_underdocumented(self);
/// # Safety
unsafe fn at_least_somewhat_documented(self);
}
+pub unsafe trait UnsafeTrait {
+ fn method();
+}
+
+/// # Safety
+pub unsafe trait DocumentedUnsafeTrait {
+ fn method2();
+}
+
pub struct Struct;
-impl UnsafeTrait for Struct {
+impl SafeTraitUnsafeMethods for Struct {
unsafe fn woefully_underdocumented(self) {
// all is well
}
}
}
+unsafe impl UnsafeTrait for Struct {
+ fn method() {}
+}
+
+unsafe impl DocumentedUnsafeTrait for Struct {
+ fn method2() {}
+}
+
impl Struct {
pub unsafe fn more_undocumented_unsafe() -> Self {
unimplemented!();
very_unsafe!();
// we don't lint code from external macros
-undocd_unsafe!();
+external! {
+ pub unsafe fn oy_vey() {
+ unimplemented!();
+ }
+}
fn main() {
unsafe {
drive();
}
}
+
+// do not lint if any parent has `#[doc(hidden)]` attribute
+// see #7347
+#[doc(hidden)]
+pub mod __macro {
+ pub struct T;
+ impl T {
+ pub unsafe fn f() {}
+ }
+}
+
+/// # Implementation safety
+pub unsafe trait DocumentedUnsafeTraitWithImplementationHeader {
+ fn method();
+}