Skip to content

Commit be4794c

Browse files
committed
Auto merge of #152321 - Zalathar:rollup-ezxwhfJ, r=Zalathar
Rollup of 5 pull requests Successful merges: - #150443 (Support long diff conflict markers) - #151887 (Remove some unnecessary `try`-related type annotations) - #152037 (Suppress unused_mut lint if mutation fails due to borrowck error) - #152067 (Weaken `assert_dep_node_not_yet_allocated_in_current_session` for multiple threads) - #151227 (Document `-Zcache-proc-macros`)
2 parents 13c3873 + 5d88832 commit be4794c

21 files changed

Lines changed: 193 additions & 67 deletions

File tree

compiler/rustc_borrowck/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
12051205
"access_place: suppressing error place_span=`{:?}` kind=`{:?}`",
12061206
place_span, kind
12071207
);
1208+
1209+
// If the place is being mutated, then mark it as such anyway in order to suppress the
1210+
// `unused_mut` lint, which is likely incorrect once the access place error has been
1211+
// resolved.
1212+
if rw == ReadOrWrite::Write(WriteKind::Mutate)
1213+
&& let Ok(root_place) =
1214+
self.is_mutable(place_span.0.as_ref(), is_local_mutation_allowed)
1215+
{
1216+
self.add_used_mut(root_place, state);
1217+
}
1218+
12081219
return;
12091220
}
12101221

compiler/rustc_borrowck/src/nll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ pub(super) fn dump_nll_mir<'tcx>(
231231
dumper.dump_mir(body);
232232

233233
// Also dump the region constraint graph as a graphviz file.
234-
let _: io::Result<()> = try {
234+
let _ = try {
235235
let mut file = dumper.create_dump_file("regioncx.all.dot", body)?;
236236
regioncx.dump_graphviz_raw_constraints(tcx, &mut file)?;
237237
};
238238

239239
// Also dump the region constraint SCC graph as a graphviz file.
240-
let _: io::Result<()> = try {
240+
let _ = try {
241241
let mut file = dumper.create_dump_file("regioncx.scc.dot", body)?;
242242
regioncx.dump_graphviz_scc_constraints(tcx, &mut file)?;
243243
};

compiler/rustc_borrowck/src/polonius/dump.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) fn dump_polonius_mir<'tcx>(
5858

5959
let dumper = dumper.set_extra_data(extra_data).set_options(options);
6060

61-
let _: io::Result<()> = try {
61+
let _ = try {
6262
let mut file = dumper.create_dump_file("html", body)?;
6363
emit_polonius_dump(
6464
&dumper,

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::ffi::{OsStr, OsString};
22
use std::fs::{self, File};
33
use std::io::prelude::*;
44
use std::path::{Path, PathBuf};
5-
use std::{env, io, iter, mem, str};
5+
use std::{env, iter, mem, str};
66

77
use find_msvc_tools;
88
use rustc_hir::attrs::WindowsSubsystemKind;
@@ -809,7 +809,7 @@ impl<'a> Linker for GccLinker<'a> {
809809

810810
if self.sess.target.is_like_darwin {
811811
// Write a plain, newline-separated list of symbols
812-
let res: io::Result<()> = try {
812+
let res = try {
813813
let mut f = File::create_buffered(&path)?;
814814
for (sym, _) in symbols {
815815
debug!(" _{sym}");
@@ -821,7 +821,7 @@ impl<'a> Linker for GccLinker<'a> {
821821
}
822822
self.link_arg("-exported_symbols_list").link_arg(path);
823823
} else if self.sess.target.is_like_windows {
824-
let res: io::Result<()> = try {
824+
let res = try {
825825
let mut f = File::create_buffered(&path)?;
826826

827827
// .def file similar to MSVC one but without LIBRARY section
@@ -845,7 +845,7 @@ impl<'a> Linker for GccLinker<'a> {
845845
self.link_arg("--export").link_arg(sym);
846846
}
847847
} else if crate_type == CrateType::Executable && !self.sess.target.is_like_solaris {
848-
let res: io::Result<()> = try {
848+
let res = try {
849849
let mut f = File::create_buffered(&path)?;
850850
writeln!(f, "{{")?;
851851
for (sym, _) in symbols {
@@ -860,7 +860,7 @@ impl<'a> Linker for GccLinker<'a> {
860860
self.link_arg("--dynamic-list").link_arg(path);
861861
} else {
862862
// Write an LD version script
863-
let res: io::Result<()> = try {
863+
let res = try {
864864
let mut f = File::create_buffered(&path)?;
865865
writeln!(f, "{{")?;
866866
if !symbols.is_empty() {
@@ -1139,7 +1139,7 @@ impl<'a> Linker for MsvcLinker<'a> {
11391139
}
11401140

11411141
let path = tmpdir.join("lib.def");
1142-
let res: io::Result<()> = try {
1142+
let res = try {
11431143
let mut f = File::create_buffered(&path)?;
11441144

11451145
// Start off with the standard module name header and then go
@@ -1735,7 +1735,7 @@ impl<'a> Linker for AixLinker<'a> {
17351735
symbols: &[(String, SymbolExportKind)],
17361736
) {
17371737
let path = tmpdir.join("list.exp");
1738-
let res: io::Result<()> = try {
1738+
let res = try {
17391739
let mut f = File::create_buffered(&path)?;
17401740
// FIXME: use llvm-nm to generate export list.
17411741
for (symbol, _) in symbols {
@@ -2135,7 +2135,7 @@ impl<'a> Linker for BpfLinker<'a> {
21352135
symbols: &[(String, SymbolExportKind)],
21362136
) {
21372137
let path = tmpdir.join("symbols");
2138-
let res: io::Result<()> = try {
2138+
let res = try {
21392139
let mut f = File::create_buffered(&path)?;
21402140
for (sym, _) in symbols {
21412141
writeln!(f, "{sym}")?;

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ pub fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) ->
11111111
// know that later). If we are not doing LTO, there is only one optimized
11121112
// version of each module, so we re-use that.
11131113
let dep_node = cgu.codegen_dep_node(tcx);
1114-
tcx.dep_graph.assert_dep_node_not_yet_allocated_in_current_session(&dep_node, || {
1114+
tcx.dep_graph.assert_dep_node_not_yet_allocated_in_current_session(tcx.sess, &dep_node, || {
11151115
format!(
11161116
"CompileCodegenUnit dep-node for CGU `{}` already exists before marking.",
11171117
cgu.name()

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ fn show_md_content_with_pager(content: &str, color: ColorConfig) {
503503
};
504504

505505
// Try to print via the pager, pretty output if possible.
506-
let pager_res: Option<()> = try {
506+
let pager_res = try {
507507
let mut pager = cmd.stdin(Stdio::piped()).spawn().ok()?;
508508

509509
let pager_stdin = pager.stdin.as_mut()?;

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_ast::tokenstream::{self, DelimSpacing, Spacing, TokenStream};
77
use rustc_ast::util::literal::escape_byte_str_symbol;
88
use rustc_ast_pretty::pprust;
99
use rustc_data_structures::fx::FxHashMap;
10-
use rustc_errors::{Diag, ErrorGuaranteed, MultiSpan, PResult};
10+
use rustc_errors::{Diag, ErrorGuaranteed, MultiSpan};
1111
use rustc_parse::lexer::{StripTokens, nfc_normalize};
1212
use rustc_parse::parser::Parser;
1313
use rustc_parse::{exp, new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal};
@@ -591,7 +591,7 @@ impl server::Server for Rustc<'_, '_> {
591591

592592
fn ts_expand_expr(&mut self, stream: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
593593
// Parse the expression from our tokenstream.
594-
let expr: PResult<'_, _> = try {
594+
let expr = try {
595595
let mut p = Parser::new(self.psess(), stream.clone(), Some("proc_macro expand expr"));
596596
let expr = p.parse_expr()?;
597597
if p.token != token::Eof {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ fn compare_synthetic_generics<'tcx>(
18441844
// The case where the impl method uses `impl Trait` but the trait method uses
18451845
// explicit generics
18461846
err.span_label(impl_span, "expected generic parameter, found `impl Trait`");
1847-
let _: Option<_> = try {
1847+
try {
18481848
// try taking the name from the trait impl
18491849
// FIXME: this is obviously suboptimal since the name can already be used
18501850
// as another generic argument
@@ -1881,7 +1881,7 @@ fn compare_synthetic_generics<'tcx>(
18811881
// The case where the trait method uses `impl Trait`, but the impl method uses
18821882
// explicit generics.
18831883
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
1884-
let _: Option<_> = try {
1884+
try {
18851885
let impl_m = impl_m.def_id.as_local()?;
18861886
let impl_m = tcx.hir_expect_impl_item(impl_m);
18871887
let (sig, _) = impl_m.expect_fn();

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
582582
let deps_output = outputs.path(OutputType::DepInfo);
583583
let deps_filename = deps_output.as_path();
584584

585-
let result: io::Result<()> = try {
585+
let result = try {
586586
// Build a list of files used to compile the output and
587587
// write Makefile-compatible dependency rules
588588
let mut files: IndexMap<String, (u64, Option<SourceFileHash>)> = sess

compiler/rustc_lint/src/types.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -746,24 +746,23 @@ fn pat_ty_is_known_nonnull<'tcx>(
746746
typing_env: ty::TypingEnv<'tcx>,
747747
pat: ty::Pattern<'tcx>,
748748
) -> bool {
749-
Option::unwrap_or_default(
750-
try {
751-
match *pat {
752-
ty::PatternKind::Range { start, end } => {
753-
let start = start.try_to_value()?.try_to_bits(tcx, typing_env)?;
754-
let end = end.try_to_value()?.try_to_bits(tcx, typing_env)?;
755-
756-
// This also works for negative numbers, as we just need
757-
// to ensure we aren't wrapping over zero.
758-
start > 0 && end >= start
759-
}
760-
ty::PatternKind::NotNull => true,
761-
ty::PatternKind::Or(patterns) => {
762-
patterns.iter().all(|pat| pat_ty_is_known_nonnull(tcx, typing_env, pat))
763-
}
749+
try {
750+
match *pat {
751+
ty::PatternKind::Range { start, end } => {
752+
let start = start.try_to_value()?.try_to_bits(tcx, typing_env)?;
753+
let end = end.try_to_value()?.try_to_bits(tcx, typing_env)?;
754+
755+
// This also works for negative numbers, as we just need
756+
// to ensure we aren't wrapping over zero.
757+
start > 0 && end >= start
764758
}
765-
},
766-
)
759+
ty::PatternKind::NotNull => true,
760+
ty::PatternKind::Or(patterns) => {
761+
patterns.iter().all(|pat| pat_ty_is_known_nonnull(tcx, typing_env, pat))
762+
}
763+
}
764+
}
765+
.unwrap_or_default()
767766
}
768767

769768
/// Given a non-null scalar (or transparent) type `ty`, return the nullable version of that type.

0 commit comments

Comments
 (0)