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 10 pull requests #75383

Merged
merged 47 commits into from
Aug 11, 2020
Merged
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
ef29161
make parts of rustc_typeck public
Ryan1729 Aug 3, 2020
5565c1a
run cargo dev new_lint then move transmutes_expressible_as_ptr_casts …
Ryan1729 Aug 3, 2020
0c37239
make InheritedBuilder::enter public
Ryan1729 Aug 3, 2020
b4e6e70
initial compiling version of TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS
Ryan1729 Aug 3, 2020
7061b1c
write currently failing test for transmutes_expressible_as_ptr_casts
Ryan1729 Aug 3, 2020
b4ecee9
accidentally cause an ICE by putting the TRANSMUTES_EXPRESSIBLE_AS_PT…
Ryan1729 Aug 3, 2020
1e5c14d
try putting the can_be_expressed_as_pointer_cast at the top and find …
Ryan1729 Aug 3, 2020
7a818c0
get the expected number of errors by acknowledging that other lints a…
Ryan1729 Aug 3, 2020
ab93133
address some review comments
Ryan1729 Aug 4, 2020
6fdd1db
add description to assert
Ryan1729 Aug 4, 2020
8ba4101
add documentation to functions that call `do_check` and add a test ag…
Ryan1729 Aug 6, 2020
afd4909
add extra error message to the expected stderr for transmutes_express…
Ryan1729 Aug 6, 2020
5447247
change filter to assert, and update comments
Ryan1729 Aug 6, 2020
e3170bb
add newline to transmutes_expressible_as_ptr_casts.rs
Ryan1729 Aug 6, 2020
4027f15
run ./x.py fmt
Ryan1729 Aug 6, 2020
007dc94
run clippy_dev update_lints
Ryan1729 Aug 6, 2020
32691da
run clippy_dev fmt
Ryan1729 Aug 6, 2020
d897fd2
Apply suggestions from code review
Ryan1729 Aug 6, 2020
c04c4cb
copy over *.fixed file
Ryan1729 Aug 7, 2020
48a6c21
Only add a border for the rust logo
GuillaumeGomez Aug 7, 2020
b21a3de
Don't try to use wasm intrinsics on vectors
alexcrichton Aug 9, 2020
b02bf05
update stderr for transmutes_expressible_as_ptr_casts
Ryan1729 Aug 9, 2020
0fbf450
add a test example of where transmutes_expressible_as_ptr_casts shoul…
Ryan1729 Aug 9, 2020
58b8b11
fix unary minus on usize and unused variable errors in .fixed file
Ryan1729 Aug 9, 2020
d2e7293
add allow unused_unsafe and allow dead_code
Ryan1729 Aug 9, 2020
2627eed
Avoid deleting temporary files on error
Mark-Simulacrum Aug 9, 2020
bff69c9
move const_eval error reporting logic into rustc_mir::const_eval::error
RalfJung Aug 9, 2020
fd41bde
instance: only polymorphize upvar substs
davidtwco Aug 9, 2020
a0e0575
evaluate required_consts when pushing stack frame in Miri engine
RalfJung Aug 9, 2020
1fa7203
bless MIR
RalfJung Aug 9, 2020
7dba693
Use intra-doc links
denisvasilik Aug 9, 2020
fd3851a
add test for unused erroneous const in CTFE
RalfJung Aug 10, 2020
4ed0c6a
Use existing `infcx` when emitting trait impl diagnostic
Aaron1011 Aug 10, 2020
a34bc79
Add help button
GuillaumeGomez Aug 10, 2020
d7e7271
Remove AsRef link as it is in the prelude
denisvasilik Aug 10, 2020
f260462
Remove links that are in scope
denisvasilik Aug 10, 2020
eea8581
Use intra-doc links
denisvasilik Aug 10, 2020
63d1e37
Rollup merge of #75098 - Ryan1729:clippy-pointer-cast-lint-experiment…
Dylan-DPC Aug 10, 2020
2ad7c16
Rollup merge of #75249 - GuillaumeGomez:rust-logo-border, r=Manishearth
Dylan-DPC Aug 10, 2020
992988b
Rollup merge of #75315 - Mark-Simulacrum:save-temps, r=ecstatic-morse
Dylan-DPC Aug 10, 2020
2932638
Rollup merge of #75316 - alexcrichton:fix-wasm-simd, r=oli-obk
Dylan-DPC Aug 10, 2020
1e41af3
Rollup merge of #75337 - davidtwco:polymorphization-75255-fixes, r=eddyb
Dylan-DPC Aug 10, 2020
9edec57
Rollup merge of #75339 - RalfJung:eval-required, r=oli-obk
Dylan-DPC Aug 10, 2020
dff868e
Rollup merge of #75363 - Aaron1011:fix/diag-infcx, r=lcnr
Dylan-DPC Aug 10, 2020
51ed33d
Rollup merge of #75366 - GuillaumeGomez:help-button, r=jyn514
Dylan-DPC Aug 10, 2020
d00c703
Rollup merge of #75369 - denisvasilik:intra-doc-links-core-borrow, r=…
Dylan-DPC Aug 10, 2020
0a738d4
Rollup merge of #75379 - denisvasilik:intra-docs-links-core-cmp, r=Dy…
Dylan-DPC Aug 10, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3367,6 +3367,7 @@ dependencies = [
"smallvec 1.4.0",
"stable_deref_trait",
"stacker",
"tempfile",
"tracing",
"winapi 0.3.8",
]
Expand Down
11 changes: 4 additions & 7 deletions library/core/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
/// provide a reference to related type `T`, it is often better to use
/// [`AsRef<T>`] as more types can safely implement it.
///
/// [`AsRef<T>`]: ../../std/convert/trait.AsRef.html
/// [`BorrowMut<T>`]: trait.BorrowMut.html
/// [`BorrowMut<T>`]: BorrowMut
/// [`Box<T>`]: ../../std/boxed/struct.Box.html
/// [`Mutex<T>`]: ../../std/sync/struct.Mutex.html
/// [`Rc<T>`]: ../../std/rc/struct.Rc.html
/// [`str`]: ../../std/primitive.str.html
/// [`String`]: ../../std/string/struct.String.html
/// [`borrow`]: #tymethod.borrow
/// [`borrow`]: Borrow::borrow
///
/// # Examples
///
Expand Down Expand Up @@ -152,10 +150,9 @@
/// If it wants to allow others access to the underlying `str`, it can do
/// that via `AsRef<str>` which doesn’t carry any extra requirements.
///
/// [`Hash`]: ../../std/hash/trait.Hash.html
/// [`Hash`]: crate::hash::Hash
/// [`HashMap<K, V>`]: ../../std/collections/struct.HashMap.html
/// [`String`]: ../../std/string/struct.String.html
/// [`str`]: ../../std/primitive.str.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Borrow<Borrowed: ?Sized> {
/// Immutably borrows from an owned value.
Expand Down Expand Up @@ -187,7 +184,7 @@ pub trait Borrow<Borrowed: ?Sized> {
/// an underlying type by providing a mutable reference. See [`Borrow<T>`]
/// for more information on borrowing as another type.
///
/// [`Borrow<T>`]: trait.Borrow.html
/// [`Borrow<T>`]: Borrow
#[stable(feature = "rust1", since = "1.0.0")]
pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
/// Mutably borrows from an owned value.
Expand Down
10 changes: 2 additions & 8 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@
//!
//! For more details, see the respective documentation of each item in the list.
//!
//! [`Eq`]: trait.Eq.html
//! [`PartialEq`]: trait.PartialEq.html
//! [`Ord`]: trait.Ord.html
//! [`PartialOrd`]: trait.PartialOrd.html
//! [`Ordering`]: enum.Ordering.html
//! [`Reverse`]: struct.Reverse.html
//! [`max`]: fn.max.html
//! [`min`]: fn.min.html
//! [`max`]: Ord::max
//! [`min`]: Ord::min

#![stable(feature = "rust1", since = "1.0.0")]

Expand Down
55 changes: 31 additions & 24 deletions src/librustc_codegen_llvm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,20 +728,25 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
// codegen. Note that this has a semantic difference in that the
// intrinsic can trap whereas `fptoui` never traps. That difference,
// however, is handled by `fptosui_may_trap` above.
//
// Note that we skip the wasm intrinsics for vector types where `fptoui`
// must be used instead.
if self.wasm_and_missing_nontrapping_fptoint() {
let src_ty = self.cx.val_ty(val);
let float_width = self.cx.float_width(src_ty);
let int_width = self.cx.int_width(dest_ty);
let name = match (int_width, float_width) {
(32, 32) => Some("llvm.wasm.trunc.unsigned.i32.f32"),
(32, 64) => Some("llvm.wasm.trunc.unsigned.i32.f64"),
(64, 32) => Some("llvm.wasm.trunc.unsigned.i64.f32"),
(64, 64) => Some("llvm.wasm.trunc.unsigned.i64.f64"),
_ => None,
};
if let Some(name) = name {
let intrinsic = self.get_intrinsic(name);
return self.call(intrinsic, &[val], None);
if self.cx.type_kind(src_ty) != TypeKind::Vector {
let float_width = self.cx.float_width(src_ty);
let int_width = self.cx.int_width(dest_ty);
let name = match (int_width, float_width) {
(32, 32) => Some("llvm.wasm.trunc.unsigned.i32.f32"),
(32, 64) => Some("llvm.wasm.trunc.unsigned.i32.f64"),
(64, 32) => Some("llvm.wasm.trunc.unsigned.i64.f32"),
(64, 64) => Some("llvm.wasm.trunc.unsigned.i64.f64"),
_ => None,
};
if let Some(name) = name {
let intrinsic = self.get_intrinsic(name);
return self.call(intrinsic, &[val], None);
}
}
}
unsafe { llvm::LLVMBuildFPToUI(self.llbuilder, val, dest_ty, UNNAMED) }
Expand All @@ -750,18 +755,20 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
fn fptosi(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
if self.wasm_and_missing_nontrapping_fptoint() {
let src_ty = self.cx.val_ty(val);
let float_width = self.cx.float_width(src_ty);
let int_width = self.cx.int_width(dest_ty);
let name = match (int_width, float_width) {
(32, 32) => Some("llvm.wasm.trunc.signed.i32.f32"),
(32, 64) => Some("llvm.wasm.trunc.signed.i32.f64"),
(64, 32) => Some("llvm.wasm.trunc.signed.i64.f32"),
(64, 64) => Some("llvm.wasm.trunc.signed.i64.f64"),
_ => None,
};
if let Some(name) = name {
let intrinsic = self.get_intrinsic(name);
return self.call(intrinsic, &[val], None);
if self.cx.type_kind(src_ty) != TypeKind::Vector {
let float_width = self.cx.float_width(src_ty);
let int_width = self.cx.int_width(dest_ty);
let name = match (int_width, float_width) {
(32, 32) => Some("llvm.wasm.trunc.signed.i32.f32"),
(32, 64) => Some("llvm.wasm.trunc.signed.i32.f64"),
(64, 32) => Some("llvm.wasm.trunc.signed.i64.f32"),
(64, 64) => Some("llvm.wasm.trunc.signed.i64.f64"),
_ => None,
};
if let Some(name) = name {
let intrinsic = self.get_intrinsic(name);
return self.call(intrinsic, &[val], None);
}
}
}
unsafe { llvm::LLVMBuildFPToSI(self.llbuilder, val, dest_ty, UNNAMED) }
Expand Down
39 changes: 15 additions & 24 deletions src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_fs_util::fix_windows_verbatim_for_gcc;
use rustc_hir::def_id::CrateNum;
use rustc_middle::middle::cstore::{EncodedMetadata, LibSource, NativeLib};
Expand All @@ -23,7 +24,7 @@ use super::rpath::{self, RPathConfig};
use crate::{looks_like_rust_object_file, CodegenResults, CrateInfo, METADATA_FILENAME};

use cc::windows_registry;
use tempfile::{Builder as TempFileBuilder, TempDir};
use tempfile::Builder as TempFileBuilder;

use std::ffi::OsString;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -70,35 +71,29 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
}
});

let tmpdir = TempFileBuilder::new()
.prefix("rustc")
.tempdir()
.unwrap_or_else(|err| sess.fatal(&format!("couldn't create a temp dir: {}", err)));

if outputs.outputs.should_codegen() {
let tmpdir = TempFileBuilder::new()
.prefix("rustc")
.tempdir()
.unwrap_or_else(|err| sess.fatal(&format!("couldn't create a temp dir: {}", err)));
let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps);
let out_filename = out_filename(sess, crate_type, outputs, crate_name);
match crate_type {
CrateType::Rlib => {
let _timer = sess.timer("link_rlib");
link_rlib::<B>(
sess,
codegen_results,
RlibFlavor::Normal,
&out_filename,
&tmpdir,
)
.build();
link_rlib::<B>(sess, codegen_results, RlibFlavor::Normal, &out_filename, &path)
.build();
}
CrateType::Staticlib => {
link_staticlib::<B>(sess, codegen_results, &out_filename, &tmpdir);
link_staticlib::<B>(sess, codegen_results, &out_filename, &path);
}
_ => {
link_natively::<B>(
sess,
crate_type,
&out_filename,
codegen_results,
tmpdir.path(),
path.as_ref(),
target_cpu,
);
}
Expand All @@ -107,10 +102,6 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename, "link");
}
}

if sess.opts.cg.save_temps {
let _ = tmpdir.into_path();
}
}

// Remove the temporary object file and metadata if we aren't saving temps
Expand Down Expand Up @@ -279,8 +270,8 @@ pub fn each_linked_rlib(
/// building an `.rlib` (stomping over one another), or writing an `.rmeta` into a
/// directory being searched for `extern crate` (observing an incomplete file).
/// The returned path is the temporary file containing the complete metadata.
pub fn emit_metadata(sess: &Session, metadata: &EncodedMetadata, tmpdir: &TempDir) -> PathBuf {
let out_filename = tmpdir.path().join(METADATA_FILENAME);
pub fn emit_metadata(sess: &Session, metadata: &EncodedMetadata, tmpdir: &MaybeTempDir) -> PathBuf {
let out_filename = tmpdir.as_ref().join(METADATA_FILENAME);
let result = fs::write(&out_filename, &metadata.raw_data);

if let Err(e) = result {
Expand All @@ -301,7 +292,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
codegen_results: &CodegenResults,
flavor: RlibFlavor,
out_filename: &Path,
tmpdir: &TempDir,
tmpdir: &MaybeTempDir,
) -> B {
info!("preparing rlib to {:?}", out_filename);
let mut ab = <B as ArchiveBuilder>::new(sess, out_filename, None);
Expand Down Expand Up @@ -406,7 +397,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
sess: &'a Session,
codegen_results: &CodegenResults,
out_filename: &Path,
tempdir: &TempDir,
tempdir: &MaybeTempDir,
) {
let mut ab =
link_rlib::<B>(sess, codegen_results, RlibFlavor::StaticlibBase, out_filename, tempdir);
Expand Down
1 change: 1 addition & 0 deletions src/librustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bitflags = "1.2.1"
measureme = "0.7.1"
libc = "0.2"
stacker = "0.1.9"
tempfile = "3.0.5"

[dependencies.parking_lot]
version = "0.10"
Expand Down
1 change: 1 addition & 0 deletions src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub mod vec_linked_list;
pub mod work_queue;
pub use atomic_ref::AtomicRef;
pub mod frozen;
pub mod temp_dir;

pub struct OnDrop<F: Fn()>(pub F);

Expand Down
34 changes: 34 additions & 0 deletions src/librustc_data_structures/temp_dir.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::mem::ManuallyDrop;
use std::path::Path;
use tempfile::TempDir;

/// This is used to avoid TempDir being dropped on error paths unintentionally.
#[derive(Debug)]
pub struct MaybeTempDir {
dir: ManuallyDrop<TempDir>,
// Whether the TempDir should be deleted on drop.
keep: bool,
}

impl Drop for MaybeTempDir {
fn drop(&mut self) {
// Safety: We are in the destructor, and no further access will
// occur.
let dir = unsafe { ManuallyDrop::take(&mut self.dir) };
if self.keep {
dir.into_path();
}
}
}

impl AsRef<Path> for MaybeTempDir {
fn as_ref(&self) -> &Path {
self.dir.path()
}
}

impl MaybeTempDir {
pub fn new(dir: TempDir, keep_on_drop: bool) -> MaybeTempDir {
MaybeTempDir { dir: ManuallyDrop::new(dir), keep: keep_on_drop }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::{Subtype, TyCtxtInferExt, ValuePairs};
use crate::infer::{Subtype, ValuePairs};
use crate::traits::ObligationCauseCode::CompareImplMethodObligation;
use rustc_errors::ErrorReported;
use rustc_hir as hir;
Expand Down Expand Up @@ -53,7 +53,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
}

fn emit_err(&self, sp: Span, expected: Ty<'tcx>, found: Ty<'tcx>, trait_def_id: DefId) {
let tcx = self.tcx();
let trait_sp = self.tcx().def_span(trait_def_id);
let mut err = self
.tcx()
Expand Down Expand Up @@ -85,9 +84,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
);
}

if let Some((expected, found)) = tcx
.infer_ctxt()
.enter(|infcx| infcx.expected_found_str_ty(&ExpectedFound { expected, found }))
if let Some((expected, found)) =
self.infcx.expected_found_str_ty(&ExpectedFound { expected, found })
{
// Highlighted the differences when showing the "expected/found" note.
err.note_expected_found(&"", expected, &"", found);
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use rustc_ast::{self, ast, visit};
use rustc_codegen_ssa::back::link::emit_metadata;
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::sync::{par_iter, Lrc, OnceCell, ParallelIterator, WorkerLocal};
use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_data_structures::{box_region_allow_access, declare_box_region_type, parallel};
use rustc_errors::{ErrorReported, PResult};
use rustc_expand::base::ExtCtxt;
Expand Down Expand Up @@ -974,6 +975,7 @@ fn encode_and_write_metadata(
.prefix("rmeta")
.tempdir_in(out_filename.parent().unwrap())
.unwrap_or_else(|err| tcx.sess.fatal(&format!("couldn't create a temp dir: {}", err)));
let metadata_tmpdir = MaybeTempDir::new(metadata_tmpdir, tcx.sess.opts.cg.save_temps);
let metadata_filename = emit_metadata(tcx.sess, &metadata, &metadata_tmpdir);
if let Err(e) = fs::rename(&metadata_filename, &out_filename) {
tcx.sess.fatal(&format!("failed to write {}: {}", out_filename.display(), e));
Expand Down
Loading