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 11 pull requests #78956

Merged
merged 25 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift click to select a range
d72d5f4
Dogfood Duration API in std::time tests
workingjubilee Oct 22, 2020
ef027a1
Duration::zero() -> Duration::ZERO
workingjubilee Oct 22, 2020
b989d46
Support enable/disable sanitizers/profiler per target
12101111 Oct 25, 2020
af4d178
Fixup tests: Duration::MIN -> ::ZERO
workingjubilee Oct 27, 2020
82f3a23
Remove Duration::MIN entirely
workingjubilee Oct 27, 2020
439171e
look at assoc ct, check the type of nodes
lcnr Nov 7, 2020
685fd53
BTreeMap: split off most code of append, slightly improve interfaces
ssomers Oct 26, 2020
ffa70d7
Support inlining diverging function calls
tmiasko Nov 9, 2020
c8943c6
Add flags customizing behaviour of MIR inlining
tmiasko Nov 10, 2020
03eec5c
Cleanup and comment intra-doc link pass
jyn514 Nov 10, 2020
ce91c68
rustc_taret: Remove `TargetOptions::is_like_android`
petrochenkov Nov 10, 2020
ca17a91
rustc_target: Move target env "gnu" from `linux_base` to `linux_gnu_b…
petrochenkov Nov 10, 2020
1854425
Fix typo in comment
eltociear Nov 11, 2020
2453ce7
Ship llvm-cov through llvm-tools
dalance Nov 11, 2020
62f0a78
Rollup merge of #78216 - workingjubilee:duration-zero, r=m-ou-se
jonas-schievink Nov 11, 2020
194b968
Rollup merge of #78354 - 12101111:rustbuild_profiler, r=Mark-Simulacrum
jonas-schievink Nov 11, 2020
56e0806
Rollup merge of #78417 - ssomers:btree_chop_up_2, r=Mark-Simulacrum
jonas-schievink Nov 11, 2020
2e0a0b4
Rollup merge of #78832 - lcnr:const-evaluatable-unevaluated, r=oli-obk
jonas-schievink Nov 11, 2020
919177f
Rollup merge of #78873 - tmiasko:inline-opts, r=oli-obk
jonas-schievink Nov 11, 2020
0b521e5
Rollup merge of #78899 - tmiasko:inline-diverging, r=oli-obk
jonas-schievink Nov 11, 2020
a8a0c65
Rollup merge of #78923 - jyn514:intra-doc-comments, r=Manishearth
jonas-schievink Nov 11, 2020
5ac0ae4
Rollup merge of #78929 - petrochenkov:linuxbase, r=joshtriplett
jonas-schievink Nov 11, 2020
904b658
Rollup merge of #78930 - petrochenkov:notlikeandroid, r=Mark-Simulacrum
jonas-schievink Nov 11, 2020
f311458
Rollup merge of #78942 - eltociear:patch-1, r=jonas-schievink
jonas-schievink Nov 11, 2020
61c0a2c
Rollup merge of #78947 - dalance:llvm_cov, r=Mark-Simulacrum
jonas-schievink Nov 11, 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
Prev Previous commit
Next Next commit
look at assoc ct, check the type of nodes
  • Loading branch information
lcnr committed Nov 7, 2020
commit 439171e094e00e7d3ac0b2d8f65c23cac87836f2
17 changes: 17 additions & 0 deletions compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 512,13 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
block = &self.body.basic_blocks()[next];
} else {
assert_eq!(self.locals[mir::RETURN_PLACE], self.nodes.last().unwrap());
// `AbstractConst`s should not contain any promoteds as they require references which
// are not allowed.
assert!(!self.nodes.iter().any(|n| matches!(
n.node,
Node::Leaf(ty::Const { val: ty::ConstKind::Unevaluated(_, _, Some(_)), ty: _ })
)));

self.nodes[self.locals[mir::RETURN_PLACE]].used = true;
if let Some(&unused) = self.nodes.iter().find(|n| !n.used) {
self.error(Some(unused.span), "dead code")?;
Expand Down Expand Up @@ -609,6 616,10 @@ pub(super) fn try_unify<'tcx>(
(Node::Leaf(a_ct), Node::Leaf(b_ct)) => {
let a_ct = a_ct.subst(tcx, a.substs);
let b_ct = b_ct.subst(tcx, b.substs);
if a_ct.ty != b_ct.ty {
return false;
}

match (a_ct.val, b_ct.val) {
// We can just unify errors with everything to reduce the amount of
// emitted errors here.
Expand All @@ -621,6 632,12 @@ pub(super) fn try_unify<'tcx>(
// we do not want to use `assert_eq!(a(), b())` to infer that `N` and `M` have to be `1`. This
// means that we only allow inference variables if they are equal.
(ty::ConstKind::Infer(a_val), ty::ConstKind::Infer(b_val)) => a_val == b_val,
// We may want to instead recurse into unevaluated constants here. That may require some
// care to prevent infinite recursion, so let's just ignore this for now.
(
ty::ConstKind::Unevaluated(a_def, a_substs, None),
ty::ConstKind::Unevaluated(b_def, b_substs, None),
) => a_def == b_def && a_substs == b_substs,
// FIXME(const_evaluatable_checked): We may want to either actually try
// to evaluate `a_ct` and `b_ct` if they are are fully concrete or something like
// this, for now we just return false here.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 1,31 @@
// run-pass
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]

pub trait BlockCipher {
const BLOCK_SIZE: usize;
}

struct FooCipher;
impl BlockCipher for FooCipher {
const BLOCK_SIZE: usize = 64;
}

struct BarCipher;
impl BlockCipher for BarCipher {
const BLOCK_SIZE: usize = 32;
}

pub struct Block<C>(C);

pub fn test<C: BlockCipher, const M: usize>()
where
[u8; M - C::BLOCK_SIZE]: Sized,
{
let _ = [0; M - C::BLOCK_SIZE];
}

fn main() {
test::<FooCipher, 128>();
test::<BarCipher, 64>();
}
Original file line number Diff line number Diff line change
@@ -0,0 1,16 @@
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]

use std::mem::size_of;
use std::marker::PhantomData;

struct Foo<T>(PhantomData<T>);

fn test<T>() -> [u8; size_of::<T>()] {
[0; size_of::<Foo<T>>()]
//~^ ERROR unconstrained generic constant
}

fn main() {
test::<u32>();
}
Original file line number Diff line number Diff line change
@@ -0,0 1,14 @@
error: unconstrained generic constant
--> $DIR/different-fn.rs:10:9
|
LL | [0; size_of::<Foo<T>>()]
| ^^^^^^^^^^^^^^^^^^^
|
help: consider adding a `where` bound for this expression
--> $DIR/different-fn.rs:10:9
|
LL | [0; size_of::<Foo<T>>()]
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error