Skip to content

Commit deba5dd

Browse files
committed
Auto merge of rust-lang#106656 - JohnTitor:rollup-rk2qltg, r=JohnTitor
Rollup of 9 pull requests Successful merges: - rust-lang#105034 (Add example for iterator_flatten) - rust-lang#105708 (Enable atomic cas for bpf targets) - rust-lang#106175 (Fix bad import suggestion with nested `use` tree) - rust-lang#106204 (No need to take opaques in `check_type_bounds`) - rust-lang#106387 (Revert "bootstrap: Get rid of `tail_args` in `stream_cargo`") - rust-lang#106636 (Accept old spelling of Fuchsia target triples) - rust-lang#106639 (update Miri) - rust-lang#106640 (update test for inductive canonical cycles) - rust-lang#106647 (rustdoc: merge common CSS for `a`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d53924d + ed840a6 commit deba5dd

File tree

48 files changed

+553
-177
lines changed

Some content is hidden

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

48 files changed

+553
-177
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
318318

319319
// This is still required for many(half of the tests in ui/type-alias-impl-trait)
320320
// tests to pass
321-
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
321+
let _ = infcx.take_opaque_types();
322322

323323
if errors.is_empty() {
324324
definition_ty

compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
209209
);
210210

211211
translate_outlives_facts(&mut checker);
212-
let opaque_type_values = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
212+
let opaque_type_values = infcx.take_opaque_types();
213213

214214
let opaque_type_values = opaque_type_values
215215
.into_iter()

compiler/rustc_const_eval/src/util/compare_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ pub fn is_subtype<'tcx>(
5858
// even if they're constrained in our current function.
5959
//
6060
// It seems very unlikely that this hides any bugs.
61-
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
61+
let _ = infcx.take_opaque_types();
6262
errors.is_empty()
6363
}

compiler/rustc_hir_analysis/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ fn check_opaque_meets_bounds<'tcx>(
475475
}
476476
}
477477
// Clean up after ourselves
478-
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
478+
let _ = infcx.take_opaque_types();
479479
}
480480

481481
fn is_enum_of_nonnullable_ptr<'tcx>(

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ fn compare_asyncness<'tcx>(
424424
ty::Alias(ty::Opaque, ..) => {
425425
// allow both `async fn foo()` and `fn foo() -> impl Future`
426426
}
427-
ty::Error(rustc_errors::ErrorGuaranteed { .. }) => {
427+
ty::Error(_) => {
428428
// We don't know if it's ok, but at least it's already an error.
429429
}
430430
_ => {
@@ -1972,22 +1972,6 @@ pub(super) fn check_type_bounds<'tcx>(
19721972
&outlives_environment,
19731973
)?;
19741974

1975-
let constraints = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
1976-
for (key, value) in constraints {
1977-
infcx
1978-
.err_ctxt()
1979-
.report_mismatched_types(
1980-
&ObligationCause::misc(
1981-
value.hidden_type.span,
1982-
tcx.hir().local_def_id_to_hir_id(impl_ty.def_id.expect_local()),
1983-
),
1984-
tcx.mk_opaque(key.def_id.to_def_id(), key.substs),
1985-
value.hidden_type.ty,
1986-
TypeError::Mismatch,
1987-
)
1988-
.emit();
1989-
}
1990-
19911975
Ok(())
19921976
}
19931977

compiler/rustc_hir_typeck/src/writeback.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
534534

535535
#[instrument(skip(self), level = "debug")]
536536
fn visit_opaque_types(&mut self) {
537-
let opaque_types =
538-
self.fcx.infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
537+
let opaque_types = self.fcx.infcx.take_opaque_types();
539538
for (opaque_type_key, decl) in opaque_types {
540539
let hidden_type = self.resolve(decl.hidden_type, &decl.hidden_type.span);
541540
let opaque_type_key = self.resolve(opaque_type_key, &decl.hidden_type.span);

compiler/rustc_infer/src/infer/canonical/query_response.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ impl<'tcx> InferCtxt<'tcx> {
156156
/// As the new solver does canonicalization slightly differently, this is also used there
157157
/// for now. This should hopefully change fairly soon.
158158
pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
159-
self.inner
160-
.borrow_mut()
161-
.opaque_type_storage
162-
.take_opaque_types()
159+
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
163160
.into_iter()
164161
.map(|(k, v)| (self.tcx.mk_opaque(k.def_id.to_def_id(), k.substs), v.hidden_type.ty))
165162
.collect()

compiler/rustc_infer/src/infer/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,12 @@ impl<'tcx> InferCtxt<'tcx> {
13381338
var_infos
13391339
}
13401340

1341+
#[instrument(level = "debug", skip(self), ret)]
1342+
pub fn take_opaque_types(&self) -> opaque_types::OpaqueTypeMap<'tcx> {
1343+
debug_assert_ne!(self.defining_use_anchor, DefiningAnchor::Error);
1344+
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
1345+
}
1346+
13411347
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
13421348
self.resolve_vars_if_possible(t).to_string()
13431349
}

compiler/rustc_infer/src/infer/opaque_types/table.rs

-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
2929
}
3030
}
3131

32-
#[instrument(level = "debug", ret)]
33-
pub fn take_opaque_types(&mut self) -> OpaqueTypeMap<'tcx> {
34-
std::mem::take(&mut self.opaque_types)
35-
}
36-
3732
#[inline]
3833
pub(crate) fn with_log<'a>(
3934
&'a mut self,

compiler/rustc_resolve/src/diagnostics.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ impl<'a> Resolver<'a> {
161161
found_use,
162162
DiagnosticMode::Normal,
163163
path,
164+
"",
164165
);
165166
err.emit();
166167
} else if let Some((span, msg, sugg, appl)) = suggestion {
@@ -690,6 +691,7 @@ impl<'a> Resolver<'a> {
690691
FoundUse::Yes,
691692
DiagnosticMode::Pattern,
692693
vec![],
694+
"",
693695
);
694696
}
695697
err
@@ -1344,6 +1346,7 @@ impl<'a> Resolver<'a> {
13441346
FoundUse::Yes,
13451347
DiagnosticMode::Normal,
13461348
vec![],
1349+
"",
13471350
);
13481351

13491352
if macro_kind == MacroKind::Derive && (ident.name == sym::Send || ident.name == sym::Sync) {
@@ -2309,7 +2312,7 @@ enum FoundUse {
23092312
}
23102313

23112314
/// Whether a binding is part of a pattern or a use statement. Used for diagnostics.
2312-
enum DiagnosticMode {
2315+
pub(crate) enum DiagnosticMode {
23132316
Normal,
23142317
/// The binding is part of a pattern
23152318
Pattern,
@@ -2324,6 +2327,8 @@ pub(crate) fn import_candidates(
23242327
// This is `None` if all placement locations are inside expansions
23252328
use_placement_span: Option<Span>,
23262329
candidates: &[ImportSuggestion],
2330+
mode: DiagnosticMode,
2331+
append: &str,
23272332
) {
23282333
show_candidates(
23292334
session,
@@ -2333,8 +2338,9 @@ pub(crate) fn import_candidates(
23332338
candidates,
23342339
Instead::Yes,
23352340
FoundUse::Yes,
2336-
DiagnosticMode::Import,
2341+
mode,
23372342
vec![],
2343+
append,
23382344
);
23392345
}
23402346

@@ -2352,6 +2358,7 @@ fn show_candidates(
23522358
found_use: FoundUse,
23532359
mode: DiagnosticMode,
23542360
path: Vec<Segment>,
2361+
append: &str,
23552362
) {
23562363
if candidates.is_empty() {
23572364
return;
@@ -2416,7 +2423,7 @@ fn show_candidates(
24162423
// produce an additional newline to separate the new use statement
24172424
// from the directly following item.
24182425
let additional_newline = if let FoundUse::Yes = found_use { "" } else { "\n" };
2419-
candidate.0 = format!("{}{};\n{}", add_use, &candidate.0, additional_newline);
2426+
candidate.0 = format!("{add_use}{}{append};\n{additional_newline}", &candidate.0);
24202427
}
24212428

24222429
err.span_suggestions(

compiler/rustc_resolve/src/imports.rs

+55-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! A bunch of methods and structures more or less related to resolving imports.
22
3-
use crate::diagnostics::{import_candidates, Suggestion};
3+
use crate::diagnostics::{import_candidates, DiagnosticMode, Suggestion};
44
use crate::Determinacy::{self, *};
55
use crate::Namespace::*;
66
use crate::{module_to_string, names_to_string, ImportSuggestion};
@@ -402,7 +402,7 @@ struct UnresolvedImportError {
402402
label: Option<String>,
403403
note: Option<String>,
404404
suggestion: Option<Suggestion>,
405-
candidate: Option<Vec<ImportSuggestion>>,
405+
candidates: Option<Vec<ImportSuggestion>>,
406406
}
407407

408408
pub struct ImportResolver<'a, 'b> {
@@ -475,12 +475,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
475475
errors = vec![];
476476
}
477477
if seen_spans.insert(err.span) {
478-
let path = import_path_to_string(
479-
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
480-
&import.kind,
481-
err.span,
482-
);
483-
errors.push((path, err));
478+
errors.push((import, err));
484479
prev_root_id = import.root_id;
485480
}
486481
} else if is_indeterminate {
@@ -494,10 +489,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
494489
label: None,
495490
note: None,
496491
suggestion: None,
497-
candidate: None,
492+
candidates: None,
498493
};
494+
// FIXME: there should be a better way of doing this than
495+
// formatting this as a string then checking for `::`
499496
if path.contains("::") {
500-
errors.push((path, err))
497+
errors.push((import, err))
501498
}
502499
}
503500
}
@@ -507,7 +504,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
507504
}
508505
}
509506

510-
fn throw_unresolved_import_error(&self, errors: Vec<(String, UnresolvedImportError)>) {
507+
fn throw_unresolved_import_error(&self, errors: Vec<(&Import<'_>, UnresolvedImportError)>) {
511508
if errors.is_empty() {
512509
return;
513510
}
@@ -516,7 +513,17 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
516513
const MAX_LABEL_COUNT: usize = 10;
517514

518515
let span = MultiSpan::from_spans(errors.iter().map(|(_, err)| err.span).collect());
519-
let paths = errors.iter().map(|(path, _)| format!("`{}`", path)).collect::<Vec<_>>();
516+
let paths = errors
517+
.iter()
518+
.map(|(import, err)| {
519+
let path = import_path_to_string(
520+
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
521+
&import.kind,
522+
err.span,
523+
);
524+
format!("`{path}`")
525+
})
526+
.collect::<Vec<_>>();
520527
let msg = format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),);
521528

522529
let mut diag = struct_span_err!(self.r.session, span, E0432, "{}", &msg);
@@ -525,7 +532,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
525532
diag.note(note);
526533
}
527534

528-
for (_, err) in errors.into_iter().take(MAX_LABEL_COUNT) {
535+
for (import, err) in errors.into_iter().take(MAX_LABEL_COUNT) {
529536
if let Some(label) = err.label {
530537
diag.span_label(err.span, label);
531538
}
@@ -538,14 +545,36 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
538545
diag.multipart_suggestion(&msg, suggestions, applicability);
539546
}
540547

541-
if let Some(candidate) = &err.candidate {
542-
import_candidates(
543-
self.r.session,
544-
&self.r.untracked.source_span,
545-
&mut diag,
546-
Some(err.span),
547-
&candidate,
548-
)
548+
if let Some(candidates) = &err.candidates {
549+
match &import.kind {
550+
ImportKind::Single { nested: false, source, target, .. } => import_candidates(
551+
self.r.session,
552+
&self.r.untracked.source_span,
553+
&mut diag,
554+
Some(err.span),
555+
&candidates,
556+
DiagnosticMode::Import,
557+
(source != target)
558+
.then(|| format!(" as {target}"))
559+
.as_deref()
560+
.unwrap_or(""),
561+
),
562+
ImportKind::Single { nested: true, source, target, .. } => {
563+
import_candidates(
564+
self.r.session,
565+
&self.r.untracked.source_span,
566+
&mut diag,
567+
None,
568+
&candidates,
569+
DiagnosticMode::Normal,
570+
(source != target)
571+
.then(|| format!(" as {target}"))
572+
.as_deref()
573+
.unwrap_or(""),
574+
);
575+
}
576+
_ => {}
577+
}
549578
}
550579
}
551580

@@ -707,14 +736,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
707736
String::from("a similar path exists"),
708737
Applicability::MaybeIncorrect,
709738
)),
710-
candidate: None,
739+
candidates: None,
711740
},
712741
None => UnresolvedImportError {
713742
span,
714743
label: Some(label),
715744
note: None,
716745
suggestion,
717-
candidate: None,
746+
candidates: None,
718747
},
719748
};
720749
return Some(err);
@@ -761,7 +790,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
761790
)),
762791
note: None,
763792
suggestion: None,
764-
candidate: None,
793+
candidates: None,
765794
});
766795
}
767796
}
@@ -873,7 +902,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
873902
let resolutions = resolutions.as_ref().into_iter().flat_map(|r| r.iter());
874903
let names = resolutions
875904
.filter_map(|(BindingKey { ident: i, .. }, resolution)| {
876-
if *i == ident {
905+
if i.name == ident.name {
877906
return None;
878907
} // Never suggest the same name
879908
match *resolution.borrow() {
@@ -943,7 +972,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
943972
label: Some(label),
944973
note,
945974
suggestion,
946-
candidate: if !parent_suggestion.is_empty() {
975+
candidates: if !parent_suggestion.is_empty() {
947976
Some(parent_suggestion)
948977
} else {
949978
None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub use crate::spec::aarch64_unknown_fuchsia::target;

compiler/rustc_target/src/spec/bpf_base.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub fn opts(endian: Endian) -> TargetOptions {
66
allow_asm: true,
77
endian,
88
linker_flavor: LinkerFlavor::Bpf,
9-
atomic_cas: false,
9+
atomic_cas: true,
1010
dynamic_linking: true,
1111
no_builtins: true,
1212
panic_strategy: PanicStrategy::Abort,
@@ -19,6 +19,10 @@ pub fn opts(endian: Endian) -> TargetOptions {
1919
obj_is_bitcode: true,
2020
requires_lto: false,
2121
singlethread: true,
22+
// When targeting the `v3` cpu in llvm, 32-bit atomics are also supported.
23+
// But making this value change based on the target cpu can be mostly confusing
24+
// and would require a bit of a refactor.
25+
min_atomic_width: Some(64),
2226
max_atomic_width: Some(64),
2327
..Default::default()
2428
}

compiler/rustc_target/src/spec/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ impl fmt::Display for StackProtector {
981981
}
982982

983983
macro_rules! supported_targets {
984-
( $(($triple:literal, $module:ident ),)+ ) => {
984+
( $(($triple:literal, $module:ident),)+ ) => {
985985
$(mod $module;)+
986986

987987
/// List of supported targets
@@ -1109,7 +1109,11 @@ supported_targets! {
11091109
("x86_64-apple-darwin", x86_64_apple_darwin),
11101110
("i686-apple-darwin", i686_apple_darwin),
11111111

1112+
// FIXME(#106649): Remove aarch64-fuchsia in favor of aarch64-unknown-fuchsia
1113+
("aarch64-fuchsia", aarch64_fuchsia),
11121114
("aarch64-unknown-fuchsia", aarch64_unknown_fuchsia),
1115+
// FIXME(#106649): Remove x86_64-fuchsia in favor of x86_64-unknown-fuchsia
1116+
("x86_64-fuchsia", x86_64_fuchsia),
11131117
("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia),
11141118

11151119
("avr-unknown-gnu-atmega328", avr_unknown_gnu_atmega328),

0 commit comments

Comments
 (0)