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

Closed
wants to merge 32 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9abcfa5
Don't link with --export-dynamic on wasm32-wasi
sunfishcode Jan 21, 2021
77a9e3e
combine: stop eagerly evaluating consts
lcnr Jan 24, 2021
fe39653
Check that value is explicitly none
JulianKnodt Dec 27, 2020
d1727ed
Add lint for 2229 migrations
arora-aman Dec 28, 2020
2c651eb
Process mentioned upvars for analysis first pass after ExprUseVisitor
arora-aman Nov 21, 2020
36352d2
Migrations first pass
arora-aman Dec 15, 2020
d30a5bf
Tests for 2229 lint
arora-aman Dec 30, 2020
9ac023d
Mark the lint doc as compile_fail
arora-aman Jan 3, 2021
f106e18
PR fixup
arora-aman Jan 19, 2021
11abaa1
New migration
arora-aman Jan 26, 2021
b421cd5
Restrict precision of captures with `capture_disjoint_fields` set
arora-aman Dec 4, 2020
3488082
Compute mutability of closure captures
arora-aman Dec 2, 2020
1373f98
Test cases for handling mutable references
arora-aman Dec 13, 2020
0897db5
Test for restricting capture precision
arora-aman Dec 14, 2020
604cbdc
Fix unused 'mut' warning for capture's root variable
arora-aman Dec 16, 2020
c748f32
Fix incorrect use mut diagnostics
arora-aman Dec 13, 2020
ffd5327
Add fixme for precise path diagnostics
arora-aman Jan 12, 2021
fadf03e
Fix typos
arora-aman Jan 29, 2021
0f4bab2
Fixme for closure origin when reborrow is implemented
arora-aman Jan 29, 2021
5a3b85c
Remove changes to Cargo.lock
arora-aman Jan 30, 2021
9946b54
add suggestion for nested fields
b-naber Jan 28, 2021
6946534
Remove const_in_array_rep_expr
JulianKnodt Jan 26, 2021
6695690
Fix small typo
Seppel3210 Jan 31, 2021
8940a26
stabilize int_bits_const
KodrAus Jan 31, 2021
cd9a250
Rollup merge of #80092 - sexxi-goose:restrict_precision, r=nikomatsakis
jonas-schievink Jan 31, 2021
0155051
Rollup merge of #80404 - JulianKnodt:arr_ref, r=oli-obk
jonas-schievink Jan 31, 2021
61ab140
Rollup merge of #80629 - sexxi-goose:migrations_1, r=nikomatsakis
jonas-schievink Jan 31, 2021
666d2ad
Rollup merge of #81255 - sunfishcode:wasi-no-export-dynamic, r=alexcr…
jonas-schievink Jan 31, 2021
9fc2952
Rollup merge of #81351 - lcnr:big-money-big-prices, r=oli-obk
jonas-schievink Jan 31, 2021
6443825
Rollup merge of #81480 - b-naber:nested_fields_suggestion, r=estebank
jonas-schievink Jan 31, 2021
2b9fec7
Rollup merge of #81589 - Seppel3210:master, r=jonas-schievink
jonas-schievink Jan 31, 2021
bd990cc
Rollup merge of #81590 - KodrAus:stabilize/int_bits_const, r=m-ou-se
jonas-schievink Jan 31, 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
28 changes: 20 additions & 8 deletions compiler/rustc_infer/src/infer/combine.rs
Original file line number Diff line number Diff line change
@@ -542,10 +542,6 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
true
}

fn visit_ct_substs(&self) -> bool {
true
}

fn binders<T>(
&mut self,
a: ty::Binder<T>,
@@ -736,6 +732,16 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
}
}
}
ty::ConstKind::Unevaluated(def, substs, promoted)
if self.tcx().lazy_normalization() =>
{
assert_eq!(promoted, None);
let substs = self.relate_with_variance(ty::Variance::Invariant, substs, substs)?;
Ok(self.tcx().mk_const(ty::Const {
ty: c.ty,
val: ty::ConstKind::Unevaluated(def, substs, promoted),
}))
}
_ => relate::super_relate_consts(self, c, c),
}
}
@@ -821,10 +827,6 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
true
}

fn visit_ct_substs(&self) -> bool {
true
}

fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
_variance: ty::Variance,
@@ -958,6 +960,16 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
}
}
}
ty::ConstKind::Unevaluated(def, substs, promoted)
if self.tcx().lazy_normalization() =>
{
assert_eq!(promoted, None);
let substs = self.relate_with_variance(ty::Variance::Invariant, substs, substs)?;
Ok(self.tcx().mk_const(ty::Const {
ty: c.ty,
val: ty::ConstKind::Unevaluated(def, substs, promoted),
}))
}
_ => relate::super_relate_consts(self, c, c),
}
}
11 changes: 1 addition & 10 deletions compiler/rustc_middle/src/ty/relate.rs
Original file line number Diff line number Diff line change
@@ -33,15 +33,6 @@ pub trait TypeRelation<'tcx>: Sized {
/// relation. Just affects error messages.
fn a_is_expected(&self) -> bool;

/// Whether we should look into the substs of unevaluated constants
/// even if `feature(const_evaluatable_checked)` is active.
///
/// This is needed in `combine` to prevent accidentially creating
/// infinite types as we abuse `TypeRelation` to walk a type there.
fn visit_ct_substs(&self) -> bool {
false
}

fn with_cause<F, R>(&mut self, _cause: Cause, f: F) -> R
where
F: FnOnce(&mut Self) -> R,
@@ -588,7 +579,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
(
ty::ConstKind::Unevaluated(a_def, a_substs, None),
ty::ConstKind::Unevaluated(b_def, b_substs, None),
) if tcx.features().const_evaluatable_checked && !relation.visit_ct_substs() => {
) if tcx.features().const_evaluatable_checked => {
if tcx.try_unify_abstract_consts(((a_def, a_substs), (b_def, b_substs))) {
Ok(a.val)
} else {
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/issues/issue-69654-run-pass.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// run-pass
#![feature(const_generics)]
#![allow(incomplete_features, unused_braces)]

@@ -15,4 +14,5 @@ where

fn main() {
Foo::foo();
//~^ ERROR no function or associated item
}
15 changes: 15 additions & 0 deletions src/test/ui/const-generics/issues/issue-69654-run-pass.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0599]: no function or associated item named `foo` found for struct `Foo<{_: usize}>` in the current scope
--> $DIR/issue-69654-run-pass.rs:16:10
|
LL | struct Foo<const N: usize> {}
| -------------------------- function or associated item `foo` not found for this
...
LL | Foo::foo();
| ^^^ function or associated item not found in `Foo<{_: usize}>`
|
= note: the method `foo` exists but the following trait bounds were not satisfied:
`[u8; _]: Bar<[(); _]>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
1 change: 1 addition & 0 deletions src/test/ui/const-generics/issues/issue-69654.rs
Original file line number Diff line number Diff line change
@@ -15,4 +15,5 @@ where

fn main() {
Foo::foo();
//~^ ERROR no function or associated item
}
17 changes: 15 additions & 2 deletions src/test/ui/const-generics/issues/issue-69654.stderr
Original file line number Diff line number Diff line change
@@ -4,6 +4,19 @@ error[E0423]: expected value, found type parameter `T`
LL | impl<T> Bar<T> for [u8; T] {}
| ^ not a value

error: aborting due to previous error
error[E0599]: no function or associated item named `foo` found for struct `Foo<{_: usize}>` in the current scope
--> $DIR/issue-69654.rs:17:10
|
LL | struct Foo<const N: usize> {}
| -------------------------- function or associated item `foo` not found for this
...
LL | Foo::foo();
| ^^^ function or associated item not found in `Foo<{_: usize}>`
|
= note: the method `foo` exists but the following trait bounds were not satisfied:
`[u8; _]: Bar<[(); _]>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0423`.
Some errors have detailed explanations: E0423, E0599.
For more information about an error, try `rustc --explain E0423`.
3 changes: 1 addition & 2 deletions src/test/ui/const-generics/occurs-check/unused-substs-1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// build-pass
#![feature(const_generics)]
#![allow(incomplete_features)]

@@ -10,5 +9,5 @@ where
A<N>: Bar<N>;

fn main() {
let _ = A;
let _ = A; //~ERROR the trait bound
}
17 changes: 17 additions & 0 deletions src/test/ui/const-generics/occurs-check/unused-substs-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0277]: the trait bound `A<{_: usize}>: Bar<{_: usize}>` is not satisfied
--> $DIR/unused-substs-1.rs:12:13
|
LL | / struct A<const N: usize>
LL | | where
LL | | A<N>: Bar<N>;
| |_________________- required by `A`
...
LL | let _ = A;
| ^ the trait `Bar<{_: usize}>` is not implemented for `A<{_: usize}>`
|
= help: the following implementations were found:
<A<7_usize> as Bar<N>>

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/occurs-check/unused-substs-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// check-pass
#![feature(const_generics)]
#![allow(incomplete_features)]

@@ -24,4 +23,6 @@ fn main() {
// `t` is `ty::Infer(TyVar(_#1t))`
// `foo` contains `ty::Infer(TyVar(_#1t))` in its substs
t = foo;
//~^ ERROR mismatched types
//~| NOTE cyclic type
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0308]: mismatched types
--> $DIR/unused-substs-2.rs:25:9
|
LL | t = foo;
| ^^^ cyclic type of infinite size

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
3 changes: 2 additions & 1 deletion src/test/ui/const-generics/occurs-check/unused-substs-3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// check-pass
#![feature(const_generics)]
#![allow(incomplete_features)]

@@ -15,4 +14,6 @@ fn main() {
// `t` is `ty::Infer(TyVar(_#1t))`
// `foo` contains `ty::Infer(TyVar(_#1t))` in its substs
t = foo;
//~^ ERROR mismatched types
//~| NOTE cyclic type
}
12 changes: 12 additions & 0 deletions src/test/ui/const-generics/occurs-check/unused-substs-3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/unused-substs-3.rs:16:9
|
LL | t = foo;
| ^^^
| |
| cyclic type of infinite size
| help: try using a conversion method: `foo.to_vec()`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
3 changes: 1 addition & 2 deletions src/test/ui/const-generics/occurs-check/unused-substs-4.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// build-pass
#![feature(const_generics)]
#![allow(incomplete_features)]

@@ -8,5 +7,5 @@ fn bind<const N: usize>(value: [u8; N]) -> [u8; 3 + 4] {

fn main() {
let mut arr = Default::default();
arr = bind(arr);
arr = bind(arr); //~ ERROR mismatched type
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0308]: mismatched types
--> $DIR/unused-substs-4.rs:10:11
|
LL | arr = bind(arr);
| ^^^^^^^^^ encountered a self-referencing constant

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.