Skip to content

Commit

Permalink
Auto merge of #3427 - rust-lang:rustup-2024-03-29, r=saethlin
Browse files Browse the repository at this point in the history
Automatic Rustup
  • Loading branch information
bors committed Mar 29, 2024
2 parents 58a771e + ed29546 commit eae940f
Show file tree
Hide file tree
Showing 356 changed files with 5,529 additions and 2,604 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
schedule:
# Run weekly
- cron: '0 0 * * Sun'
# Re-bump deps every 4 hours
- cron: '0 */4 * * *'
workflow_dispatch:
# Needed so we can run it manually
permissions:
Expand Down Expand Up @@ -42,7 +40,7 @@ jobs:
# Exit with error if open and S-waiting-on-bors
if [[ "$STATE" == "OPEN" && "$WAITING_ON_BORS" == "true" ]]; then
gh run cancel ${{ github.run_id }}
exit 1
fi
update:
Expand All @@ -65,10 +63,7 @@ jobs:
- name: cargo update
# Remove first line that always just says "Updating crates.io index"
# If there are no changes, cancel the job here
run: |
cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
git status --porcelain | grep -q Cargo.lock || gh run cancel ${{ github.run_id }}
run: cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
- name: upload Cargo.lock artifact for use in PR
uses: actions/upload-artifact@v4
with:
Expand All @@ -95,11 +90,11 @@ jobs:
uses: actions/checkout@v4

- name: download Cargo.lock from update job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Cargo-lock
- name: download cargo-update log from update job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: cargo-updates

Expand Down Expand Up @@ -134,14 +129,14 @@ jobs:
# Exit with error if PR is closed
STATE=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json state --jq '.state')
if [[ "$STATE" != "OPEN" ]]; then
gh run cancel ${{ github.run_id }}
exit 1
fi
gh pr edit cargo_update --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY
- name: open new pull request
# Only run if there wasn't an existing PR and if this is the weekly run
if: steps.edit.outcome != 'success' && github.event.schedule == '0 0 * * Sun'
# Only run if there wasn't an existing PR
if: steps.edit.outcome != 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr create --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ Katze <[email protected]>
Keegan McAllister <[email protected]> <[email protected]>
Kerem Kat <[email protected]>
Kevin Butler <[email protected]>
Kevin Reid <[email protected]> <[email protected]>
Kevin Jiang <[email protected]>
Kornel Lesiński <[email protected]>
Krishna Sai Veera Reddy <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ toolchain.
directory and uncomment the line `MSYS2_PATH_TYPE=inherit`.

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

3. Start a MINGW64 or MINGW32 shell (depending on whether you want 32-bit
or 64-bit Rust) either from your start menu, or by running `mingw64.exe`
Expand Down
10 changes: 10 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 1.77.1 (2024-03-28)
===========================

<a id="1.77.1"></a>

- [Revert stripping debuginfo by default for Windows](https://github.com/rust-lang/cargo/pull/13654)
This fixes a regression in 1.77 by reverting to the previous default.
Platforms other than Windows are not affected.
- Internal: [Fix heading anchor rendering in doc pages](https://github.com/rust-lang/rust/pull/122693)

Version 1.77.0 (2024-03-21)
==========================

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pprust/state/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub(crate) struct FixupContext {
}

/// The default amount of fixing is minimal fixing. Fixups should be turned on
/// in a targetted fashion where needed.
/// in a targeted fashion where needed.
impl Default for FixupContext {
fn default() -> Self {
FixupContext {
Expand Down
16 changes: 13 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![allow(rustc::untranslatable_diagnostic)]

use either::Either;
use hir::ClosureKind;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan};
Expand Down Expand Up @@ -463,6 +464,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
} else if let UseSpans::FnSelfUse { kind: CallKind::Normal { .. }, .. } = move_spans
{
// We already suggest cloning for these cases in `explain_captures`.
} else if let UseSpans::ClosureUse {
closure_kind:
ClosureKind::Coroutine(CoroutineKind::Desugared(_, CoroutineSource::Block)),
args_span: _,
capture_kind_span: _,
path_span,
} = move_spans
{
self.suggest_cloning(err, ty, expr, path_span);
} else if self.suggest_hoisting_call_outside_loop(err, expr) {
// The place where the the type moves would be misleading to suggest clone.
// #121466
Expand Down Expand Up @@ -621,7 +631,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}

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

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

let span = in_loop.span;
if !finder.found_breaks.is_empty()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
}
self.cx.borrowck_context.constraints.outlives_constraints.push(constraint)
}
// If the region is live at at least one location in the promoted MIR,
// If the region is live at least one location in the promoted MIR,
// then add a liveness constraint to the main MIR for this region
// at the location provided as an argument to this method
//
Expand Down
157 changes: 126 additions & 31 deletions compiler/rustc_builtin_macros/src/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ use rustc_ast::ptr::P;
use rustc_ast::token;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast_pretty::pprust;
use rustc_expand::base::{check_zero_tts, get_single_str_from_tts, parse_expr, resolve_path};
use rustc_data_structures::sync::Lrc;
use rustc_expand::base::{
check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr,
resolve_path,
};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt};
use rustc_expand::base::{MacEager, MacResult, MacroExpanderResult};
use rustc_expand::module::DirOwnership;
use rustc_parse::new_parser_from_file;
use rustc_parse::parser::{ForceCollect, Parser};
use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::Symbol;
use rustc_span::{Pos, Span};

use smallvec::SmallVec;
use std::path::{Path, PathBuf};
use std::rc::Rc;

// These macros all relate to the file system; they either return
Expand Down Expand Up @@ -182,35 +187,26 @@ pub fn expand_include_str(
tts: TokenStream,
) -> MacroExpanderResult<'static> {
let sp = cx.with_def_site_ctxt(sp);
let ExpandResult::Ready(mac) = get_single_str_from_tts(cx, sp, tts, "include_str!") else {
let ExpandResult::Ready(mac) = get_single_str_spanned_from_tts(cx, sp, tts, "include_str!")
else {
return ExpandResult::Retry(());
};
let file = match mac {
Ok(file) => file,
let (path, path_span) = match mac {
Ok(res) => res,
Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)),
};
let file = match resolve_path(&cx.sess, file.as_str(), sp) {
Ok(f) => f,
Err(err) => {
let guar = err.emit();
return ExpandResult::Ready(DummyResult::any(sp, guar));
}
};
ExpandResult::Ready(match cx.source_map().load_binary_file(&file) {
ExpandResult::Ready(match load_binary_file(cx, path.as_str().as_ref(), sp, path_span) {
Ok(bytes) => match std::str::from_utf8(&bytes) {
Ok(src) => {
let interned_src = Symbol::intern(src);
MacEager::expr(cx.expr_str(sp, interned_src))
}
Err(_) => {
let guar = cx.dcx().span_err(sp, format!("{} wasn't a utf-8 file", file.display()));
let guar = cx.dcx().span_err(sp, format!("`{path}` wasn't a utf-8 file"));
DummyResult::any(sp, guar)
}
},
Err(e) => {
let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e));
DummyResult::any(sp, guar)
}
Err(dummy) => dummy,
})
}

Expand All @@ -220,28 +216,127 @@ pub fn expand_include_bytes(
tts: TokenStream,
) -> MacroExpanderResult<'static> {
let sp = cx.with_def_site_ctxt(sp);
let ExpandResult::Ready(mac) = get_single_str_from_tts(cx, sp, tts, "include_bytes!") else {
let ExpandResult::Ready(mac) = get_single_str_spanned_from_tts(cx, sp, tts, "include_bytes!")
else {
return ExpandResult::Retry(());
};
let file = match mac {
Ok(file) => file,
let (path, path_span) = match mac {
Ok(res) => res,
Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)),
};
let file = match resolve_path(&cx.sess, file.as_str(), sp) {
Ok(f) => f,
ExpandResult::Ready(match load_binary_file(cx, path.as_str().as_ref(), sp, path_span) {
Ok(bytes) => {
let expr = cx.expr(sp, ast::ExprKind::IncludedBytes(bytes));
MacEager::expr(expr)
}
Err(dummy) => dummy,
})
}

fn load_binary_file(
cx: &mut ExtCtxt<'_>,
original_path: &Path,
macro_span: Span,
path_span: Span,
) -> Result<Lrc<[u8]>, Box<dyn MacResult>> {
let resolved_path = match resolve_path(&cx.sess, original_path, macro_span) {
Ok(path) => path,
Err(err) => {
let guar = err.emit();
return ExpandResult::Ready(DummyResult::any(sp, guar));
return Err(DummyResult::any(macro_span, guar));
}
};
ExpandResult::Ready(match cx.source_map().load_binary_file(&file) {
Ok(bytes) => {
let expr = cx.expr(sp, ast::ExprKind::IncludedBytes(bytes));
MacEager::expr(expr)
match cx.source_map().load_binary_file(&resolved_path) {
Ok(data) => Ok(data),
Err(io_err) => {
let mut err = cx.dcx().struct_span_err(
macro_span,
format!("couldn't read `{}`: {io_err}", resolved_path.display()),
);

if original_path.is_relative() {
let source_map = cx.sess.source_map();
let new_path = source_map
.span_to_filename(macro_span.source_callsite())
.into_local_path()
.and_then(|src| find_path_suggestion(source_map, src.parent()?, original_path))
.and_then(|path| path.into_os_string().into_string().ok());

if let Some(new_path) = new_path {
err.span_suggestion(
path_span,
"there is a file with the same name in a different directory",
format!("\"{}\"", new_path.replace('\\', "/").escape_debug()),
rustc_lint_defs::Applicability::MachineApplicable,
);
}
}
let guar = err.emit();
Err(DummyResult::any(macro_span, guar))
}
Err(e) => {
let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e));
DummyResult::any(sp, guar)
}
}

fn find_path_suggestion(
source_map: &SourceMap,
base_dir: &Path,
wanted_path: &Path,
) -> Option<PathBuf> {
// Fix paths that assume they're relative to cargo manifest dir
let mut base_c = base_dir.components();
let mut wanted_c = wanted_path.components();
let mut without_base = None;
while let Some(wanted_next) = wanted_c.next() {
if wanted_c.as_path().file_name().is_none() {
break;
}
// base_dir may be absolute
while let Some(base_next) = base_c.next() {
if base_next == wanted_next {
without_base = Some(wanted_c.as_path());
break;
}
}
}
let root_absolute = without_base.into_iter().map(PathBuf::from);

let base_dir_components = base_dir.components().count();
// Avoid going all the way to the root dir
let max_parent_components = if base_dir.is_relative() {
base_dir_components + 1
} else {
base_dir_components.saturating_sub(1)
};

// Try with additional leading ../
let mut prefix = PathBuf::new();
let add = std::iter::from_fn(|| {
prefix.push("..");
Some(prefix.join(wanted_path))
})
.take(max_parent_components.min(3));

// Try without leading directories
let mut trimmed_path = wanted_path;
let remove = std::iter::from_fn(|| {
let mut components = trimmed_path.components();
let removed = components.next()?;
trimmed_path = components.as_path();
let _ = trimmed_path.file_name()?; // ensure there is a file name left
Some([
Some(trimmed_path.to_path_buf()),
(removed != std::path::Component::ParentDir)
.then(|| Path::new("..").join(trimmed_path)),
])
})
.flatten()
.flatten()
.take(4);

for new_path in root_absolute.chain(add).chain(remove) {
if source_map.file_exists(&base_dir.join(&new_path)) {
return Some(new_path);
}
}
None
}
Loading

0 comments on commit eae940f

Please sign in to comment.