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]
|
[toolchain]
|
||||||
channel = "nightly-2021-11-08"
|
channel = "nightly-2021-12-20"
|
||||||
components = ["rustc-dev"]
|
components = ["rustc-dev"]
|
||||||
|
@ -337,7 +337,7 @@ impl Rewrite for ast::Attribute {
|
|||||||
} else {
|
} else {
|
||||||
let should_skip = self
|
let should_skip = self
|
||||||
.ident()
|
.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);
|
.unwrap_or(false);
|
||||||
let prefix = attr_prefix(self);
|
let prefix = attr_prefix(self);
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ impl Rewrite for ast::Attribute {
|
|||||||
|
|
||||||
let literal_str = literal.as_str();
|
let literal_str = literal.as_str();
|
||||||
let doc_comment_formatter =
|
let doc_comment_formatter =
|
||||||
DocCommentFormatter::new(&*literal_str, comment_style);
|
DocCommentFormatter::new(literal_str, comment_style);
|
||||||
let doc_comment = format!("{}", doc_comment_formatter);
|
let doc_comment = format!("{}", doc_comment_formatter);
|
||||||
return rewrite_doc_comment(
|
return rewrite_doc_comment(
|
||||||
&doc_comment,
|
&doc_comment,
|
||||||
|
@ -616,10 +616,10 @@ impl<'a> FmtVisitor<'a> {
|
|||||||
(TyAlias(lty), TyAlias(rty))
|
(TyAlias(lty), TyAlias(rty))
|
||||||
if both_type(<y.ty, &rty.ty) || both_opaque(<y.ty, &rty.ty) =>
|
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(..)) => {
|
(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()),
|
(Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()),
|
||||||
(TyAlias(ty), _) if is_type(&ty.ty) => Ordering::Less,
|
(TyAlias(ty), _) if is_type(&ty.ty) => Ordering::Less,
|
||||||
@ -1029,7 +1029,7 @@ pub(crate) fn format_trait(
|
|||||||
if !bounds.is_empty() {
|
if !bounds.is_empty() {
|
||||||
let ident_hi = context
|
let ident_hi = context
|
||||||
.snippet_provider
|
.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 bound_hi = bounds.last().unwrap().span().hi();
|
||||||
let snippet = context.snippet(mk_sp(ident_hi, bound_hi));
|
let snippet = context.snippet(mk_sp(ident_hi, bound_hi));
|
||||||
if contains_comment(snippet) {
|
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]) {
|
fn push_inline_mod_directory(&mut self, id: symbol::Ident, attrs: &[ast::Attribute]) {
|
||||||
if let Some(path) = find_path_value(attrs) {
|
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 };
|
self.directory.ownership = DirectoryOwnership::Owned { relative: None };
|
||||||
} else {
|
} else {
|
||||||
// We have to push on the current module name in the case of relative
|
// 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 DirectoryOwnership::Owned { relative } = &mut self.directory.ownership {
|
||||||
if let Some(ident) = relative.take() {
|
if let Some(ident) = relative.take() {
|
||||||
// remove the relative offset
|
// 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 {
|
fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
|
||||||
match (&a.kind, &b.kind) {
|
match (&a.kind, &b.kind) {
|
||||||
(&ast::ItemKind::Mod(..), &ast::ItemKind::Mod(..)) => {
|
(&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)) => {
|
(&ast::ItemKind::ExternCrate(ref a_name), &ast::ItemKind::ExternCrate(ref b_name)) => {
|
||||||
// `extern crate foo as bar;`
|
// `extern crate foo as bar;`
|
||||||
// ^^^ Comparing this.
|
// ^^^ Comparing this.
|
||||||
let a_orig_name = a_name.map_or_else(|| a.ident.as_str(), rustc_span::Symbol::as_str);
|
let a_orig_name = a_name.unwrap_or(a.ident.name);
|
||||||
let b_orig_name = b_name.map_or_else(|| b.ident.as_str(), rustc_span::Symbol::as_str);
|
let b_orig_name = b_name.unwrap_or(b.ident.name);
|
||||||
let result = a_orig_name.cmp(&b_orig_name);
|
let result = a_orig_name.as_str().cmp(b_orig_name.as_str());
|
||||||
if result != Ordering::Equal {
|
if result != Ordering::Equal {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
|
|||||||
(Some(..), None) => Ordering::Greater,
|
(Some(..), None) => Ordering::Greater,
|
||||||
(None, Some(..)) => Ordering::Less,
|
(None, Some(..)) => Ordering::Less,
|
||||||
(None, None) => Ordering::Equal,
|
(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!(),
|
_ => unreachable!(),
|
||||||
|
@ -95,15 +95,17 @@ pub(crate) enum ParserError {
|
|||||||
|
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
pub(crate) fn submod_path_from_attr(attrs: &[ast::Attribute], path: &Path) -> Option<PathBuf> {
|
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
|
// On windows, the base path might have the form
|
||||||
// `\\?\foo\bar` in which case it does not tolerate
|
// `\\?\foo\bar` in which case it does not tolerate
|
||||||
// mixed `/` and `\` separators, so canonicalize
|
// mixed `/` and `\` separators, so canonicalize
|
||||||
// `/` to `\`.
|
// `/` to `\`.
|
||||||
#[cfg(windows)]
|
#[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(
|
pub(crate) fn parse_file_as_module(
|
||||||
|
@ -260,7 +260,7 @@ fn is_skip(meta_item: &MetaItem) -> bool {
|
|||||||
match meta_item.kind {
|
match meta_item.kind {
|
||||||
MetaItemKind::Word => {
|
MetaItemKind::Word => {
|
||||||
let path_str = pprust::path_to_string(&meta_item.path);
|
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) => {
|
MetaItemKind::List(ref l) => {
|
||||||
meta_item.has_name(sym::cfg_attr) && l.len() == 2 && is_skip_nested(&l[1])
|
meta_item.has_name(sym::cfg_attr) && l.len() == 2 && is_skip_nested(&l[1])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user