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 9 pull requests #129993

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7627a54
Call the target libdir target libdir
Noratrieb Jun 7, 2024
27f92b6
fix: get llvm type of global val
LYF1999 Aug 8, 2024
c6111c0
Remove the `'body` lifetime on `FilterInformation`.
nnethercote Aug 29, 2024
0a282ea
Move `WriteInfo` out of `Allocations`.
nnethercote Aug 29, 2024
ad5a6e1
Remove `Allocations`.
nnethercote Aug 29, 2024
1be2204
Simplify `Candidate`.
nnethercote Aug 29, 2024
0d156f2
Unify scraped examples with other code examples
GuillaumeGomez Aug 30, 2024
5b75f8a
Update rustdoc GUI tests
GuillaumeGomez Aug 30, 2024
5afc461
Fix wrong rounded corners when line numbers are displayed on code exa…
GuillaumeGomez Aug 31, 2024
84259ff
Add GUI tests to ensure that rounded corners on code blocks are worki…
GuillaumeGomez Aug 31, 2024
35a7c1b
Fix position of scraped examples title on mobile devices
GuillaumeGomez Sep 1, 2024
dd5f7bc
Add GUI regression test for scraped examples title position on mobile
GuillaumeGomez Sep 1, 2024
4825fb1
Add missing CSS variables in GUI test for `custom-theme.css`
GuillaumeGomez Sep 1, 2024
5a85632
Correctly handle code examples buttons position
GuillaumeGomez Sep 1, 2024
01d8235
Fix scraped examples background gradient
GuillaumeGomez Sep 1, 2024
e3af6dc
Simplify CSS but wrapping scraped example into a div and move the tit…
GuillaumeGomez Sep 2, 2024
55bc638
Fix wrong padding for expanded scraped example
GuillaumeGomez Sep 2, 2024
65e78db
Elaborate on deriving vs implementing `Copy`
chancancode Sep 3, 2024
3626b66
Update marker.rs
chancancode Sep 3, 2024
efc20de
Update marker.rs
chancancode Sep 3, 2024
277a08c
Update marker.rs
chancancode Sep 3, 2024
e45b53e
Update marker.rs
chancancode Sep 3, 2024
7157f98
Fix square corners on line numbers when code is collapsed
GuillaumeGomez Sep 3, 2024
a4f2a31
Don't ICE when dumping MIR of a synthetic coroutine body
compiler-errors Aug 28, 2024
5525043
Rename dump of coroutine by-move-body to be more consistent, adjust test
compiler-errors Aug 28, 2024
8860008
Re-parent the by-move body
compiler-errors Aug 28, 2024
2031eac
run_make_support: rename `Command::stdin` to `stdin_buf` and add `std…
jieyouxu Sep 4, 2024
afed862
tests: use renamed `stdin_buf`
jieyouxu Sep 5, 2024
8871ce0
run_make_support: make each command invocation only-run-once
jieyouxu Sep 5, 2024
a459403
Sort impl associated items by kinds and then by appearance
GuillaumeGomez Aug 23, 2024
f96aff9
Add regression test for impl associated items sorting
GuillaumeGomez Aug 23, 2024
1884983
Make impl associated constants sorted first
GuillaumeGomez Aug 25, 2024
d059f37
Add missing sidebar associated items
GuillaumeGomez Aug 26, 2024
238944c
Add regression test for sidebar associated items
GuillaumeGomez Aug 26, 2024
8f9c4b3
Update to new rustdoc internal API
GuillaumeGomez Sep 5, 2024
f8f4d50
Don't worry about uncaptured contravariant lifetimes if they outlive …
compiler-errors Aug 12, 2024
7064135
Do less work on the good path
compiler-errors Aug 12, 2024
c1d0410
Review comments
compiler-errors Aug 19, 2024
b514f52
Rollup merge of #126136 - Noratrieb:bootstrap-naming, r=onur-ozkan
matthiaskrgr Sep 5, 2024
9039bcf
Rollup merge of #128820 - LYF1999:yf/dev, r=nikic
matthiaskrgr Sep 5, 2024
8f396e0
Rollup merge of #129028 - compiler-errors:contra, r=lcnr
matthiaskrgr Sep 5, 2024
36f4539
Rollup merge of #129471 - GuillaumeGomez:sort-impl-associated-items, …
matthiaskrgr Sep 5, 2024
41ce7a9
Rollup merge of #129706 - compiler-errors:scratch, r=estebank
matthiaskrgr Sep 5, 2024
e590201
Rollup merge of #129720 - nnethercote:simplify-dest_prop-mm, r=cjgillot
matthiaskrgr Sep 5, 2024
3f99c12
Rollup merge of #129796 - GuillaumeGomez:unify-code-examples, r=notri…
matthiaskrgr Sep 5, 2024
86bd866
Rollup merge of #129938 - chancancode:patch-1, r=thomcc
matthiaskrgr Sep 5, 2024
0be10be
Rollup merge of #129973 - jieyouxu:rework-rmake-stdio, r=Kobzol
matthiaskrgr Sep 5, 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
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<'ll> CodegenCx<'ll, '_> {
let val_llty = self.val_ty(v);

let g = self.get_static_inner(def_id, val_llty);
let llty = self.val_ty(g);
let llty = llvm::LLVMGlobalGetValueType(g);

let g = if val_llty == llty {
g
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ unsafe extern "C" {
pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
pub fn LLVMGlobalGetValueType(Global: &Value) -> &Type;

// Operations on global variables
pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
Expand Down
375 changes: 287 additions & 88 deletions compiler/rustc_lint/src/impl_trait_overcaptures.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(array_windows)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(extract_if)]
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_middle/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io:
let def_id = body.source.def_id();
let kind = tcx.def_kind(def_id);
let is_function = match kind {
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..) => true,
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..) | DefKind::SyntheticCoroutineBody => {
true
}
_ => tcx.is_closure_like(def_id),
};
match (kind, body.source.promoted) {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_mir_transform/src/coroutine/by_move_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ pub fn coroutine_by_move_body_def_id<'tcx>(

let mut by_move_body = body.clone();
MakeByMoveBody { tcx, field_remapping, by_move_coroutine_ty }.visit_body(&mut by_move_body);
dump_mir(tcx, false, "coroutine_by_move", &0, &by_move_body, |_, _| Ok(()));

let body_def = tcx.create_def(coroutine_def_id, kw::Empty, DefKind::SyntheticCoroutineBody);
// This will always be `{closure#1}`, since the original coroutine is `{closure#0}`.
let body_def = tcx.create_def(parent_def_id, kw::Empty, DefKind::SyntheticCoroutineBody);
by_move_body.source =
mir::MirSource::from_instance(InstanceKind::Item(body_def.def_id().to_def_id()));
dump_mir(tcx, false, "built", &"after", &by_move_body, |_, _| Ok(()));

// Inherited from the by-ref coroutine.
body_def.codegen_fn_attrs(tcx.codegen_fn_attrs(coroutine_def_id).clone());
Expand Down
113 changes: 46 additions & 67 deletions compiler/rustc_mir_transform/src/dest_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {

fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let def_id = body.source.def_id();
let mut allocations = Allocations::default();
let mut candidates = Candidates::default();
let mut write_info = WriteInfo::default();
trace!(func = ?tcx.def_path_str(def_id));

let borrowed = rustc_mir_dataflow::impls::borrowed_locals(body);
Expand Down Expand Up @@ -191,20 +192,15 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
loop {
// PERF: Can we do something smarter than recalculating the candidates and liveness
// results?
let mut candidates = find_candidates(
body,
&borrowed,
&mut allocations.candidates,
&mut allocations.candidates_reverse,
);
candidates.reset_and_find(body, &borrowed);
trace!(?candidates);
dest_prop_mir_dump(tcx, body, &points, &live, round_count);

FilterInformation::filter_liveness(
&mut candidates,
&points,
&live,
&mut allocations.write_info,
&mut write_info,
body,
);

Expand Down Expand Up @@ -253,20 +249,8 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
}
}

/// Container for the various allocations that we need.
///
/// We store these here and hand out `&mut` access to them, instead of dropping and recreating them
/// frequently. Everything with a `&'alloc` lifetime points into here.
#[derive(Default)]
struct Allocations {
candidates: FxIndexMap<Local, Vec<Local>>,
candidates_reverse: FxIndexMap<Local, Vec<Local>>,
write_info: WriteInfo,
// PERF: Do this for `MaybeLiveLocals` allocations too.
}

#[derive(Debug)]
struct Candidates<'alloc> {
#[derive(Debug, Default)]
struct Candidates {
/// The set of candidates we are considering in this optimization.
///
/// We will always merge the key into at most one of its values.
Expand All @@ -281,11 +265,12 @@ struct Candidates<'alloc> {
///
/// We will still report that we would like to merge `_1` and `_2` in an attempt to allow us to
/// remove that assignment.
c: &'alloc mut FxIndexMap<Local, Vec<Local>>,
c: FxIndexMap<Local, Vec<Local>>,

/// A reverse index of the `c` set; if the `c` set contains `a => Place { local: b, proj }`,
/// then this contains `b => a`.
// PERF: Possibly these should be `SmallVec`s?
reverse: &'alloc mut FxIndexMap<Local, Vec<Local>>,
reverse: FxIndexMap<Local, Vec<Local>>,
}

//////////////////////////////////////////////////////////
Expand Down Expand Up @@ -358,19 +343,40 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Merger<'a, 'tcx> {
//
// This section enforces bullet point 2

struct FilterInformation<'a, 'body, 'alloc, 'tcx> {
body: &'body Body<'tcx>,
struct FilterInformation<'a, 'tcx> {
body: &'a Body<'tcx>,
points: &'a DenseLocationMap,
live: &'a SparseIntervalMatrix<Local, PointIndex>,
candidates: &'a mut Candidates<'alloc>,
write_info: &'alloc mut WriteInfo,
candidates: &'a mut Candidates,
write_info: &'a mut WriteInfo,
at: Location,
}

// We first implement some utility functions which we will expose removing candidates according to
// different needs. Throughout the liveness filtering, the `candidates` are only ever accessed
// through these methods, and not directly.
impl<'alloc> Candidates<'alloc> {
impl Candidates {
/// Collects the candidates for merging.
///
/// This is responsible for enforcing the first and third bullet point.
fn reset_and_find<'tcx>(&mut self, body: &Body<'tcx>, borrowed: &BitSet<Local>) {
self.c.clear();
self.reverse.clear();
let mut visitor = FindAssignments { body, candidates: &mut self.c, borrowed };
visitor.visit_body(body);
// Deduplicate candidates.
for (_, cands) in self.c.iter_mut() {
cands.sort();
cands.dedup();
}
// Generate the reverse map.
for (src, cands) in self.c.iter() {
for dest in cands.iter().copied() {
self.reverse.entry(dest).or_default().push(*src);
}
}
}

/// Just `Vec::retain`, but the condition is inverted and we add debugging output
fn vec_filter_candidates(
src: Local,
Expand Down Expand Up @@ -445,7 +451,7 @@ enum CandidateFilter {
Remove,
}

impl<'a, 'body, 'alloc, 'tcx> FilterInformation<'a, 'body, 'alloc, 'tcx> {
impl<'a, 'tcx> FilterInformation<'a, 'tcx> {
/// Filters the set of candidates to remove those that conflict.
///
/// The steps we take are exactly those that are outlined at the top of the file. For each
Expand All @@ -463,12 +469,12 @@ impl<'a, 'body, 'alloc, 'tcx> FilterInformation<'a, 'body, 'alloc, 'tcx> {
/// before the statement/terminator will correctly report locals that are read in the
/// statement/terminator to be live. We are additionally conservative by treating all written to
/// locals as also being read from.
fn filter_liveness<'b>(
candidates: &mut Candidates<'alloc>,
fn filter_liveness(
candidates: &mut Candidates,
points: &DenseLocationMap,
live: &SparseIntervalMatrix<Local, PointIndex>,
write_info_alloc: &'alloc mut WriteInfo,
body: &'b Body<'tcx>,
write_info: &mut WriteInfo,
body: &Body<'tcx>,
) {
let mut this = FilterInformation {
body,
Expand All @@ -477,7 +483,7 @@ impl<'a, 'body, 'alloc, 'tcx> FilterInformation<'a, 'body, 'alloc, 'tcx> {
candidates,
// We don't actually store anything at this scope, we just keep things here to be able
// to reuse the allocation.
write_info: write_info_alloc,
write_info,
// Doesn't matter what we put here, will be overwritten before being used
at: Location::START,
};
Expand Down Expand Up @@ -734,40 +740,13 @@ fn places_to_candidate_pair<'tcx>(
Some((a, b))
}

/// Collects the candidates for merging
///
/// This is responsible for enforcing the first and third bullet point.
fn find_candidates<'alloc, 'tcx>(
body: &Body<'tcx>,
borrowed: &BitSet<Local>,
candidates: &'alloc mut FxIndexMap<Local, Vec<Local>>,
candidates_reverse: &'alloc mut FxIndexMap<Local, Vec<Local>>,
) -> Candidates<'alloc> {
candidates.clear();
candidates_reverse.clear();
let mut visitor = FindAssignments { body, candidates, borrowed };
visitor.visit_body(body);
// Deduplicate candidates
for (_, cands) in candidates.iter_mut() {
cands.sort();
cands.dedup();
}
// Generate the reverse map
for (src, cands) in candidates.iter() {
for dest in cands.iter().copied() {
candidates_reverse.entry(dest).or_default().push(*src);
}
}
Candidates { c: candidates, reverse: candidates_reverse }
}

struct FindAssignments<'a, 'alloc, 'tcx> {
struct FindAssignments<'a, 'tcx> {
body: &'a Body<'tcx>,
candidates: &'alloc mut FxIndexMap<Local, Vec<Local>>,
candidates: &'a mut FxIndexMap<Local, Vec<Local>>,
borrowed: &'a BitSet<Local>,
}

impl<'tcx> Visitor<'tcx> for FindAssignments<'_, '_, 'tcx> {
impl<'tcx> Visitor<'tcx> for FindAssignments<'_, 'tcx> {
fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) {
if let StatementKind::Assign(box (
lhs,
Expand Down Expand Up @@ -819,9 +798,9 @@ fn is_local_required(local: Local, body: &Body<'_>) -> bool {
/////////////////////////////////////////////////////////
// MIR Dump

fn dest_prop_mir_dump<'body, 'tcx>(
fn dest_prop_mir_dump<'tcx>(
tcx: TyCtxt<'tcx>,
body: &'body Body<'tcx>,
body: &Body<'tcx>,
points: &DenseLocationMap,
live: &SparseIntervalMatrix<Local, PointIndex>,
round: usize,
Expand Down
15 changes: 13 additions & 2 deletions library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,19 @@ marker_impls! {
/// }
/// ```
///
/// There is a small difference between the two: the `derive` strategy will also place a `Copy`
/// bound on type parameters, which isn't always desired.
/// There is a small difference between the two. The `derive` strategy will also place a `Copy`
/// bound on type parameters:
///
/// ```
/// #[derive(Clone)]
/// struct MyStruct<T>(T);
///
/// impl<T: Copy> Copy for MyStruct<T> { }
/// ```
///
/// This isn't always desired. For example, shared references (`&T`) can be copied regardless of
/// whether `T` is `Copy`. Likewise, a generic struct containing markers such as [`PhantomData`]
/// could potentially be duplicated with a bit-wise copy.
///
/// ## What's the difference between `Copy` and `Clone`?
///
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ impl Step for Std {
// We skip populating the sysroot in non-zero stage because that'll lead
// to rlib/rmeta conflicts if std gets built during this session.
if compiler.stage == 0 {
let libdir = builder.sysroot_libdir(compiler, target);
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
let libdir = builder.sysroot_target_libdir(compiler, target);
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
}
drop(_guard);
Expand Down Expand Up @@ -257,8 +257,8 @@ impl Step for Rustc {
false,
);

let libdir = builder.sysroot_libdir(compiler, target);
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
let libdir = builder.sysroot_target_libdir(compiler, target);
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
add_to_sysroot(builder, &libdir, &hostdir, &librustc_stamp(builder, compiler, target));
}
}
Expand Down
Loading
Loading