Skip to content

Commit f4ec0e7

Browse files
committed
Auto merge of rust-lang#96322 - matthiaskrgr:rollup-9xejxrf, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - rust-lang#96272 (Update `validate_uninhabited_zsts.rs` test after MIR building changes) - rust-lang#96273 (Make `E0117` error clear) - rust-lang#96315 (Make the lifetime accurate which is used in the region constraints part) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5ffebc2 + eeed267 commit f4ec0e7

26 files changed

+94
-70
lines changed

compiler/rustc_borrowck/src/constraints/graph.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> RegionGraph<'s, 'tcx, D> {
190190

191191
/// Given a region `R`, iterate over all regions `R1` such that
192192
/// there exists a constraint `R: R1`.
193-
crate fn outgoing_regions(&self, region_sup: RegionVid) -> Successors<'_, 'tcx, D> {
193+
crate fn outgoing_regions(&self, region_sup: RegionVid) -> Successors<'s, 'tcx, D> {
194194
Successors {
195195
edges: self.constraint_graph.outgoing_edges(region_sup, self.set, self.static_region),
196196
}
@@ -225,10 +225,7 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> graph::WithSuccessors for RegionGraph
225225
}
226226
}
227227

228-
impl<'s, 'graph, 'tcx, D: ConstraintGraphDirecton> graph::GraphSuccessors<'graph>
229-
for RegionGraph<'s, 'tcx, D>
230-
{
228+
impl<'s, 'tcx, D: ConstraintGraphDirecton> graph::GraphSuccessors<'_> for RegionGraph<'s, 'tcx, D> {
231229
type Item = RegionVid;
232-
// FIXME - why can't this be `'graph, 'tcx`
233-
type Iter = Successors<'graph, 'graph, D>;
230+
type Iter = Successors<'s, 'tcx, D>;
234231
}

compiler/rustc_typeck/src/coherence/orphan.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fn orphan_check_impl(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGua
5050
tcx,
5151
sp,
5252
tr.path.span,
53+
trait_ref.self_ty(),
5354
impl_.self_ty.span,
5455
&impl_.generics,
5556
err,
@@ -201,18 +202,23 @@ fn emit_orphan_check_error<'tcx>(
201202
tcx: TyCtxt<'tcx>,
202203
sp: Span,
203204
trait_span: Span,
205+
self_ty: Ty<'tcx>,
204206
self_ty_span: Span,
205207
generics: &hir::Generics<'tcx>,
206208
err: traits::OrphanCheckErr<'tcx>,
207209
) -> Result<!, ErrorGuaranteed> {
208210
Err(match err {
209211
traits::OrphanCheckErr::NonLocalInputType(tys) => {
212+
let msg = match self_ty.kind() {
213+
ty::Adt(..) => "can be implemented for types defined outside of the crate",
214+
_ if self_ty.is_primitive() => "can be implemented for primitive types",
215+
_ => "can be implemented for arbitrary types",
216+
};
210217
let mut err = struct_span_err!(
211218
tcx.sess,
212219
sp,
213220
E0117,
214-
"only traits defined in the current crate can be implemented for \
215-
arbitrary types"
221+
"only traits defined in the current crate {msg}"
216222
);
217223
err.span_label(sp, "impl doesn't use only types from inside the current crate");
218224
for (ty, is_target_ty) in &tys {

src/test/ui/coherence/coherence-cow.re_a.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
1+
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
22
--> $DIR/coherence-cow.rs:18:1
33
|
44
LL | impl<T> Remote for Pair<T,Cover<T>> { }

src/test/ui/coherence/coherence-cow.re_b.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
1+
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
22
--> $DIR/coherence-cow.rs:22:1
33
|
44
LL | impl<T> Remote for Pair<Cover<T>,T> { }

src/test/ui/coherence/coherence-cow.re_c.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
1+
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
22
--> $DIR/coherence-cow.rs:26:1
33
|
44
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }

src/test/ui/coherence/coherence-impls-copy.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
1+
error[E0117]: only traits defined in the current crate can be implemented for primitive types
22
--> $DIR/coherence-impls-copy.rs:5:1
33
|
44
LL | impl Copy for i32 {}

src/test/ui/coherence/coherence-orphan.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
1+
error[E0117]: only traits defined in the current crate can be implemented for primitive types
22
--> $DIR/coherence-orphan.rs:10:1
33
|
44
LL | impl TheTrait<usize> for isize { }
@@ -10,7 +10,7 @@ LL | impl TheTrait<usize> for isize { }
1010
|
1111
= note: define and implement a trait or new type instead
1212

13-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
13+
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
1414
--> $DIR/coherence-orphan.rs:17:1
1515
|
1616
LL | impl !Send for Vec<isize> { }

src/test/ui/coherence/coherence-overlapping-pairs.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
1+
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
22
--> $DIR/coherence-overlapping-pairs.rs:8:1
33
|
44
LL | impl<T> Remote for lib::Pair<T,Foo> { }

src/test/ui/coherence/coherence-pair-covered-uncovered-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
1+
error[E0117]: only traits defined in the current crate can be implemented for primitive types
22
--> $DIR/coherence-pair-covered-uncovered-1.rs:12:1
33
|
44
LL | impl<T, U> Remote1<Pair<T, Local<U>>> for i32 { }

src/test/ui/coherence/coherence-pair-covered-uncovered.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
1+
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
22
--> $DIR/coherence-pair-covered-uncovered.rs:8:1
33
|
44
LL | impl<T,U> Remote for Pair<T,Local<U>> { }

0 commit comments

Comments
 (0)