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 #78197

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7b652d3
Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling
nielx Sep 19, 2020
cc0b718
Mark inout asm! operands as used in liveness pass
oliviacrain Oct 15, 2020
fd193f2
Treat InOut variables like other input variables
oliviacrain Oct 17, 2020
4e2c59a
Greatly improve display for small mobile devices screens
GuillaumeGomez Oct 18, 2020
17c6c59
Mark InOut operands as used in RWU table with write_place
oliviacrain Oct 19, 2020
8f0bced
Refactor liveness-issue-77915 to liveness-asm and improve tests
oliviacrain Oct 19, 2020
d80f127
Avoid panic_bounds_check in fmt::write.
m-ou-se Oct 19, 2020
c647735
rustc_lint: remove unused to_string
est31 Oct 20, 2020
00d23cf
Make {u,}int_range functions a bit nicer
est31 Oct 20, 2020
fa09404
Fix build failure of rustfmt
bishtpawan Oct 20, 2020
ea24395
Add debug_asserts for the unsafe indexing in fmt::write.
m-ou-se Oct 20, 2020
5948e62
Sync LLVM submodule if it has been initialized
est31 Oct 20, 2020
356d5b5
Add test to check for fmt::write bloat.
m-ou-se Oct 20, 2020
e852a4a
Update cargo
ehuss Oct 20, 2020
3adac03
Add test case for #77062
wesleywiser Oct 21, 2020
2720b2d
Limit liveness-asm tests to x86_64
oliviacrain Oct 21, 2020
dc29c7a
Bless liveness-asm output
oliviacrain Oct 21, 2020
7f58477
Fix formatting
bishtpawan Oct 21, 2020
51de590
Add tracking issue number for pin_static_ref.
m-ou-se Oct 21, 2020
6fdb31a
Rollup merge of #77976 - oliviacrain:issue-77915-fix, r=matthewjasper
jonas-schievink Oct 21, 2020
d8545bf
Rollup merge of #78009 - nielx:fix/CMAKE_SYSTEM_NAME, r=Mark-Simulacrum
jonas-schievink Oct 21, 2020
6126d4e
Rollup merge of #78084 - GuillaumeGomez:improve-mobile-display, r=jyn…
jonas-schievink Oct 21, 2020
525c35c
Rollup merge of #78122 - fusion-engineering-forks:fmt-write-bounds-ch…
jonas-schievink Oct 21, 2020
60298b2
Rollup merge of #78153 - est31:downloaded_llvm_maybe_sync, r=Mark-Sim…
jonas-schievink Oct 21, 2020
e203d96
Rollup merge of #78155 - est31:rustc_lint_types_refactor, r=davidtwco
jonas-schievink Oct 21, 2020
599f553
Rollup merge of #78156 - bishtpawan:bugfix/rustfmt-no-longer-builds, …
jonas-schievink Oct 21, 2020
56d4032
Rollup merge of #78169 - ehuss:update-cargo, r=ehuss
jonas-schievink Oct 21, 2020
dd77265
Rollup merge of #78172 - wesleywiser:close_77062, r=oli-obk
jonas-schievink Oct 21, 2020
891f3f7
Rollup merge of #78188 - fusion-engineering-forks:static-ref-tracking…
jonas-schievink Oct 21, 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
15 changes: 14 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ dependencies = [
"crypto-hash",
"curl",
"curl-sys",
"env_logger 0.7.1",
"env_logger 0.8.1",
"filetime",
"flate2",
"fwdansi",
Expand Down Expand Up @@ -1035,6 +1035,19 @@ dependencies = [
"termcolor",
]

[[package]]
name = "env_logger"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd"
dependencies = [
"atty",
"humantime 2.0.1",
"log",
"regex",
"termcolor",
]

[[package]]
name = "error_index_generator"
version = "0.0.0"
Expand Down
35 changes: 18 additions & 17 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ fn lint_overflowing_range_endpoint<'tcx>(
// We need to preserve the literal's suffix,
// as it may determine typing information.
let suffix = match lit.node {
LitKind::Int(_, LitIntType::Signed(s)) => s.name_str().to_string(),
LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str().to_string(),
LitKind::Int(_, LitIntType::Unsuffixed) => "".to_string(),
LitKind::Int(_, LitIntType::Signed(s)) => s.name_str(),
LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str(),
LitKind::Int(_, LitIntType::Unsuffixed) => "",
_ => bug!(),
};
let suggestion = format!("{}..={}{}", start, lit_val - 1, suffix);
Expand All @@ -170,24 +170,25 @@ fn lint_overflowing_range_endpoint<'tcx>(
// warnings are consistent between 32- and 64-bit platforms.
fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) {
match int_ty {
ast::IntTy::Isize => (i64::MIN as i128, i64::MAX as i128),
ast::IntTy::I8 => (i8::MIN as i64 as i128, i8::MAX as i128),
ast::IntTy::I16 => (i16::MIN as i64 as i128, i16::MAX as i128),
ast::IntTy::I32 => (i32::MIN as i64 as i128, i32::MAX as i128),
ast::IntTy::I64 => (i64::MIN as i128, i64::MAX as i128),
ast::IntTy::I128 => (i128::MIN as i128, i128::MAX),
ast::IntTy::Isize => (i64::MIN.into(), i64::MAX.into()),
ast::IntTy::I8 => (i8::MIN.into(), i8::MAX.into()),
ast::IntTy::I16 => (i16::MIN.into(), i16::MAX.into()),
ast::IntTy::I32 => (i32::MIN.into(), i32::MAX.into()),
ast::IntTy::I64 => (i64::MIN.into(), i64::MAX.into()),
ast::IntTy::I128 => (i128::MIN, i128::MAX),
}
}

fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) {
match uint_ty {
ast::UintTy::Usize => (u64::MIN as u128, u64::MAX as u128),
ast::UintTy::U8 => (u8::MIN as u128, u8::MAX as u128),
ast::UintTy::U16 => (u16::MIN as u128, u16::MAX as u128),
ast::UintTy::U32 => (u32::MIN as u128, u32::MAX as u128),
ast::UintTy::U64 => (u64::MIN as u128, u64::MAX as u128),
ast::UintTy::U128 => (u128::MIN, u128::MAX),
}
let max = match uint_ty {
ast::UintTy::Usize => u64::MAX.into(),
ast::UintTy::U8 => u8::MAX.into(),
ast::UintTy::U16 => u16::MAX.into(),
ast::UintTy::U32 => u32::MAX.into(),
ast::UintTy::U64 => u64::MAX.into(),
ast::UintTy::U128 => u128::MAX,
};
(0, max)
}

fn get_bin_hex_repr(cx: &LateContext<'_>, lit: &hir::Lit) -> Option<String> {
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_mir_build/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> {

let func_ty = func.ty(body, tcx);
if let ty::FnDef(callee, substs) = *func_ty.kind() {
let (callee, call_substs) =
if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, substs) {
(instance.def_id(), instance.substs)
} else {
(callee, substs)
};
let normalized_substs = tcx.normalize_erasing_regions(param_env, substs);
let (callee, call_substs) = if let Ok(Some(instance)) =
Instance::resolve(tcx, param_env, callee, normalized_substs)
{
(instance.def_id(), instance.substs)
} else {
(callee, normalized_substs)
};

// FIXME(#57965): Make this work across function boundaries

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
hir::InlineAsmOperand::InOut { expr, .. } => {
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE);
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE | ACC_USE);
}
hir::InlineAsmOperand::SplitInOut { out_expr, .. } => {
if let Some(expr) = out_expr {
Expand Down
28 changes: 21 additions & 7 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,9 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
// a string piece.
for (arg, piece) in fmt.iter().zip(args.pieces.iter()) {
formatter.buf.write_str(*piece)?;
run(&mut formatter, arg, &args.args)?;
// SAFETY: arg and args.args come from the same Arguments,
// which guarantees the indexes are always within bounds.
unsafe { run(&mut formatter, arg, &args.args) }?;
idx += 1;
}
}
Expand All @@ -1096,25 +1098,37 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
Ok(())
}

fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV1<'_>]) -> Result {
unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV1<'_>]) -> Result {
fmt.fill = arg.format.fill;
fmt.align = arg.format.align;
fmt.flags = arg.format.flags;
fmt.width = getcount(args, &arg.format.width);
fmt.precision = getcount(args, &arg.format.precision);
// SAFETY: arg and args come from the same Arguments,
// which guarantees the indexes are always within bounds.
unsafe {
fmt.width = getcount(args, &arg.format.width);
fmt.precision = getcount(args, &arg.format.precision);
}

// Extract the correct argument
let value = args[arg.position];
debug_assert!(arg.position < args.len());
// SAFETY: arg and args come from the same Arguments,
// which guarantees its index is always within bounds.
let value = unsafe { args.get_unchecked(arg.position) };

// Then actually do some printing
(value.formatter)(value.value, fmt)
}

fn getcount(args: &[ArgumentV1<'_>], cnt: &rt::v1::Count) -> Option<usize> {
unsafe fn getcount(args: &[ArgumentV1<'_>], cnt: &rt::v1::Count) -> Option<usize> {
match *cnt {
rt::v1::Count::Is(n) => Some(n),
rt::v1::Count::Implied => None,
rt::v1::Count::Param(i) => args[i].as_usize(),
rt::v1::Count::Param(i) => {
debug_assert!(i < args.len());
// SAFETY: cnt and args come from the same Arguments,
// which guarantees this index is always within bounds.
unsafe { args.get_unchecked(i).as_usize() }
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ impl<T: ?Sized> Pin<&'static T> {
///
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
/// never ends.
#[unstable(feature = "pin_static_ref", issue = "none")]
#[unstable(feature = "pin_static_ref", issue = "78186")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
// SAFETY: The 'static borrow guarantees the data will not be
Expand All @@ -800,7 +800,7 @@ impl<T: ?Sized> Pin<&'static mut T> {
///
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
/// never ends.
#[unstable(feature = "pin_static_ref", issue = "none")]
#[unstable(feature = "pin_static_ref", issue = "78186")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
// SAFETY: The 'static borrow guarantees the data will not be
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,10 +891,15 @@ def update_submodules(self):
).decode(default_encoding).splitlines()]
filtered_submodules = []
submodules_names = []
llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git"))
for module in submodules:
if module.endswith("llvm-project"):
# Don't sync the llvm-project submodule either if an external LLVM
# was provided, or if we are downloading LLVM. Also, if the
# submodule has been initialized already, sync it anyways so that
# it doesn't mess up contributor pull requests.
if self.get_toml('llvm-config') or self.downloading_llvm():
if self.get_toml('lld') != 'true':
if self.get_toml('lld') != 'true' and not llvm_checked_out:
continue
check = self.check_submodule(module, slow_submodules)
filtered_submodules.append((module, check))
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ fn configure_cmake(
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
} else if target.contains("windows") {
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
} else if target.contains("haiku") {
cfg.define("CMAKE_SYSTEM_NAME", "Haiku");
}
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
// that case like CMake we cannot easily determine system version either.
Expand Down
35 changes: 35 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,41 @@ h4 > .notable-traits {
#titles, #titles > div {
height: 73px;
}

#main > table:not(.table-display) td {
word-break: break-word;
min-width: 10%;
}

.search-container > div {
display: block;
width: calc(100% - 37px);
}

#crate-search {
width: 100%;
border-radius: 4px;
border: 0;
}

#crate-search + .search-input {
width: calc(100% + 71px);
margin-left: -36px;
}

#theme-picker, #settings-menu {
padding: 5px;
width: 31px;
height: 31px;
}

#theme-picker {
margin-top: -2px;
}

#settings-menu {
top: 7px;
}
}

h3.notable {
Expand Down
7 changes: 7 additions & 0 deletions src/test/run-make/fmt-write-bloat/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-include ../../run-make-fulldeps/tools.mk

NM=nm

all: main.rs
$(RUSTC) $< -O
$(NM) $(call RUN_BINFILE,main) | $(CGREP) -v panicking panic_fmt panic_bounds_check pad_integral Display Debug
32 changes: 32 additions & 0 deletions src/test/run-make/fmt-write-bloat/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![feature(lang_items)]
#![feature(start)]
#![no_std]

use core::fmt;
use core::fmt::Write;

#[link(name = "c")]
extern "C" {}

struct Dummy;

impl fmt::Write for Dummy {
#[inline(never)]
fn write_str(&mut self, _: &str) -> fmt::Result {
Ok(())
}
}

#[start]
fn main(_: isize, _: *const *const u8) -> isize {
let _ = writeln!(Dummy, "Hello World");
0
}

#[lang = "eh_personality"]
fn eh_personality() {}

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
loop {}
}
5 changes: 5 additions & 0 deletions src/test/ui/consts/issue-77062-large-zst-array.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// build-pass

fn main() {
let _ = &[(); usize::MAX];
}
44 changes: 44 additions & 0 deletions src/test/ui/liveness/liveness-asm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Ensure inout asm! operands are marked as used by the liveness pass

// only-x86_64
// check-pass

#![feature(asm)]
#![allow(dead_code)]
#![warn(unused_assignments)]
#![warn(unused_variables)]

// Test the single inout case
unsafe fn f1(mut src: *const u8) {
asm!("/*{0}*/", inout(reg) src); //~ WARN value assigned to `src` is never read
}

unsafe fn f2(mut src: *const u8) -> *const u8 {
asm!("/*{0}*/", inout(reg) src);
src
}

// Test the split inout case
unsafe fn f3(mut src: *const u8) {
asm!("/*{0}*/", inout(reg) src => src); //~ WARN value assigned to `src` is never read
}

unsafe fn f4(mut src: *const u8) -> *const u8 {
asm!("/*{0}*/", inout(reg) src => src);
src
}

// Tests the use of field projections
struct S {
field: *mut u8,
}

unsafe fn f5(src: &mut S) {
asm!("/*{0}*/", inout(reg) src.field);
}

unsafe fn f6(src: &mut S) {
asm!("/*{0}*/", inout(reg) src.field => src.field);
}

fn main() {}
23 changes: 23 additions & 0 deletions src/test/ui/liveness/liveness-asm.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
warning: value assigned to `src` is never read
--> $DIR/liveness-asm.rs:13:32
|
LL | asm!("/*{0}*/", inout(reg) src);
| ^^^
|
note: the lint level is defined here
--> $DIR/liveness-asm.rs:8:9
|
LL | #![warn(unused_assignments)]
| ^^^^^^^^^^^^^^^^^^
= help: maybe it is overwritten before being read?

warning: value assigned to `src` is never read
--> $DIR/liveness-asm.rs:23:39
|
LL | asm!("/*{0}*/", inout(reg) src => src);
| ^^^
|
= help: maybe it is overwritten before being read?

warning: 2 warnings emitted

2 changes: 1 addition & 1 deletion src/tools/cargo
Submodule cargo updated 84 files
+1 −1 Cargo.toml
+2 −2 ci/validate-man.sh
+6 −2 crates/cargo-test-support/src/lib.rs
+4 −6 crates/mdman/src/format/md.rs
+1 −1 crates/mdman/src/lib.rs
+14 −0 crates/mdman/tests/compare/expected/links.1
+22 −1 crates/mdman/tests/compare/expected/links.md
+10 −0 crates/mdman/tests/compare/expected/links.txt
+1 −1 crates/mdman/tests/compare/expected/options.md
+7 −0 crates/mdman/tests/compare/includes/links-include.md
+14 −0 crates/mdman/tests/compare/links.md
+13 −1 src/bin/cargo/commands/run.rs
+175 −40 src/cargo/ops/cargo_compile.rs
+4 −0 src/cargo/ops/cargo_run.rs
+6 −1 src/cargo/util/command_prelude.rs
+6 −1 src/cargo/util/restricted_names.rs
+1 −1 src/doc/man/cargo-publish.md
+19 −6 src/doc/man/generated_txt/cargo-bench.txt
+19 −6 src/doc/man/generated_txt/cargo-build.txt
+19 −6 src/doc/man/generated_txt/cargo-check.txt
+11 −3 src/doc/man/generated_txt/cargo-doc.txt
+21 −7 src/doc/man/generated_txt/cargo-fix.txt
+1 −1 src/doc/man/generated_txt/cargo-publish.txt
+9 −4 src/doc/man/generated_txt/cargo-rustc.txt
+9 −4 src/doc/man/generated_txt/cargo-rustdoc.txt
+20 −7 src/doc/man/generated_txt/cargo-test.txt
+10 −2 src/doc/man/generated_txt/cargo-tree.txt
+2 −1 src/doc/man/includes/options-targets-lib-bin.md
+11 −4 src/doc/man/includes/options-targets.md
+8 −2 src/doc/man/includes/section-package-selection.md
+33 −19 src/doc/src/commands/cargo-bench.md
+32 −18 src/doc/src/commands/cargo-build.md
+32 −18 src/doc/src/commands/cargo-check.md
+9 −9 src/doc/src/commands/cargo-clean.md
+21 −14 src/doc/src/commands/cargo-doc.md
+7 −7 src/doc/src/commands/cargo-fetch.md
+33 −19 src/doc/src/commands/cargo-fix.md
+6 −6 src/doc/src/commands/cargo-generate-lockfile.md
+1 −1 src/doc/src/commands/cargo-help.md
+5 −5 src/doc/src/commands/cargo-init.md
+11 −11 src/doc/src/commands/cargo-install.md
+3 −3 src/doc/src/commands/cargo-locate-project.md
+5 −5 src/doc/src/commands/cargo-login.md
+5 −5 src/doc/src/commands/cargo-metadata.md
+5 −5 src/doc/src/commands/cargo-new.md
+7 −7 src/doc/src/commands/cargo-owner.md
+10 −10 src/doc/src/commands/cargo-package.md
+5 −5 src/doc/src/commands/cargo-pkgid.md
+16 −16 src/doc/src/commands/cargo-publish.md
+11 −11 src/doc/src/commands/cargo-run.md
+24 −16 src/doc/src/commands/cargo-rustc.md
+24 −16 src/doc/src/commands/cargo-rustdoc.md
+4 −4 src/doc/src/commands/cargo-search.md
+32 −18 src/doc/src/commands/cargo-test.md
+14 −8 src/doc/src/commands/cargo-tree.md
+5 −5 src/doc/src/commands/cargo-uninstall.md
+6 −6 src/doc/src/commands/cargo-update.md
+5 −5 src/doc/src/commands/cargo-vendor.md
+5 −5 src/doc/src/commands/cargo-verify-project.md
+1 −1 src/doc/src/commands/cargo-version.md
+7 −7 src/doc/src/commands/cargo-yank.md
+36 −36 src/doc/src/commands/cargo.md
+21 −7 src/etc/man/cargo-bench.1
+21 −7 src/etc/man/cargo-build.1
+21 −7 src/etc/man/cargo-check.1
+10 −3 src/etc/man/cargo-doc.1
+21 −7 src/etc/man/cargo-fix.1
+6 −6 src/etc/man/cargo-metadata.1
+1 −1 src/etc/man/cargo-publish.1
+13 −5 src/etc/man/cargo-rustc.1
+13 −5 src/etc/man/cargo-rustdoc.1
+21 −7 src/etc/man/cargo-test.1
+8 −2 src/etc/man/cargo-tree.1
+102 −0 tests/testsuite/bench.rs
+220 −28 tests/testsuite/build.rs
+109 −1 tests/testsuite/check.rs
+108 −0 tests/testsuite/doc.rs
+535 −0 tests/testsuite/glob_targets.rs
+1 −0 tests/testsuite/main.rs
+10 −1 tests/testsuite/run.rs
+20 −0 tests/testsuite/rustc.rs
+20 −0 tests/testsuite/rustdoc.rs
+185 −4 tests/testsuite/test.rs
+40 −7 tests/testsuite/tree.rs