Skip to content

Commit

Permalink
Pretty-print $crate::foo::bar as ::foo::bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Dec 22, 2016
1 parent f10f50b commit 8a1acb2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ impl<'a> State<'a> {
if i > 0 {
word(&mut self.s, "::")?
}
if segment.name != keywords::CrateRoot.name() {
if segment.name != keywords::CrateRoot.name() && segment.name != "$crate" {
self.print_name(segment.name)?;
self.print_path_parameters(&segment.parameters, colons_before_params)?;
}
Expand All @@ -1674,7 +1674,7 @@ impl<'a> State<'a> {
if i > 0 {
word(&mut self.s, "::")?
}
if segment.name != keywords::CrateRoot.name() {
if segment.name != keywords::CrateRoot.name() && segment.name != "$crate" {
self.print_name(segment.name)?;
self.print_path_parameters(&segment.parameters, colons_before_params)?;
}
Expand Down
3 changes: 2 additions & 1 deletion src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2351,7 +2351,8 @@ impl<'a> State<'a> {
if i > 0 {
try!(word(&mut self.s, "::"))
}
if segment.identifier.name != keywords::CrateRoot.name() {
if segment.identifier.name != keywords::CrateRoot.name() &&
segment.identifier.name != "$crate" {
try!(self.print_ident(segment.identifier));
if let Some(ref parameters) = segment.parameters {
try!(self.print_path_parameters(parameters, colons_before_params));
Expand Down
2 changes: 1 addition & 1 deletion src/test/pretty/issue-4264.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@



(($crate::fmt::format as
((::fmt::format as
fn(std::fmt::Arguments<'_>) -> std::string::String {std::fmt::format})(((<::std::fmt::Arguments>::new_v1
as
fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments<'_>::new_v1})(({
Expand Down

0 comments on commit 8a1acb2

Please sign in to comment.