Skip to content

Commit

Permalink
Merge pull request rust-lang#5140 from calebcartwright/subtree-sync-2…
Browse files Browse the repository at this point in the history
…021-12-19

Subtree sync
  • Loading branch information
calebcartwright authored Dec 20, 2021
2 parents 57ac92b + b214938 commit 0346bc7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-11-08"
channel = "nightly-2021-12-20"
components = ["rustc-dev"]
4 changes: 2 additions & 2 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl Rewrite for ast::Attribute {
} else {
let should_skip = self
.ident()
.map(|s| context.skip_context.skip_attribute(&s.name.as_str()))
.map(|s| context.skip_context.skip_attribute(s.name.as_str()))
.unwrap_or(false);
let prefix = attr_prefix(self);

Expand All @@ -356,7 +356,7 @@ impl Rewrite for ast::Attribute {

let literal_str = literal.as_str();
let doc_comment_formatter =
DocCommentFormatter::new(&*literal_str, comment_style);
DocCommentFormatter::new(literal_str, comment_style);
let doc_comment = format!("{}", doc_comment_formatter);
return rewrite_doc_comment(
&doc_comment,
Expand Down
6 changes: 3 additions & 3 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,10 @@ impl<'a> FmtVisitor<'a> {
(TyAlias(lty), TyAlias(rty))
if both_type(&lty.ty, &rty.ty) || both_opaque(&lty.ty, &rty.ty) =>
{
a.ident.as_str().cmp(&b.ident.as_str())
a.ident.as_str().cmp(b.ident.as_str())
}
(Const(..), Const(..)) | (MacCall(..), MacCall(..)) => {
a.ident.as_str().cmp(&b.ident.as_str())
a.ident.as_str().cmp(b.ident.as_str())
}
(Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()),
(TyAlias(ty), _) if is_type(&ty.ty) => Ordering::Less,
Expand Down Expand Up @@ -1029,7 +1029,7 @@ pub(crate) fn format_trait(
if !bounds.is_empty() {
let ident_hi = context
.snippet_provider
.span_after(item.span, &item.ident.as_str());
.span_after(item.span, item.ident.as_str());
let bound_hi = bounds.last().unwrap().span().hi();
let snippet = context.snippet(mk_sp(ident_hi, bound_hi));
if contains_comment(snippet) {
Expand Down
6 changes: 3 additions & 3 deletions src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {

fn push_inline_mod_directory(&mut self, id: symbol::Ident, attrs: &[ast::Attribute]) {
if let Some(path) = find_path_value(attrs) {
self.directory.path.push(&*path.as_str());
self.directory.path.push(path.as_str());
self.directory.ownership = DirectoryOwnership::Owned { relative: None };
} else {
// We have to push on the current module name in the case of relative
Expand All @@ -467,10 +467,10 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
if let DirectoryOwnership::Owned { relative } = &mut self.directory.ownership {
if let Some(ident) = relative.take() {
// remove the relative offset
self.directory.path.push(&*ident.as_str());
self.directory.path.push(ident.as_str());
}
}
self.directory.path.push(&*id.as_str());
self.directory.path.push(id.as_str());
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/reorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ use crate::visitor::FmtVisitor;
fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
match (&a.kind, &b.kind) {
(&ast::ItemKind::Mod(..), &ast::ItemKind::Mod(..)) => {
a.ident.as_str().cmp(&b.ident.as_str())
a.ident.as_str().cmp(b.ident.as_str())
}
(&ast::ItemKind::ExternCrate(ref a_name), &ast::ItemKind::ExternCrate(ref b_name)) => {
// `extern crate foo as bar;`
// ^^^ Comparing this.
let a_orig_name = a_name.map_or_else(|| a.ident.as_str(), rustc_span::Symbol::as_str);
let b_orig_name = b_name.map_or_else(|| b.ident.as_str(), rustc_span::Symbol::as_str);
let result = a_orig_name.cmp(&b_orig_name);
let a_orig_name = a_name.unwrap_or(a.ident.name);
let b_orig_name = b_name.unwrap_or(b.ident.name);
let result = a_orig_name.as_str().cmp(b_orig_name.as_str());
if result != Ordering::Equal {
return result;
}
Expand All @@ -44,7 +44,7 @@ fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
(Some(..), None) => Ordering::Greater,
(None, Some(..)) => Ordering::Less,
(None, None) => Ordering::Equal,
(Some(..), Some(..)) => a.ident.as_str().cmp(&b.ident.as_str()),
(Some(..), Some(..)) => a.ident.as_str().cmp(b.ident.as_str()),
}
}
_ => unreachable!(),
Expand Down
8 changes: 5 additions & 3 deletions src/syntux/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,17 @@ pub(crate) enum ParserError {

impl<'a> Parser<'a> {
pub(crate) fn submod_path_from_attr(attrs: &[ast::Attribute], path: &Path) -> Option<PathBuf> {
let path_string = first_attr_value_str_by_name(attrs, sym::path)?.as_str();
let path_sym = first_attr_value_str_by_name(attrs, sym::path)?;
let path_str = path_sym.as_str();

// On windows, the base path might have the form
// `\\?\foo\bar` in which case it does not tolerate
// mixed `/` and `\` separators, so canonicalize
// `/` to `\`.
#[cfg(windows)]
let path_string = path_string.replace("/", "\\");
let path_str = path_str.replace("/", "\\");

Some(path.join(&*path_string))
Some(path.join(path_str))
}

pub(crate) fn parse_file_as_module(
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fn is_skip(meta_item: &MetaItem) -> bool {
match meta_item.kind {
MetaItemKind::Word => {
let path_str = pprust::path_to_string(&meta_item.path);
path_str == *skip_annotation().as_str() || path_str == *depr_skip_annotation().as_str()
path_str == skip_annotation().as_str() || path_str == depr_skip_annotation().as_str()
}
MetaItemKind::List(ref l) => {
meta_item.has_name(sym::cfg_attr) && l.len() == 2 && is_skip_nested(&l[1])
Expand Down

0 comments on commit 0346bc7

Please sign in to comment.