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

cleanup: don't manually unwrap_or_default() #131013

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions compiler/rustc_expand/src/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ impl server::TokenStream for Rustc<'_, '_> {
base: Option<Self::TokenStream>,
trees: Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>,
) -> Self::TokenStream {
let mut stream =
if let Some(base) = base { base } else { tokenstream::TokenStream::default() };
let mut stream = base.unwrap_or_default();
for tree in trees {
for tt in (tree, &mut *self).to_internal() {
stream.push_tree(tt);
Expand All @@ -642,8 +641,7 @@ impl server::TokenStream for Rustc<'_, '_> {
base: Option<Self::TokenStream>,
streams: Vec<Self::TokenStream>,
) -> Self::TokenStream {
let mut stream =
if let Some(base) = base { base } else { tokenstream::TokenStream::default() };
let mut stream = base.unwrap_or_default();
for s in streams {
stream.push_stream(s);
}
Expand Down
10 changes: 3 additions & 7 deletions compiler/rustc_hir_typeck/src/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1369,13 +1369,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for (&var_hir_id, _) in upvars.iter() {
let mut diagnostics_info = Vec::new();

let auto_trait_diagnostic = if let Some(diagnostics_info) =
self.compute_2229_migrations_for_trait(min_captures, var_hir_id, closure_clause)
{
diagnostics_info
} else {
FxIndexMap::default()
};
let auto_trait_diagnostic = self
.compute_2229_migrations_for_trait(min_captures, var_hir_id, closure_clause)
.unwrap_or_default();

let drop_reorder_diagnostic = if let Some(diagnostics_info) = self
.compute_2229_migrations_for_drop(
Expand Down
Loading