Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E0753] Use of inner doc comment in invalid context #2531

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

MahadMuhammad
Copy link
Contributor

Use of inner doc comment in invalid context - E0753


Code Tested:

// ErrorCode - E0753
pub fn main ()
{
  //! inner doc allowed
  let _x = 42;
  // { dg-error "expected outer doc comment, inner doc" "" { target *-*-* } .+1 }
  //! inner doc disallowed
  mod module
  {
    /*! inner doc allowed */
    /// outer doc allowed
    // { dg-error "expected outer doc comment, inner doc" "" { target *-*-* } .+1 }
    /*! but inner doc not here */
    mod x { }
  }
}

Output:

/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/bad_inner_doc.rs:6:3: error: expected outer doc comment, inner doc ('//!' or '/*!') only allowed at start of item and before any outer attribute or doc ('#[', '///' or '/**') [E0753]
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/bad_inner_doc.rs:12:5: error: expected outer doc comment, inner doc ('//!' or '/*!') only allowed at start of item and before any outer attribute or doc ('#[', '///' or '/**') [E0753]
compiler exited with status 1
PASS: rust/compile/bad_inner_doc.rs  at line 5 (test for errors, line 6)
PASS: rust/compile/bad_inner_doc.rs  at line 11 (test for errors, line 12)
PASS: rust/compile/bad_inner_doc.rs (test for excess errors)

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_outer_attribute): Added errorcode & updated error function.

gcc/testsuite/ChangeLog:

* rust/compile/bad_inner_doc.rs: 

@P-E-P P-E-P added enhancement diagnostic diagnostic static analysis labels Aug 7, 2023
gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_outer_attribute):
	Added errorcode & updated error function.

gcc/testsuite/ChangeLog:

	* rust/compile/bad_inner_doc.rs:
	Updated comment to pass testcase.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@philberty philberty added this pull request to the merge queue Aug 17, 2023
Merged via the queue into Rust-GCC:master with commit 0110145 Aug 17, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic diagnostic static analysis enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants