Skip to content

Commit 4413f8c

Browse files
committed
Member constraints already covered all of E0482 already, so that error never occurred anymore
1 parent 2220faf commit 4413f8c

File tree

4 files changed

+6
-65
lines changed

4 files changed

+6
-65
lines changed

compiler/rustc_error_codes/src/error_codes/E0482.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
A lifetime of a returned value does not outlive the function call.
24

35
Erroneous code example:
46

5-
```compile_fail,E0482
7+
```compile_fail,E0700
68
fn prefix<'a>(
79
words: impl Iterator<Item = &'a str>
810
) -> impl Iterator<Item = String> { // error!
@@ -41,7 +43,7 @@ fn prefix(
4143

4244
A similar lifetime problem might arise when returning closures:
4345

44-
```compile_fail,E0482
46+
```compile_fail,E0700
4547
fn foo(
4648
x: &mut Vec<i32>
4749
) -> impl FnMut(&mut Vec<i32>) -> &[i32] { // error!

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

-20
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
5353
infer::RelateObjectBound(span) => {
5454
label_or_note(span, "...so that it can be closed over into an object");
5555
}
56-
infer::CallReturn(span) => {
57-
label_or_note(span, "...so that return value is valid for the call");
58-
}
5956
infer::DataBorrowed(ty, span) => {
6057
label_or_note(
6158
span,
@@ -281,23 +278,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
281278
);
282279
err
283280
}
284-
infer::CallReturn(span) => {
285-
let mut err = struct_span_err!(
286-
self.tcx.sess,
287-
span,
288-
E0482,
289-
"lifetime of return value does not outlive the function call"
290-
);
291-
note_and_explain_region(
292-
self.tcx,
293-
&mut err,
294-
"the return value is only valid for ",
295-
sup,
296-
"",
297-
None,
298-
);
299-
err
300-
}
301281
infer::DataBorrowed(ty, span) => {
302282
let mut err = struct_span_err!(
303283
self.tcx.sess,

compiler/rustc_infer/src/infer/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,6 @@ pub enum SubregionOrigin<'tcx> {
417417
/// (&'a &'b T) where a >= b
418418
ReferenceOutlivesReferent(Ty<'tcx>, Span),
419419

420-
/// Region in return type of invoked fn must enclose call
421-
CallReturn(Span),
422-
423420
/// Comparing the signature and requirements of an impl method against
424421
/// the containing trait.
425422
CompareImplMethodObligation {
@@ -1803,7 +1800,6 @@ impl<'tcx> SubregionOrigin<'tcx> {
18031800
ReborrowUpvar(a, _) => a,
18041801
DataBorrowed(_, a) => a,
18051802
ReferenceOutlivesReferent(_, a) => a,
1806-
CallReturn(a) => a,
18071803
CompareImplMethodObligation { span, .. } => span,
18081804
CompareImplTypeObligation { span, .. } => span,
18091805
}

compiler/rustc_trait_selection/src/opaque_types.rs

+2-39
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
66
use rustc_infer::infer::error_reporting::unexpected_hidden_region_diagnostic;
77
use rustc_infer::infer::opaque_types::OpaqueTypeDecl;
88
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
9-
use rustc_infer::infer::{self, InferCtxt, InferOk};
9+
use rustc_infer::infer::{InferCtxt, InferOk};
1010
use rustc_middle::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor};
1111
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst};
1212
use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt};
@@ -295,51 +295,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
295295
hir::OpaqueTyOrigin::TyAlias => 0,
296296
};
297297

298-
let span = tcx.def_span(def_id);
299-
300-
// Check if the `impl Trait` bounds include region bounds.
301-
// For example, this would be true for:
302-
//
303-
// fn foo<'a, 'b, 'c>() -> impl Trait<'c> + 'a + 'b
304-
//
305-
// but false for:
306-
//
307-
// fn foo<'c>() -> impl Trait<'c>
308-
//
309-
// unless `Trait` was declared like:
310-
//
311-
// trait Trait<'c>: 'c
312-
//
313-
// in which case it would be true.
314-
//
315-
// This is used during regionck to decide whether we need to
316-
// impose any additional constraints to ensure that region
317-
// variables in `concrete_ty` wind up being constrained to
318-
// something from `substs` (or, at minimum, things that outlive
319-
// the fn body). (Ultimately, writeback is responsible for this
320-
// check.)
321-
let bounds = tcx.explicit_item_bounds(def_id);
322-
debug!("{:#?}", bounds);
323-
let bounds = bounds.iter().map(|(bound, _)| bound.subst(tcx, opaque_type_key.substs));
324-
debug!("{:#?}", bounds);
325-
let opaque_type = tcx.mk_opaque(def_id, opaque_type_key.substs);
326-
327-
// (A) The regions that appear in the hidden type must be equal to
298+
// The regions that appear in the hidden type must be equal to
328299
// one of the regions in scope for the opaque type.
329300
self.generate_member_constraint(
330301
concrete_ty,
331302
opaque_defn,
332303
opaque_type_key,
333304
first_own_region,
334305
);
335-
336-
// (B) We can also generate outlives bounds that must be enforced.
337-
for required_region in required_region_bounds(tcx, opaque_type, bounds) {
338-
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
339-
tcx,
340-
op: |r| self.sub_regions(infer::CallReturn(span), required_region, r),
341-
});
342-
}
343306
}
344307

345308
/// As a fallback, we sometimes generate an "in constraint". For

0 commit comments

Comments
 (0)