Skip to content

Commit cb18e83

Browse files
committed
Auto merge of rust-lang#93645 - matthiaskrgr:rollup-eua2621, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#92735 (Add crate filter parameter in URL) - rust-lang#93402 (Windows: Disable LLVM crash dialog boxes.) - rust-lang#93508 (Add rustdoc info to jsondocck output) - rust-lang#93551 (Add package.json in gitignore) - rust-lang#93555 (Link `try_exists` docs to `Path::exists`) - rust-lang#93585 (Missing tests for rust-lang#92630) - rust-lang#93593 (Fix ret > 1 bound if shadowed by const) - rust-lang#93630 (clippy::perf fixes) - rust-lang#93631 (rustc_mir_dataflow: use iter::once instead of Some().into_iter) - rust-lang#93632 (rustdoc: clippy::complexity fixes) - rust-lang#93638 (rustdoc: remove unused Hash impl) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4e8fb74 + 1426f0e commit cb18e83

File tree

33 files changed

+276
-123
lines changed

33 files changed

+276
-123
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ __pycache__/
7171
## Node
7272
node_modules
7373
package-lock.json
74+
package.json
7475

7576
## Rustdoc GUI tests
7677
src/test/rustdoc-gui/src/**.lock

compiler/rustc_codegen_llvm/src/back/archive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
219219

220220
match result {
221221
Err(e) => {
222-
self.config.sess.fatal(&format!("Error calling dlltool: {}", e.to_string()));
222+
self.config.sess.fatal(&format!("Error calling dlltool: {}", e));
223223
}
224224
Ok(output) if !output.status.success() => self.config.sess.fatal(&format!(
225225
"Dlltool could not create import library: {}\n{}",

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
987987

988988
extern "C" {
989989
pub fn LLVMRustInstallFatalErrorHandler();
990+
pub fn LLVMRustDisableSystemDialogsOnCrash();
990991

991992
// Create and destroy contexts.
992993
pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;

compiler/rustc_codegen_llvm/src/llvm_util.rs

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ unsafe fn configure_llvm(sess: &Session) {
4646
let mut llvm_args = Vec::with_capacity(n_args + 1);
4747

4848
llvm::LLVMRustInstallFatalErrorHandler();
49+
// On Windows, an LLVM assertion will open an Abort/Retry/Ignore dialog
50+
// box for the purpose of launching a debugger. However, on CI this will
51+
// cause it to hang until it times out, which can take several hours.
52+
if std::env::var_os("CI").is_some() {
53+
llvm::LLVMRustDisableSystemDialogsOnCrash();
54+
}
4955

5056
fn llvm_arg_to_arg_name(full_arg: &str) -> &str {
5157
full_arg.trim().split(|c: char| c == '=' || c.is_whitespace()).next().unwrap_or("")

compiler/rustc_interface/src/interface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
126126

127127
// If the user tried to use a key="value" flag, but is missing the quotes, provide
128128
// a hint about how to resolve this.
129-
if s.contains("=") && !s.contains("=\"") && !s.ends_with("\"") {
129+
if s.contains('=') && !s.contains("=\"") && !s.ends_with('"') {
130130
error!(concat!(
131131
r#"expected `key` or `key="value"`, ensure escaping is appropriate"#,
132132
r#" for your shell, try 'key="value"' or key=\"value\""#

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ extern "C" void LLVMRustInstallFatalErrorHandler() {
7676
install_fatal_error_handler(FatalErrorHandler);
7777
}
7878

79+
extern "C" void LLVMRustDisableSystemDialogsOnCrash() {
80+
sys::DisableSystemDialogsOnCrash();
81+
}
82+
7983
extern "C" char *LLVMRustGetLastError(void) {
8084
char *Ret = LastError;
8185
LastError = nullptr;

compiler/rustc_middle/src/ty/assoc.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,11 @@ impl<'tcx> AssocItems<'tcx> {
160160
&self,
161161
tcx: TyCtxt<'_>,
162162
ident: Ident,
163+
// Sorted in order of what kinds to look at
163164
kinds: &[AssocKind],
164165
parent_def_id: DefId,
165166
) -> Option<&ty::AssocItem> {
166-
self.filter_by_name_unhygienic(ident.name)
167-
.filter(|item| kinds.contains(&item.kind))
168-
.find(|item| tcx.hygienic_eq(ident, item.ident(tcx), parent_def_id))
167+
kinds.iter().find_map(|kind| self.find_by_name_and_kind(tcx, ident, *kind, parent_def_id))
169168
}
170169

171170
/// Returns the associated item with the given name in the given `Namespace`, if one exists.

compiler/rustc_mir_dataflow/src/elaborate_drops.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::ty::subst::SubstsRef;
88
use rustc_middle::ty::util::IntTypeExt;
99
use rustc_middle::ty::{self, Ty, TyCtxt};
1010
use rustc_target::abi::VariantIdx;
11-
use std::fmt;
11+
use std::{fmt, iter};
1212

1313
/// The value of an inserted drop flag.
1414
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
@@ -329,8 +329,7 @@ where
329329
mut succ: BasicBlock,
330330
fields: &[(Place<'tcx>, Option<D::Path>)],
331331
) -> Vec<BasicBlock> {
332-
Some(succ)
333-
.into_iter()
332+
iter::once(succ)
334333
.chain(fields.iter().rev().zip(unwind_ladder).map(|(&(place, path), &unwind_succ)| {
335334
succ = self.drop_subpath(place, path, succ, unwind_succ);
336335
succ

compiler/rustc_parse/src/parser/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1702,11 +1702,11 @@ impl<'a> Parser<'a> {
17021702

17031703
// Try to lowercase the prefix if it's a valid base prefix.
17041704
fn fix_base_capitalisation(s: &str) -> Option<String> {
1705-
if let Some(stripped) = s.strip_prefix("B") {
1705+
if let Some(stripped) = s.strip_prefix('B') {
17061706
Some(format!("0b{stripped}"))
1707-
} else if let Some(stripped) = s.strip_prefix("O") {
1707+
} else if let Some(stripped) = s.strip_prefix('O') {
17081708
Some(format!("0o{stripped}"))
1709-
} else if let Some(stripped) = s.strip_prefix("X") {
1709+
} else if let Some(stripped) = s.strip_prefix('X') {
17101710
Some(format!("0x{stripped}"))
17111711
} else {
17121712
None

compiler/rustc_typeck/src/astconv/mod.rs

+30-29
Original file line numberDiff line numberDiff line change
@@ -887,15 +887,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
887887
.find_by_name_and_kind(self.tcx(), assoc_name, ty::AssocKind::Type, trait_def_id)
888888
.is_some()
889889
}
890-
fn trait_defines_associated_named(&self, trait_def_id: DefId, assoc_name: Ident) -> bool {
890+
fn trait_defines_associated_const_named(&self, trait_def_id: DefId, assoc_name: Ident) -> bool {
891891
self.tcx()
892892
.associated_items(trait_def_id)
893-
.find_by_name_and_kinds(
894-
self.tcx(),
895-
assoc_name,
896-
&[ty::AssocKind::Type, ty::AssocKind::Const],
897-
trait_def_id,
898-
)
893+
.find_by_name_and_kind(self.tcx(), assoc_name, ty::AssocKind::Const, trait_def_id)
899894
.is_some()
900895
}
901896

@@ -1145,13 +1140,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11451140

11461141
// We have already adjusted the item name above, so compare with `ident.normalize_to_macros_2_0()` instead
11471142
// of calling `filter_by_name_and_kind`.
1148-
let assoc_item = tcx
1149-
.associated_items(candidate.def_id())
1150-
.filter_by_name_unhygienic(assoc_ident.name)
1151-
.find(|i| {
1152-
(i.kind == ty::AssocKind::Type || i.kind == ty::AssocKind::Const)
1153-
&& i.ident(tcx).normalize_to_macros_2_0() == assoc_ident
1154-
})
1143+
let find_item_of_kind = |kind| {
1144+
tcx.associated_items(candidate.def_id())
1145+
.filter_by_name_unhygienic(assoc_ident.name)
1146+
.find(|i| i.kind == kind && i.ident(tcx).normalize_to_macros_2_0() == assoc_ident)
1147+
};
1148+
let assoc_item = find_item_of_kind(ty::AssocKind::Type)
1149+
.or_else(|| find_item_of_kind(ty::AssocKind::Const))
11551150
.expect("missing associated type");
11561151

11571152
if !assoc_item.vis.is_accessible_from(def_scope, tcx) {
@@ -1657,11 +1652,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16571652
I: Iterator<Item = ty::PolyTraitRef<'tcx>>,
16581653
{
16591654
let mut matching_candidates = all_candidates()
1660-
.filter(|r| self.trait_defines_associated_named(r.def_id(), assoc_name));
1661-
1662-
let bound = match matching_candidates.next() {
1663-
Some(bound) => bound,
1664-
None => {
1655+
.filter(|r| self.trait_defines_associated_type_named(r.def_id(), assoc_name));
1656+
let mut const_candidates = all_candidates()
1657+
.filter(|r| self.trait_defines_associated_const_named(r.def_id(), assoc_name));
1658+
1659+
let (bound, next_cand) = match (matching_candidates.next(), const_candidates.next()) {
1660+
(Some(bound), _) => (bound, matching_candidates.next()),
1661+
(None, Some(bound)) => (bound, const_candidates.next()),
1662+
(None, None) => {
16651663
self.complain_about_assoc_type_not_found(
16661664
all_candidates,
16671665
&ty_param_name(),
@@ -1671,10 +1669,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16711669
return Err(ErrorReported);
16721670
}
16731671
};
1674-
16751672
debug!("one_bound_for_assoc_type: bound = {:?}", bound);
16761673

1677-
if let Some(bound2) = matching_candidates.next() {
1674+
if let Some(bound2) = next_cand {
16781675
debug!("one_bound_for_assoc_type: bound2 = {:?}", bound2);
16791676

16801677
let is_equality = is_equality();
@@ -1759,6 +1756,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
17591756
return Err(ErrorReported);
17601757
}
17611758
}
1759+
17621760
Ok(bound)
17631761
}
17641762

@@ -1893,14 +1891,17 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
18931891

18941892
// We have already adjusted the item name above, so compare with `ident.normalize_to_macros_2_0()` instead
18951893
// of calling `filter_by_name_and_kind`.
1896-
let item = tcx
1897-
.associated_items(trait_did)
1898-
.in_definition_order()
1899-
.find(|i| {
1900-
i.kind.namespace() == Namespace::TypeNS
1901-
&& i.ident(tcx).normalize_to_macros_2_0() == assoc_ident
1902-
})
1903-
.expect("missing associated type");
1894+
let item = tcx.associated_items(trait_did).in_definition_order().find(|i| {
1895+
i.kind.namespace() == Namespace::TypeNS
1896+
&& i.ident(tcx).normalize_to_macros_2_0() == assoc_ident
1897+
});
1898+
// Assume that if it's not matched, there must be a const defined with the same name
1899+
// but it was used in a type position.
1900+
let Some(item) = item else {
1901+
let msg = format!("found associated const `{assoc_ident}` when type was expected");
1902+
tcx.sess.struct_span_err(span, &msg).emit();
1903+
return Err(ErrorReported);
1904+
};
19041905

19051906
let ty = self.projected_ty_from_poly_trait_ref(span, item.def_id, assoc_segment, bound);
19061907
let ty = self.normalize_ty(span, ty);

compiler/rustc_typeck/src/check/expr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1587,10 +1587,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15871587
) {
15881588
let len = remaining_fields.len();
15891589

1590-
let mut displayable_field_names =
1591-
remaining_fields.keys().map(|ident| ident.as_str()).collect::<Vec<_>>();
1592-
1593-
displayable_field_names.sort();
1590+
let mut displayable_field_names: Vec<&str> =
1591+
remaining_fields.keys().map(|ident| ident.as_str()).collect();
1592+
// sorting &str primitives here, sort_unstable is ok
1593+
displayable_field_names.sort_unstable();
15941594

15951595
let mut truncated_fields_error = String::new();
15961596
let remaining_fields_names = match &displayable_field_names[..] {

library/core/tests/future.rs

+8
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,11 @@ fn block_on(fut: impl Future) {
118118
}
119119
}
120120
}
121+
122+
// just tests by whether or not this compiles
123+
fn _pending_impl_all_auto_traits<T>() {
124+
use std::panic::{RefUnwindSafe, UnwindSafe};
125+
fn all_auto_traits<T: Send + Sync + Unpin + UnwindSafe + RefUnwindSafe>() {}
126+
127+
all_auto_traits::<std::future::Pending<T>>();
128+
}

library/core/tests/hash/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,11 @@ fn test_build_hasher_object_safe() {
146146

147147
let _: &dyn BuildHasher<Hasher = DefaultHasher> = &RandomState::new();
148148
}
149+
150+
// just tests by whether or not this compiles
151+
fn _build_hasher_default_impl_all_auto_traits<T>() {
152+
use std::panic::{RefUnwindSafe, UnwindSafe};
153+
fn all_auto_traits<T: Send + Sync + Unpin + UnwindSafe + RefUnwindSafe>() {}
154+
155+
all_auto_traits::<std::hash::BuildHasherDefault<T>>();
156+
}

library/core/tests/iter/traits/iterator.rs

+8
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,11 @@ fn test_collect() {
496496
let b: Vec<isize> = a.iter().cloned().collect();
497497
assert!(a == b);
498498
}
499+
500+
// just tests by whether or not this compiles
501+
fn _empty_impl_all_auto_traits<T>() {
502+
use std::panic::{RefUnwindSafe, UnwindSafe};
503+
fn all_auto_traits<T: Send + Sync + Unpin + UnwindSafe + RefUnwindSafe>() {}
504+
505+
all_auto_traits::<std::iter::Empty<T>>();
506+
}

library/std/src/fs.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
22882288
/// This function will traverse symbolic links to query information about the
22892289
/// destination file. In case of broken symbolic links this will return `Ok(false)`.
22902290
///
2291-
/// As opposed to the `exists()` method, this one doesn't silently ignore errors
2291+
/// As opposed to the [`Path::exists`] method, this one doesn't silently ignore errors
22922292
/// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission
22932293
/// denied on some of the parent directories.)
22942294
///
@@ -2301,6 +2301,8 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
23012301
/// assert!(!fs::try_exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
23022302
/// assert!(fs::try_exists("/root/secret_file.txt").is_err());
23032303
/// ```
2304+
///
2305+
/// [`Path::exists`]: crate::path::Path::exists
23042306
// FIXME: stabilization should modify documentation of `exists()` to recommend this method
23052307
// instead.
23062308
#[unstable(feature = "path_try_exists", issue = "83186")]

library/std/src/path.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2730,7 +2730,7 @@ impl Path {
27302730
/// This function will traverse symbolic links to query information about the
27312731
/// destination file. In case of broken symbolic links this will return `Ok(false)`.
27322732
///
2733-
/// As opposed to the `exists()` method, this one doesn't silently ignore errors
2733+
/// As opposed to the [`exists()`] method, this one doesn't silently ignore errors
27342734
/// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission
27352735
/// denied on some of the parent directories.)
27362736
///
@@ -2743,6 +2743,8 @@ impl Path {
27432743
/// assert!(!Path::new("does_not_exist.txt").try_exists().expect("Can't check existence of file does_not_exist.txt"));
27442744
/// assert!(Path::new("/root/secret_file.txt").try_exists().is_err());
27452745
/// ```
2746+
///
2747+
/// [`exists()`]: Self::exists
27462748
// FIXME: stabilization should modify documentation of `exists()` to recommend this method
27472749
// instead.
27482750
#[unstable(feature = "path_try_exists", issue = "83186")]

src/librustdoc/clean/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1533,9 +1533,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
15331533
for pb in obj.projection_bounds() {
15341534
bindings.push(TypeBinding {
15351535
name: cx.tcx.associated_item(pb.item_def_id()).name,
1536-
kind: TypeBindingKind::Equality {
1537-
term: pb.skip_binder().term.clean(cx).into(),
1538-
},
1536+
kind: TypeBindingKind::Equality { term: pb.skip_binder().term.clean(cx) },
15391537
});
15401538
}
15411539

src/librustdoc/clean/types.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ crate fn collapse_doc_fragments(doc_strings: &[DocFragment]) -> String {
953953
/// A link that has not yet been rendered.
954954
///
955955
/// This link will be turned into a rendered link by [`Item::links`].
956-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
956+
#[derive(Clone, Debug, PartialEq, Eq)]
957957
crate struct ItemLink {
958958
/// The original link written in the markdown
959959
crate link: String,
@@ -1036,8 +1036,7 @@ impl Attributes {
10361036
// Additional documentation should be shown before the original documentation
10371037
let other_attrs = additional_attrs
10381038
.into_iter()
1039-
.map(|(attrs, id)| attrs.iter().map(move |attr| (attr, Some(id))))
1040-
.flatten()
1039+
.flat_map(|(attrs, id)| attrs.iter().map(move |attr| (attr, Some(id))))
10411040
.chain(attrs.iter().map(|attr| (attr, None)))
10421041
.filter_map(clean_attr)
10431042
.collect();

src/librustdoc/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,12 @@ impl Options {
439439
matches
440440
.opt_str("default-theme")
441441
.iter()
442-
.map(|theme| {
442+
.flat_map(|theme| {
443443
vec![
444444
("use-system-theme".to_string(), "false".to_string()),
445445
("theme".to_string(), theme.to_string()),
446446
]
447447
})
448-
.flatten()
449448
.collect(),
450449
matches
451450
.opt_strs("default-setting")

src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl core::fmt::Write for Buffer {
7676
}
7777

7878
#[inline]
79-
fn write_fmt(self: &mut Self, args: fmt::Arguments<'_>) -> fmt::Result {
79+
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> fmt::Result {
8080
self.buffer.write_fmt(args)
8181
}
8282
}

src/librustdoc/html/highlight.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ impl Decorations {
274274
let (mut starts, mut ends): (Vec<_>, Vec<_>) = info
275275
.0
276276
.into_iter()
277-
.map(|(kind, ranges)| ranges.into_iter().map(move |(lo, hi)| ((lo, kind), hi)))
278-
.flatten()
277+
.flat_map(|(kind, ranges)| ranges.into_iter().map(move |(lo, hi)| ((lo, kind), hi)))
279278
.unzip();
280279

281280
// Sort the sequences in document order.

src/librustdoc/html/render/search_index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
8181
lastpathid += 1;
8282

8383
if let Some(&(ref fqp, short)) = paths.get(&defid) {
84-
crate_paths.push((short, fqp.last().unwrap().clone()));
84+
crate_paths.push((short, *fqp.last().unwrap()));
8585
Some(pathid)
8686
} else {
8787
None

0 commit comments

Comments
 (0)