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 6 pull requests #60250

Merged
merged 19 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3b686d5
tweak unresolved label suggestion
euclio Apr 4, 2019
553ec5d
Update run-make PGO test to new commandline syntax.
michaelwoerister Apr 17, 2019
4269be3
Prefix PROFILER_SUPPORT and SANITIZER_SUPPORT test env vars with RUST…
michaelwoerister Apr 18, 2019
227be65
compiletest: Allow for tests requiring profiler-rt or sanitizer-rt su…
michaelwoerister Apr 18, 2019
e2acaee
Add codegen test that makes sure PGO instrumentation is emitted as ex…
michaelwoerister Apr 16, 2019
cc77087
Use new `needs-(profiler|sanitizer)-support` compiletest directive to…
michaelwoerister Apr 18, 2019
7af0fcc
Reexport IntErrorKind in std
meithecatte Apr 22, 2019
4a073dd
Fix #58270, fix off-by-one error in error diagnostics.
xldenis Apr 16, 2019
ff976fe
Fix ignore-logic for sanitizer run-make tests.
michaelwoerister Apr 24, 2019
eb37c64
Remove incorrect debug assertion in interpret
matthewjasper Dec 29, 2018
ff4d4b2
Allow subtyping of the final expression of a constant
matthewjasper Mar 30, 2019
e9c687b
Evaluate hair::ExprKind::Use in into
matthewjasper Mar 30, 2019
04023dc
Add regression test for #53249.
davidtwco Apr 24, 2019
5440cf1
Rollup merge of #59560 - matthewjasper:mir-generation-cleanup, r=oli-obk
Centril Apr 25, 2019
a552beb
Rollup merge of #59697 - euclio:label-fixes, r=zackmdavis
Centril Apr 25, 2019
bb892be
Rollup merge of #60038 - michaelwoerister:pgo-updates-2, r=alexcrichton
Centril Apr 25, 2019
a4ef188
Rollup merge of #60160 - xldenis:fix-overlapping-zero-width-annotatio…
Centril Apr 25, 2019
3fffcd3
Rollup merge of #60185 - NieDzejkob:int-error-kind-reexport, r=rkruppe
Centril Apr 25, 2019
1443f3b
Rollup merge of #60243 - davidtwco:issue-53249, r=cramertj
Centril Apr 25, 2019
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 src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,11 +1268,11 @@ impl Step for Compiletest {
builder.add_rust_test_threads(&mut cmd);

if builder.config.sanitizers {
cmd.env("SANITIZER_SUPPORT", "1");
cmd.env("RUSTC_SANITIZER_SUPPORT", "1");
}

if builder.config.profiler {
cmd.env("PROFILER_SUPPORT", "1");
cmd.env("RUSTC_PROFILER_SUPPORT", "1");
}

cmd.env("RUST_TEST_TMPDIR", builder.out.join("tmp"));
Expand Down
10 changes: 10 additions & 0 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ impl EmitterWriter {
// 6..7. This is degenerate input, but it's best to degrade
// gracefully -- and the parser likes to supply a span like
// that for EOF, in particular.

if lo.col_display == hi.col_display && lo.line == hi.line {
hi.col_display += 1;
}
Expand Down Expand Up @@ -547,6 +548,15 @@ impl EmitterWriter {
&& j > i // multiline lines).
&& p == 0 // We're currently on the first line, move the label one line down
{
// If we're overlapping with an un-labelled annotation with the same span
// we can just merge them in the output
if next.start_col == annotation.start_col
&& next.end_col == annotation.end_col
&& !next.has_label()
{
continue;
}

// This annotation needs a new line in the output.
p += 1;
break;
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_mir/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
let source = unpack!(block = this.as_operand(block, scope, source));
block.and(Rvalue::Cast(CastKind::Misc, source, expr.ty))
}
ExprKind::Use { source } => {
let source = unpack!(block = this.as_operand(block, scope, source));
block.and(Rvalue::Use(source))
}
ExprKind::Pointer { cast, source } => {
let source = unpack!(block = this.as_operand(block, scope, source));
block.and(Rvalue::Cast(CastKind::Pointer(cast), source, expr.ty))
Expand Down Expand Up @@ -363,6 +359,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
| ExprKind::Match { .. }
| ExprKind::If { .. }
| ExprKind::NeverToAny { .. }
| ExprKind::Use { .. }
| ExprKind::Loop { .. }
| ExprKind::LogicalOp { .. }
| ExprKind::Call { .. }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/expr/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl Category {
| ExprKind::If { .. }
| ExprKind::Match { .. }
| ExprKind::NeverToAny { .. }
| ExprKind::Use { .. }
| ExprKind::Call { .. } => Some(Category::Rvalue(RvalueFunc::Into)),

ExprKind::Array { .. }
Expand All @@ -58,7 +59,6 @@ impl Category {
| ExprKind::Binary { .. }
| ExprKind::Box { .. }
| ExprKind::Cast { .. }
| ExprKind::Use { .. }
| ExprKind::Pointer { .. }
| ExprKind::Repeat { .. }
| ExprKind::Borrow { .. }
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_mir/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
success.unit()
}
}
ExprKind::Use { source } => {
this.into(destination, block, source)
}

// These cases don't actually need a destination
ExprKind::Assign { .. }
Expand Down Expand Up @@ -379,7 +382,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
| ExprKind::Binary { .. }
| ExprKind::Box { .. }
| ExprKind::Cast { .. }
| ExprKind::Use { .. }
| ExprKind::Pointer { .. }
| ExprKind::Repeat { .. }
| ExprKind::Borrow { .. }
Expand Down
33 changes: 28 additions & 5 deletions src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,21 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
build::construct_fn(cx, id, arguments, safety, abi,
return_ty, yield_ty, return_ty_span, body)
} else {
build::construct_const(cx, body_id, return_ty_span)
// Get the revealed type of this const. This is *not* the adjusted
// type of its body, which may be a subtype of this type. For
// example:
//
// fn foo(_: &()) {}
// static X: fn(&'static ()) = foo;
//
// The adjusted type of the body of X is `for<'a> fn(&'a ())` which
// is not the same as the type of X. We need the type of the return
// place to be the type of the constant because NLL typeck will
// equate them.

let return_ty = cx.tables().node_type(id);

build::construct_const(cx, body_id, return_ty, return_ty_span)
};

// Convert the Mir to global types.
Expand Down Expand Up @@ -730,16 +744,25 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
fn construct_const<'a, 'gcx, 'tcx>(
hir: Cx<'a, 'gcx, 'tcx>,
body_id: hir::BodyId,
ty_span: Span,
const_ty: Ty<'tcx>,
const_ty_span: Span,
) -> Mir<'tcx> {
let tcx = hir.tcx();
let ast_expr = &tcx.hir().body(body_id).value;
let ty = hir.tables().expr_ty_adjusted(ast_expr);
let owner_id = tcx.hir().body_owner(body_id);
let span = tcx.hir().span(owner_id);
let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span, vec![], vec![]);
let mut builder = Builder::new(
hir,
span,
0,
Safety::Safe,
const_ty,
const_ty_span,
vec![],
vec![],
);

let mut block = START_BLOCK;
let ast_expr = &tcx.hir().body(body_id).value;
let expr = builder.hir.mirror(ast_expr);
unpack!(block = builder.into_expr(&Place::RETURN_PLACE, block, expr));

Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
)?;
}

Cast(kind, ref operand, cast_ty) => {
debug_assert_eq!(self.monomorphize(cast_ty)?, dest.layout.ty);
Cast(kind, ref operand, _) => {
let src = self.eval_operand(operand, None)?;
self.cast(src, kind, dest)?;
}
Expand Down
15 changes: 13 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver<'_>,
"use of undeclared label `{}`",
name);
if let Some(lev_candidate) = lev_candidate {
err.span_label(span, format!("did you mean `{}`?", lev_candidate));
err.span_suggestion(
span,
"a label with a similar name exists in this scope",
lev_candidate.to_string(),
Applicability::MaybeIncorrect,
);
} else {
err.span_label(span, format!("undeclared label `{}`", name));
}
Expand Down Expand Up @@ -4280,7 +4285,13 @@ impl<'a> Resolver<'a> {
// Picks the first label that is "close enough", which is not necessarily
// the closest match
let close_match = self.search_label(label.ident, |rib, ident| {
let names = rib.bindings.iter().map(|(id, _)| &id.name);
let names = rib.bindings.iter().filter_map(|(id, _)| {
if id.span.ctxt() == label.ident.span.ctxt() {
Some(&id.name)
} else {
None
}
});
find_best_match_for_name(names, &*ident.as_str(), None)
});
self.record_def(expr.id, err_path_resolution());
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,8 @@ fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

fcx.check_expr_coercable_to_type(&body.value, revealed_ty);

fcx.write_ty(id, revealed_ty);

fcx
};

Expand Down
8 changes: 8 additions & 0 deletions src/librustc_typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
for arg in &body.arguments {
wbcx.visit_node_id(arg.pat.span, arg.hir_id);
}
// Type only exists for constants and statics, not functions.
match self.tcx.hir().body_owner_kind(item_id) {
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => {
let item_hir_id = self.tcx.hir().node_to_hir_id(item_id);
wbcx.visit_node_id(body.value.span, item_hir_id);
}
hir::BodyOwnerKind::Closure | hir::BodyOwnerKind::Fn => (),
}
wbcx.visit_body(body);
wbcx.visit_upvar_capture_map();
wbcx.visit_upvar_list_map();
Expand Down
1 change: 1 addition & 0 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
#![feature(hash_raw_entry)]
#![feature(hashmap_internals)]
#![feature(int_error_internals)]
#![feature(int_error_matching)]
#![feature(integer_atomics)]
#![feature(lang_items)]
#![feature(libc)]
Expand Down
6 changes: 6 additions & 0 deletions src/libstd/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128,
#[stable(feature = "signed_nonzero", since = "1.34.0")]
pub use core::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize};

#[unstable(feature = "int_error_matching",
reason = "it can be useful to match errors when making error messages \
for integer parsing",
issue = "22639")]
pub use core::num::IntErrorKind;

#[cfg(test)] use crate::fmt;
#[cfg(test)] use crate::ops::{Add, Sub, Mul, Div, Rem};

Expand Down
20 changes: 20 additions & 0 deletions src/test/codegen/pgo-instrumentation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Test that `-Zpgo-gen` creates expected instrumentation artifacts in LLVM IR.

// needs-profiler-support
// compile-flags: -Z pgo-gen -Ccodegen-units=1

// CHECK: @__llvm_profile_raw_version =
// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global
// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global
// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}main{{.*}} = private global
// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}main{{.*}} = private global
// CHECK: @__llvm_profile_filename = {{.*}}"default_%m.profraw\00"{{.*}}

#[inline(never)]
fn some_function() {

}

fn main() {
some_function();
}
21 changes: 10 additions & 11 deletions src/test/mir-opt/array-index-is-temporary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@ fn main() {
// START rustc.main.EraseRegions.after.mir
// bb0: {
// ...
// _6 = &mut _2;
// _5 = &mut (*_6);
// _4 = move _5 as *mut usize (Misc);
// _3 = move _4;
// _5 = &mut _2;
// _4 = &mut (*_5);
// _3 = move _4 as *mut usize (Misc);
// ...
// _8 = _3;
// _7 = const foo(move _8) -> bb1;
// _7 = _3;
// _6 = const foo(move _7) -> bb1;
// }
//
// bb1: {
// ...
// _9 = _2;
// _10 = Len(_1);
// _11 = Lt(_9, _10);
// assert(move _11, "index out of bounds: the len is move _10 but the index is _9") -> bb2;
// _8 = _2;
// _9 = Len(_1);
// _10 = Lt(_8, _9);
// assert(move _10, "index out of bounds: the len is move _9 but the index is _8") -> bb2;
// }
//
// bb2: {
// _1[_9] = move _7;
// _1[_8] = move _6;
// ...
// return;
// }
Expand Down
14 changes: 7 additions & 7 deletions src/test/mir-opt/retag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ fn main() {
// _10 = move _8;
// Retag(_10);
// ...
// _15 = &mut (*_10);
// Retag(_15);
// _14 = move _15 as *mut i32 (Misc);
// Retag([raw] _14);
// _13 = &mut (*_10);
// Retag(_13);
// _12 = move _13 as *mut i32 (Misc);
// Retag([raw] _12);
// ...
// _18 = move _19(move _20) -> bb2;
// _16 = move _17(move _18) -> bb2;
// }
//
// bb2: {
// Retag(_18);
// Retag(_16);
// ...
// _22 = const Test::foo_shr(move _23, move _25) -> bb3;
// _20 = const Test::foo_shr(move _21, move _23) -> bb3;
// }
//
// bb3: {
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-make-fulldeps/pgo-gen-lto/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# needs-profiler-support

-include ../tools.mk

all:
ifeq ($(PROFILER_SUPPORT),1)
$(RUSTC) -Copt-level=3 -Clto=fat -Z pgo-gen="$(TMPDIR)" test.rs
$(call RUN,test) || exit 1
[ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1)
endif
6 changes: 3 additions & 3 deletions src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# needs-profiler-support

-include ../tools.mk

all:
ifeq ($(PROFILER_SUPPORT),1)
$(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)/test.profraw" --emit=llvm-ir test.rs
$(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)" --emit=llvm-ir test.rs
# We expect symbols starting with "__llvm_profile_".
$(CGREP) "__llvm_profile_" < $(TMPDIR)/test.ll
# We do NOT expect the "__imp_" version of these symbols.
$(CGREP) -v "__imp___llvm_profile_" < $(TMPDIR)/test.ll # 64 bit
$(CGREP) -v "__imp____llvm_profile_" < $(TMPDIR)/test.ll # 32 bit
endif
4 changes: 2 additions & 2 deletions src/test/run-make-fulldeps/pgo-gen/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# needs-profiler-support

-include ../tools.mk

all:
ifeq ($(PROFILER_SUPPORT),1)
$(RUSTC) -g -Z pgo-gen="$(TMPDIR)" test.rs
$(call RUN,test) || exit 1
[ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1)
endif
4 changes: 2 additions & 2 deletions src/test/run-make-fulldeps/profile/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# needs-profiler-support

-include ../tools.mk

all:
ifeq ($(PROFILER_SUPPORT),1)
$(RUSTC) -g -Z profile test.rs
$(call RUN,test) || exit 1
[ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1)
[ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1)
endif
6 changes: 2 additions & 4 deletions src/test/run-make-fulldeps/sanitizer-address/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# needs-sanitizer-support

-include ../tools.mk

LOG := $(TMPDIR)/log.txt

# NOTE the address sanitizer only supports x86_64 linux and macOS

ifeq ($(TARGET),x86_64-apple-darwin)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
EXTRA_RUSTFLAG=-C rpath
else
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)

# Apparently there are very specific Linux kernels, notably the one that's
# currently on Travis CI, which contain a buggy commit that triggers failures in
Expand All @@ -23,7 +23,5 @@ endif
endif

all:
ifeq ($(ASAN_SUPPORT),1)
$(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan
$(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow
endif
Loading