Skip to content

Commit 9b0a099

Browse files
committed
Auto merge of #103048 - Dylan-DPC:rollup-47r62js, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #102847 (impl AsFd and AsRawFd for io::{Stdin, Stdout, Stderr}, not the sys versions) - #102856 (Only test duplicate inherent impl items in a single place) - #102914 (Migrate css highlight without change) - #102938 (Move some tests to more reasonable directories) - #103015 (fix a typo) - #103018 (More dupe word typos) - #103025 (rustdoc: remove unused CSS `.search-container > *`) - #103031 (Suppress irrefutable let patterns lint for prefixes in match guards) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3271760 + 7cf09c5 commit 9b0a099

File tree

89 files changed

+389
-352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+389
-352
lines changed

compiler/rustc_borrowck/src/universal_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
414414

415415
let typeck_root_def_id = self.infcx.tcx.typeck_root_def_id(self.mir_def.did.to_def_id());
416416

417-
// If this is is a 'root' body (not a closure/generator/inline const), then
417+
// If this is a 'root' body (not a closure/generator/inline const), then
418418
// there are no extern regions, so the local regions start at the same
419419
// position as the (empty) sub-list of extern regions
420420
let first_local_index = if self.mir_def.did.to_def_id() == typeck_root_def_id {

compiler/rustc_codegen_cranelift/build_system/rustc_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub(crate) fn get_file_name(crate_name: &str, crate_type: &str) -> String {
6565
}
6666

6767
/// Similar to `get_file_name`, but converts any dashes (`-`) in the `crate_name` to
68-
/// underscores (`_`). This is specially made for the the rustc and cargo wrappers
68+
/// underscores (`_`). This is specially made for the rustc and cargo wrappers
6969
/// which have a dash in the name, and that is not allowed in a crate name.
7070
pub(crate) fn get_wrapper_file_name(crate_name: &str, crate_type: &str) -> String {
7171
let crate_name = crate_name.replace('-', "_");

compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub(super) fn from_casted_value<'tcx>(
193193
kind: StackSlotKind::ExplicitSlot,
194194
// FIXME Don't force the size to a multiple of 16 bytes once Cranelift gets a way to
195195
// specify stack slot alignment.
196-
// Stack slot size may be bigger for for example `[u8; 3]` which is packed into an `i32`.
196+
// Stack slot size may be bigger for example `[u8; 3]` which is packed into an `i32`.
197197
// It may also be smaller for example when the type is a wrapper around an integer with a
198198
// larger alignment than the integer.
199199
size: (std::cmp::max(abi_param_size, layout_size) + 15) / 16 * 16,

compiler/rustc_codegen_llvm/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ pub(crate) fn link(
537537
mut modules: Vec<ModuleCodegen<ModuleLlvm>>,
538538
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
539539
use super::lto::{Linker, ModuleBuffer};
540-
// Sort the modules by name to ensure to ensure deterministic behavior.
540+
// Sort the modules by name to ensure deterministic behavior.
541541
modules.sort_by(|a, b| a.name.cmp(&b.name));
542542
let (first, elements) =
543543
modules.split_first().expect("Bug! modules must contain at least one module.");

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl CoverageMapGenerator {
129129
// LLVM Coverage Mapping Format version 6 (zero-based encoded as 5)
130130
// requires setting the first filename to the compilation directory.
131131
// Since rustc generates coverage maps with relative paths, the
132-
// compilation directory can be combined with the the relative paths
132+
// compilation directory can be combined with the relative paths
133133
// to get absolute paths, if needed.
134134
let working_dir = tcx
135135
.sess

compiler/rustc_const_eval/src/const_eval/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct ConstEvalErr<'tcx> {
6464
impl<'tcx> ConstEvalErr<'tcx> {
6565
/// Turn an interpreter error into something to report to the user.
6666
/// As a side-effect, if RUSTC_CTFE_BACKTRACE is set, this prints the backtrace.
67-
/// Should be called only if the error is actually going to to be reported!
67+
/// Should be called only if the error is actually going to be reported!
6868
pub fn new<'mir, M: Machine<'mir, 'tcx>>(
6969
ecx: &InterpCx<'mir, 'tcx, M>,
7070
error: InterpErrorInfo<'tcx>,

compiler/rustc_const_eval/src/interpret/memory.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
794794
todo.extend(static_roots);
795795
while let Some(id) = todo.pop() {
796796
if reachable.insert(id) {
797-
// This is a new allocation, add the allocation it points to to `todo`.
797+
// This is a new allocation, add the allocation it points to `todo`.
798798
if let Some((_, alloc)) = self.memory.alloc_map.get(id) {
799799
todo.extend(
800800
alloc.provenance().values().filter_map(|prov| prov.get_alloc_id()),

compiler/rustc_data_structures/src/graph/vec_graph/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ impl<N: Idx + Ord> VecGraph<N> {
2929
// Store the *target* of each edge into `edge_targets`.
3030
let edge_targets: Vec<N> = edge_pairs.iter().map(|&(_, target)| target).collect();
3131

32-
// Create the *edge starts* array. We are iterating over over
33-
// the (sorted) edge pairs. We maintain the invariant that the
32+
// Create the *edge starts* array. We are iterating over the
33+
// (sorted) edge pairs. We maintain the invariant that the
3434
// length of the `node_starts` array is enough to store the
3535
// current source node -- so when we see that the source node
3636
// for an edge is greater than the current length, we grow the

compiler/rustc_expand/src/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl InvocationKind {
327327
fn placeholder_visibility(&self) -> Option<ast::Visibility> {
328328
// HACK: For unnamed fields placeholders should have the same visibility as the actual
329329
// fields because for tuple structs/variants resolve determines visibilities of their
330-
// constructor using these field visibilities before attributes on them are are expanded.
330+
// constructor using these field visibilities before attributes on them are expanded.
331331
// The assumption is that the attribute expansion cannot change field visibilities,
332332
// and it holds because only inert attributes are supported in this position.
333333
match self {

compiler/rustc_hir_analysis/src/check/fallback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
7272
//
7373
// - Unconstrained ints are replaced with `i32`.
7474
//
75-
// - Unconstrained floats are replaced with with `f64`.
75+
// - Unconstrained floats are replaced with `f64`.
7676
//
7777
// - Non-numerics may get replaced with `()` or `!`, depending on
7878
// how they were categorized by `calculate_diverging_fallback`

compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/cfg_build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> {
210210
}
211211

212212
/// For an expression with an uninhabited return type (e.g. a function that returns !),
213-
/// this adds a self edge to to the CFG to model the fact that the function does not
213+
/// this adds a self edge to the CFG to model the fact that the function does not
214214
/// return.
215215
fn handle_uninhabited_return(&mut self, expr: &Expr<'tcx>) {
216216
let ty = self.typeck_results.expr_ty(expr);

compiler/rustc_hir_analysis/src/check/upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
352352
/// and that the path can be captured with required capture kind (depending on use in closure,
353353
/// move closure etc.)
354354
///
355-
/// Returns the set of of adjusted information along with the inferred closure kind and span
355+
/// Returns the set of adjusted information along with the inferred closure kind and span
356356
/// associated with the closure kind inference.
357357
///
358358
/// Note that we *always* infer a minimal kind, even if

compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs

+35-6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,37 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
5858
== item2.ident(self.tcx).normalize_to_macros_2_0()
5959
}
6060

61+
fn check_for_duplicate_items_in_impl(&self, impl_: DefId) {
62+
let impl_items = self.tcx.associated_items(impl_);
63+
64+
let mut seen_items = FxHashMap::default();
65+
for impl_item in impl_items.in_definition_order() {
66+
let span = self.tcx.def_span(impl_item.def_id);
67+
let ident = impl_item.ident(self.tcx);
68+
69+
let norm_ident = ident.normalize_to_macros_2_0();
70+
match seen_items.entry(norm_ident) {
71+
Entry::Occupied(entry) => {
72+
let former = entry.get();
73+
let mut err = struct_span_err!(
74+
self.tcx.sess,
75+
span,
76+
E0592,
77+
"duplicate definitions with name `{}`",
78+
ident,
79+
);
80+
err.span_label(span, format!("duplicate definitions for `{}`", ident));
81+
err.span_label(*former, format!("other definition for `{}`", ident));
82+
83+
err.emit();
84+
}
85+
Entry::Vacant(entry) => {
86+
entry.insert(span);
87+
}
88+
}
89+
}
90+
}
91+
6192
fn check_for_common_items_in_impls(
6293
&self,
6394
impl1: DefId,
@@ -133,12 +164,6 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
133164

134165
let impls = self.tcx.inherent_impls(id.def_id);
135166

136-
// If there is only one inherent impl block,
137-
// there is nothing to overlap check it with
138-
if impls.len() <= 1 {
139-
return;
140-
}
141-
142167
let overlap_mode = OverlapMode::get(self.tcx, id.def_id.to_def_id());
143168

144169
let impls_items = impls
@@ -152,6 +177,8 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
152177
const ALLOCATING_ALGO_THRESHOLD: usize = 500;
153178
if impls.len() < ALLOCATING_ALGO_THRESHOLD {
154179
for (i, &(&impl1_def_id, impl_items1)) in impls_items.iter().enumerate() {
180+
self.check_for_duplicate_items_in_impl(impl1_def_id);
181+
155182
for &(&impl2_def_id, impl_items2) in &impls_items[(i + 1)..] {
156183
if self.impls_have_common_items(impl_items1, impl_items2) {
157184
self.check_for_overlapping_inherent_impls(
@@ -290,6 +317,8 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
290317
impl_blocks.sort_unstable();
291318
for (i, &impl1_items_idx) in impl_blocks.iter().enumerate() {
292319
let &(&impl1_def_id, impl_items1) = &impls_items[impl1_items_idx];
320+
self.check_for_duplicate_items_in_impl(impl1_def_id);
321+
293322
for &impl2_items_idx in impl_blocks[(i + 1)..].iter() {
294323
let &(&impl2_def_id, impl_items2) = &impls_items[impl2_items_idx];
295324
if self.impls_have_common_items(impl_items1, impl_items2) {

compiler/rustc_hir_analysis/src/impl_wf_check.rs

+1-39
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111
use crate::constrained_generic_params as cgp;
1212
use min_specialization::check_min_specialization;
1313

14-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
14+
use rustc_data_structures::fx::FxHashSet;
1515
use rustc_errors::struct_span_err;
1616
use rustc_hir::def::DefKind;
1717
use rustc_hir::def_id::LocalDefId;
1818
use rustc_middle::ty::query::Providers;
1919
use rustc_middle::ty::{self, TyCtxt, TypeVisitable};
2020
use rustc_span::{Span, Symbol};
2121

22-
use std::collections::hash_map::Entry::{Occupied, Vacant};
23-
2422
mod min_specialization;
2523

2624
/// Checks that all the type/lifetime parameters on an impl also
@@ -59,7 +57,6 @@ fn check_mod_impl_wf(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
5957
for id in module.items() {
6058
if matches!(tcx.def_kind(id.def_id), DefKind::Impl) {
6159
enforce_impl_params_are_constrained(tcx, id.def_id.def_id);
62-
enforce_impl_items_are_distinct(tcx, id.def_id.def_id);
6360
if min_specialization {
6461
check_min_specialization(tcx, id.def_id.def_id);
6562
}
@@ -194,38 +191,3 @@ fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol
194191
}
195192
err.emit();
196193
}
197-
198-
/// Enforce that we do not have two items in an impl with the same name.
199-
fn enforce_impl_items_are_distinct(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) {
200-
if tcx.impl_trait_ref(impl_def_id).is_some() {
201-
return;
202-
}
203-
let mut seen_type_items = FxHashMap::default();
204-
let mut seen_value_items = FxHashMap::default();
205-
for &impl_item_ref in tcx.associated_item_def_ids(impl_def_id) {
206-
let impl_item = tcx.associated_item(impl_item_ref);
207-
let seen_items = match impl_item.kind {
208-
ty::AssocKind::Type => &mut seen_type_items,
209-
_ => &mut seen_value_items,
210-
};
211-
let span = tcx.def_span(impl_item_ref);
212-
let ident = impl_item.ident(tcx);
213-
match seen_items.entry(ident.normalize_to_macros_2_0()) {
214-
Occupied(entry) => {
215-
let mut err = struct_span_err!(
216-
tcx.sess,
217-
span,
218-
E0201,
219-
"duplicate definitions with name `{}`:",
220-
ident
221-
);
222-
err.span_label(*entry.get(), format!("previous definition of `{}` here", ident));
223-
err.span_label(span, "duplicate definition");
224-
err.emit();
225-
}
226-
Vacant(entry) => {
227-
entry.insert(span);
228-
}
229-
}
230-
}
231-
}

compiler/rustc_infer/src/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1150,8 +1150,8 @@ impl<'tcx> InferCtxt<'tcx> {
11501150
/// Return the universe that the region `r` was created in. For
11511151
/// most regions (e.g., `'static`, named regions from the user,
11521152
/// etc) this is the root universe U0. For inference variables or
1153-
/// placeholders, however, it will return the universe which which
1154-
/// they are associated.
1153+
/// placeholders, however, it will return the universe which they
1154+
/// are associated.
11551155
pub fn universe_of_region(&self, r: ty::Region<'tcx>) -> ty::UniverseIndex {
11561156
self.inner.borrow_mut().unwrap_region_constraints().universe(r)
11571157
}

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3310,7 +3310,7 @@ declare_lint! {
33103310
/// explicitly.
33113311
///
33123312
/// To access a library from a binary target within the same crate,
3313-
/// use `your_crate_name::` as the path path instead of `lib::`:
3313+
/// use `your_crate_name::` as the path instead of `lib::`:
33143314
///
33153315
/// ```rust,compile_fail
33163316
/// // bar/src/lib.rs

compiler/rustc_lint_defs/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3937,7 +3937,7 @@ declare_lint! {
39373937
///
39383938
/// The compiler disables the automatic implementation if an explicit one
39393939
/// exists for given type constructor. The exact rules governing this
3940-
/// are currently unsound and quite subtle and and will be modified in the future.
3940+
/// are currently unsound, quite subtle, and will be modified in the future.
39413941
/// This change will cause the automatic implementation to be disabled in more
39423942
/// cases, potentially breaking some code.
39433943
pub SUSPICIOUS_AUTO_TRAIT_IMPLS,

compiler/rustc_middle/src/mir/interpret/pointer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub trait PointerArithmetic: HasDataLayout {
4343
let val = val as i64;
4444
// Now wrap-around into the machine_isize range.
4545
if val > self.machine_isize_max() {
46-
// This can only happen the the ptr size is < 64, so we know max_usize_plus_1 fits into
46+
// This can only happen if the ptr size is < 64, so we know max_usize_plus_1 fits into
4747
// i64.
4848
debug_assert!(self.pointer_size().bits() < 64);
4949
let max_usize_plus_1 = 1u128 << self.pointer_size().bits();

compiler/rustc_middle/src/ty/fold.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
//!
1414
//! There are three groups of traits involved in each traversal.
1515
//! - `TypeFoldable`. This is implemented once for many types, including:
16-
//! - Types of interest, for which the the methods delegate to the
17-
//! folder.
16+
//! - Types of interest, for which the methods delegate to the folder.
1817
//! - All other types, including generic containers like `Vec` and `Option`.
1918
//! It defines a "skeleton" of how they should be folded.
2019
//! - `TypeSuperFoldable`. This is implemented only for each type of interest,

compiler/rustc_middle/src/ty/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ impl<'tcx> Ty<'tcx> {
958958
}
959959
}
960960

961-
/// Checks if `ty` has has a significant drop.
961+
/// Checks if `ty` has a significant drop.
962962
///
963963
/// Note that this method can return false even if `ty` has a destructor
964964
/// attached; even if that is the case then the adt has been marked with

compiler/rustc_middle/src/ty/visit.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
//!
1111
//! There are three groups of traits involved in each traversal.
1212
//! - `TypeVisitable`. This is implemented once for many types, including:
13-
//! - Types of interest, for which the the methods delegate to the
14-
//! visitor.
13+
//! - Types of interest, for which the methods delegate to the visitor.
1514
//! - All other types, including generic containers like `Vec` and `Option`.
1615
//! It defines a "skeleton" of how they should be visited.
1716
//! - `TypeSuperVisitable`. This is implemented only for each type of interest,

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,12 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
370370

371371
// Check if the let source is while, for there is no alternative place to put a prefix,
372372
// and we shouldn't lint.
373+
// For let guards inside a match, prefixes might use bindings of the match pattern,
374+
// so can't always be moved out.
375+
// FIXME: Add checking whether the bindings are actually used in the prefix,
376+
// and lint if they are not.
373377
let let_source = let_source_parent(self.tcx, top, None);
374-
if !matches!(let_source, LetSource::WhileLet) {
378+
if !matches!(let_source, LetSource::WhileLet | LetSource::IfLetGuard) {
375379
// Emit the lint
376380
let prefix = &chain_refutabilities[..until];
377381
lint_affix(prefix, "leading", "outside of the construct");
@@ -1151,10 +1155,14 @@ fn let_source_parent(tcx: TyCtxt<'_>, parent: HirId, pat_id: Option<HirId>) -> L
11511155

11521156
let parent_parent = hir.get_parent_node(parent);
11531157
let parent_parent_node = hir.get(parent_parent);
1154-
if let hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(_), span, .. }) =
1155-
parent_parent_node
1156-
{
1157-
return LetSource::LetElse(*span);
1158+
match parent_parent_node {
1159+
hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(_), span, .. }) => {
1160+
return LetSource::LetElse(*span);
1161+
}
1162+
hir::Node::Arm(hir::Arm { guard: Some(hir::Guard::If(_)), .. }) => {
1163+
return LetSource::IfLetGuard;
1164+
}
1165+
_ => {}
11581166
}
11591167

11601168
let parent_parent_parent = hir.get_parent_node(parent_parent);

compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ fn is_useful<'p, 'tcx>(
885885
// that has the potential to trigger the `non_exhaustive_omitted_patterns` lint.
886886
// To understand the workings checkout `Constructor::split` and `SplitWildcard::new/into_ctors`
887887
if is_non_exhaustive_and_wild
888-
// We check that the match has a wildcard pattern and that that wildcard is useful,
888+
// We check that the match has a wildcard pattern and that wildcard is useful,
889889
// meaning there are variants that are covered by the wildcard. Without the check
890890
// for `witness_preference` the lint would trigger on `if let NonExhaustiveEnum::A = foo {}`
891891
&& usefulness.is_useful() && matches!(witness_preference, RealArm)

compiler/rustc_parse/src/parser/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,7 @@ impl<'a> Parser<'a> {
22322232
///
22332233
/// When encountering code like `foo::< bar + 3 >` or `foo::< bar - baz >` we suggest
22342234
/// `foo::<{ bar + 3 }>` and `foo::<{ bar - baz }>`, respectively. We only provide a suggestion
2235-
/// if we think that that the resulting expression would be well formed.
2235+
/// if we think that the resulting expression would be well formed.
22362236
pub fn recover_const_arg(
22372237
&mut self,
22382238
start: Span,

0 commit comments

Comments
 (0)