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 4 pull requests #123264

Merged
merged 44 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
377caa2
we have to ignore RUSTC_WORKSPACE_WRAPPER as well
RalfJung Mar 26, 2024
5f73da7
Auto merge of #3417 - RalfJung:RUSTC_WORKSPACE_WRAPPER, r=RalfJung
bors Mar 26, 2024
22b00b9
run_dep_mode: treat program.args and program.env consistently
RalfJung Mar 25, 2024
a9b4a94
run command: simplify flag computation
RalfJung Mar 26, 2024
5b877a3
cargo-miri: clean up info_query treatment a bit, and update comment a…
RalfJung Mar 25, 2024
eee5a77
Preparing for merge from rustc
RalfJung Mar 26, 2024
c51eb81
Merge from rustc
RalfJung Mar 26, 2024
78d556e
Auto merge of #3418 - RalfJung:cargo-miri, r=RalfJung
bors Mar 26, 2024
89a36c0
fmt
RalfJung Mar 26, 2024
2e198d0
Auto merge of #3419 - RalfJung:rustup, r=RalfJung
bors Mar 26, 2024
df73cb7
Tree Borrows: Make tree root always be `Active` and initialized
JoJoDeveloping Mar 25, 2024
8b2b84e
Auto merge of #3415 - JoJoDeveloping:tree-borrows-initialized-root, r…
bors Mar 26, 2024
86b5740
add eyre to test-cargo-miri
RalfJung Mar 26, 2024
9f11ed7
Auto merge of #3420 - RalfJung:eyre, r=RalfJung
bors Mar 26, 2024
a8fb4a0
avoid mutating the global environment
RalfJung Mar 26, 2024
3c041c4
Auto merge of #3421 - RalfJung:remove-remove-var, r=RalfJung
bors Mar 26, 2024
a379a95
test-cargo-miri: add proc-macro2 instead of anyhow
RalfJung Mar 26, 2024
08c149b
rename our proc-macro test crate to a more clear name
RalfJung Mar 26, 2024
673ff09
update proc-macro2
RalfJung Mar 26, 2024
f151914
update the remaining test-cargo-miri dependencies as well (while we a…
RalfJung Mar 26, 2024
58a771e
Auto merge of #3423 - RalfJung:proc-macro-2, r=RalfJung
bors Mar 26, 2024
29a59be
Preparing for merge from rustc
Mar 29, 2024
ed29546
Merge from rustc
Mar 29, 2024
eae940f
Auto merge of #3427 - rust-lang:rustup-2024-03-29, r=saethlin
bors Mar 29, 2024
a4087b7
Log BOLT args in bootstrap `rustc` shim
Kobzol Mar 29, 2024
fee9a8e
Preparing for merge from rustc
Mar 30, 2024
28521fd
Merge from rustc
Mar 30, 2024
d3accba
Auto merge of #3428 - rust-lang:rustup-2024-03-30, r=RalfJung
bors Mar 30, 2024
bda301e
Stop calling visitors V
compiler-errors Mar 29, 2024
e1b8441
Require enum indices to be contiguous
Nadrieril Mar 30, 2024
a8b0f6f
make some doc comments not doc tests
RalfJung Mar 30, 2024
f04352a
Auto merge of #3430 - RalfJung:doc, r=RalfJung
bors Mar 30, 2024
9f6c675
run GC stress test only for host tests
RalfJung Mar 30, 2024
7f6d89d
move tests away from the slow Windows builder
RalfJung Mar 30, 2024
10217fd
cotrol stacked borrows consistency check with its own feature flag
RalfJung Mar 30, 2024
a8fd61b
Auto merge of #3432 - RalfJung:gc-stress, r=RalfJung
bors Mar 30, 2024
723aced
Auto merge of #3434 - RalfJung:stacked-borrows-cache-consistency, r=R…
bors Mar 30, 2024
2dd8247
Preparing for merge from rustc
Mar 31, 2024
eb8e8c0
Merge from rustc
Mar 31, 2024
d5de305
Auto merge of #3435 - rust-lang:rustup-2024-03-31, r=saethlin
bors Mar 31, 2024
0928a54
Rollup merge of #123189 - Kobzol:rustc-shim-log, r=onur-ozkan
matthiaskrgr Mar 31, 2024
d77608b
Rollup merge of #123211 - compiler-errors:V, r=estebank
matthiaskrgr Mar 31, 2024
f04d068
Rollup merge of #123242 - Nadrieril:require-contiguous-enum-indices, …
matthiaskrgr Mar 31, 2024
9abf4bc
Rollup merge of #123260 - RalfJung:miri, r=RalfJung
matthiaskrgr Mar 31, 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
15 changes: 12 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,19 +540,23 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
}

/// Suggest `map[k] = v` => `map.insert(k, v)` and the like.
fn suggest_map_index_mut_alternatives(&self, ty: Ty<'tcx>, err: &mut Diag<'tcx>, span: Span) {
let Some(adt) = ty.ty_adt_def() else { return };
let did = adt.did();
if self.infcx.tcx.is_diagnostic_item(sym::HashMap, did)
|| self.infcx.tcx.is_diagnostic_item(sym::BTreeMap, did)
{
struct V<'a, 'tcx> {
/// Walks through the HIR, looking for the corresponding span for this error.
/// When it finds it, see if it corresponds to assignment operator whose LHS
/// is an index expr.
struct SuggestIndexOperatorAlternativeVisitor<'a, 'tcx> {
assign_span: Span,
err: &'a mut Diag<'tcx>,
ty: Ty<'tcx>,
suggested: bool,
}
impl<'a, 'tcx> Visitor<'tcx> for V<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for SuggestIndexOperatorAlternativeVisitor<'a, 'tcx> {
fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
hir::intravisit::walk_stmt(self, stmt);
let expr = match stmt.kind {
Expand Down Expand Up @@ -645,7 +649,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let Some(body_id) = hir_map.maybe_body_owned_by(local_def_id) else { return };
let body = self.infcx.tcx.hir().body(body_id);

let mut v = V { assign_span: span, err, ty, suggested: false };
let mut v = SuggestIndexOperatorAlternativeVisitor {
assign_span: span,
err,
ty,
suggested: false,
};
v.visit_body(body);
if !v.suggested {
err.help(format!(
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,10 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
{
if let &hir::ClosureBinder::For { span: for_sp, .. } = binder {
fn span_of_infer(ty: &hir::Ty<'_>) -> Option<Span> {
struct V;
impl<'v> Visitor<'v> for V {
/// Look for `_` anywhere in the signature of a `for<> ||` closure.
/// This is currently disallowed.
struct FindInferInClosureWithBinder;
impl<'v> Visitor<'v> for FindInferInClosureWithBinder {
type Result = ControlFlow<Span>;
fn visit_ty(&mut self, t: &'v hir::Ty<'v>) -> Self::Result {
if matches!(t.kind, hir::TyKind::Infer) {
Expand All @@ -429,7 +431,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
}
}
}
V.visit_ty(ty).break_value()
FindInferInClosureWithBinder.visit_ty(ty).break_value()
}

let infer_in_rt_sp = match fn_decl.output {
Expand Down
21 changes: 10 additions & 11 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1916,22 +1916,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pat: &'tcx hir::Pat<'tcx>,
ty: Ty<'tcx>,
) {
struct V {
pat_hir_ids: Vec<hir::HirId>,
}

impl<'tcx> Visitor<'tcx> for V {
fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
self.pat_hir_ids.push(p.hir_id);
hir::intravisit::walk_pat(self, p);
}
}
if let Err(guar) = ty.error_reported() {
struct OverwritePatternsWithError {
pat_hir_ids: Vec<hir::HirId>,
}
impl<'tcx> Visitor<'tcx> for OverwritePatternsWithError {
fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
self.pat_hir_ids.push(p.hir_id);
hir::intravisit::walk_pat(self, p);
}
}
// Override the types everywhere with `err()` to avoid knock on errors.
let err = Ty::new_error(self.tcx, guar);
self.write_ty(hir_id, err);
self.write_ty(pat.hir_id, err);
let mut visitor = V { pat_hir_ids: vec![] };
let mut visitor = OverwritePatternsWithError { pat_hir_ids: vec![] };
hir::intravisit::walk_pat(&mut visitor, pat);
// Mark all the subpatterns as `{type error}` as well. This allows errors for specific
// subpatterns to be silenced.
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_pattern_analysis/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ use std::iter::once;
use smallvec::SmallVec;

use rustc_apfloat::ieee::{DoubleS, IeeeFloat, SingleS};
use rustc_index::bit_set::GrowableBitSet;
use rustc_index::bit_set::{BitSet, GrowableBitSet};
use rustc_index::IndexVec;

use self::Constructor::*;
use self::MaybeInfiniteInt::*;
use self::SliceKind::*;

use crate::index;
use crate::PatCx;

/// Whether we have seen a constructor in the column or not.
Expand Down Expand Up @@ -920,10 +920,7 @@ pub enum ConstructorSet<Cx: PatCx> {
Struct { empty: bool },
/// This type has the following list of constructors. If `variants` is empty and
/// `non_exhaustive` is false, don't use this; use `NoConstructors` instead.
Variants {
variants: index::IdxContainer<Cx::VariantIdx, VariantVisibility>,
non_exhaustive: bool,
},
Variants { variants: IndexVec<Cx::VariantIdx, VariantVisibility>, non_exhaustive: bool },
/// The type is `&T`.
Ref,
/// The type is a union.
Expand Down Expand Up @@ -1025,7 +1022,7 @@ impl<Cx: PatCx> ConstructorSet<Cx> {
}
}
ConstructorSet::Variants { variants, non_exhaustive } => {
let mut seen_set = index::IdxSet::new_empty(variants.len());
let mut seen_set = BitSet::new_empty(variants.len());
for idx in seen.iter().filter_map(|c| c.as_variant()) {
seen_set.insert(idx);
}
Expand Down
49 changes: 4 additions & 45 deletions compiler/rustc_pattern_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,9 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

use std::fmt;

#[cfg(feature = "rustc")]
pub mod index {
// Faster version when the indices of variants are `0..variants.len()`.
pub use rustc_index::bit_set::BitSet as IdxSet;
pub use rustc_index::Idx;
pub use rustc_index::IndexVec as IdxContainer;
}
#[cfg(not(feature = "rustc"))]
pub mod index {
// Slower version when the indices of variants are something else.
pub trait Idx: Copy + PartialEq + Eq + std::hash::Hash {}
impl<T: Copy + PartialEq + Eq + std::hash::Hash> Idx for T {}

#[derive(Debug)]
pub struct IdxContainer<K, V>(pub rustc_hash::FxHashMap<K, V>);
impl<K: Idx, V> IdxContainer<K, V> {
pub fn len(&self) -> usize {
self.0.len()
}
pub fn iter_enumerated(&self) -> impl Iterator<Item = (K, &V)> {
self.0.iter().map(|(k, v)| (*k, v))
}
}

impl<V> FromIterator<V> for IdxContainer<usize, V> {
fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self {
Self(iter.into_iter().enumerate().collect())
}
}

#[derive(Debug)]
pub struct IdxSet<T>(pub rustc_hash::FxHashSet<T>);
impl<T: Idx> IdxSet<T> {
pub fn new_empty(_len: usize) -> Self {
Self(Default::default())
}
pub fn contains(&self, elem: T) -> bool {
self.0.contains(&elem)
}
pub fn insert(&mut self, elem: T) {
self.0.insert(elem);
}
}
}
// Re-exports to avoid rustc_index version issues.
pub use rustc_index::Idx;
pub use rustc_index::IndexVec;

#[cfg(feature = "rustc")]
use rustc_middle::ty::Ty;
Expand Down Expand Up @@ -96,7 +55,7 @@ pub trait PatCx: Sized + fmt::Debug {
/// Errors that can abort analysis.
type Error: fmt::Debug;
/// The index of an enum variant.
type VariantIdx: Clone + index::Idx + fmt::Debug;
type VariantIdx: Clone + Idx + fmt::Debug;
/// A string literal
type StrLit: Clone + PartialEq + fmt::Debug;
/// Extra data to store in a match arm.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1128,10 +1128,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
err: &mut Diag<'_>,
) -> bool {
let span = obligation.cause.span;
struct V {
/// Look for the (direct) sub-expr of `?`, and return it if it's a `.` method call.
struct FindMethodSubexprOfTry {
search_span: Span,
}
impl<'v> Visitor<'v> for V {
impl<'v> Visitor<'v> for FindMethodSubexprOfTry {
type Result = ControlFlow<&'v hir::Expr<'v>>;
fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) -> Self::Result {
if let hir::ExprKind::Match(expr, _arms, hir::MatchSource::TryDesugar(_)) = ex.kind
Expand All @@ -1149,8 +1150,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. }) => body_id,
_ => return false,
};
let ControlFlow::Break(expr) =
(V { search_span: span }).visit_body(self.tcx.hir().body(*body_id))
let ControlFlow::Break(expr) = (FindMethodSubexprOfTry { search_span: span })
.visit_body(self.tcx.hir().body(*body_id))
else {
return false;
};
Expand Down
12 changes: 6 additions & 6 deletions src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ fn main() {
}
}

if env::var_os("RUSTC_BOLT_LINK_FLAGS").is_some() {
if let Some("rustc_driver") = crate_name {
cmd.arg("-Clink-args=-Wl,-q");
}
}

let is_test = args.iter().any(|a| a == "--test");
if verbose > 2 {
let rust_env_vars =
Expand All @@ -244,12 +250,6 @@ fn main() {
eprintln!("{prefix} libdir: {libdir:?}");
}

if env::var_os("RUSTC_BOLT_LINK_FLAGS").is_some() {
if let Some("rustc_driver") = crate_name {
cmd.arg("-Clink-args=-Wl,-q");
}
}

bin_helpers::maybe_dump(format!("stage{stage}-rustc"), &cmd);

let start = Instant::now();
Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ harness = false
[features]
default = ["stack-cache"]
stack-cache = []
stack-cache-consistency-check = ["stack-cache"]

# Be aware that this file is inside a workspace when used via the
# submodule in the rustc repo. That means there are many cargo features
Expand Down
Loading
Loading