Skip to content

Commit eae940f

Browse files
committed
Auto merge of #3427 - rust-lang:rustup-2024-03-29, r=saethlin
Automatic Rustup
2 parents 58a771e + ed29546 commit eae940f

File tree

356 files changed

+5529
-2604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+5529
-2604
lines changed

.github/workflows/dependencies.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
schedule:
77
# Run weekly
88
- cron: '0 0 * * Sun'
9-
# Re-bump deps every 4 hours
10-
- cron: '0 */4 * * *'
119
workflow_dispatch:
1210
# Needed so we can run it manually
1311
permissions:
@@ -42,7 +40,7 @@ jobs:
4240
4341
# Exit with error if open and S-waiting-on-bors
4442
if [[ "$STATE" == "OPEN" && "$WAITING_ON_BORS" == "true" ]]; then
45-
gh run cancel ${{ github.run_id }}
43+
exit 1
4644
fi
4745
4846
update:
@@ -65,10 +63,7 @@ jobs:
6563
6664
- name: cargo update
6765
# Remove first line that always just says "Updating crates.io index"
68-
# If there are no changes, cancel the job here
69-
run: |
70-
cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
71-
git status --porcelain | grep -q Cargo.lock || gh run cancel ${{ github.run_id }}
66+
run: cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
7267
- name: upload Cargo.lock artifact for use in PR
7368
uses: actions/upload-artifact@v4
7469
with:
@@ -95,11 +90,11 @@ jobs:
9590
uses: actions/checkout@v4
9691

9792
- name: download Cargo.lock from update job
98-
uses: actions/download-artifact@v3
93+
uses: actions/download-artifact@v4
9994
with:
10095
name: Cargo-lock
10196
- name: download cargo-update log from update job
102-
uses: actions/download-artifact@v3
97+
uses: actions/download-artifact@v4
10398
with:
10499
name: cargo-updates
105100

@@ -134,14 +129,14 @@ jobs:
134129
# Exit with error if PR is closed
135130
STATE=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json state --jq '.state')
136131
if [[ "$STATE" != "OPEN" ]]; then
137-
gh run cancel ${{ github.run_id }}
132+
exit 1
138133
fi
139134
140135
gh pr edit cargo_update --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY
141136
142137
- name: open new pull request
143-
# Only run if there wasn't an existing PR and if this is the weekly run
144-
if: steps.edit.outcome != 'success' && github.event.schedule == '0 0 * * Sun'
138+
# Only run if there wasn't an existing PR
139+
if: steps.edit.outcome != 'success'
145140
env:
146141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147142
run: gh pr create --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ Katze <[email protected]>
324324
325325
Kerem Kat <[email protected]>
326326
Kevin Butler <[email protected]>
327+
327328
Kevin Jiang <[email protected]>
328329
Kornel Lesiński <[email protected]>
329330
Krishna Sai Veera Reddy <[email protected]>

INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ toolchain.
151151
directory and uncomment the line `MSYS2_PATH_TYPE=inherit`.
152152

153153
You could install and use MSYS2's version of git instead with `pacman`,
154-
however this is not recommended as it's excrutiatingly slow, and not frequently
155-
tested for compatability.
154+
however this is not recommended as it's excruciatingly slow, and not frequently
155+
tested for compatibility.
156156

157157
3. Start a MINGW64 or MINGW32 shell (depending on whether you want 32-bit
158158
or 64-bit Rust) either from your start menu, or by running `mingw64.exe`

RELEASES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 1.77.1 (2024-03-28)
2+
===========================
3+
4+
<a id="1.77.1"></a>
5+
6+
- [Revert stripping debuginfo by default for Windows](https://github.com/rust-lang/cargo/pull/13654)
7+
This fixes a regression in 1.77 by reverting to the previous default.
8+
Platforms other than Windows are not affected.
9+
- Internal: [Fix heading anchor rendering in doc pages](https://github.com/rust-lang/rust/pull/122693)
10+
111
Version 1.77.0 (2024-03-21)
212
==========================
313

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(crate) struct FixupContext {
7575
}
7676

7777
/// The default amount of fixing is minimal fixing. Fixups should be turned on
78-
/// in a targetted fashion where needed.
78+
/// in a targeted fashion where needed.
7979
impl Default for FixupContext {
8080
fn default() -> Self {
8181
FixupContext {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(rustc::untranslatable_diagnostic)]
55

66
use either::Either;
7+
use hir::ClosureKind;
78
use rustc_data_structures::captures::Captures;
89
use rustc_data_structures::fx::FxIndexSet;
910
use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan};
@@ -463,6 +464,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
463464
} else if let UseSpans::FnSelfUse { kind: CallKind::Normal { .. }, .. } = move_spans
464465
{
465466
// We already suggest cloning for these cases in `explain_captures`.
467+
} else if let UseSpans::ClosureUse {
468+
closure_kind:
469+
ClosureKind::Coroutine(CoroutineKind::Desugared(_, CoroutineSource::Block)),
470+
args_span: _,
471+
capture_kind_span: _,
472+
path_span,
473+
} = move_spans
474+
{
475+
self.suggest_cloning(err, ty, expr, path_span);
466476
} else if self.suggest_hoisting_call_outside_loop(err, expr) {
467477
// The place where the the type moves would be misleading to suggest clone.
468478
// #121466
@@ -621,7 +631,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
621631
}
622632

623633
// FIXME: We make sure that this is a normal top-level binding,
624-
// but we could suggest `todo!()` for all uninitalized bindings in the pattern pattern
634+
// but we could suggest `todo!()` for all uninitialized bindings in the pattern pattern
625635
if let hir::StmtKind::Let(hir::LetStmt { span, ty, init: None, pat, .. }) =
626636
&ex.kind
627637
&& let hir::PatKind::Binding(..) = pat.kind
@@ -749,7 +759,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
749759
true
750760
}
751761

752-
/// In a move error that occurs on a call wihtin a loop, we try to identify cases where cloning
762+
/// In a move error that occurs on a call within a loop, we try to identify cases where cloning
753763
/// the value would lead to a logic error. We infer these cases by seeing if the moved value is
754764
/// part of the logic to break the loop, either through an explicit `break` or if the expression
755765
/// is part of a `while let`.
@@ -950,7 +960,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
950960
{
951961
// FIXME: We could check that the call's *parent* takes `&mut val` to make the
952962
// suggestion more targeted to the `mk_iter(val).next()` case. Maybe do that only to
953-
// check for wheter to suggest `let value` or `let mut value`.
963+
// check for whether to suggest `let value` or `let mut value`.
954964

955965
let span = in_loop.span;
956966
if !finder.found_breaks.is_empty()

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
608608
}
609609
self.cx.borrowck_context.constraints.outlives_constraints.push(constraint)
610610
}
611-
// If the region is live at at least one location in the promoted MIR,
611+
// If the region is live at least one location in the promoted MIR,
612612
// then add a liveness constraint to the main MIR for this region
613613
// at the location provided as an argument to this method
614614
//

compiler/rustc_builtin_macros/src/source_util.rs

Lines changed: 126 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@ use rustc_ast::ptr::P;
33
use rustc_ast::token;
44
use rustc_ast::tokenstream::TokenStream;
55
use rustc_ast_pretty::pprust;
6-
use rustc_expand::base::{check_zero_tts, get_single_str_from_tts, parse_expr, resolve_path};
6+
use rustc_data_structures::sync::Lrc;
7+
use rustc_expand::base::{
8+
check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr,
9+
resolve_path,
10+
};
711
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt};
812
use rustc_expand::base::{MacEager, MacResult, MacroExpanderResult};
913
use rustc_expand::module::DirOwnership;
1014
use rustc_parse::new_parser_from_file;
1115
use rustc_parse::parser::{ForceCollect, Parser};
1216
use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
17+
use rustc_span::source_map::SourceMap;
1318
use rustc_span::symbol::Symbol;
1419
use rustc_span::{Pos, Span};
15-
1620
use smallvec::SmallVec;
21+
use std::path::{Path, PathBuf};
1722
use std::rc::Rc;
1823

1924
// These macros all relate to the file system; they either return
@@ -182,35 +187,26 @@ pub fn expand_include_str(
182187
tts: TokenStream,
183188
) -> MacroExpanderResult<'static> {
184189
let sp = cx.with_def_site_ctxt(sp);
185-
let ExpandResult::Ready(mac) = get_single_str_from_tts(cx, sp, tts, "include_str!") else {
190+
let ExpandResult::Ready(mac) = get_single_str_spanned_from_tts(cx, sp, tts, "include_str!")
191+
else {
186192
return ExpandResult::Retry(());
187193
};
188-
let file = match mac {
189-
Ok(file) => file,
194+
let (path, path_span) = match mac {
195+
Ok(res) => res,
190196
Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)),
191197
};
192-
let file = match resolve_path(&cx.sess, file.as_str(), sp) {
193-
Ok(f) => f,
194-
Err(err) => {
195-
let guar = err.emit();
196-
return ExpandResult::Ready(DummyResult::any(sp, guar));
197-
}
198-
};
199-
ExpandResult::Ready(match cx.source_map().load_binary_file(&file) {
198+
ExpandResult::Ready(match load_binary_file(cx, path.as_str().as_ref(), sp, path_span) {
200199
Ok(bytes) => match std::str::from_utf8(&bytes) {
201200
Ok(src) => {
202201
let interned_src = Symbol::intern(src);
203202
MacEager::expr(cx.expr_str(sp, interned_src))
204203
}
205204
Err(_) => {
206-
let guar = cx.dcx().span_err(sp, format!("{} wasn't a utf-8 file", file.display()));
205+
let guar = cx.dcx().span_err(sp, format!("`{path}` wasn't a utf-8 file"));
207206
DummyResult::any(sp, guar)
208207
}
209208
},
210-
Err(e) => {
211-
let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e));
212-
DummyResult::any(sp, guar)
213-
}
209+
Err(dummy) => dummy,
214210
})
215211
}
216212

@@ -220,28 +216,127 @@ pub fn expand_include_bytes(
220216
tts: TokenStream,
221217
) -> MacroExpanderResult<'static> {
222218
let sp = cx.with_def_site_ctxt(sp);
223-
let ExpandResult::Ready(mac) = get_single_str_from_tts(cx, sp, tts, "include_bytes!") else {
219+
let ExpandResult::Ready(mac) = get_single_str_spanned_from_tts(cx, sp, tts, "include_bytes!")
220+
else {
224221
return ExpandResult::Retry(());
225222
};
226-
let file = match mac {
227-
Ok(file) => file,
223+
let (path, path_span) = match mac {
224+
Ok(res) => res,
228225
Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)),
229226
};
230-
let file = match resolve_path(&cx.sess, file.as_str(), sp) {
231-
Ok(f) => f,
227+
ExpandResult::Ready(match load_binary_file(cx, path.as_str().as_ref(), sp, path_span) {
228+
Ok(bytes) => {
229+
let expr = cx.expr(sp, ast::ExprKind::IncludedBytes(bytes));
230+
MacEager::expr(expr)
231+
}
232+
Err(dummy) => dummy,
233+
})
234+
}
235+
236+
fn load_binary_file(
237+
cx: &mut ExtCtxt<'_>,
238+
original_path: &Path,
239+
macro_span: Span,
240+
path_span: Span,
241+
) -> Result<Lrc<[u8]>, Box<dyn MacResult>> {
242+
let resolved_path = match resolve_path(&cx.sess, original_path, macro_span) {
243+
Ok(path) => path,
232244
Err(err) => {
233245
let guar = err.emit();
234-
return ExpandResult::Ready(DummyResult::any(sp, guar));
246+
return Err(DummyResult::any(macro_span, guar));
235247
}
236248
};
237-
ExpandResult::Ready(match cx.source_map().load_binary_file(&file) {
238-
Ok(bytes) => {
239-
let expr = cx.expr(sp, ast::ExprKind::IncludedBytes(bytes));
240-
MacEager::expr(expr)
249+
match cx.source_map().load_binary_file(&resolved_path) {
250+
Ok(data) => Ok(data),
251+
Err(io_err) => {
252+
let mut err = cx.dcx().struct_span_err(
253+
macro_span,
254+
format!("couldn't read `{}`: {io_err}", resolved_path.display()),
255+
);
256+
257+
if original_path.is_relative() {
258+
let source_map = cx.sess.source_map();
259+
let new_path = source_map
260+
.span_to_filename(macro_span.source_callsite())
261+
.into_local_path()
262+
.and_then(|src| find_path_suggestion(source_map, src.parent()?, original_path))
263+
.and_then(|path| path.into_os_string().into_string().ok());
264+
265+
if let Some(new_path) = new_path {
266+
err.span_suggestion(
267+
path_span,
268+
"there is a file with the same name in a different directory",
269+
format!("\"{}\"", new_path.replace('\\', "/").escape_debug()),
270+
rustc_lint_defs::Applicability::MachineApplicable,
271+
);
272+
}
273+
}
274+
let guar = err.emit();
275+
Err(DummyResult::any(macro_span, guar))
241276
}
242-
Err(e) => {
243-
let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e));
244-
DummyResult::any(sp, guar)
277+
}
278+
}
279+
280+
fn find_path_suggestion(
281+
source_map: &SourceMap,
282+
base_dir: &Path,
283+
wanted_path: &Path,
284+
) -> Option<PathBuf> {
285+
// Fix paths that assume they're relative to cargo manifest dir
286+
let mut base_c = base_dir.components();
287+
let mut wanted_c = wanted_path.components();
288+
let mut without_base = None;
289+
while let Some(wanted_next) = wanted_c.next() {
290+
if wanted_c.as_path().file_name().is_none() {
291+
break;
245292
}
293+
// base_dir may be absolute
294+
while let Some(base_next) = base_c.next() {
295+
if base_next == wanted_next {
296+
without_base = Some(wanted_c.as_path());
297+
break;
298+
}
299+
}
300+
}
301+
let root_absolute = without_base.into_iter().map(PathBuf::from);
302+
303+
let base_dir_components = base_dir.components().count();
304+
// Avoid going all the way to the root dir
305+
let max_parent_components = if base_dir.is_relative() {
306+
base_dir_components + 1
307+
} else {
308+
base_dir_components.saturating_sub(1)
309+
};
310+
311+
// Try with additional leading ../
312+
let mut prefix = PathBuf::new();
313+
let add = std::iter::from_fn(|| {
314+
prefix.push("..");
315+
Some(prefix.join(wanted_path))
246316
})
317+
.take(max_parent_components.min(3));
318+
319+
// Try without leading directories
320+
let mut trimmed_path = wanted_path;
321+
let remove = std::iter::from_fn(|| {
322+
let mut components = trimmed_path.components();
323+
let removed = components.next()?;
324+
trimmed_path = components.as_path();
325+
let _ = trimmed_path.file_name()?; // ensure there is a file name left
326+
Some([
327+
Some(trimmed_path.to_path_buf()),
328+
(removed != std::path::Component::ParentDir)
329+
.then(|| Path::new("..").join(trimmed_path)),
330+
])
331+
})
332+
.flatten()
333+
.flatten()
334+
.take(4);
335+
336+
for new_path in root_absolute.chain(add).chain(remove) {
337+
if source_map.file_exists(&base_dir.join(&new_path)) {
338+
return Some(new_path);
339+
}
340+
}
341+
None
247342
}

0 commit comments

Comments
 (0)