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

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2daaf2b
replace some adhoc logic with article_and_descr
mark-i-m Mar 16, 2020
1661a0a
convert a couple more errors
mark-i-m Mar 22, 2020
cdb2c3c
use static strs
mark-i-m Mar 22, 2020
1e5d81d
Fix invalid suggestion on `&mut` iterators yielding `&` references
tirr-c Mar 22, 2020
82f4a1a
get rid of ConstPropUnsupported; use ZST marker structs instead
RalfJung Mar 22, 2020
12607ef
Add lint when no doc is present at the crate-level
GuillaumeGomez Dec 1, 2019
f767f54
rename NO_CRATE_LEVEL_DOC lint into MISSING_CRATE_LEVEL_DOC
GuillaumeGomez Feb 11, 2020
a8b0e40
Improve code readability
GuillaumeGomez Feb 11, 2020
ffe1289
Update tests
GuillaumeGomez Feb 11, 2020
9664002
Update to new diagnostic
GuillaumeGomez Feb 12, 2020
be97eb4
Update lint name to follow convention
GuillaumeGomez Mar 22, 2020
d40dff9
the crate and tests
mark-i-m Mar 22, 2020
cda81da
avoid unsafe code, use upcasting-trait instead (trick by oli)
RalfJung Mar 22, 2020
5e8b795
fix one more test
mark-i-m Mar 22, 2020
410385d
add macro to reduce boilerplate and keep readable messages
RalfJung Mar 23, 2020
e619b85
make sure we are checking the size of the right thing
RalfJung Mar 23, 2020
19e6935
Clean up E0452 explanation
GuillaumeGomez Mar 23, 2020
799b15e
Evaluate repeat expression lengths as late as possible
oli-obk Mar 14, 2020
fa5a15c
Document most methods on `ty::Const`
oli-obk Mar 14, 2020
3f89c38
Inline `const_param_def_id` at its only use site
oli-obk Mar 14, 2020
770be24
Use `DefId`s to identify anon consts when converting from HIR to ty::…
oli-obk Mar 17, 2020
c3b9881
Remove `ReClosureBound`
matthewjasper Mar 11, 2020
9bcd9fe
Address review comments
oli-obk Mar 23, 2020
c7c2fa1
Make `needs_drop` less pessimistic on generators
jonas-schievink Mar 14, 2020
9ebc72f
Adjust mir-opt test and make it drop something
jonas-schievink Mar 15, 2020
124ab20
Limit `from_anon_const` to `AnonConst`s.
oli-obk Mar 23, 2020
1df7641
Fix rebase fallout
jonas-schievink Mar 23, 2020
e75158d
Account for bad placeholder types in where clauses
estebank Mar 23, 2020
5aa15bf
Remove leftover mentions of `from_anon_const`
oli-obk Mar 23, 2020
4f513b5
Split out some impls from rustc::mir into a separate submodule
oli-obk Mar 23, 2020
ccedc15
Rollup merge of #66938 - GuillaumeGomez:lint-for-no-crate-level-doc, …
Centril Mar 23, 2020
093602e
Rollup merge of #69740 - mark-i-m:describe-it-3, r=eddyb
Centril Mar 23, 2020
32b6b1e
Rollup merge of #69981 - oli-obk:const_blocks, r=eddyb
Centril Mar 23, 2020
c8fb14e
Rollup merge of #70015 - jonas-schievink:gen-needs-drop, r=matthewjasper
Centril Mar 23, 2020
a897944
Rollup merge of #70264 - tirr-c:issue-69789-mut-suggestion, r=estebank
Centril Mar 23, 2020
c213d76
Rollup merge of #70267 - RalfJung:const-prop-unsup, r=oli-obk,wesleyw…
Centril Mar 23, 2020
4c53bfe
Rollup merge of #70277 - matthewjasper:remove-closurebound, r=nikomat…
Centril Mar 23, 2020
de1b094
Rollup merge of #70294 - estebank:bad-placeholder-in-where, r=Centril
Centril Mar 23, 2020
c98c56e
Rollup merge of #70309 - GuillaumeGomez:cleanup-e0452, r=Dylan-DPC
Centril Mar 23, 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
2 changes: 1 addition & 1 deletion src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl dyn Any {
// Get `TypeId` of the type this function is instantiated with.
let t = TypeId::of::<T>();

// Get `TypeId` of the type in the trait object.
// Get `TypeId` of the type in the trait object (`self`).
let concrete = self.type_id();

// Compare both `TypeId`s on equality.
Expand Down
3 changes: 0 additions & 3 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionKind {
ty::ReFree(ref free_region) => {
free_region.hash_stable(hcx, hasher);
}
ty::ReClosureBound(vid) => {
vid.hash_stable(hcx, hasher);
}
ty::ReVar(..) | ty::RePlaceholder(..) => {
bug!("StableHasher: unexpected region {:?}", *self)
}
Expand Down
40 changes: 29 additions & 11 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_hir as hir;
use rustc_macros::HashStable;
use rustc_session::CtfeBacktrace;
use rustc_span::{def_id::DefId, Pos, Span};
use std::{any::Any, fmt};
use std::{any::Any, fmt, mem};

#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)]
pub enum ErrorHandled {
Expand Down Expand Up @@ -449,9 +449,6 @@ impl fmt::Debug for UndefinedBehaviorInfo {
pub enum UnsupportedOpInfo {
/// Free-form case. Only for errors that are never caught!
Unsupported(String),
/// When const-prop encounters a situation it does not support, it raises this error.
/// This must not allocate for performance reasons (hence `str`, not `String`).
ConstPropUnsupported(&'static str),
/// Accessing an unsupported foreign static.
ReadForeignStatic(DefId),
/// Could not find MIR for a function.
Expand All @@ -470,9 +467,6 @@ impl fmt::Debug for UnsupportedOpInfo {
use UnsupportedOpInfo::*;
match self {
Unsupported(ref msg) => write!(f, "{}", msg),
ConstPropUnsupported(ref msg) => {
write!(f, "Constant propagation encountered an unsupported situation: {}", msg)
}
ReadForeignStatic(did) => {
write!(f, "tried to read from foreign (extern) static {:?}", did)
}
Expand Down Expand Up @@ -514,6 +508,29 @@ impl fmt::Debug for ResourceExhaustionInfo {
}
}

/// A trait to work around not having trait object upcasting.
pub trait AsAny: Any {
fn as_any(&self) -> &dyn Any;
}

impl<T: Any> AsAny for T {
#[inline(always)]
fn as_any(&self) -> &dyn Any {
self
}
}

/// A trait for machine-specific errors (or other "machine stop" conditions).
pub trait MachineStopType: AsAny + fmt::Debug + Send {}
impl MachineStopType for String {}

impl dyn MachineStopType {
#[inline(always)]
pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
self.as_any().downcast_ref()
}
}

pub enum InterpError<'tcx> {
/// The program caused undefined behavior.
UndefinedBehavior(UndefinedBehaviorInfo),
Expand All @@ -527,7 +544,7 @@ pub enum InterpError<'tcx> {
ResourceExhaustion(ResourceExhaustionInfo),
/// Stop execution for a machine-controlled reason. This is never raised by
/// the core engine itself.
MachineStop(Box<dyn Any + Send>),
MachineStop(Box<dyn MachineStopType>),
}

pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
Expand All @@ -547,7 +564,7 @@ impl fmt::Debug for InterpError<'_> {
InvalidProgram(ref msg) => write!(f, "{:?}", msg),
UndefinedBehavior(ref msg) => write!(f, "{:?}", msg),
ResourceExhaustion(ref msg) => write!(f, "{:?}", msg),
MachineStop(_) => bug!("unhandled MachineStop"),
MachineStop(ref msg) => write!(f, "{:?}", msg),
}
}
}
Expand All @@ -558,8 +575,9 @@ impl InterpError<'_> {
/// waste of resources.
pub fn allocates(&self) -> bool {
match self {
InterpError::MachineStop(_)
| InterpError::Unsupported(UnsupportedOpInfo::Unsupported(_))
// Zero-sized boxes do not allocate.
InterpError::MachineStop(b) => mem::size_of_val::<dyn MachineStopType>(&**b) > 0,
InterpError::Unsupported(UnsupportedOpInfo::Unsupported(_))
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::ValidationFailure(_))
| InterpError::UndefinedBehavior(UndefinedBehaviorInfo::Ub(_)) => true,
_ => false,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ mod value;

pub use self::error::{
struct_error, ConstEvalErr, ConstEvalRawResult, ConstEvalResult, ErrorHandled, FrameInfo,
InterpError, InterpErrorInfo, InterpResult, InvalidProgramInfo, ResourceExhaustionInfo,
UndefinedBehaviorInfo, UnsupportedOpInfo,
InterpError, InterpErrorInfo, InterpResult, InvalidProgramInfo, MachineStopType,
ResourceExhaustionInfo, UndefinedBehaviorInfo, UnsupportedOpInfo,
};

pub use self::value::{get_slice_bytes, ConstValue, RawConst, Scalar, ScalarMaybeUndef};
Expand Down Expand Up @@ -156,7 +156,7 @@ pub struct LitToConstInput<'tcx> {
pub enum LitToConstError {
/// The literal's inferred type did not match the expected `ty` in the input.
/// This is used for graceful error handling (`delay_span_bug`) in
/// type checking (`AstConv::ast_const_to_const`).
/// type checking (`Const::from_anon_const`).
TypeError,
UnparseableFloat,
Reported,
Expand Down
Loading