Skip to content

Commit

Permalink
Auto merge of #80655 - GuillaumeGomez:rollup-ai7soid, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #80580 (Add suggestion for "ignore" doc code block)
 - #80591 (remove allow(incomplete_features) from std)
 - #80617 (Detect invalid rustdoc test commands)
 - #80628 (reduce borrowing and (de)referencing around match patterns (clippy::match_ref_pats))
 - #80646 (Clean up in `each_child_of_item`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jan 3, 2021
2 parents bcd6975 + 539c435 commit db69136
Show file tree
Hide file tree
Showing 36 changed files with 159 additions and 119 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ pub enum WherePredicate {
impl WherePredicate {
pub fn span(&self) -> Span {
match self {
&WherePredicate::BoundPredicate(ref p) => p.span,
&WherePredicate::RegionPredicate(ref p) => p.span,
&WherePredicate::EqPredicate(ref p) => p.span,
WherePredicate::BoundPredicate(p) => p.span,
WherePredicate::RegionPredicate(p) => p.span,
WherePredicate::EqPredicate(p) => p.span,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,11 +1212,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}

fn visit_pat(&mut self, pat: &'a Pat) {
match pat.kind {
PatKind::Lit(ref expr) => {
match &pat.kind {
PatKind::Lit(expr) => {
self.check_expr_within_pat(expr, false);
}
PatKind::Range(ref start, ref end, _) => {
PatKind::Range(start, end, _) => {
if let Some(expr) = start {
self.check_expr_within_pat(expr, true);
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_builtin_macros/src/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ pub fn expand_deriving_hash(
}

fn hash_substructure(cx: &mut ExtCtxt<'_>, trait_span: Span, substr: &Substructure<'_>) -> P<Expr> {
let state_expr = match &substr.nonself_args {
&[o_f] => o_f,
let state_expr = match substr.nonself_args {
[o_f] => o_f,
_ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`"),
};
let call_hash = |span, thing_expr| {
Expand All @@ -64,9 +64,9 @@ fn hash_substructure(cx: &mut ExtCtxt<'_>, trait_span: Span, substr: &Substructu
};
let mut stmts = Vec::new();

let fields = match *substr.fields {
Struct(_, ref fs) | EnumMatching(_, 1, .., ref fs) => fs,
EnumMatching(.., ref fs) => {
let fields = match substr.fields {
Struct(_, fs) | EnumMatching(_, 1, .., fs) => fs,
EnumMatching(.., fs) => {
let variant_value = deriving::call_intrinsic(
cx,
trait_span,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ impl GenericBound<'_> {

pub fn span(&self) -> Span {
match self {
&GenericBound::Trait(ref t, ..) => t.span,
&GenericBound::LangItemTrait(_, span, ..) => span,
&GenericBound::Outlives(ref l) => l.span,
GenericBound::Trait(t, ..) => t.span,
GenericBound::LangItemTrait(_, span, ..) => *span,
GenericBound::Outlives(l) => l.span,
}
}
}
Expand Down Expand Up @@ -538,9 +538,9 @@ pub enum WherePredicate<'hir> {
impl WherePredicate<'_> {
pub fn span(&self) -> Span {
match self {
&WherePredicate::BoundPredicate(ref p) => p.span,
&WherePredicate::RegionPredicate(ref p) => p.span,
&WherePredicate::EqPredicate(ref p) => p.span,
WherePredicate::BoundPredicate(p) => p.span,
WherePredicate::RegionPredicate(p) => p.span,
WherePredicate::EqPredicate(p) => p.span,
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,8 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
visitor: &mut V,
predicate: &'v WherePredicate<'v>,
) {
match predicate {
&WherePredicate::BoundPredicate(WhereBoundPredicate {
match *predicate {
WherePredicate::BoundPredicate(WhereBoundPredicate {
ref bounded_ty,
bounds,
bound_generic_params,
Expand All @@ -907,11 +907,11 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(
walk_list!(visitor, visit_param_bound, bounds);
walk_list!(visitor, visit_generic_param, bound_generic_params);
}
&WherePredicate::RegionPredicate(WhereRegionPredicate { ref lifetime, bounds, .. }) => {
WherePredicate::RegionPredicate(WhereRegionPredicate { ref lifetime, bounds, .. }) => {
visitor.visit_lifetime(lifetime);
walk_list!(visitor, visit_param_bound, bounds);
}
&WherePredicate::EqPredicate(WhereEqPredicate {
WherePredicate::EqPredicate(WhereEqPredicate {
hir_id, ref lhs_ty, ref rhs_ty, ..
}) => {
visitor.visit_id(hir_id);
Expand Down
20 changes: 9 additions & 11 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2233,19 +2233,19 @@ impl<'a> State<'a> {
}

match predicate {
&hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate {
ref bound_generic_params,
ref bounded_ty,
hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate {
bound_generic_params,
bounded_ty,
bounds,
..
}) => {
self.print_formal_generic_params(bound_generic_params);
self.print_type(&bounded_ty);
self.print_bounds(":", bounds);
self.print_bounds(":", *bounds);
}
&hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate {
ref lifetime,
ref bounds,
hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate {
lifetime,
bounds,
..
}) => {
self.print_lifetime(lifetime);
Expand All @@ -2264,10 +2264,8 @@ impl<'a> State<'a> {
}
}
}
&hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
ref lhs_ty,
ref rhs_ty,
..
hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
lhs_ty, rhs_ty, ..
}) => {
self.print_type(lhs_ty);
self.s.space();
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_incremental/src/assert_dep_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ fn filter_nodes<'q>(
sources: &Option<FxHashSet<&'q DepNode>>,
targets: &Option<FxHashSet<&'q DepNode>>,
) -> FxHashSet<&'q DepNode> {
if let &Some(ref sources) = sources {
if let &Some(ref targets) = targets {
if let Some(sources) = sources {
if let Some(targets) = targets {
walk_between(query, sources, targets)
} else {
walk_nodes(query, sources, OUTGOING)
}
} else if let &Some(ref targets) = targets {
} else if let Some(targets) = targets {
walk_nodes(query, targets, INCOMING)
} else {
query.nodes().into_iter().collect()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
return Some(());
}
if let &ty::Adt(def, _) = ta.kind() {
if let ty::Adt(def, _) = ta.kind() {
let path_ = self.tcx.def_path_str(def.did);
if path_ == other_path {
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,8 @@ impl EarlyLintPass for DeprecatedAttr {
if attr.ident().map(|ident| ident.name) == Some(n) {
if let &AttributeGate::Gated(
Stability::Deprecated(link, suggestion),
ref name,
ref reason,
name,
reason,
_,
) = g
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
}

fn check_pat(&mut self, cx: &LateContext<'_>, p: &hir::Pat<'_>) {
if let &PatKind::Binding(_, hid, ident, _) = &p.kind {
if let PatKind::Binding(_, hid, ident, _) = p.kind {
if let hir::Node::Pat(parent_pat) = cx.tcx.hir().get(cx.tcx.hir().get_parent_node(hid))
{
if let PatKind::Struct(_, field_pats, _) = &parent_pat.kind {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,11 +862,11 @@ impl EarlyLintPass for UnusedParens {
}

fn check_ty(&mut self, cx: &EarlyContext<'_>, ty: &ast::Ty) {
if let &ast::TyKind::Paren(ref r) = &ty.kind {
if let ast::TyKind::Paren(r) = &ty.kind {
match &r.kind {
&ast::TyKind::TraitObject(..) => {}
&ast::TyKind::ImplTrait(_, ref bounds) if bounds.len() > 1 => {}
&ast::TyKind::Array(_, ref len) => {
ast::TyKind::TraitObject(..) => {}
ast::TyKind::ImplTrait(_, bounds) if bounds.len() > 1 => {}
ast::TyKind::Array(_, len) => {
self.check_unused_delims_expr(
cx,
&len.value,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ impl Collector<'tcx> {
fn process_command_line(&mut self) {
// First, check for errors
let mut renames = FxHashSet::default();
for &(ref name, ref new_name, _) in &self.tcx.sess.opts.libs {
if let &Some(ref new_name) = new_name {
for (name, new_name, _) in &self.tcx.sess.opts.libs {
if let Some(ref new_name) = new_name {
let any_duplicate = self
.libs
.iter()
.filter_map(|lib| lib.name.as_ref())
.any(|n| n.as_str() == *name);
.any(|n| &n.as_str() == name);
if new_name.is_empty() {
self.tcx.sess.err(&format!(
"an empty renaming target was specified for library `{}`",
Expand Down Expand Up @@ -240,7 +240,7 @@ impl Collector<'tcx> {
if kind != NativeLibKind::Unspecified {
lib.kind = kind;
}
if let &Some(ref new_name) = new_name {
if let Some(new_name) = new_name {
lib.name = Some(Symbol::intern(new_name));
}
return true;
Expand Down
29 changes: 12 additions & 17 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,19 +1055,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {

// Iterate over all children.
let macros_only = self.dep_kind.lock().macros_only();
let children = self.root.tables.children.get(self, id).unwrap_or_else(Lazy::empty);
for child_index in children.decode((self, sess)) {
if macros_only {
continue;
}

// Get the item.
if let Some(child_kind) = self.maybe_kind(child_index) {
match child_kind {
EntryKind::MacroDef(..) => {}
_ if macros_only => continue,
_ => {}
}
if !macros_only {
let children = self.root.tables.children.get(self, id).unwrap_or_else(Lazy::empty);

for child_index in children.decode((self, sess)) {
// Get the item.
let child_kind = match self.maybe_kind(child_index) {
Some(child_kind) => child_kind,
None => continue,
};

// Hand off the item to the callback.
match child_kind {
Expand Down Expand Up @@ -1102,8 +1098,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
}

let def_key = self.def_key(child_index);
let span = self.get_span(child_index, sess);
if def_key.disambiguated_data.data.get_opt_name().is_some() {
let span = self.get_span(child_index, sess);
let kind = self.def_kind(child_index);
let ident = self.item_ident(child_index, sess);
let vis = self.get_visibility(child_index);
Expand Down Expand Up @@ -1137,9 +1133,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
// within the crate. We only need this for fictive constructors,
// for other constructors correct visibilities
// were already encoded in metadata.
let attrs: Vec<_> =
self.get_item_attrs(def_id.index, sess).collect();
if sess.contains_name(&attrs, sym::non_exhaustive) {
let mut attrs = self.get_item_attrs(def_id.index, sess);
if attrs.any(|item| item.has_name(sym::non_exhaustive)) {
let crate_def_id = self.local_def_id(CRATE_DEF_INDEX);
vis = ty::Visibility::Restricted(crate_def_id);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ pub fn suggest_constraining_type_param(
}
}

match &param_spans[..] {
&[&param_span] => suggest_restrict(param_span.shrink_to_hi()),
match param_spans[..] {
[&param_span] => suggest_restrict(param_span.shrink_to_hi()),
_ => {
err.span_suggestion_verbose(
generics.where_clause.tail_span_for_suggestion(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
.find_map(|p| self.is_upvar_field_projection(p));

let deref_base = match deref_target_place.projection.as_ref() {
&[ref proj_base @ .., ProjectionElem::Deref] => {
[proj_base @ .., ProjectionElem::Deref] => {
PlaceRef { local: deref_target_place.local, projection: &proj_base }
}
_ => bug!("deref_target_place is not a deref projection"),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir/src/borrow_check/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1855,8 +1855,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self.assert_iscleanup(body, block_data, unwind, true);
}
}
TerminatorKind::InlineAsm { ref destination, .. } => {
if let &Some(target) = destination {
TerminatorKind::InlineAsm { destination, .. } => {
if let Some(target) = destination {
self.assert_iscleanup(body, block_data, target, is_cleanup);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/naked_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<'tcx> Visitor<'tcx> for CheckParameters<'tcx> {
fn check_asm<'tcx>(tcx: TyCtxt<'tcx>, hir_id: HirId, body: &'tcx hir::Body<'tcx>, fn_span: Span) {
let mut this = CheckInlineAssembly { tcx, items: Vec::new() };
this.visit_body(body);
if let &[(ItemKind::Asm, _)] = &this.items[..] {
if let [(ItemKind::Asm, _)] = this.items[..] {
// Ok.
} else {
tcx.struct_span_lint_hir(UNSUPPORTED_NAKED_FUNCTIONS, hir_id, fn_span, |lint| {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_save_analysis/src/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<'tcx> DumpVisitor<'tcx> {
}
ref v => {
let mut value = format!("{}::{}", enum_data.name, name);
if let &hir::VariantData::Tuple(ref fields, _) = v {
if let hir::VariantData::Tuple(fields, _) = v {
value.push('(');
value.push_str(
&fields
Expand Down Expand Up @@ -653,7 +653,7 @@ impl<'tcx> DumpVisitor<'tcx> {
let map = &self.tcx.hir();
self.nest_typeck_results(map.local_def_id(item.hir_id), |v| {
v.visit_ty(&typ);
if let &Some(ref trait_ref) = trait_ref {
if let Some(trait_ref) = trait_ref {
v.process_path(trait_ref.hir_ref_id, &hir::QPath::Resolved(None, &trait_ref.path));
}
v.process_generic_params(generics, "", item.hir_id);
Expand Down Expand Up @@ -1082,7 +1082,7 @@ impl<'tcx> DumpVisitor<'tcx> {
);
}

if let &Some(ref default_ty) = default_ty {
if let Some(default_ty) = default_ty {
self.visit_ty(default_ty)
}
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_trait_selection/src/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ impl AutoTraitFinder<'tcx> {
infcx.resolve_vars_if_possible(Obligation::new(dummy_cause.clone(), new_env, pred));
let result = select.select(&obligation);

match &result {
&Ok(Some(ref impl_source)) => {
match result {
Ok(Some(ref impl_source)) => {
// If we see an explicit negative impl (e.g., `impl !Send for MyStruct`),
// we immediately bail out, since it's impossible for us to continue.

Expand Down Expand Up @@ -339,8 +339,8 @@ impl AutoTraitFinder<'tcx> {
return None;
}
}
&Ok(None) => {}
&Err(SelectionError::Unimplemented) => {
Ok(None) => {}
Err(SelectionError::Unimplemented) => {
if self.is_param_no_infer(pred.skip_binder().trait_ref.substs) {
already_visited.remove(&pred);
self.add_user_pred(
Expand Down Expand Up @@ -863,7 +863,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> {

fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
(match r {
&ty::ReVar(vid) => self.vid_to_region.get(&vid).cloned(),
ty::ReVar(vid) => self.vid_to_region.get(vid).cloned(),
_ => None,
})
.unwrap_or_else(|| r.super_fold_with(self))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
code: &ObligationCauseCode<'tcx>,
) -> Option<(String, Option<Span>)> {
match code {
&ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
ObligationCauseCode::BuiltinDerivedObligation(data) => {
let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_ref);
match self.get_parent_trait_ref(&data.parent_code) {
Some(t) => Some(t),
Expand Down
Loading

0 comments on commit db69136

Please sign in to comment.