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 13 pull requests #76350

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
18ad5a5
Add a regression test for issue-72793
JohnTitor Aug 19, 2020
e5f9d7f
BTreeMap: introduce marker::ValMut and reserve marker::Mut for unique…
ssomers Jul 23, 2020
aa40c02
Unstable Book: add links to tracking issues for FFI features
ArekPiekarz Aug 26, 2020
f03d0b3
`impl Rc::new_cyclic`
mental32 Aug 27, 2020
42fb270
typo
mental32 Aug 29, 2020
bb5e79c
Link vec doc to & reference
pickfire Aug 29, 2020
1b19354
[WIP] Fix intra-doc links on pub re-exports
jyn514 Aug 29, 2020
20a6866
Try removing [prim@reference]
pickfire Aug 30, 2020
e885f00
Comment out test for generated docs until rustdoc changes its behavio…
jyn514 Aug 30, 2020
d715015
Improve tests
jyn514 Aug 30, 2020
81e85ce
Move to Arc::clone(&x) over x.clone() in library/std
poliorcetics Aug 30, 2020
6b75e3d
Move to Arc::clone(&x) over x.clone() in library/core
poliorcetics Aug 30, 2020
864f2dc
Refactor byteorder to std in rustc_middle
workingjubilee Aug 20, 2020
fd959c1
Remove reference to byteorder limits
workingjubilee Aug 20, 2020
28d3100
Be explicit that we're handling bytes
workingjubilee Aug 20, 2020
91c9351
Explain contract of {read, write}_target_uint
workingjubilee Aug 21, 2020
b688314
Fix big endian read/write
workingjubilee Aug 22, 2020
ec0924f
do not apply DerefMut on union field
RalfJung Aug 16, 2020
44defae
also detect DerefMut in nested union fields
RalfJung Aug 16, 2020
97974e3
only emit error for ManuallyDrop derefs
RalfJung Aug 16, 2020
66b340f
test more ways of mutably accessing a place
RalfJung Aug 30, 2020
0f301e8
Removed [inline] and copied over comments from Arc::new_cyclic
mental32 Sep 1, 2020
8783c62
Add missing link in README
camelid Sep 2, 2020
89ae59a
Remove needless .to_owned() for link
jyn514 Jul 6, 2020
d5495e2
Refactor `ItemLink` into its own struct
jyn514 Jul 6, 2020
31a7b6e
Refactor RenderedLink into its own type
jyn514 Jul 6, 2020
9815010
Remove disambiguators from link text
jyn514 Jul 6, 2020
9d7e797
display_for -> suggestion_for
jyn514 Aug 29, 2020
4df6490
Link & primitive using relative link
pickfire Sep 3, 2020
6e43ff5
Add check for doc alias on associated const in trait impls
GuillaumeGomez Aug 24, 2020
b61eab5
Add test for doc alias on associated const in trait impls
GuillaumeGomez Aug 24, 2020
85146b9
Add slice primitive link to vec
pickfire Sep 4, 2020
18c14fd
Misc cleanup
jyn514 Aug 29, 2020
ed3950b
Enable profiler tests on Windows-gnu
mati865 Aug 5, 2020
1ea121c
Fix warning whe building profiler_builtins crate
mati865 Aug 24, 2020
03fd825
Ignore failing PGO/coverage tests on MinGW
mati865 Aug 24, 2020
e8fc38d
Update llvm submodule
mati865 Aug 31, 2020
57672a2
Rollup merge of #75200 - ssomers:btree_valmut, r=Mark-Simulacrum
Dylan-DPC Sep 4, 2020
eb2aca7
Rollup merge of #75584 - RalfJung:union-no-deref, r=matthewjasper
Dylan-DPC Sep 4, 2020
0ad0fee
Rollup merge of #75695 - JohnTitor:regression-test, r=Dylan-DPC
Dylan-DPC Sep 4, 2020
e818838
Rollup merge of #75741 - workingjubilee:refactor-byteorder, r=matthew…
Dylan-DPC Sep 4, 2020
9178eb0
Rollup merge of #75872 - mati865:pgo-tests, r=petrochenkov
Dylan-DPC Sep 4, 2020
6920100
Rollup merge of #75888 - GuillaumeGomez:trait-impl-assoc-const-doc-al…
Dylan-DPC Sep 4, 2020
8528e20
Rollup merge of #75954 - ArekPiekarz:unstable_book_ffi_tracking_issue…
Dylan-DPC Sep 4, 2020
e3e4705
Rollup merge of #75994 - mental32:impl-rc-new-cyclic, r=KodrAus
Dylan-DPC Sep 4, 2020
aeaecbe
Rollup merge of #76060 - pickfire:patch-12, r=jyn514
Dylan-DPC Sep 4, 2020
07a6c2c
Rollup merge of #76078 - jyn514:no-disambiguator, r=manishearth
Dylan-DPC Sep 4, 2020
aa6f881
Rollup merge of #76082 - jyn514:top-level-links, r=ollie27,GuillaumeG…
Dylan-DPC Sep 4, 2020
b3850fa
Rollup merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAus
Dylan-DPC Sep 4, 2020
62ffaad
Rollup merge of #76229 - camelid:patch-3, r=jonas-schievink
Dylan-DPC Sep 4, 2020
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,15 @@ jobs:
- name: x86_64-mingw-1
env:
SCRIPT: make ci-mingw-subset-1
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu"
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu --enable-profiler"
CUSTOM_MINGW: 1
NO_DEBUG_ASSERTIONS: 1
NO_LLVM_ASSERTIONS: 1
os: windows-latest-xl
- name: x86_64-mingw-2
env:
SCRIPT: make ci-mingw-subset-2
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu"
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu --enable-profiler"
CUSTOM_MINGW: 1
os: windows-latest-xl
- name: dist-x86_64-msvc
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3720,7 +3720,6 @@ name = "rustc_middle"
version = "0.0.0"
dependencies = [
"bitflags",
"byteorder",
"chalk-ir",
"measureme",
"polonius-engine",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ The Rust community congregates in a few places:
If you are interested in contributing to the Rust project, please take a look
at the [Getting Started][gettingstarted] guide in the [rustc-dev-guide].

[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org

## License

Rust is primarily distributed under the terms of both the MIT license
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ rustc_index = { path = "../rustc_index" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
byteorder = { version = "1.3" }
chalk-ir = "0.14.0"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
measureme = "0.7.1"
Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {

/// Reads a *non-ZST* scalar.
///
/// ZSTs can't be read for two reasons:
/// * byte-order cannot work with zero-element buffers;
/// * in order to obtain a `Pointer`, we need to check for ZSTness anyway due to integer
/// pointers being valid for ZSTs.
/// ZSTs can't be read because in order to obtain a `Pointer`, we need to check
/// for ZSTness anyway due to integer pointers being valid for ZSTs.
///
/// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to call `InterpCx::read_scalar` instead of this method.
Expand Down Expand Up @@ -397,10 +395,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {

/// Writes a *non-ZST* scalar.
///
/// ZSTs can't be read for two reasons:
/// * byte-order cannot work with zero-element buffers;
/// * in order to obtain a `Pointer`, we need to check for ZSTness anyway due to integer
/// pointers being valid for ZSTs.
/// ZSTs can't be read because in order to obtain a `Pointer`, we need to check
/// for ZSTness anyway due to integer pointers being valid for ZSTs.
///
/// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to call `InterpCx::write_scalar` instead of this method.
Expand Down
32 changes: 23 additions & 9 deletions compiler/rustc_middle/src/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ mod value;
use std::convert::TryFrom;
use std::fmt;
use std::io;
use std::io::{Read, Write};
use std::num::NonZeroU32;
use std::sync::atomic::{AtomicU32, Ordering};

use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt};
use rustc_ast::LitKind;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::{HashMapExt, Lock};
Expand Down Expand Up @@ -561,19 +561,33 @@ pub fn write_target_uint(
mut target: &mut [u8],
data: u128,
) -> Result<(), io::Error> {
let len = target.len();
// This u128 holds an "any-size uint" (since smaller uints can fits in it)
// So we do not write all bytes of the u128, just the "payload".
match endianness {
Endian::Little => target.write_uint128::<LittleEndian>(data, len),
Endian::Big => target.write_uint128::<BigEndian>(data, len),
}
Endian::Little => target.write(&data.to_le_bytes())?,
Endian::Big => target.write(&data.to_be_bytes()[16 - target.len()..])?,
};
debug_assert!(target.len() == 0); // We should have filled the target buffer.
Ok(())
}

#[inline]
pub fn read_target_uint(endianness: Endian, mut source: &[u8]) -> Result<u128, io::Error> {
match endianness {
Endian::Little => source.read_uint128::<LittleEndian>(source.len()),
Endian::Big => source.read_uint128::<BigEndian>(source.len()),
}
// This u128 holds an "any-size uint" (since smaller uints can fits in it)
let mut buf = [0u8; std::mem::size_of::<u128>()];
// So we do not read exactly 16 bytes into the u128, just the "payload".
let uint = match endianness {
Endian::Little => {
source.read(&mut buf)?;
Ok(u128::from_le_bytes(buf))
}
Endian::Big => {
source.read(&mut buf[16 - source.len()..])?;
Ok(u128::from_be_bytes(buf))
}
};
debug_assert!(source.len() == 0); // We should have consumed the source buffer.
uint
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,23 @@ impl CheckAttrVisitor<'tcx> {
None
}
}
Target::AssocConst => {
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
// We can't link to trait impl's consts.
let err = "associated constant in trait implementation block";
match containing_item.kind {
ItemKind::Impl { of_trait: Some(_), .. } => Some(err),
_ => None,
}
}
_ => None,
} {
self.tcx
.sess
.struct_span_err(
meta.span(),
&format!("`#[doc(alias = \"...\")]` isn't allowed on {}", err,),
&format!("`#[doc(alias = \"...\")]` isn't allowed on {}", err),
)
.emit();
}
Expand Down
27 changes: 25 additions & 2 deletions compiler/rustc_typeck/src/check/place_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Convert auto-derefs, indices, etc of an expression from `Deref` and `Index`
/// into `DerefMut` and `IndexMut` respectively.
///
/// This is a second pass of typechecking derefs/indices. We need this we do not
/// This is a second pass of typechecking derefs/indices. We need this because we do not
/// always know whether a place needs to be mutable or not in the first pass.
/// This happens whether there is an implicit mutable reborrow, e.g. when the type
/// is used as the receiver of a method call.
Expand All @@ -211,13 +211,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
debug!("convert_place_derefs_to_mutable: exprs={:?}", exprs);

// Fix up autoderefs and derefs.
let mut inside_union = false;
for (i, &expr) in exprs.iter().rev().enumerate() {
debug!("convert_place_derefs_to_mutable: i={} expr={:?}", i, expr);

let mut source = self.node_ty(expr.hir_id);
if matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::UnDeref, _)) {
// Clear previous flag; after a pointer indirection it does not apply any more.
inside_union = false;
}
if source.ty_adt_def().map_or(false, |adt| adt.is_union()) {
inside_union = true;
}
// Fix up the autoderefs. Autorefs can only occur immediately preceding
// overloaded place ops, and will be fixed by them in order to get
// the correct region.
let mut source = self.node_ty(expr.hir_id);
// Do not mutate adjustments in place, but rather take them,
// and replace them after mutating them, to avoid having the
// typeck results borrowed during (`deref_mut`) method resolution.
Expand All @@ -236,6 +244,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let ty::Ref(region, _, mutbl) = *method.sig.output().kind() {
*deref = OverloadedDeref { region, mutbl };
}
// If this is a union field, also throw an error for `DerefMut` of `ManuallyDrop` (see RFC 2514).
// This helps avoid accidental drops.
if inside_union
&& source.ty_adt_def().map_or(false, |adt| adt.is_manually_drop())
{
let mut err = self.tcx.sess.struct_span_err(
expr.span,
"not automatically applying `DerefMut` on `ManuallyDrop` union field",
);
err.help(
"writing to this reference calls the destructor for the old value",
);
err.help("add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor");
err.emit();
}
}
}
source = adjustment.target;
Expand Down
Loading