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 15 pull requests #81437

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b43aa96
Print failure message on all tests that should panic, but don't
johanngan Jan 10, 2021
2624b3e
Improve diagnostics for Precise Capture
ChrisPardy Nov 23, 2020
3056dd0
fix tidy
ChrisPardy Jan 16, 2021
b8115b8
fix line numbers
ChrisPardy Jan 16, 2021
63a1eee
Reset LateContext enclosing body in nested items
camsteffen Jan 18, 2021
21fb586
Query for TypeckResults in LateContext::qpath_res
camsteffen Jan 18, 2021
0724573
Move a few more types to `rustc_type_ir`
LeSeulArtichaut Dec 12, 2020
933bb18
Use `rustc_type_ir::{IntTy,UintTy,FloatTy} instead of the `rustc_ast`…
LeSeulArtichaut Dec 12, 2020
50e1ae1
Use ty::{IntTy,UintTy,FloatTy} in rustc
LeSeulArtichaut Dec 12, 2020
e0d64b9
Use ty::{IntTy,UintTy,FloatTy} in rustdoc and clippy
LeSeulArtichaut Dec 12, 2020
eaba3da
Remove qpath_res util function
camsteffen Jan 18, 2021
e25959b
Make more traits of the From/Into family diagnostic items
flip1995 Jan 22, 2021
3b8f1b7
Make `-Z time-passes` less noisy
jyn514 Jan 22, 2021
f241c10
Improve flatten-fuse tests
SkiFire13 Jan 23, 2021
5aa625b
Manually fuse the inner iterator in FlattenCompat
SkiFire13 Jan 23, 2021
8a18fb0
Stabilize `Seek::stream_position` & change feature of `Seek::stream_len`
LukasKalbertodt Dec 19, 2020
48f9dbf
clean up some const error reporting around promoteds
RalfJung Jan 24, 2021
6d4e03a
codegen: assume constants cannot fail to evaluate
RalfJung Jan 24, 2021
77a9e3e
combine: stop eagerly evaluating consts
lcnr Jan 24, 2021
26b4baf
Point to span of upvar making closure FnMut
sledgehammervampire Jan 18, 2021
ef3127d
Completely remove search query parameter when clearing search input
GuillaumeGomez Jan 25, 2021
09518db
Improve URL handling when clicking on a menu link while being on the …
GuillaumeGomez Jan 25, 2021
cf71d83
add tests
ChrisPardy Jan 26, 2021
582a171
add const_evaluatable_checked test
lcnr Jan 27, 2021
b519deb
const_evaluatable: stop looking into type aliases
lcnr Jan 27, 2021
f96a67c
Rollup merge of #70904 - LukasKalbertodt:stabilize-seek-convenience, …
jonas-schievink Jan 27, 2021
c340661
Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakis
jonas-schievink Jan 27, 2021
4fa9e70
Rollup merge of #80868 - johanngan:should-panic-msg-with-expected, r=…
jonas-schievink Jan 27, 2021
955e015
Rollup merge of #81062 - sexxi-goose:precise_capture_diagnostics, r=n…
jonas-schievink Jan 27, 2021
d20e044
Rollup merge of #81158 - 1000teslas:issue-80313-fix, r=Aaron1011
jonas-schievink Jan 27, 2021
9e0013a
Rollup merge of #81176 - camsteffen:qpath-res, r=oli-obk
jonas-schievink Jan 27, 2021
9983e9f
Rollup merge of #81277 - flip1995:from_diag_items, r=matthewjasper
jonas-schievink Jan 27, 2021
b74f5fd
Rollup merge of #81284 - jyn514:impl-times, r=wesleywiser
jonas-schievink Jan 27, 2021
8ad6d14
Rollup merge of #81306 - SkiFire13:fuse-flatten, r=cuviper
jonas-schievink Jan 27, 2021
92ce338
Rollup merge of #81327 - RalfJung:codegen-no-const-fail, r=oli-obk
jonas-schievink Jan 27, 2021
f8fa0d1
Rollup merge of #81333 - RalfJung:const-err-simplify, r=oli-obk
jonas-schievink Jan 27, 2021
4f56d32
Rollup merge of #81351 - lcnr:big-money-big-prices, r=oli-obk
jonas-schievink Jan 27, 2021
7e0cd72
Rollup merge of #81379 - GuillaumeGomez:improve-urls, r=Nemo157
jonas-schievink Jan 27, 2021
00bbc1e
Rollup merge of #81430 - lcnr:elaborate-const-eval, r=oli-obk
jonas-schievink Jan 27, 2021
2ae3263
Rollup merge of #81433 - lcnr:stop-looking-into-ty-alias, r=oli-obk
jonas-schievink Jan 27, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4345,6 +4345,7 @@ dependencies = [
"bitflags",
"rustc_data_structures",
"rustc_index",
"rustc_macros",
"rustc_serialize",
]

Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ pub(crate) fn codegen_constant<'tcx>(
{
Ok(const_val) => const_val,
Err(_) => {
if promoted.is_none() {
fx.tcx
.sess
.span_err(constant.span, "erroneous constant encountered");
}
fx.tcx
.sess
.span_err(constant.span, "erroneous constant encountered");
return crate::trap::trap_unreachable_ret_value(
fx,
fx.layout_of(const_.ty),
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,14 @@ mod vtable;
mod prelude {
pub(crate) use std::convert::{TryFrom, TryInto};

pub(crate) use rustc_ast::ast::{FloatTy, IntTy, UintTy};
pub(crate) use rustc_span::Span;

pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE};
pub(crate) use rustc_middle::bug;
pub(crate) use rustc_middle::mir::{self, *};
pub(crate) use rustc_middle::ty::layout::{self, TyAndLayout};
pub(crate) use rustc_middle::ty::{
self, FnSig, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable,
self, FloatTy, FnSig, Instance, InstanceDef, IntTy, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable, UintTy,
};
pub(crate) use rustc_target::abi::{Abi, LayoutOf, Scalar, Size, VariantIdx};

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
lhs: Self::Value,
rhs: Self::Value,
) -> (Self::Value, Self::Value) {
use rustc_ast::IntTy::*;
use rustc_ast::UintTy::*;
use rustc_middle::ty::{Int, Uint};
use rustc_middle::ty::{IntTy::*, UintTy::*};

let new_kind = match ty.kind() {
Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.pointer_width)),
Expand Down
35 changes: 17 additions & 18 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::llvm::debuginfo::{
};
use crate::value::Value;

use rustc_ast as ast;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::const_cstr;
use rustc_data_structures::fingerprint::Fingerprint;
Expand Down Expand Up @@ -830,37 +829,37 @@ trait MsvcBasicName {
fn msvc_basic_name(self) -> &'static str;
}

impl MsvcBasicName for ast::IntTy {
impl MsvcBasicName for ty::IntTy {
fn msvc_basic_name(self) -> &'static str {
match self {
ast::IntTy::Isize => "ptrdiff_t",
ast::IntTy::I8 => "__int8",
ast::IntTy::I16 => "__int16",
ast::IntTy::I32 => "__int32",
ast::IntTy::I64 => "__int64",
ast::IntTy::I128 => "__int128",
ty::IntTy::Isize => "ptrdiff_t",
ty::IntTy::I8 => "__int8",
ty::IntTy::I16 => "__int16",
ty::IntTy::I32 => "__int32",
ty::IntTy::I64 => "__int64",
ty::IntTy::I128 => "__int128",
}
}
}

impl MsvcBasicName for ast::UintTy {
impl MsvcBasicName for ty::UintTy {
fn msvc_basic_name(self) -> &'static str {
match self {
ast::UintTy::Usize => "size_t",
ast::UintTy::U8 => "unsigned __int8",
ast::UintTy::U16 => "unsigned __int16",
ast::UintTy::U32 => "unsigned __int32",
ast::UintTy::U64 => "unsigned __int64",
ast::UintTy::U128 => "unsigned __int128",
ty::UintTy::Usize => "size_t",
ty::UintTy::U8 => "unsigned __int8",
ty::UintTy::U16 => "unsigned __int16",
ty::UintTy::U32 => "unsigned __int32",
ty::UintTy::U64 => "unsigned __int64",
ty::UintTy::U128 => "unsigned __int128",
}
}
}

impl MsvcBasicName for ast::FloatTy {
impl MsvcBasicName for ty::FloatTy {
fn msvc_basic_name(self) -> &'static str {
match self {
ast::FloatTy::F32 => "float",
ast::FloatTy::F64 => "double",
ty::FloatTy::F32 => "float",
ty::FloatTy::F64 => "double",
}
}
}
Expand Down
37 changes: 18 additions & 19 deletions compiler/rustc_codegen_llvm/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ use crate::llvm;
use crate::llvm::{Bool, False, True};
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use rustc_ast as ast;
use rustc_codegen_ssa::common::TypeKind;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_middle::bug;
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::Ty;
use rustc_middle::ty::{self, Ty};
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
use rustc_target::abi::{AddressSpace, Align, Integer, Size};

Expand Down Expand Up @@ -80,32 +79,32 @@ impl CodegenCx<'ll, 'tcx> {
self.type_i8()
}

crate fn type_int_from_ty(&self, t: ast::IntTy) -> &'ll Type {
crate fn type_int_from_ty(&self, t: ty::IntTy) -> &'ll Type {
match t {
ast::IntTy::Isize => self.type_isize(),
ast::IntTy::I8 => self.type_i8(),
ast::IntTy::I16 => self.type_i16(),
ast::IntTy::I32 => self.type_i32(),
ast::IntTy::I64 => self.type_i64(),
ast::IntTy::I128 => self.type_i128(),
ty::IntTy::Isize => self.type_isize(),
ty::IntTy::I8 => self.type_i8(),
ty::IntTy::I16 => self.type_i16(),
ty::IntTy::I32 => self.type_i32(),
ty::IntTy::I64 => self.type_i64(),
ty::IntTy::I128 => self.type_i128(),
}
}

crate fn type_uint_from_ty(&self, t: ast::UintTy) -> &'ll Type {
crate fn type_uint_from_ty(&self, t: ty::UintTy) -> &'ll Type {
match t {
ast::UintTy::Usize => self.type_isize(),
ast::UintTy::U8 => self.type_i8(),
ast::UintTy::U16 => self.type_i16(),
ast::UintTy::U32 => self.type_i32(),
ast::UintTy::U64 => self.type_i64(),
ast::UintTy::U128 => self.type_i128(),
ty::UintTy::Usize => self.type_isize(),
ty::UintTy::U8 => self.type_i8(),
ty::UintTy::U16 => self.type_i16(),
ty::UintTy::U32 => self.type_i32(),
ty::UintTy::U64 => self.type_i64(),
ty::UintTy::U128 => self.type_i128(),
}
}

crate fn type_float_from_ty(&self, t: ast::FloatTy) -> &'ll Type {
crate fn type_float_from_ty(&self, t: ty::FloatTy) -> &'ll Type {
match t {
ast::FloatTy::F32 => self.type_f32(),
ast::FloatTy::F64 => self.type_f64(),
ty::FloatTy::F32 => self.type_f32(),
ty::FloatTy::F64 => self.type_f64(),
}
}

Expand Down
20 changes: 8 additions & 12 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,20 +875,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
ty::Uint(_) => value.to_string(),
ty::Int(int_ty) => {
match int_ty.normalize(bx.tcx().sess.target.pointer_width) {
ast::IntTy::I8 => (value as i8).to_string(),
ast::IntTy::I16 => (value as i16).to_string(),
ast::IntTy::I32 => (value as i32).to_string(),
ast::IntTy::I64 => (value as i64).to_string(),
ast::IntTy::I128 => (value as i128).to_string(),
ast::IntTy::Isize => unreachable!(),
ty::IntTy::I8 => (value as i8).to_string(),
ty::IntTy::I16 => (value as i16).to_string(),
ty::IntTy::I32 => (value as i32).to_string(),
ty::IntTy::I64 => (value as i64).to_string(),
ty::IntTy::I128 => (value as i128).to_string(),
ty::IntTy::Isize => unreachable!(),
}
}
ty::Float(ast::FloatTy::F32) => {
f32::from_bits(value as u32).to_string()
}
ty::Float(ast::FloatTy::F64) => {
f64::from_bits(value as u64).to_string()
}
ty::Float(ty::FloatTy::F32) => f32::from_bits(value as u32).to_string(),
ty::Float(ty::FloatTy::F64) => f64::from_bits(value as u64).to_string(),
_ => span_bug!(span, "asm const has bad type {}", ty),
};
InlineAsmOperandRef::Const { string }
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_codegen_ssa/src/mir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
.tcx()
.const_eval_resolve(ty::ParamEnv::reveal_all(), def, substs, promoted, None)
.map_err(|err| {
if promoted.is_none() {
self.cx
.tcx()
.sess
.span_err(constant.span, "erroneous constant encountered");
}
self.cx.tcx().sess.span_err(constant.span, "erroneous constant encountered");
err
}),
ty::ConstKind::Value(value) => Ok(value),
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_codegen_ssa/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(

fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info(&mut bx);

let mut all_consts_ok = true;
for const_ in &mir.required_consts {
if let Err(err) = fx.eval_mir_constant(const_) {
all_consts_ok = false;
match err {
// errored or at least linted
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {}
Expand All @@ -199,6 +201,25 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
}
}
}
if !all_consts_ok {
// There is no delay_span_bug here, we just have to rely on a hard error actually having
// been raised.
bx.abort();
// `abort` does not terminate the block, so we still need to generate
// an `unreachable` terminator after it.
bx.unreachable();
// We also have to delete all the other basic blocks again...
for bb in mir.basic_blocks().indices() {
if bb != mir::START_BLOCK {
unsafe {
bx.delete_basic_block(fx.blocks[bb]);
}
}
}
// FIXME: Can we somehow avoid all this by evaluating the consts before creating the basic
// blocks? The tricky part is doing that without duplicating `fx.eval_mir_constant`.
return;
}

let memory_locals = analyze::non_ssa_locals(&fx);

Expand Down
25 changes: 4 additions & 21 deletions compiler/rustc_codegen_ssa/src/mir/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use crate::glue;
use crate::traits::*;
use crate::MemFlags;

use rustc_errors::ErrorReported;
use rustc_middle::mir;
use rustc_middle::mir::interpret::{ConstValue, ErrorHandled, Pointer, Scalar};
use rustc_middle::mir::interpret::{ConstValue, Pointer, Scalar};
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::Ty;
use rustc_target::abi::{Abi, Align, LayoutOf, Size};
Expand Down Expand Up @@ -439,25 +438,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}

mir::Operand::Constant(ref constant) => {
self.eval_mir_constant_to_operand(bx, constant).unwrap_or_else(|err| {
match err {
// errored or at least linted
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {}
ErrorHandled::TooGeneric => {
bug!("codegen encountered polymorphic constant")
}
}
// Allow RalfJ to sleep soundly knowing that even refactorings that remove
// the above error (or silence it under some conditions) will not cause UB.
bx.abort();
// We still have to return an operand but it doesn't matter,
// this code is unreachable.
let ty = self.monomorphize(constant.literal.ty);
let layout = bx.cx().layout_of(ty);
bx.load_operand(PlaceRef::new_sized(
bx.cx().const_undef(bx.cx().type_ptr_to(bx.cx().backend_type(layout))),
layout,
))
// This cannot fail because we checked all required_consts in advance.
self.eval_mir_constant_to_operand(bx, constant).unwrap_or_else(|_err| {
span_bug!(constant.span, "erroneous constant not captured by required_consts")
})
}
}
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,15 +929,17 @@ pub struct ExtCtxt<'a> {
pub force_mode: bool,
pub expansions: FxHashMap<Span, Vec<String>>,
/// Called directly after having parsed an external `mod foo;` in expansion.
pub(super) extern_mod_loaded: Option<&'a dyn Fn(&ast::Crate)>,
///
/// `Ident` is the module name.
pub(super) extern_mod_loaded: Option<&'a dyn Fn(&ast::Crate, Ident)>,
}

impl<'a> ExtCtxt<'a> {
pub fn new(
sess: &'a Session,
ecfg: expand::ExpansionConfig<'a>,
resolver: &'a mut dyn ResolverExpand,
extern_mod_loaded: Option<&'a dyn Fn(&ast::Crate)>,
extern_mod_loaded: Option<&'a dyn Fn(&ast::Crate, Ident)>,
) -> ExtCtxt<'a> {
ExtCtxt {
sess,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
proc_macros: vec![],
};
if let Some(extern_mod_loaded) = self.cx.extern_mod_loaded {
extern_mod_loaded(&krate);
extern_mod_loaded(&krate, ident);
}

*old_mod = krate.module;
Expand Down
Loading