Auto merge of #60748 - Centril:rollup-rr63jqo, r=Centril
Rollup of 4 pull requests Successful merges: - #60720 (Remove unnecessary unwraps) - #60727 (add comment to `Rc`/`Arc`'s `Eq` specialization) - #60733 (Cleanup the .await HIR lowering with .stmt(..).) - #60741 (Remove redundant "let mut" in write_graph_label) Failed merges: r? @ghost
This commit is contained in:
commit
d28e948b92
5 changed files with 47 additions and 34 deletions
|
@ -932,6 +932,11 @@ impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// We're doing this specialization here, and not as a more general optimization on `&T`, because it
|
||||||
|
/// would otherwise add a cost to all equality checks on refs. We assume that `Rc`s are used to
|
||||||
|
/// store large values, that are slow to clone, but also heavy to check for equality, causing this
|
||||||
|
/// cost to pay off more easily. It's also more likely to have two `Rc` clones, that point to
|
||||||
|
/// the same value, than two `&T`s.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T: ?Sized + Eq> RcEqIdent<T> for Rc<T> {
|
impl<T: ?Sized + Eq> RcEqIdent<T> for Rc<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -1377,6 +1377,11 @@ impl<T: ?Sized + PartialEq> ArcEqIdent<T> for Arc<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// We're doing this specialization here, and not as a more general optimization on `&T`, because it
|
||||||
|
/// would otherwise add a cost to all equality checks on refs. We assume that `Arc`s are used to
|
||||||
|
/// store large values, that are slow to clone, but also heavy to check for equality, causing this
|
||||||
|
/// cost to pay off more easily. It's also more likely to have two `Arc` clones, that point to
|
||||||
|
/// the same value, than two `&T`s.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T: ?Sized + Eq> ArcEqIdent<T> for Arc<T> {
|
impl<T: ?Sized + Eq> ArcEqIdent<T> for Arc<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -5647,11 +5647,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
hir_vec![ready_arm, pending_arm],
|
hir_vec![ready_arm, pending_arm],
|
||||||
hir::MatchSource::AwaitDesugar,
|
hir::MatchSource::AwaitDesugar,
|
||||||
));
|
));
|
||||||
hir::Stmt {
|
self.stmt(span, hir::StmtKind::Expr(match_expr))
|
||||||
hir_id: self.next_id(),
|
|
||||||
node: hir::StmtKind::Expr(match_expr),
|
|
||||||
span,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let yield_stmt = {
|
let yield_stmt = {
|
||||||
|
@ -5661,11 +5657,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
hir::ExprKind::Yield(P(unit)),
|
hir::ExprKind::Yield(P(unit)),
|
||||||
ThinVec::new(),
|
ThinVec::new(),
|
||||||
));
|
));
|
||||||
hir::Stmt {
|
self.stmt(span, hir::StmtKind::Expr(yield_expr))
|
||||||
hir_id: self.next_id(),
|
|
||||||
node: hir::StmtKind::Expr(yield_expr),
|
|
||||||
span,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let loop_block = P(self.block_all(
|
let loop_block = P(self.block_all(
|
||||||
|
|
|
@ -167,7 +167,7 @@ fn write_graph_label<'a, 'gcx, 'tcx, W: Write>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
write!(w, r#"{:?}: {}; // {}<br align="left"/>"#,
|
write!(w, r#"{:?}: {}; // {}<br align="left"/>"#,
|
||||||
Place::Base(PlaceBase::Local(local)), escape(&decl.ty), name)?;
|
Place::Base(PlaceBase::Local(local)), escape(&decl.ty), name)?;
|
||||||
} else {
|
} else {
|
||||||
write!(w, r#"let mut {:?}: {};<br align="left"/>"#,
|
write!(w, r#"{:?}: {};<br align="left"/>"#,
|
||||||
Place::Base(PlaceBase::Local(local)), escape(&decl.ty))?;
|
Place::Base(PlaceBase::Local(local)), escape(&decl.ty))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,14 +91,21 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
CandidateSource::ImplSource(impl_did) => {
|
CandidateSource::ImplSource(impl_did) => {
|
||||||
// Provide the best span we can. Use the item, if local to crate, else
|
// Provide the best span we can. Use the item, if local to crate, else
|
||||||
// the impl, if local to crate (item may be defaulted), else nothing.
|
// the impl, if local to crate (item may be defaulted), else nothing.
|
||||||
let item = self.associated_item(impl_did, item_name, Namespace::Value)
|
let item = match self.associated_item(
|
||||||
.or_else(|| {
|
impl_did,
|
||||||
self.associated_item(
|
item_name,
|
||||||
self.tcx.impl_trait_ref(impl_did).unwrap().def_id,
|
Namespace::Value,
|
||||||
item_name,
|
).or_else(|| {
|
||||||
Namespace::Value,
|
let impl_trait_ref = self.tcx.impl_trait_ref(impl_did)?;
|
||||||
)
|
self.associated_item(
|
||||||
}).unwrap();
|
impl_trait_ref.def_id,
|
||||||
|
item_name,
|
||||||
|
Namespace::Value,
|
||||||
|
)
|
||||||
|
}) {
|
||||||
|
Some(item) => item,
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
let note_span = self.tcx.hir().span_if_local(item.def_id).or_else(|| {
|
let note_span = self.tcx.hir().span_if_local(item.def_id).or_else(|| {
|
||||||
self.tcx.hir().span_if_local(impl_did)
|
self.tcx.hir().span_if_local(impl_did)
|
||||||
});
|
});
|
||||||
|
@ -132,9 +139,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CandidateSource::TraitSource(trait_did) => {
|
CandidateSource::TraitSource(trait_did) => {
|
||||||
let item = self
|
let item = match self.associated_item(
|
||||||
.associated_item(trait_did, item_name, Namespace::Value)
|
trait_did,
|
||||||
.unwrap();
|
item_name,
|
||||||
|
Namespace::Value)
|
||||||
|
{
|
||||||
|
Some(item) => item,
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
let item_span = self.tcx.sess.source_map()
|
let item_span = self.tcx.sess.source_map()
|
||||||
.def_span(self.tcx.def_span(item.def_id));
|
.def_span(self.tcx.def_span(item.def_id));
|
||||||
if sources.len() > 1 {
|
if sources.len() > 1 {
|
||||||
|
@ -251,8 +263,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
if let &QPath::Resolved(_, ref path) = &qpath {
|
if let &QPath::Resolved(_, ref path) = &qpath {
|
||||||
if let hir::def::Res::Local(hir_id) = path.res {
|
if let hir::def::Res::Local(hir_id) = path.res {
|
||||||
let span = tcx.hir().span_by_hir_id(hir_id);
|
let span = tcx.hir().span_by_hir_id(hir_id);
|
||||||
let snippet = tcx.sess.source_map().span_to_snippet(span)
|
let snippet = tcx.sess.source_map().span_to_snippet(span);
|
||||||
.unwrap();
|
|
||||||
let filename = tcx.sess.source_map().span_to_filename(span);
|
let filename = tcx.sess.source_map().span_to_filename(span);
|
||||||
|
|
||||||
let parent_node = self.tcx.hir().get_by_hir_id(
|
let parent_node = self.tcx.hir().get_by_hir_id(
|
||||||
|
@ -263,12 +274,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
concrete_type,
|
concrete_type,
|
||||||
);
|
);
|
||||||
|
|
||||||
match (filename, parent_node) {
|
match (filename, parent_node, snippet) {
|
||||||
(FileName::Real(_), Node::Local(hir::Local {
|
(FileName::Real(_), Node::Local(hir::Local {
|
||||||
source: hir::LocalSource::Normal,
|
source: hir::LocalSource::Normal,
|
||||||
ty,
|
ty,
|
||||||
..
|
..
|
||||||
})) => {
|
}), Ok(ref snippet)) => {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
// account for `let x: _ = 42;`
|
// account for `let x: _ = 42;`
|
||||||
// ^^^^
|
// ^^^^
|
||||||
|
@ -375,14 +386,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id),
|
self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id),
|
||||||
);
|
);
|
||||||
|
|
||||||
let span = call_expr.span.trim_start(item_name.span).unwrap();
|
if let Some(span) = call_expr.span.trim_start(item_name.span) {
|
||||||
|
err.span_suggestion(
|
||||||
err.span_suggestion(
|
span,
|
||||||
span,
|
"remove the arguments",
|
||||||
"remove the arguments",
|
String::new(),
|
||||||
String::new(),
|
Applicability::MaybeIncorrect,
|
||||||
Applicability::MaybeIncorrect,
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue