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

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
57ace0d
Ensures `make` tests run under /bin/dash, like CI, and fixes a Makefile
richkadel Feb 4, 2021
ca3a714
Set SHELL = /bin/dash only if it exists
richkadel Feb 6, 2021
471ed5f
Use ItemCtxt::to_ty
camsteffen Feb 10, 2021
883988b
RELEASES.md 1.50: Group platform support notes together
joshtriplett Feb 10, 2021
d3fea13
bootstrap: Locate llvm-dwp based on llvm-config bindir
dtolnay Feb 10, 2021
3c1d792
Only initialize what is used
bugadani Jan 17, 2021
a6d4137
Fix assosiated typo
therealprof Feb 10, 2021
d64b749
Allow casting mut array ref to mut ptr
osa1 Jan 28, 2021
f13bbea
Catch errors on localStorage setting failure
lovasoa Feb 10, 2021
16f0ccd
Fix getCurrentValue
lovasoa Feb 10, 2021
5034b50
bootstrap: fix wrong docs installation path
pietroalbini Feb 10, 2021
b16c54c
Rollup merge of #81129 - bugadani:lighter-move-errors, r=petrochenkov
JohnTitor Feb 11, 2021
e1f0108
Rollup merge of #81479 - osa1:issue24151, r=lcnr
JohnTitor Feb 11, 2021
3a1c146
Rollup merge of #81734 - richkadel:fixfordash, r=pnkfelix
JohnTitor Feb 11, 2021
7143db0
Rollup merge of #81947 - camsteffen:to-ty, r=jyn514
JohnTitor Feb 11, 2021
2d7d7b4
Rollup merge of #81954 - joshtriplett:release-notes-group-platform-no…
JohnTitor Feb 11, 2021
25f1a61
Rollup merge of #81955 - dtolnay:dwp, r=Mark-Simulacrum
JohnTitor Feb 11, 2021
a06ccef
Rollup merge of #81959 - therealprof:fix-typo, r=oli-obk
JohnTitor Feb 11, 2021
2b19246
Rollup merge of #81964 - lovasoa:patch-1, r=GuillaumeGomez
JohnTitor Feb 11, 2021
12be68c
Rollup merge of #81968 - pietroalbini:fix-doc-install-path, r=Mark-Si…
JohnTitor Feb 11, 2021
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 RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Compiler
- [Added tier 3\* support for the `armv5te-unknown-linux-uclibceabi` target.][78142]
- [Added tier 3 support for the `aarch64-apple-ios-macabi` target.][77484]
- [The `x86_64-unknown-freebsd` is now built with the full toolset.][79484]
- [Dropped support for all cloudabi targets.][78439]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.
Expand Down Expand Up @@ -77,7 +78,6 @@ Compatibility Notes
- [`#![test]` as an inner attribute is now considered unstable like other inner macro
attributes, and reports an error by default through the `soft_unstable` lint.][79003]
- [Overriding a `forbid` lint at the same level that it was set is now a hard error.][78864]
- [Dropped support for all cloudabi targets.][78439]
- [You can no longer intercept `panic!` calls by supplying your own macro.][78343] It's
recommended to use the `#[panic_handler]` attribute to provide your own implementation.
- [Semi-colons after item statements (e.g. `struct Foo {};`) now produce a warning.][78296]
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_data_structures/src/graph/dominators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ pub struct Dominators<N: Idx> {
}

impl<Node: Idx> Dominators<Node> {
pub fn dummy() -> Self {
Self { post_order_rank: IndexVec::new(), immediate_dominators: IndexVec::new() }
}

pub fn is_reachable(&self, node: Node) -> bool {
self.immediate_dominators[node].is_some()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
);
}

// Attempt to search similar mutable assosiated items for suggestion.
// Attempt to search similar mutable associated items for suggestion.
// In the future, attempt in all path but initially for RHS of for_loop
fn suggest_similar_mut_method_for_for_loop(&self, err: &mut DiagnosticBuilder<'_>) {
let hir = self.infcx.tcx.hir();
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_mir/src/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,14 @@ fn do_mir_borrowck<'a, 'tcx>(

for (idx, move_data_results) in promoted_errors {
let promoted_body = &promoted[idx];
let dominators = promoted_body.dominators();

if let Err((move_data, move_errors)) = move_data_results {
let mut promoted_mbcx = MirBorrowckCtxt {
infcx,
param_env,
body: promoted_body,
move_data: &move_data,
location_table: &LocationTable::new(promoted_body),
location_table, // no need to create a real one for the promoted, it is not used
movable_generator,
fn_self_span_reported: Default::default(),
locals_are_invalidated_at_exit,
Expand All @@ -288,7 +287,7 @@ fn do_mir_borrowck<'a, 'tcx>(
used_mut: Default::default(),
used_mut_upvars: SmallVec::new(),
borrow_set: Rc::clone(&borrow_set),
dominators,
dominators: Dominators::dummy(), // not used
upvars: Vec::new(),
local_names: IndexVec::from_elem(None, &promoted_body.local_decls),
region_names: RefCell::default(),
Expand Down
39 changes: 24 additions & 15 deletions compiler/rustc_mir/src/borrow_check/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2191,19 +2191,18 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
CastKind::Pointer(PointerCast::ArrayToPointer) => {
let ty_from = op.ty(body, tcx);

let opt_ty_elem = match ty_from.kind() {
ty::RawPtr(ty::TypeAndMut {
mutbl: hir::Mutability::Not,
ty: array_ty,
}) => match array_ty.kind() {
ty::Array(ty_elem, _) => Some(ty_elem),
_ => None,
},
let opt_ty_elem_mut = match ty_from.kind() {
ty::RawPtr(ty::TypeAndMut { mutbl: array_mut, ty: array_ty }) => {
match array_ty.kind() {
ty::Array(ty_elem, _) => Some((ty_elem, *array_mut)),
_ => None,
}
}
_ => None,
};

let ty_elem = match opt_ty_elem {
Some(ty_elem) => ty_elem,
let (ty_elem, ty_mut) = match opt_ty_elem_mut {
Some(ty_elem_mut) => ty_elem_mut,
None => {
span_mirbug!(
self,
Expand All @@ -2215,11 +2214,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
};

let ty_to = match ty.kind() {
ty::RawPtr(ty::TypeAndMut {
mutbl: hir::Mutability::Not,
ty: ty_to,
}) => ty_to,
let (ty_to, ty_to_mut) = match ty.kind() {
ty::RawPtr(ty::TypeAndMut { mutbl: ty_to_mut, ty: ty_to }) => {
(ty_to, *ty_to_mut)
}
_ => {
span_mirbug!(
self,
Expand All @@ -2231,6 +2229,17 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
};

if ty_to_mut == Mutability::Mut && ty_mut == Mutability::Not {
span_mirbug!(
self,
rvalue,
"ArrayToPointer cast from const {:?} to mut {:?}",
ty,
ty_to
);
return;
}

if let Err(terr) = self.sub_types(
ty_elem,
ty_to,
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_typeck/src/check/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
m_expr: ty::TypeAndMut<'tcx>,
m_cast: ty::TypeAndMut<'tcx>,
) -> Result<CastKind, CastError> {
// array-ptr-cast.

if m_expr.mutbl == hir::Mutability::Not && m_cast.mutbl == hir::Mutability::Not {
// array-ptr-cast: allow mut-to-mut, mut-to-const, const-to-const
if m_expr.mutbl == hir::Mutability::Mut || m_cast.mutbl == hir::Mutability::Not {
if let ty::Array(ety, _) = m_expr.ty.kind() {
// Due to the limitations of LLVM global constants,
// region pointers end up pointing at copies of
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl ItemCtxt<'tcx> {
ItemCtxt { tcx, item_def_id }
}

pub fn to_ty(&self, ast_ty: &'tcx hir::Ty<'tcx>) -> Ty<'tcx> {
pub fn to_ty(&self, ast_ty: &hir::Ty<'_>) -> Ty<'tcx> {
AstConv::ast_ty_to_ty(self, ast_ty)
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
let env_node_id = tcx.hir().get_parent_item(hir_ty.hir_id);
let env_def_id = tcx.hir().local_def_id(env_node_id);
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.to_def_id());

astconv::AstConv::ast_ty_to_ty(&item_cx, hir_ty)
item_cx.to_ty(hir_ty)
}

pub fn hir_trait_to_predicates<'tcx>(
Expand Down
7 changes: 5 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,11 @@ impl Step for Assemble {
let src_exe = exe("llvm-dwp", target_compiler.host);
let dst_exe = exe("rust-llvm-dwp", target_compiler.host);
let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host });
let llvm_bin_dir = llvm_config_bin.parent().unwrap();
builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
if !builder.config.dry_run {
let llvm_bin_dir = output(Command::new(llvm_config_bin).arg("--bindir"));
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
}
}

// Ensure that `libLLVM.so` ends up in the newly build compiler directory,
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn install_sh(
let prefix = default_path(&builder.config.prefix, "/usr/local");
let sysconfdir = prefix.join(default_path(&builder.config.sysconfdir, "/etc"));
let datadir = prefix.join(default_path(&builder.config.datadir, "share"));
let docdir = prefix.join(default_path(&builder.config.docdir, "share/doc"));
let docdir = prefix.join(default_path(&builder.config.docdir, "share/doc/rust"));
let mandir = prefix.join(default_path(&builder.config.mandir, "share/man"));
let libdir = prefix.join(default_path(&builder.config.libdir, "lib"));
let bindir = prefix.join(&builder.config.bindir); // Default in config.rs
Expand Down
31 changes: 8 additions & 23 deletions src/librustdoc/html/static/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,20 @@ function hasOwnProperty(obj, property) {
return Object.prototype.hasOwnProperty.call(obj, property);
}

function usableLocalStorage() {
// Check if the browser supports localStorage at all:
if (typeof Storage === "undefined") {
return false;
}
// Check if we can access it; this access will fail if the browser
// preferences deny access to localStorage, e.g., to prevent storage of
// "cookies" (or cookie-likes, as is the case here).
try {
return window.localStorage !== null && window.localStorage !== undefined;
} catch(err) {
// Storage is supported, but browser preferences deny access to it.
return false;
}
}

function updateLocalStorage(name, value) {
if (usableLocalStorage()) {
localStorage[name] = value;
} else {
// No Web Storage support so we do nothing
try {
window.localStorage.setItem(name, value);
} catch(e) {
// localStorage is not accessible, do nothing
}
}

function getCurrentValue(name) {
if (usableLocalStorage() && localStorage[name] !== undefined) {
return localStorage[name];
try {
return window.localStorage.getItem(name);
} catch(e) {
return null;
}
return null;
}

function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
Expand Down
3 changes: 1 addition & 2 deletions src/test/run-make-fulldeps/coverage-reports/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# ignore-test Broken; accidentally silently ignored on Linux CI; FIXME(#81688)
# needs-profiler-support
# ignore-windows-gnu
# min-llvm-version: 11.0
Expand Down Expand Up @@ -128,7 +127,7 @@ endif
$$( \
for file in $(TMPDIR)/rustdoc-$@/*/rust_out; \
do \
[[ -x $$file ]] && printf "%s %s " -object $$file; \
[ -x "$$file" ] && printf "%s %s " -object $$file; \
done \
) \
2> "$(TMPDIR)"/show_coverage_stderr.$@.txt \
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-make-fulldeps/coverage/coverage_tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@
# Enabling `-C link-dead-code` is not necessary when compiling with `-Z instrument-coverage`,
# due to improvements in the coverage map generation, to add unreachable functions known to Rust.
# Therefore, `-C link-dead-code` is no longer automatically enabled.

UNAME = $(shell uname)
13 changes: 13 additions & 0 deletions src/test/run-make-fulldeps/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ CGREP := "$(S)/src/etc/cat-and-grep.sh"
# diff with common flags for multi-platform diffs against text output
DIFF := diff -u --strip-trailing-cr

# Some of the Rust CI platforms use `/bin/dash` to run `shell` script in
# Makefiles. Other platforms, including many developer platforms, default to
# `/bin/bash`. (In many cases, `make` is actually using `/bin/sh`, but `sh`
# is configured to execute one or the other shell binary). `dash` features
# support only a small subset of `bash` features, so `dash` can be thought of as
# the lowest common denominator, and tests should be validated against `dash`
# whenever possible. Most developer platforms include `/bin/dash`, but to ensure
# tests still work when `/bin/dash`, if not available, this `SHELL` override is
# conditional:
ifneq (,$(wildcard /bin/dash))
SHELL := /bin/dash
endif

# This is the name of the binary we will generate and run; use this
# e.g. for `$(CC) -o $(RUN_BINFILE)`.
RUN_BINFILE = $(TMPDIR)/$(1)
Expand Down
14 changes: 12 additions & 2 deletions src/test/ui/array-slice-vec/vector-cast-weirdness.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Issue #14893. Tests that casts from vectors don't behave strangely in the
// presence of the `_` type shorthand notation.
//
// Update: after a change to the way casts are done, we have more type information
// around and so the errors here are no longer exactly the same.
//
// Update: With PR #81479 some of the previously rejected cases are now allowed.
// New test cases added.

struct X {
y: [u8; 2],
Expand All @@ -12,13 +16,19 @@ fn main() {

// No longer a type mismatch - the `_` can be fully resolved by type inference.
let p1: *const u8 = &x1.y as *const _;
let p1: *mut u8 = &x1.y as *mut _;
//~^ ERROR: casting `&[u8; 2]` as `*mut u8` is invalid
let t1: *const [u8; 2] = &x1.y as *const _;
let t1: *mut [u8; 2] = &x1.y as *mut _;
//~^ ERROR: casting `&[u8; 2]` as `*mut [u8; 2]` is invalid
let h1: *const [u8; 2] = &x1.y as *const [u8; 2];
let t1: *mut [u8; 2] = &x1.y as *mut [u8; 2];
//~^ ERROR: casting `&[u8; 2]` as `*mut [u8; 2]` is invalid

let mut x1 = X { y: [0, 0] };

// This is still an error since we don't allow casts from &mut [T; n] to *mut T.
let p1: *mut u8 = &mut x1.y as *mut _; //~ ERROR casting
let p1: *mut u8 = &mut x1.y as *mut _;
let p2: *const u8 = &mut x1.y as *const _;
let t1: *mut [u8; 2] = &mut x1.y as *mut _;
let h1: *mut [u8; 2] = &mut x1.y as *mut [u8; 2];
}
22 changes: 17 additions & 5 deletions src/test/ui/array-slice-vec/vector-cast-weirdness.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
error[E0606]: casting `&mut [u8; 2]` as `*mut u8` is invalid
--> $DIR/vector-cast-weirdness.rs:21:23
error[E0606]: casting `&[u8; 2]` as `*mut u8` is invalid
--> $DIR/vector-cast-weirdness.rs:19:23
|
LL | let p1: *mut u8 = &mut x1.y as *mut _;
| ^^^^^^^^^^^^^^^^^^^
LL | let p1: *mut u8 = &x1.y as *mut _;
| ^^^^^^^^^^^^^^^

error: aborting due to previous error
error[E0606]: casting `&[u8; 2]` as `*mut [u8; 2]` is invalid
--> $DIR/vector-cast-weirdness.rs:22:28
|
LL | let t1: *mut [u8; 2] = &x1.y as *mut _;
| ^^^^^^^^^^^^^^^

error[E0606]: casting `&[u8; 2]` as `*mut [u8; 2]` is invalid
--> $DIR/vector-cast-weirdness.rs:25:28
|
LL | let t1: *mut [u8; 2] = &x1.y as *mut [u8; 2];
| ^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0606`.