Merge pull request #5140 from calebcartwright/subtree-sync-2021-12-19
Subtree sync
This commit is contained in:
commit
0346bc74a7
@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2021-11-08"
|
||||
channel = "nightly-2021-12-20"
|
||||
components = ["rustc-dev"]
|
||||
|
@ -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);
|
||||
|
||||
@ -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,
|
||||
|
@ -616,10 +616,10 @@ impl<'a> FmtVisitor<'a> {
|
||||
(TyAlias(lty), TyAlias(rty))
|
||||
if both_type(<y.ty, &rty.ty) || both_opaque(<y.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,
|
||||
@ -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) {
|
||||
|
@ -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
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
@ -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!(),
|
||||
|
@ -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(
|
||||
|
@ -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])
|
||||
|
Loading…
x
Reference in New Issue
Block a user