Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #106565

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9553a4d
Fix process-panic-after-fork.rs to pass on newer versions of Android.
pcc Dec 10, 2022
5cccb36
higher-ranked lifetime message
compiler-errors Dec 18, 2022
82cf6f2
UPDATE - migrate base.rs to new diagnostics infrastructure
JhonnyBillM Nov 17, 2022
78796ba
ADD - fixme in type_names.rs until we are able to translate InterpError
JhonnyBillM Nov 6, 2022
d41112a
UPDATE - migrate constant.rs to new diagnostics infrastructure
JhonnyBillM Nov 6, 2022
e26366a
[WIP] UPDATE - migrate intrinsic.rs to new diagnostic infrastructure
JhonnyBillM Nov 13, 2022
d1030fa
UPDATE - migrate fn simd_simple_float_intrinsic error messages
JhonnyBillM Nov 17, 2022
2774446
ADD - create and emit Bug support for Diagnostics
JhonnyBillM Nov 23, 2022
29d8c87
DELETE - fn span_invalid_monomorphization_error and localize intrinsi…
JhonnyBillM Nov 27, 2022
4d63d7d
UPDATE - migrate outstanding diagnostic in link.rs
JhonnyBillM Nov 27, 2022
8360a40
Migrate named_anon_conflict.rs
IntQuant Sep 8, 2022
2118ff4
Migrate placeholder_error.rs
IntQuant Sep 10, 2022
3935a81
Migrate trait_impl_difference.rs
IntQuant Sep 13, 2022
0634b01
Partial work on static_impl_trait.rs
IntQuant Sep 16, 2022
57fdd19
Rebase and fix
IntQuant Sep 22, 2022
6c19c08
More descriptive names for ActualImplExplNotes variants
IntQuant Sep 25, 2022
71d24da
Split into several messages
IntQuant Sep 29, 2022
eb7ce17
Use eager translation
IntQuant Oct 14, 2022
40b2218
Rename subdiagnostic fields that do not need to be unique now
IntQuant Oct 15, 2022
19b8579
Address changes of pr 103345
IntQuant Oct 24, 2022
7ecd064
Split infer_explicit_lifetime_required into several diags
IntQuant Nov 3, 2022
62f9962
Made ty_or_sig and trait_path use their actual types instead of String
IntQuant Nov 3, 2022
a861737
Fix nits
IntQuant Nov 3, 2022
dda3eba
Fix broken rebase
IntQuant Nov 7, 2022
2a8b17d
Fix formatting
IntQuant Nov 29, 2022
0c50e1f
eager is the default now
IntQuant Dec 28, 2022
ce6b717
Detect closures assigned to binding in block
estebank Jan 5, 2023
43bec83
docs: make `HashSet::retain` doctest more clear
Ezrashaw Jan 7, 2023
a7ac923
rustdoc: remove no-op mobile CSS `.content { margin-left: 0 }`
notriddle Jan 7, 2023
ce32867
Add regression test for #100772
JohnTitor Jan 5, 2023
1d3ab79
Rollup merge of #101936 - IntQuant:issue-100717-infer-4, r=compiler-e…
matthiaskrgr Jan 7, 2023
59e3b36
Rollup merge of #104543 - JhonnyBillM:migrate-codegen-ssa-to-diagnost…
matthiaskrgr Jan 7, 2023
4239e54
Rollup merge of #105517 - pcc:process-panic-after-fork, r=davidtwco
matthiaskrgr Jan 7, 2023
58a2367
Rollup merge of #105859 - compiler-errors:hr-lifetime-add, r=davidtwco
matthiaskrgr Jan 7, 2023
1730aa2
Rollup merge of #106495 - JohnTitor:issue-100772, r=compiler-errors
matthiaskrgr Jan 7, 2023
07a47a3
Rollup merge of #106509 - estebank:closure-in-block, r=davidtwco
matthiaskrgr Jan 7, 2023
e33c22c
Rollup merge of #106553 - Ezrashaw:fix-hashset-doctest, r=JohnTitor
matthiaskrgr Jan 7, 2023
9639646
Rollup merge of #106556 - notriddle:notriddle/margin-left-content-mob…
matthiaskrgr Jan 7, 2023
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
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,7 @@ dependencies = [
"rustc_span",
"rustc_symbol_mangling",
"rustc_target",
"rustc_type_ir",
"serde_json",
"smallvec",
"snap",
Expand Down Expand Up @@ -4024,6 +4025,7 @@ dependencies = [
"rustc_serialize",
"rustc_span",
"rustc_target",
"rustc_type_ir",
"serde",
"serde_json",
"termcolor",
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_borrowck/src/borrowck_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
closure_kind: &str,
borrowed_path: &str,
capture_span: Span,
scope: &str,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
closure_span,
E0373,
"{} may outlive the current function, but it borrows {}, which is owned by the current \
function",
closure_kind,
borrowed_path,
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
which is owned by the current {scope}",
);
err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))
.span_label(closure_span, format!("may outlive borrowed value {}", borrowed_path));
Expand Down
31 changes: 27 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
//
// then just use the normal error. The closure isn't escaping
// and `move` will not help here.
(
Some(name),
BorrowExplanation::UsedLater(LaterUseKind::ClosureCapture, var_or_use_span, _),
) => self.report_escaping_closure_capture(
borrow_spans,
borrow_span,
&RegionName {
name: self.synthesize_region_name(),
source: RegionNameSource::Static,
},
ConstraintCategory::CallArgument(None),
var_or_use_span,
&format!("`{}`", name),
"block",
),
(
Some(name),
BorrowExplanation::MustBeValidFor {
Expand All @@ -1443,6 +1458,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
category,
span,
&format!("`{}`", name),
"function",
),
(
name,
Expand Down Expand Up @@ -1895,6 +1911,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
Some(err)
}

#[instrument(level = "debug", skip(self))]
fn report_escaping_closure_capture(
&mut self,
use_span: UseSpans<'tcx>,
Expand All @@ -1903,6 +1920,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
category: ConstraintCategory<'tcx>,
constraint_span: Span,
captured_var: &str,
scope: &str,
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let tcx = self.infcx.tcx;
let args_span = use_span.args_or_use();
Expand Down Expand Up @@ -1933,8 +1951,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
None => "closure",
};

let mut err =
self.cannot_capture_in_long_lived_closure(args_span, kind, captured_var, var_span);
let mut err = self.cannot_capture_in_long_lived_closure(
args_span,
kind,
captured_var,
var_span,
scope,
);
err.span_suggestion_verbose(
sugg_span,
&format!(
Expand All @@ -1956,10 +1979,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if matches!(use_span.generator_kind(), Some(GeneratorKind::Async(_))) {
err.note(
"async blocks are not executed immediately and must either take a \
reference or ownership of outside variables they use",
reference or ownership of outside variables they use",
);
} else {
let msg = format!("function requires argument type to outlive `{}`", fr_name);
let msg = format!("{scope} requires argument type to outlive `{fr_name}`");
err.span_note(constraint_span, &msg);
}
}
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
/// First span returned points to the location of the conflicting use
/// Second span if `Some` is returned in the case of closures and points
/// to the use of the path
#[instrument(level = "debug", skip(self))]
fn later_use_kind(
&self,
borrow: &BorrowData<'tcx>,
Expand All @@ -461,11 +462,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let block = &self.body.basic_blocks[location.block];

let kind = if let Some(&Statement {
kind: StatementKind::FakeRead(box (FakeReadCause::ForLet(_), _)),
kind: StatementKind::FakeRead(box (FakeReadCause::ForLet(_), place)),
..
}) = block.statements.get(location.statement_index)
{
LaterUseKind::FakeLetRead
if let Some(l) = place.as_local()
&& let local_decl = &self.body.local_decls[l]
&& local_decl.ty.is_closure()
{
LaterUseKind::ClosureCapture
} else {
LaterUseKind::FakeLetRead
}
} else if self.was_captured_by_trait_object(borrow) {
LaterUseKind::TraitCapture
} else if location.statement_index == block.statements.len() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// increment the counter.
///
/// This is _not_ idempotent. Call `give_region_a_name` when possible.
fn synthesize_region_name(&self) -> Symbol {
pub(crate) fn synthesize_region_name(&self) -> Symbol {
let c = self.next_region_name.replace_with(|counter| *counter + 1);
Symbol::intern(&format!("'{:?}", c))
}
Expand Down
Loading