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 8 pull requests #88046

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4ffb1ef
Explicit notification of lack of support for `rust-docs` component for
Aug 3, 2021
c15bc2e
Remove git fetch command call
GuillaumeGomez Aug 5, 2021
c4eefc3
Run rustdoc-gui tests in parallel
dns2utf8 Jun 25, 2021
a1daa8d
Capture outputs and show output when debug flag is passed
dns2utf8 Jun 28, 2021
40136e1
Implement sequential execution
dns2utf8 Jun 28, 2021
e540aa0
Review by @GuillaumeGomez
dns2utf8 Jul 1, 2021
eca2b3b
Switch to stderr for failed tests
dns2utf8 Jul 1, 2021
c17628b
Implement summarised results
dns2utf8 Aug 9, 2021
079bf75
Detect fake spans in non_fmt_panic lint.
m-ou-se Aug 12, 2021
fe56e89
Don't put hermit rwlocks in a box.
mkroening Jun 18, 2021
f45ebe4
Don't put hermit condvars in a box.
mkroening Jun 13, 2021
fffa88e
Don't put hermit mutexes in a box.
mkroening Jun 13, 2021
b4f448a
non_fmt_panic: machine app. suggestion for assert with string msg.
m-ou-se Aug 12, 2021
5ad4106
Update non-fmt-panic tests.
m-ou-se Aug 12, 2021
8fedb31
Use is_diagnostic_item instead of get_diagnostic_item.
m-ou-se Aug 12, 2021
bbb6cb8
switch to the latest version of hermit-abi
stlankes Aug 13, 2021
f25d2bd
Assign FIXMEs to me and remove obsolete ones
fee1-dead Aug 14, 2021
6ec1b53
Forbid `!` from being used in `asm!` output
nbdd0121 Aug 12, 2021
86fa21c
Implement a finish method for the status_bar and some cleanup
dns2utf8 Aug 14, 2021
7f2b52b
More spacing between the different blocks of results
dns2utf8 Aug 14, 2021
81075e8
Rollup merge of #86692 - dns2utf8:parallelize_rustdoc-gui_tests, r=Gu…
GuillaumeGomez Aug 15, 2021
0684748
Rollup merge of #87677 - amalik18:issue-2788-fix, r=pietroalbini
GuillaumeGomez Aug 15, 2021
defc49a
Rollup merge of #87792 - GuillaumeGomez:ci-fetch, r=pietroalbini
GuillaumeGomez Aug 15, 2021
3530734
Rollup merge of #87967 - m-ou-se:non-fmt-panic-detect-fake-spans, r=c…
GuillaumeGomez Aug 15, 2021
1b7c64b
Rollup merge of #87982 - m-ou-se:non-fmt-panic-assert-str, r=cjgillot
GuillaumeGomez Aug 15, 2021
3c8c017
Rollup merge of #87985 - nbdd0121:asm, r=Amanieu
GuillaumeGomez Aug 15, 2021
e58791a
Rollup merge of #88002 - hermitcore:unbox-mutex, r=dtolnay
GuillaumeGomez Aug 15, 2021
0bf6f83
Rollup merge of #88030 - fee1-dead:fixme, r=oli-obk
GuillaumeGomez Aug 15, 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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1529,9 +1529,9 @@ dependencies = [

[[package]]
name = "hermit-abi"
version = "0.1.17"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"compiler_builtins",
"libc",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/traits/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
infcx: &InferCtxt<'_, 'tcx>,
) -> Result<(), Vec<FulfillmentError<'tcx>>>;

// FIXME this should not provide a default body for chalk as chalk should be updated
// FIXME(fee1-dead) this should not provide a default body for chalk as chalk should be updated
fn select_with_constness_where_possible(
&mut self,
infcx: &InferCtxt<'_, 'tcx>,
Expand Down
31 changes: 26 additions & 5 deletions compiler/rustc_lint/src/non_fmt_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
let mut l = lint.build("panic message is not a string literal");
l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021");
l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>");
if !span.contains(arg_span) {
if !is_arg_inside_call(arg_span, span) {
// No clue where this argument is coming from.
l.emit();
return;
Expand All @@ -120,13 +120,26 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
);
}
} else {
let ty = cx.typeck_results().expr_ty(arg);
// If this is a &str or String, we can confidently give the `"{}", ` suggestion.
let is_str = matches!(
ty.kind(),
ty::Ref(_, r, _) if *r.kind() == ty::Str,
) || matches!(
ty.ty_adt_def(),
Some(ty_def) if cx.tcx.is_diagnostic_item(sym::string_type, ty_def.did),
);
l.span_suggestion_verbose(
arg_span.shrink_to_lo(),
"add a \"{}\" format string to Display the message",
"\"{}\", ".into(),
Applicability::MaybeIncorrect,
if is_str {
Applicability::MachineApplicable
} else {
Applicability::MaybeIncorrect
},
);
if panic == sym::std_panic_macro {
if !is_str && panic == sym::std_panic_macro {
if let Some((open, close, del)) = find_delimiters(cx, span) {
l.multipart_suggestion(
"or use std::panic::panic_any instead",
Expand Down Expand Up @@ -191,7 +204,7 @@ fn check_panic_str<'tcx>(
_ => "panic message contains unused formatting placeholders",
});
l.note("this message is not used as a format string when given without arguments, but will be in Rust 2021");
if span.contains(arg.span) {
if is_arg_inside_call(arg.span, span) {
l.span_suggestion(
arg.span.shrink_to_hi(),
&format!("add the missing argument{}", pluralize!(n_arguments)),
Expand Down Expand Up @@ -222,7 +235,7 @@ fn check_panic_str<'tcx>(
cx.struct_span_lint(NON_FMT_PANICS, brace_spans.unwrap_or_else(|| vec![span]), |lint| {
let mut l = lint.build(msg);
l.note("this message is not used as a format string, but will be in Rust 2021");
if span.contains(arg.span) {
if is_arg_inside_call(arg.span, span) {
l.span_suggestion(
arg.span.shrink_to_lo(),
"add a \"{}\" format string to use the message literally",
Expand Down Expand Up @@ -270,3 +283,11 @@ fn panic_call<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>) -> (Span,
if let hygiene::ExpnKind::Macro(_, symbol) = expn.kind { symbol } else { sym::panic };
(expn.call_site, panic_macro, macro_symbol.as_str())
}

fn is_arg_inside_call(arg: Span, call: Span) -> bool {
// We only add suggestions if the argument we're looking at appears inside the
// panic call in the source file, to avoid invalid suggestions when macros are involved.
// We specifically check for the spans to not be identical, as that happens sometimes when
// proc_macros lie about spans and apply the same span to all the tokens they produce.
call.contains(arg) && !call.source_equal(&arg)
}
15 changes: 10 additions & 5 deletions compiler/rustc_passes/src/intrinsicck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl ExprVisitor<'tcx> {
reg: InlineAsmRegOrRegClass,
expr: &hir::Expr<'tcx>,
template: &[InlineAsmTemplatePiece],
is_input: bool,
tied_input: Option<(&hir::Expr<'tcx>, Option<InlineAsmType>)>,
) -> Option<InlineAsmType> {
// Check the type against the allowed types for inline asm.
Expand All @@ -150,7 +151,9 @@ impl ExprVisitor<'tcx> {
_ => unreachable!(),
};
let asm_ty = match *ty.kind() {
ty::Never | ty::Error(_) => return None,
// `!` is allowed for input but not for output (issue #87802)
ty::Never if is_input => return None,
ty::Error(_) => return None,
ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => Some(InlineAsmType::I8),
ty::Int(IntTy::I16) | ty::Uint(UintTy::U16) => Some(InlineAsmType::I16),
ty::Int(IntTy::I32) | ty::Uint(UintTy::U32) => Some(InlineAsmType::I32),
Expand Down Expand Up @@ -350,24 +353,26 @@ impl ExprVisitor<'tcx> {
for (idx, (op, _)) in asm.operands.iter().enumerate() {
match *op {
hir::InlineAsmOperand::In { reg, ref expr } => {
self.check_asm_operand_type(idx, reg, expr, asm.template, None);
self.check_asm_operand_type(idx, reg, expr, asm.template, true, None);
}
hir::InlineAsmOperand::Out { reg, late: _, ref expr } => {
if let Some(expr) = expr {
self.check_asm_operand_type(idx, reg, expr, asm.template, None);
self.check_asm_operand_type(idx, reg, expr, asm.template, false, None);
}
}
hir::InlineAsmOperand::InOut { reg, late: _, ref expr } => {
self.check_asm_operand_type(idx, reg, expr, asm.template, None);
self.check_asm_operand_type(idx, reg, expr, asm.template, false, None);
}
hir::InlineAsmOperand::SplitInOut { reg, late: _, ref in_expr, ref out_expr } => {
let in_ty = self.check_asm_operand_type(idx, reg, in_expr, asm.template, None);
let in_ty =
self.check_asm_operand_type(idx, reg, in_expr, asm.template, true, None);
if let Some(out_expr) = out_expr {
self.check_asm_operand_type(
idx,
reg,
out_expr,
asm.template,
false,
Some((in_expr, in_ty)),
);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
self.infcx.tcx
}

/// returns `true` if the predicate is considered `const` to
/// Returns `true` if the predicate is considered `const` to
/// this selection context.
pub fn is_predicate_const(&self, pred: ty::Predicate<'_>) -> bool {
match pred.kind().skip_binder() {
Expand Down
15 changes: 2 additions & 13 deletions compiler/rustc_traits/src/type_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::TraitEngineExt as _;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
use rustc_middle::ty::{
self, FnSig, Lift, PolyFnSig, PredicateKind, Ty, TyCtxt, TypeFoldable, Variance,
};
use rustc_middle::ty::{self, FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable, Variance};
use rustc_middle::ty::{ParamEnv, ParamEnvAnd, Predicate, ToPredicate};
use rustc_span::DUMMY_SP;
use rustc_trait_selection::infer::InferCtxtBuilderExt;
Expand Down Expand Up @@ -87,16 +85,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
Ok(())
}

fn prove_predicate(&mut self, mut predicate: Predicate<'tcx>) {
if let PredicateKind::Trait(mut tr) = predicate.kind().skip_binder() {
if let hir::Constness::Const = tr.constness {
// FIXME check if we actually want to prove const predicates inside AscribeUserType
tr.constness = hir::Constness::NotConst;
predicate =
predicate.kind().rebind(PredicateKind::Trait(tr)).to_predicate(self.tcx());
}
}

fn prove_predicate(&mut self, predicate: Predicate<'tcx>) {
self.fulfill_cx.register_predicate_obligation(
self.infcx,
Obligation::new(ObligationCause::dummy(), self.param_env, predicate),
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/tests/const_fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub const MY_VEC: Vec<usize> = Vec::new();
#[allow(dead_code)]
pub const MY_STRING: String = String::new();

// FIXME remove this struct once we put `K: ?const Ord` on BTreeMap::new.
// FIXME(fee1-dead) remove this struct once we put `K: ?const Ord` on BTreeMap::new.
#[derive(PartialEq, Eq, PartialOrd)]
pub struct MyType;

Expand Down
2 changes: 0 additions & 2 deletions library/alloc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#![feature(string_remove_matches)]
#![feature(const_btree_new)]
#![feature(const_trait_impl)]
// FIXME remove this when const_trait_impl is not incomplete anymore
#![allow(incomplete_features)]

use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dlmalloc = { version = "0.2.1", features = ['rustc-dep-of-std'] }
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }

[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
hermit-abi = { version = "0.1.17", features = ['rustc-dep-of-std'] }
hermit-abi = { version = "0.1.19", features = ['rustc-dep-of-std'] }

[target.wasm32-wasi.dependencies]
wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/hermit/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Condvar {
sem2: *const c_void,
}

pub type MovableCondvar = Box<Condvar>;
pub type MovableCondvar = Condvar;

unsafe impl Send for Condvar {}
unsafe impl Sync for Condvar {}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/hermit/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub struct Mutex {
inner: Spinlock<MutexInner>,
}

pub type MovableMutex = Box<Mutex>;
pub type MovableMutex = Mutex;

unsafe impl Send for Mutex {}
unsafe impl Sync for Mutex {}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/hermit/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct RWLock {
state: UnsafeCell<State>,
}

pub type MovableRWLock = Box<RWLock>;
pub type MovableRWLock = RWLock;

enum State {
Unlocked,
Expand Down
10 changes: 6 additions & 4 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ else
fi

if [ "$CI" != "" ]; then
# Get some needed information for $BASE_COMMIT
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
# Get some needed information for $BASE_COMMIT
#
# This command gets the last merge commit which we'll use as base to list
# deleted files since then.
BASE_COMMIT="$(git log --author=bors@rust-lang.org -n 2 --pretty=format:%H | tail -n 1)"
else
BASE_COMMIT=""
BASE_COMMIT=""
fi

docker \
Expand Down
4 changes: 4 additions & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Tier Policy.

All tier 2 targets with host tools support the full standard library.

**NOTE:** Tier 2 targets currently do not build the `rust-docs` component.

target | notes
-------|-------
`aarch64-apple-darwin` | ARM64 macOS (11.0+, Big Sur+)
Expand Down Expand Up @@ -112,6 +114,8 @@ The `std` column in the table below has the following meanings:

[`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html

**NOTE:** Tier 2 targets currently do not build the `rust-docs` component.

target | std | notes
-------|:---:|-------
`aarch64-apple-ios` | ✓ | ARM64 iOS
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/asm/issue-87802.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// needs-asm-support
// Make sure rustc doesn't ICE on asm! when output type is !.

#![feature(asm)]

fn hmm() -> ! {
let x;
unsafe {
asm!("/* {0} */", out(reg) x);
//~^ ERROR cannot use value of type `!` for inline assembly
}
x
}

fn main() {
hmm();
}
10 changes: 10 additions & 0 deletions src/test/ui/asm/issue-87802.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: cannot use value of type `!` for inline assembly
--> $DIR/issue-87802.rs:9:36
|
LL | asm!("/* {0} */", out(reg) x);
| ^
|
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly

error: aborting due to previous error

54 changes: 54 additions & 0 deletions src/test/ui/non-fmt-panic.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// run-rustfix
// rustfix-only-machine-applicable
// build-pass (FIXME(62277): should be check-pass)
// aux-build:fancy-panic.rs

extern crate fancy_panic;

const C: &str = "abc {}";
static S: &str = "{bla}";

#[allow(unreachable_code)]
fn main() {
panic!("{}", "here's a brace: {"); //~ WARN panic message contains a brace
std::panic!("{}", "another one: }"); //~ WARN panic message contains a brace
core::panic!("{}", "Hello {}"); //~ WARN panic message contains an unused formatting placeholder
assert!(false, "{}", "{:03x} {test} bla");
//~^ WARN panic message contains unused formatting placeholders
assert!(false, "{}", S);
//~^ WARN panic message is not a string literal
debug_assert!(false, "{}", "{{}} bla"); //~ WARN panic message contains braces
panic!("{}", C); //~ WARN panic message is not a string literal
panic!("{}", S); //~ WARN panic message is not a string literal
std::panic::panic_any(123); //~ WARN panic message is not a string literal
core::panic!("{}", &*"abc"); //~ WARN panic message is not a string literal
panic!("{}", concat!("{", "}")); //~ WARN panic message contains an unused formatting placeholder
panic!("{}", concat!("{", "{")); //~ WARN panic message contains braces

fancy_panic::fancy_panic!("test {} 123");
//~^ WARN panic message contains an unused formatting placeholder

fancy_panic::fancy_panic!(); // OK
fancy_panic::fancy_panic!(S); // OK

macro_rules! a {
() => { 123 };
}

std::panic::panic_any(a!()); //~ WARN panic message is not a string literal

panic!("{}", 1); //~ WARN panic message is not a string literal
assert!(false, "{}", 1); //~ WARN panic message is not a string literal
debug_assert!(false, "{}", 1); //~ WARN panic message is not a string literal

std::panic::panic_any(123); //~ WARN panic message is not a string literal
std::panic::panic_any(123); //~ WARN panic message is not a string literal

// Check that the lint only triggers for std::panic and core::panic,
// not any panic macro:
macro_rules! panic {
($e:expr) => ();
}
panic!("{}"); // OK
panic!(S); // OK
}
2 changes: 2 additions & 0 deletions src/test/ui/non-fmt-panic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// run-rustfix
// rustfix-only-machine-applicable
// build-pass (FIXME(62277): should be check-pass)
// aux-build:fancy-panic.rs

Expand Down
Loading