Skip to content

tracking issue for rustc parser changes #4013

Closed
@calebcartwright

Description

@calebcartwright

Looks like there's going to be some changes in the rustc parser that will involve the removal of parts of the parser interface that rustfmt uses today (default_submod_path and I'd guess submod_path_from_attr too).

rust-lang/rust#68135 (comment)

Note that methods like default_submod_path are going to be removed from the parser when we fix #64197, so making those public will likely be short-lived. (cc petrochenkov)

Not sure what the changes will entail, but opening this to help keep track of the pending upstream changes in the parser.

Places in rustfmt that'll probably be impacted by those upstream changes:

pub(crate) fn default_submod_path(
&self,
id: ast::Ident,
relative: Option<ast::Ident>,
dir_path: &Path,
) -> syntax::parse::parser::ModulePath {
syntax::parse::parser::Parser::default_submod_path(
id,
relative,
dir_path,
self.parse_sess.source_map(),
)
}

match self
.parse_sess
.default_submod_path(mod_name, relative, &self.directory.path)
.result

pub(crate) fn submod_path_from_attr(attrs: &[ast::Attribute], path: &Path) -> Option<PathBuf> {
syntax::parse::parser::Parser::submod_path_from_attr(attrs, path)
}

if let Some(path) = Parser::submod_path_from_attr(attrs, &self.directory.path) {
return Ok(SubModKind::External(
path,
DirectoryOwnership::Owned { relative: None },
));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions