@@ -141,38 +141,58 @@ TokenCollector::visit (VariadicParam ¶m)
141141void
142142TokenCollector::visit (Attribute &attrib)
143143{
144- push (Rust::Token::make (HASH , attrib.get_locus ()));
145- if (attrib.is_inner_attribute ())
146- push (Rust::Token::make (EXCLAM , UNDEF_LOCATION ));
147- push (Rust::Token::make (LEFT_SQUARE , UNDEF_LOCATION ));
148- visit (attrib.get_path ());
149-
150- if (attrib.has_attr_input ())
144+ if (attrib.is_from_comment () && attrib.has_attr_input ())
145+ {
146+ if (attrib.is_inner_attribute ())
147+ push (Rust::Token::make (INNER_DOC_COMMENT , attrib.get_locus ()));
148+ else
149+ push (Rust::Token::make (OUTER_DOC_COMMENT , attrib.get_locus ()));
150+ auto lit = (static_cast <AttrInputLiteral &> (attrib.get_attr_input ()))
151+ .get_literal ()
152+ .get_literal ();
153+ push (Rust::Token::make_doc_string_literal (attrib.get_locus (),
154+ lit.as_string ()));
155+ push (Rust::Token::make (DOC_COMMENT_END , attrib.get_locus ()));
156+ return ;
157+ }
158+ else
151159 {
152- switch (attrib.get_attr_input ().get_attr_input_type ())
160+ push (Rust::Token::make (HASH , attrib.get_locus ()));
161+ if (attrib.is_inner_attribute ())
162+ push (Rust::Token::make (EXCLAM , UNDEF_LOCATION ));
163+ push (Rust::Token::make (LEFT_SQUARE , UNDEF_LOCATION ));
164+ visit (attrib.get_path ());
165+
166+ if (attrib.has_attr_input ())
153167 {
154- case AST ::AttrInput::AttrInputType::LITERAL : {
155- visit (static_cast <AttrInputLiteral &> (attrib.get_attr_input ()));
156- break ;
157- }
158- case AST ::AttrInput::AttrInputType::MACRO : {
159- visit (static_cast <AttrInputMacro &> (attrib.get_attr_input ()));
160- break ;
161- }
162- case AST ::AttrInput::AttrInputType::META_ITEM : {
163- visit (static_cast <AttrInputMetaItemContainer &> (
164- attrib.get_attr_input ()));
165- break ;
166- }
167- case AST ::AttrInput::AttrInputType::TOKEN_TREE : {
168- visit (static_cast <DelimTokenTree &> (attrib.get_attr_input ()));
169- break ;
170- }
171- default :
172- rust_unreachable ();
168+ switch (attrib.get_attr_input ().get_attr_input_type ())
169+ {
170+ case AST ::AttrInput::AttrInputType::LITERAL : {
171+ visit (
172+ static_cast <AttrInputLiteral &> (attrib.get_attr_input ()));
173+ break ;
174+ }
175+ case AST ::AttrInput::AttrInputType::MACRO : {
176+ visit (
177+ static_cast <AttrInputMacro &> (attrib.get_attr_input ()));
178+ break ;
179+ }
180+ case AST ::AttrInput::AttrInputType::META_ITEM : {
181+ visit (static_cast <AttrInputMetaItemContainer &> (
182+ attrib.get_attr_input ()));
183+ break ;
184+ }
185+ case AST ::AttrInput::AttrInputType::TOKEN_TREE : {
186+ visit (
187+ static_cast <DelimTokenTree &> (attrib.get_attr_input ()));
188+ break ;
189+ }
190+ default :
191+ rust_unreachable ();
192+ }
173193 }
194+ push (Rust::Token::make (RIGHT_SQUARE , UNDEF_LOCATION ));
174195 }
175- push (Rust::Token::make (RIGHT_SQUARE , UNDEF_LOCATION ));
176196}
177197
178198void
0 commit comments