Skip to content

Commit deba5dd

Browse files
committed
Auto merge of #106656 - JohnTitor:rollup-rk2qltg, r=JohnTitor
Rollup of 9 pull requests Successful merges: - #105034 (Add example for iterator_flatten) - #105708 (Enable atomic cas for bpf targets) - #106175 (Fix bad import suggestion with nested `use` tree) - #106204 (No need to take opaques in `check_type_bounds`) - #106387 (Revert "bootstrap: Get rid of `tail_args` in `stream_cargo`") - #106636 (Accept old spelling of Fuchsia target triples) - #106639 (update Miri) - #106640 (update test for inductive canonical cycles) - #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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)