Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6edd86d
tests: add test for #105111
davidtwco Sep 11, 2024
207bc77
codegen_ssa: consolidate tied feature checking
davidtwco Sep 11, 2024
7b3f161
Add gate for precise capturing in traits
compiler-errors Sep 29, 2024
e4bf471
Add variances to RPITITs
compiler-errors Sep 29, 2024
f2659ef
Clarify implicit captures for RPITIT
compiler-errors Sep 29, 2024
960ba89
Don't fire refinement lint if there are errors
compiler-errors Sep 29, 2024
becf664
Match std RUSTFLAGS for host and target for `mir-opt` test
jieyouxu Oct 9, 2024
62b24ea
Compiler: Replace remaining occurrences of "object safe" with "dyn co…
fmease Oct 9, 2024
2e7a52b
Rename feature object_safe_for_dispatch to dyn_compatible_for_dispatch
fmease Oct 9, 2024
20cebae
UI tests: Rename "object safe" to "dyn compatible"
fmease Oct 9, 2024
a21a9fe
Auto merge of #13464 - y21:issue13458, r=flip1995
bors Oct 10, 2024
b12dc20
add config to explicitely test rustc with autodiff/enzyme disabled
ZuseZ4 Oct 10, 2024
1edff46
Avoid redundant additions to PATH when linking
madsmtm Oct 10, 2024
b38afa0
Rollup merge of #130308 - davidtwco:tied-target-consolidation, r=wesl…
matthiaskrgr Oct 10, 2024
6d32a03
Rollup merge of #131033 - compiler-errors:precise-capturing-in-traits…
matthiaskrgr Oct 10, 2024
b57de4b
Rollup merge of #131442 - jieyouxu:mir-opt-rebuild, r=onur-ozkan
matthiaskrgr Oct 10, 2024
f9e59e8
Rollup merge of #131470 - EnzymeAD:enzyme-testinfra2, r=jieyouxu
matthiaskrgr Oct 10, 2024
33053d3
Rollup merge of #131475 - fmease:compiler-mv-obj-safe-dyn-compat-2, r…
matthiaskrgr Oct 10, 2024
efb10c7
Rollup merge of #131492 - flip1995:clippy-master-backport, r=matthias…
matthiaskrgr Oct 10, 2024
2be866c
Rollup merge of #131493 - madsmtm:avoid-redundant-linker-path, r=jiey…
matthiaskrgr Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clarify implicit captures for RPITIT
  • Loading branch information
compiler-errors committed Oct 8, 2024
commit f2659efed32ecd8b661d1517fe3a2a32f2a65c0d
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ hir_analysis_late_bound_lifetime_in_apit = `impl Trait` can only mention lifetim
hir_analysis_late_bound_type_in_apit = `impl Trait` can only mention type parameters from an fn or impl
.label = type parameter declared here
hir_analysis_lifetime_implicitly_captured = `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
.param_label = all lifetime parameters originating from a trait are captured implicitly
hir_analysis_lifetime_must_be_first = lifetime parameter `{$name}` must be listed before non-lifetime parameters
.label = move the lifetime before this parameter
Expand Down
25 changes: 16 additions & 9 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,22 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
param_span: tcx.def_span(def_id),
});
} else {
// If the `use_span` is actually just the param itself, then we must
// have not duplicated the lifetime but captured the original.
// The "effective" `use_span` will be the span of the opaque itself,
// and the param span will be the def span of the param.
tcx.dcx().emit_err(errors::LifetimeNotCaptured {
opaque_span,
use_span: opaque_span,
param_span: use_span,
});
if tcx.def_kind(tcx.parent(param.def_id)) == DefKind::Trait {
tcx.dcx().emit_err(errors::LifetimeImplicitlyCaptured {
opaque_span,
param_span: tcx.def_span(param.def_id),
});
} else {
// If the `use_span` is actually just the param itself, then we must
// have not duplicated the lifetime but captured the original.
// The "effective" `use_span` will be the span of the opaque itself,
// and the param span will be the def span of the param.
tcx.dcx().emit_err(errors::LifetimeNotCaptured {
opaque_span,
use_span: opaque_span,
param_span: use_span,
});
}
}
continue;
}
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_hir_analysis/src/errors/precise_captures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ pub(crate) struct LifetimeNotCaptured {
pub opaque_span: Span,
}

#[derive(Diagnostic)]
#[diag(hir_analysis_lifetime_implicitly_captured)]
pub(crate) struct LifetimeImplicitlyCaptured {
#[primary_span]
pub opaque_span: Span,
#[label(hir_analysis_param_label)]
pub param_span: Span,
}

#[derive(Diagnostic)]
#[diag(hir_analysis_bad_precise_capture)]
pub(crate) struct BadPreciseCapture {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/impl-trait/precise-capturing/rpitit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use
--> $DIR/rpitit.rs:11:19
|
LL | trait TraitLt<'a: 'a> {
| -- this lifetime parameter is captured
| -- all lifetime parameters originating from a trait are captured implicitly
LL | fn hello() -> impl Sized + use<Self>;
| ^^^^^^^^^^^^^^^^^^^^^^ lifetime captured due to being mentioned in the bounds of the `impl Trait`
| ^^^^^^^^^^^^^^^^^^^^^^

error: lifetime may not live long enough
--> $DIR/rpitit.rs:15:5
Expand Down