Skip to content

Commit ed7e35f

Browse files
committed
Auto merge of #127430 - compiler-errors:rollup-76ni16s, r=compiler-errors
Rollup of 4 pull requests Successful merges: - #127386 (Uplift outlives components to `rustc_type_ir`) - #127405 (uplift `PredicateEmittingRelation`) - #127410 (Correct description of E0502) - #127417 (Show fnsig's unit output explicitly when there is output diff in diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8a8ad34 + 413345c commit ed7e35f

Some content is hidden

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

43 files changed

+499
-376
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4168,6 +4168,7 @@ dependencies = [
41684168
"rustc_index",
41694169
"rustc_macros",
41704170
"rustc_middle",
4171+
"rustc_next_trait_solver",
41714172
"rustc_span",
41724173
"rustc_target",
41734174
"rustc_type_ir",

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use rustc_data_structures::fx::FxHashMap;
22
use rustc_errors::ErrorGuaranteed;
3-
use rustc_infer::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases};
4-
use rustc_infer::infer::relate::{Relate, RelateResult, TypeRelation};
5-
use rustc_infer::infer::NllRegionVariableOrigin;
3+
use rustc_infer::infer::relate::{
4+
PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation,
5+
};
6+
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
67
use rustc_infer::traits::solve::Goal;
78
use rustc_infer::traits::Obligation;
89
use rustc_middle::mir::ConstraintCategory;
@@ -522,7 +523,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
522523
}
523524
}
524525

525-
impl<'bccx, 'tcx> PredicateEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx, 'tcx> {
526+
impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx> {
526527
fn span(&self) -> Span {
527528
self.locations.span(self.type_checker.body)
528529
}

compiler/rustc_error_codes/src/error_codes/E0502.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
A variable already borrowed as immutable was borrowed as mutable.
1+
A variable already borrowed with a certain mutability (either mutable or
2+
immutable) was borrowed again with a different mutability.
23

34
Erroneous code example:
45

@@ -13,7 +14,7 @@ fn foo(a: &mut i32) {
1314
```
1415

1516
To fix this error, ensure that you don't have any other references to the
16-
variable before trying to access it mutably:
17+
variable before trying to access it with a different mutability:
1718

1819
```
1920
fn bar(x: &mut i32) {}

compiler/rustc_hir_analysis/src/outlives/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use rustc_data_structures::fx::FxIndexMap;
2-
use rustc_infer::infer::outlives::components::{push_outlives_components, Component};
32
use rustc_middle::ty::{self, Region, Ty, TyCtxt};
43
use rustc_middle::ty::{GenericArg, GenericArgKind};
54
use rustc_middle::{bug, span_bug};
65
use rustc_span::Span;
6+
use rustc_type_ir::outlives::{push_outlives_components, Component};
77
use smallvec::smallvec;
88

99
/// Tracks the `T: 'a` or `'a: 'a` predicates that we have inferred

compiler/rustc_infer/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rustc_hir = { path = "../rustc_hir" }
1616
rustc_index = { path = "../rustc_index" }
1717
rustc_macros = { path = "../rustc_macros" }
1818
rustc_middle = { path = "../rustc_middle" }
19+
rustc_next_trait_solver = { path = "../rustc_next_trait_solver" }
1920
rustc_span = { path = "../rustc_span" }
2021
rustc_target = { path = "../rustc_target" }
2122
rustc_type_ir = { path = "../rustc_type_ir" }

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1168,14 +1168,16 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
11681168
let output1 = sig1.output();
11691169
let output2 = sig2.output();
11701170
let (x1, x2) = self.cmp(output1, output2);
1171-
if !output1.is_unit() {
1171+
let output_diff = x1 != x2;
1172+
if !output1.is_unit() || output_diff {
11721173
values.0.push_normal(" -> ");
11731174
(values.0).0.extend(x1.0);
11741175
}
1175-
if !output2.is_unit() {
1176+
if !output2.is_unit() || output_diff {
11761177
values.1.push_normal(" -> ");
11771178
(values.1).0.extend(x2.0);
11781179
}
1180+
11791181
values
11801182
}
11811183

compiler/rustc_infer/src/infer/outlives/components.rs

-266
This file was deleted.

compiler/rustc_infer/src/infer/outlives/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::infer::lexical_region_resolve;
88
use rustc_middle::traits::query::{NoSolution, OutlivesBound};
99
use rustc_middle::ty;
1010

11-
pub mod components;
1211
pub mod env;
1312
pub mod for_liveness;
1413
pub mod obligations;

compiler/rustc_infer/src/infer/outlives/obligations.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
//! might later infer `?U` to something like `&'b u32`, which would
6060
//! imply that `'b: 'a`.
6161
62-
use crate::infer::outlives::components::{push_outlives_components, Component};
6362
use crate::infer::outlives::env::RegionBoundPairs;
6463
use crate::infer::outlives::verify::VerifyBoundCx;
6564
use crate::infer::resolve::OpportunisticRegionResolver;
@@ -75,6 +74,7 @@ use rustc_middle::ty::{
7574
};
7675
use rustc_middle::ty::{GenericArgKind, PolyTypeOutlivesPredicate};
7776
use rustc_span::DUMMY_SP;
77+
use rustc_type_ir::outlives::{push_outlives_components, Component};
7878
use smallvec::smallvec;
7979

8080
use super::env::OutlivesEnvironment;
@@ -291,7 +291,7 @@ where
291291
fn components_must_outlive(
292292
&mut self,
293293
origin: infer::SubregionOrigin<'tcx>,
294-
components: &[Component<'tcx>],
294+
components: &[Component<TyCtxt<'tcx>>],
295295
region: ty::Region<'tcx>,
296296
category: ConstraintCategory<'tcx>,
297297
) {

0 commit comments

Comments
 (0)