From 6f1bdb47f2a3bb24f60f8f27683991ddd2058b03 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 15 Jan 2020 13:37:01 +0100 Subject: clean up E0197 explanation --- src/librustc_error_codes/error_codes/E0197.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/librustc_error_codes/error_codes') diff --git a/src/librustc_error_codes/error_codes/E0197.md b/src/librustc_error_codes/error_codes/E0197.md index 0d91157e572..c142b8f3664 100644 --- a/src/librustc_error_codes/error_codes/E0197.md +++ b/src/librustc_error_codes/error_codes/E0197.md @@ -1,13 +1,20 @@ +An inherent implementation was marked unsafe. + +Erroneous code example: + +```compile_fail,E0197 +struct Foo; + +unsafe impl Foo { } // error! +``` + Inherent implementations (one that do not implement a trait but provide methods associated with a type) are always safe because they are not implementing an unsafe trait. Removing the `unsafe` keyword from the inherent implementation will resolve this error. -```compile_fail,E0197 +``` struct Foo; -// this will cause this error -unsafe impl Foo { } -// converting it to this will fix it -impl Foo { } +impl Foo { } // ok! ``` -- cgit 1.4.1-3-g733a5