Skip to content

Commit

Permalink
gccrs: [E0753] Use of inner doc comment in invalid context
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MahadMuhammad committed Aug 17, 2023
1 parent efa3041 commit 516e0d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,9 @@ Parser<ManagedTokenSource>::parse_outer_attribute ()
if (lexer.peek_token ()->get_id () == INNER_DOC_COMMENT)
{
Error error (
lexer.peek_token ()->get_locus (),
"inner doc (%<//!%> or %</*!%>) only allowed at start of item "
lexer.peek_token ()->get_locus (), ErrorCode::E0753,
"expected outer doc comment, inner doc (%<//!%> or %</*!%>) only "
"allowed at start of item "
"and before any outer attribute or doc (%<#[%>, %<///%> or %</**%>)");
add_error (std::move (error));
lexer.skip_token ();
Expand Down
4 changes: 2 additions & 2 deletions gcc/testsuite/rust/compile/bad_inner_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ pub fn main ()
{
//! inner doc allowed
let _x = 42;
// { dg-error "inner doc" "" { target *-*-* } .+1 }
// { dg-error "expected outer doc comment, inner doc" "" { target *-*-* } .+1 }
//! inner doc disallowed
mod module
{
/*! inner doc allowed */
/// outer doc allowed
// { dg-error "inner doc" "" { target *-*-* } .+1 }
// { dg-error "expected outer doc comment, inner doc" "" { target *-*-* } .+1 }
/*! but inner doc not here */
mod x { }
}
Expand Down

0 comments on commit 516e0d0

Please sign in to comment.