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 6 pull requests #127635

Merged
merged 20 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
585ca16
as_simd: fix comment to be in line with 507583a (#121201)
greaka Jul 6, 2024
5bf50e6
Move a function
Nadrieril Jun 30, 2024
bff4d21
Factor out the special handling of or-patterns
Nadrieril Jun 30, 2024
c5062f7
Move or-pattern expansion inside the main part of the algorithm
Nadrieril Jun 30, 2024
8a222ff
Don't try to save an extra block
Nadrieril Jun 30, 2024
fc40247
Factor out the "process remaining candidates" cases
Nadrieril Jun 30, 2024
3e030b3
Return the `otherwise_block` instead of passing it as argument
Nadrieril Jun 30, 2024
42772e9
Address review comments
Nadrieril Jul 5, 2024
08a2992
compiletest: Better error message for bad `normalize-*` headers
Zalathar Jul 11, 2024
b77d3ef
Mark builtin syntax as internal
compiler-errors Jul 11, 2024
d902179
Revert accidental comment deletion
SkiFire13 Jul 11, 2024
d9170dc
Add regression test for issue 127545
tesuji Jul 11, 2024
872d7b8
Add suggestion for `Option<&Vec<T>> -> Option<&[T]`
tesuji Jul 11, 2024
a776e5f
Add doc for deconstruct_option_or_result
tesuji Jul 11, 2024
58fe37f
Rollup merge of #127164 - Nadrieril:clean-lowering-loop, r=matthewjasper
matthiaskrgr Jul 12, 2024
1e7ad4c
Rollup merge of #127422 - greaka:master, r=workingjubilee
matthiaskrgr Jul 12, 2024
83d1a1b
Rollup merge of #127596 - tesuji:help-unwrap-or, r=compiler-errors
matthiaskrgr Jul 12, 2024
fe564c1
Rollup merge of #127607 - Zalathar:normalize-hint, r=wesleywiser
matthiaskrgr Jul 12, 2024
ca576ea
Rollup merge of #127622 - compiler-errors:builtin-internal, r=lqd
matthiaskrgr Jul 12, 2024
c2b7842
Rollup merge of #127625 - SkiFire13:revert-comment-deletion, r=workin…
matthiaskrgr Jul 12, 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
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,8 @@ impl<'a, 'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R>
| TerminatorKind::Return
| TerminatorKind::TailCall { .. }
| TerminatorKind::CoroutineDrop => {
// Returning from the function implicitly kills storage for all locals and statics.
// Often, the storage will already have been killed by an explicit
// StorageDead, but we don't always emit those (notably on unwind paths),
// so this "extra check" serves as a kind of backup.
let borrow_set = self.borrow_set.clone();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ declare_features! (
(unstable, auto_traits, "1.50.0", Some(13231)),
/// Allows using `box` in patterns (RFC 469).
(unstable, box_patterns, "1.0.0", Some(29641)),
/// Allows builtin # foo() syntax
(internal, builtin_syntax, "1.71.0", Some(110680)),
/// Allows `#[doc(notable_trait)]`.
/// Renamed from `doc_spotlight`.
(unstable, doc_notable_trait, "1.52.0", Some(45040)),
Expand Down Expand Up @@ -361,8 +363,6 @@ declare_features! (
(unstable, async_fn_track_caller, "1.73.0", Some(110011)),
/// Allows `for await` loops.
(unstable, async_for_loop, "1.77.0", Some(118898)),
/// Allows builtin # foo() syntax
(unstable, builtin_syntax, "1.71.0", Some(110680)),
/// Allows using C-variadics.
(unstable, c_variadic, "1.34.0", Some(44930)),
/// Allows the use of `#[cfg(overflow_checks)` to check if integer overflow behaviour.
Expand Down
52 changes: 37 additions & 15 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,21 +466,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
borrow_removal_span,
});
return true;
} else if let Some((deref_ty, _)) =
self.autoderef(expr.span, found_ty_inner).silence_errors().nth(1)
&& self.can_eq(self.param_env, deref_ty, peeled)
&& error_tys_equate_as_ref
{
let sugg = prefix_wrap(".as_deref()");
err.subdiagnostic(errors::SuggestConvertViaMethod {
span: expr.span.shrink_to_hi(),
sugg,
expected,
found,
borrow_removal_span,
});
return true;
} else if let ty::Adt(adt, _) = found_ty_inner.peel_refs().kind()
} else if let ty::Ref(_, peeled_found_ty, _) = found_ty_inner.kind()
&& let ty::Adt(adt, _) = peeled_found_ty.peel_refs().kind()
&& self.tcx.is_lang_item(adt.did(), LangItem::String)
&& peeled.is_str()
// `Result::map`, conversely, does not take ref of the error type.
Expand All @@ -496,12 +483,47 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Applicability::MachineApplicable,
);
return true;
} else {
if !error_tys_equate_as_ref {
return false;
}
let mut steps = self.autoderef(expr.span, found_ty_inner).silence_errors();
if let Some((deref_ty, _)) = steps.nth(1)
&& self.can_eq(self.param_env, deref_ty, peeled)
{
let sugg = prefix_wrap(".as_deref()");
err.subdiagnostic(errors::SuggestConvertViaMethod {
span: expr.span.shrink_to_hi(),
sugg,
expected,
found,
borrow_removal_span,
});
return true;
}
for (deref_ty, n_step) in steps {
if self.can_eq(self.param_env, deref_ty, peeled) {
let explicit_deref = "*".repeat(n_step);
let sugg = prefix_wrap(&format!(".map(|v| &{explicit_deref}v)"));
err.subdiagnostic(errors::SuggestConvertViaMethod {
span: expr.span.shrink_to_hi(),
sugg,
expected,
found,
borrow_removal_span,
});
return true;
}
}
}
}

false
}

/// If `ty` is `Option<T>`, returns `T, T, None`.
/// If `ty` is `Result<T, E>`, returns `T, T, Some(E, E)`.
/// Otherwise, returns `None`.
fn deconstruct_option_or_result(
&self,
found_ty: Ty<'tcx>,
Expand Down
Loading
Loading