Skip to content

Commit 0346bc7

Browse files
Merge pull request rust-lang#5140 from calebcartwright/subtree-sync-2021-12-19
Subtree sync
2 parents 57ac92b + b214938 commit 0346bc7

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2021-11-08"
2+
channel = "nightly-2021-12-20"
33
components = ["rustc-dev"]

src/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ impl Rewrite for ast::Attribute {
337337
} else {
338338
let should_skip = self
339339
.ident()
340-
.map(|s| context.skip_context.skip_attribute(&s.name.as_str()))
340+
.map(|s| context.skip_context.skip_attribute(s.name.as_str()))
341341
.unwrap_or(false);
342342
let prefix = attr_prefix(self);
343343

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

357357
let literal_str = literal.as_str();
358358
let doc_comment_formatter =
359-
DocCommentFormatter::new(&*literal_str, comment_style);
359+
DocCommentFormatter::new(literal_str, comment_style);
360360
let doc_comment = format!("{}", doc_comment_formatter);
361361
return rewrite_doc_comment(
362362
&doc_comment,

src/items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,10 @@ impl<'a> FmtVisitor<'a> {
616616
(TyAlias(lty), TyAlias(rty))
617617
if both_type(&lty.ty, &rty.ty) || both_opaque(&lty.ty, &rty.ty) =>
618618
{
619-
a.ident.as_str().cmp(&b.ident.as_str())
619+
a.ident.as_str().cmp(b.ident.as_str())
620620
}
621621
(Const(..), Const(..)) | (MacCall(..), MacCall(..)) => {
622-
a.ident.as_str().cmp(&b.ident.as_str())
622+
a.ident.as_str().cmp(b.ident.as_str())
623623
}
624624
(Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()),
625625
(TyAlias(ty), _) if is_type(&ty.ty) => Ordering::Less,
@@ -1029,7 +1029,7 @@ pub(crate) fn format_trait(
10291029
if !bounds.is_empty() {
10301030
let ident_hi = context
10311031
.snippet_provider
1032-
.span_after(item.span, &item.ident.as_str());
1032+
.span_after(item.span, item.ident.as_str());
10331033
let bound_hi = bounds.last().unwrap().span().hi();
10341034
let snippet = context.snippet(mk_sp(ident_hi, bound_hi));
10351035
if contains_comment(snippet) {

src/modules.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
455455

456456
fn push_inline_mod_directory(&mut self, id: symbol::Ident, attrs: &[ast::Attribute]) {
457457
if let Some(path) = find_path_value(attrs) {
458-
self.directory.path.push(&*path.as_str());
458+
self.directory.path.push(path.as_str());
459459
self.directory.ownership = DirectoryOwnership::Owned { relative: None };
460460
} else {
461461
// 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> {
467467
if let DirectoryOwnership::Owned { relative } = &mut self.directory.ownership {
468468
if let Some(ident) = relative.take() {
469469
// remove the relative offset
470-
self.directory.path.push(&*ident.as_str());
470+
self.directory.path.push(ident.as_str());
471471
}
472472
}
473-
self.directory.path.push(&*id.as_str());
473+
self.directory.path.push(id.as_str());
474474
}
475475
}
476476

src/reorder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ use crate::visitor::FmtVisitor;
2626
fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
2727
match (&a.kind, &b.kind) {
2828
(&ast::ItemKind::Mod(..), &ast::ItemKind::Mod(..)) => {
29-
a.ident.as_str().cmp(&b.ident.as_str())
29+
a.ident.as_str().cmp(b.ident.as_str())
3030
}
3131
(&ast::ItemKind::ExternCrate(ref a_name), &ast::ItemKind::ExternCrate(ref b_name)) => {
3232
// `extern crate foo as bar;`
3333
// ^^^ Comparing this.
34-
let a_orig_name = a_name.map_or_else(|| a.ident.as_str(), rustc_span::Symbol::as_str);
35-
let b_orig_name = b_name.map_or_else(|| b.ident.as_str(), rustc_span::Symbol::as_str);
36-
let result = a_orig_name.cmp(&b_orig_name);
34+
let a_orig_name = a_name.unwrap_or(a.ident.name);
35+
let b_orig_name = b_name.unwrap_or(b.ident.name);
36+
let result = a_orig_name.as_str().cmp(b_orig_name.as_str());
3737
if result != Ordering::Equal {
3838
return result;
3939
}
@@ -44,7 +44,7 @@ fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
4444
(Some(..), None) => Ordering::Greater,
4545
(None, Some(..)) => Ordering::Less,
4646
(None, None) => Ordering::Equal,
47-
(Some(..), Some(..)) => a.ident.as_str().cmp(&b.ident.as_str()),
47+
(Some(..), Some(..)) => a.ident.as_str().cmp(b.ident.as_str()),
4848
}
4949
}
5050
_ => unreachable!(),

src/syntux/parser.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@ pub(crate) enum ParserError {
9595

9696
impl<'a> Parser<'a> {
9797
pub(crate) fn submod_path_from_attr(attrs: &[ast::Attribute], path: &Path) -> Option<PathBuf> {
98-
let path_string = first_attr_value_str_by_name(attrs, sym::path)?.as_str();
98+
let path_sym = first_attr_value_str_by_name(attrs, sym::path)?;
99+
let path_str = path_sym.as_str();
100+
99101
// On windows, the base path might have the form
100102
// `\\?\foo\bar` in which case it does not tolerate
101103
// mixed `/` and `\` separators, so canonicalize
102104
// `/` to `\`.
103105
#[cfg(windows)]
104-
let path_string = path_string.replace("/", "\\");
106+
let path_str = path_str.replace("/", "\\");
105107

106-
Some(path.join(&*path_string))
108+
Some(path.join(path_str))
107109
}
108110

109111
pub(crate) fn parse_file_as_module(

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ fn is_skip(meta_item: &MetaItem) -> bool {
260260
match meta_item.kind {
261261
MetaItemKind::Word => {
262262
let path_str = pprust::path_to_string(&meta_item.path);
263-
path_str == *skip_annotation().as_str() || path_str == *depr_skip_annotation().as_str()
263+
path_str == skip_annotation().as_str() || path_str == depr_skip_annotation().as_str()
264264
}
265265
MetaItemKind::List(ref l) => {
266266
meta_item.has_name(sym::cfg_attr) && l.len() == 2 && is_skip_nested(&l[1])

0 commit comments

Comments
 (0)