Skip to content

Commit cb18e83

Browse files
committed
Auto merge of #93645 - matthiaskrgr:rollup-eua2621, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - #92735 (Add crate filter parameter in URL) - #93402 (Windows: Disable LLVM crash dialog boxes.) - #93508 (Add rustdoc info to jsondocck output) - #93551 (Add package.json in gitignore) - #93555 (Link `try_exists` docs to `Path::exists`) - #93585 (Missing tests for #92630) - #93593 (Fix ret > 1 bound if shadowed by const) - #93630 (clippy::perf fixes) - #93631 (rustc_mir_dataflow: use iter::once instead of Some().into_iter) - #93632 (rustdoc: clippy::complexity fixes) - #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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 30 additions & 29 deletions
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);

0 commit comments

Comments
 (0)