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 10 pull requests #77904

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
97beb07
BTreeMap: derive type-specific variants of node_as_mut and cast_unche…
ssomers Oct 3, 2020
e55d27f
Remove unnecessary rustc_const_stable attributes.
m-ou-se Oct 8, 2020
23c3356
Mention rustdoc in `x.py setup`
jyn514 Oct 10, 2020
d7029cb
`min_const_generics` diagnostics improvements
eopb Oct 11, 2020
eec4436
Make error help clearer
eopb Oct 12, 2020
d909d69
Upgrade OpenSSL to 1.1.1h and add support for aarch64-apple-darwin
shepmaster Oct 12, 2020
5ae5b0e
Enable building Cargo for aarch64-apple-darwin
shepmaster Sep 26, 2020
eb0c996
Configure jemalloc for cross-compilation to aarch64-apple-darwin
shepmaster Sep 27, 2020
e62da8f
Remove a little jargon from error
eopb Oct 12, 2020
facb38d
A little rewording
eopb Oct 12, 2020
c16c8ac
Include `llvm-dis`, `llc` and `opt` in `llvm-tools-preview` component
Aaron1011 Oct 12, 2020
79351b1
Bless expected errors
eopb Oct 12, 2020
61e722f
Use Option::unwrap_or instead of open-coding it
LingMan Oct 12, 2020
45a34fc
Include aarch64-apple-darwin in the dist manifests
shepmaster Oct 13, 2020
a0fc455
Replace absolute paths with relative ones
est31 Oct 13, 2020
b7080e6
Give an error when running `x.py test --stage 0 src/test/ui`
jyn514 Oct 10, 2020
8b6e346
aarch64-apple-darwin now includes Cargo
shepmaster Oct 13, 2020
ccd3914
Rollup merge of #77239 - shepmaster:silicon-ci-plus, r=pietroalbini
JohnTitor Oct 13, 2020
205e23b
Rollup merge of #77569 - ssomers:btree_cleanup_1, r=Mark-Simulacrum
JohnTitor Oct 13, 2020
96693cb
Rollup merge of #77719 - fusion-engineering-forks:const-new-mutex-att…
JohnTitor Oct 13, 2020
bd9aac3
Rollup merge of #77776 - jyn514:wrong-way, r=Mark-Simulacrum
JohnTitor Oct 13, 2020
f6d9e32
Rollup merge of #77786 - jyn514:rustdoc, r=Mark-Simulacrum
JohnTitor Oct 13, 2020
0a83cb9
Rollup merge of #77825 - ethanboxx:min_const_generics_diagnostic, r=lcnr
JohnTitor Oct 13, 2020
f7c9a7e
Rollup merge of #77868 - Aaron1011:llvm-tools-opt-llc, r=Mark-Simulacrum
JohnTitor Oct 13, 2020
c1e2619
Rollup merge of #77884 - LingMan:ast_pretty_unwrap_or, r=varkor
JohnTitor Oct 13, 2020
c021c49
Rollup merge of #77892 - est31:remove_redundant_absolute_paths, r=lcnr
JohnTitor Oct 13, 2020
7664cbf
Rollup merge of #77895 - shepmaster:silicon-manifest, r=pietroalbini
JohnTitor Oct 13, 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
21 changes: 7 additions & 14 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -469,24 +469,17 @@ impl<'a> Resolver<'a> {
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
let mut err = self.session.struct_span_err(
span,
"generic parameters must not be used inside of non-trivial constant values",
);
err.span_label(
span,
&format!(
"non-trivial anonymous constants must not depend on the parameter `{}`",
name
),
"generic parameters must not be used inside const evaluations",
);
err.span_label(span, &format!("cannot perform const operation using `{}`", name));

if is_type {
err.note("type parameters are currently not permitted in anonymous constants");
err.note("type parameters may not be used in anonymous constants");
} else {
err.help(
&format!("it is currently only allowed to use either `{0}` or `{{ {0} }}` as generic constants",
name
)
);
err.help(&format!(
"const parameters may only be used as standalone arguments `{}`",
name
));
}

err
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
@@ -218,7 +218,7 @@ enum ResolutionError<'a> {
ParamInTyOfConstParam(Symbol),
/// constant values inside of type parameter defaults must not depend on generic parameters.
ParamInAnonConstInTyDefault(Symbol),
/// generic parameters must not be used inside of non-trivial constant values.
/// generic parameters must not be used inside const evaluations.
///
/// This error is only emitted when using `min_const_generics`.
ParamInNonTrivialAnonConst { name: Symbol, is_type: bool },
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/array-size-in-generic-struct-param.rs:9:48
|
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
| ^ non-trivial anonymous constants must not depend on the parameter `N`
| ^ cannot perform const operation using `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
= help: const parameters may only be used as standalone arguments `N`

error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/array-size-in-generic-struct-param.rs:20:15
|
LL | arr: [u8; CFG.arr_size],
| ^^^ non-trivial anonymous constants must not depend on the parameter `CFG`
| ^^^ cannot perform const operation using `CFG`
|
= help: it is currently only allowed to use either `CFG` or `{ CFG }` as generic constants
= help: const parameters may only be used as standalone arguments `CFG`

error: `Config` is forbidden as the type of a const generic parameter
--> $DIR/array-size-in-generic-struct-param.rs:18:21
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
#[allow(dead_code)]
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^^ ERROR generic parameters must not be used inside const evaluations

#[derive(PartialEq, Eq)]
struct Config {
@@ -19,7 +19,7 @@ struct B<const CFG: Config> {
//[min]~^ ERROR `Config` is forbidden
arr: [u8; CFG.arr_size],
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters must not be used inside of non-trivial
//[min]~^^ ERROR generic parameters must not be used inside const evaluations
}

const C: Config = Config { arr_size: 5 };
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/const-argument-if-length.rs:19:24
|
LL | pad: [u8; is_zst::<T>()],
| ^ non-trivial anonymous constants must not depend on the parameter `T`
| ^ cannot perform const operation using `T`
|
= note: type parameters are currently not permitted in anonymous constants
= note: type parameters may not be used in anonymous constants

error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/const-argument-if-length.rs:17:12
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/const-argument-if-length.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ pub struct AtLeastByte<T: ?Sized> {
value: T,
//~^ ERROR the size for values of type `T` cannot be known at compilation time
pad: [u8; is_zst::<T>()],
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
//[full]~^^ ERROR evaluation of constant value failed
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/feature-gate-const_evaluatable_checked.rs:6:33
|
LL | type Arr<const N: usize> = [u8; N - 1];
| ^ non-trivial anonymous constants must not depend on the parameter `N`
| ^ cannot perform const operation using `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
= help: const parameters may only be used as standalone arguments `N`

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
#![cfg_attr(min, feature(min_const_generics))]

type Arr<const N: usize> = [u8; N - 1];
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations

fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
//[full]~^ ERROR constant expression depends
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/simple.rs:8:53
|
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
| ^ non-trivial anonymous constants must not depend on the parameter `N`
| ^ cannot perform const operation using `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
= help: const parameters may only be used as standalone arguments `N`

error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/simple.rs:8:35
|
LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
| ^ non-trivial anonymous constants must not depend on the parameter `N`
| ^ cannot perform const operation using `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
= help: const parameters may only be used as standalone arguments `N`

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/simple_fail.rs:7:33
|
LL | type Arr<const N: usize> = [u8; N - 1];
| ^ non-trivial anonymous constants must not depend on the parameter `N`
| ^ cannot perform const operation using `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
= help: const parameters may only be used as standalone arguments `N`

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
#![allow(incomplete_features)]

type Arr<const N: usize> = [u8; N - 1]; //[full]~ ERROR evaluation of constant
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations

fn test<const N: usize>() -> Arr<N> where Arr<N>: Sized {
todo!()
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/generic-function-call-in-array-length.rs:9:39
|
LL | fn bar<const N: usize>() -> [u32; foo(N)] {
| ^ non-trivial anonymous constants must not depend on the parameter `N`
| ^ cannot perform const operation using `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
= help: const parameters may only be used as standalone arguments `N`

error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/generic-function-call-in-array-length.rs:12:13
|
LL | [0; foo(N)]
| ^ non-trivial anonymous constants must not depend on the parameter `N`
| ^ cannot perform const operation using `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
= help: const parameters may only be used as standalone arguments `N`

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -7,10 +7,10 @@
const fn foo(n: usize) -> usize { n * 2 }

fn bar<const N: usize>() -> [u32; foo(N)] {
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
//[full]~^^ ERROR constant expression depends on a generic parameter
[0; foo(N)]
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/generic-sum-in-array-length.rs:7:53
|
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
| ^ non-trivial anonymous constants must not depend on the parameter `A`
| ^ cannot perform const operation using `A`
|
= help: it is currently only allowed to use either `A` or `{ A }` as generic constants
= help: const parameters may only be used as standalone arguments `A`

error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/generic-sum-in-array-length.rs:7:57
|
LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
| ^ non-trivial anonymous constants must not depend on the parameter `B`
| ^ cannot perform const operation using `B`
|
= help: it is currently only allowed to use either `B` or `{ B }` as generic constants
= help: const parameters may only be used as standalone arguments `B`

error: aborting due to 2 previous errors

4 changes: 2 additions & 2 deletions src/test/ui/const-generics/generic-sum-in-array-length.rs
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
#![cfg_attr(min, feature(min_const_generics))]

fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~| ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
//[min]~| ERROR generic parameters must not be used inside const evaluations
//[full]~^^^ ERROR constant expression depends on a generic parameter

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/intrinsics-type_name-as-const-argument.rs:15:44
|
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
| ^ non-trivial anonymous constants must not depend on the parameter `T`
| ^ cannot perform const operation using `T`
|
= note: type parameters are currently not permitted in anonymous constants
= note: type parameters may not be used in anonymous constants

error: `&'static str` is forbidden as the type of a const generic parameter
--> $DIR/intrinsics-type_name-as-const-argument.rs:10:22
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ trait Trait<const S: &'static str> {}
struct Bug<T>
where
T: Trait<{std::intrinsics::type_name::<T>()}>
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
//[full]~^^ ERROR constant expression depends on a generic parameter
{
t: T
12 changes: 6 additions & 6 deletions src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/issue-61522-array-len-succ.rs:7:45
|
LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
| ^^^^^ non-trivial anonymous constants must not depend on the parameter `COUNT`
| ^^^^^ cannot perform const operation using `COUNT`
|
= help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
= help: const parameters may only be used as standalone arguments `COUNT`

error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/issue-61522-array-len-succ.rs:12:30
|
LL | fn inner(&self) -> &[u8; COUNT + 1] {
| ^^^^^ non-trivial anonymous constants must not depend on the parameter `COUNT`
| ^^^^^ cannot perform const operation using `COUNT`
|
= help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants
= help: const parameters may only be used as standalone arguments `COUNT`

error: aborting due to 2 previous errors

6 changes: 3 additions & 3 deletions src/test/ui/const-generics/issue-67375.min.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/issue-67375.rs:9:25
|
LL | inner: [(); { [|_: &T| {}; 0].len() }],
| ^ non-trivial anonymous constants must not depend on the parameter `T`
| ^ cannot perform const operation using `T`
|
= note: type parameters are currently not permitted in anonymous constants
= note: type parameters may not be used in anonymous constants

error[E0392]: parameter `T` is never used
--> $DIR/issue-67375.rs:7:12
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/issue-67375.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
struct Bug<T> {
//~^ ERROR parameter `T` is never used
inner: [(); { [|_: &T| {}; 0].len() }],
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
//[full]~^^ WARN cannot use constants which depend on generic parameters in types
//[full]~^^^ WARN this was previously accepted by the compiler
}
12 changes: 6 additions & 6 deletions src/test/ui/const-generics/issue-67945-1.min.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/issue-67945-1.rs:14:16
|
LL | let x: S = MaybeUninit::uninit();
| ^ non-trivial anonymous constants must not depend on the parameter `S`
| ^ cannot perform const operation using `S`
|
= note: type parameters are currently not permitted in anonymous constants
= note: type parameters may not be used in anonymous constants

error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/issue-67945-1.rs:17:45
|
LL | let b = &*(&x as *const _ as *const S);
| ^ non-trivial anonymous constants must not depend on the parameter `S`
| ^ cannot perform const operation using `S`
|
= note: type parameters are currently not permitted in anonymous constants
= note: type parameters may not be used in anonymous constants

error[E0392]: parameter `S` is never used
--> $DIR/issue-67945-1.rs:11:12
4 changes: 2 additions & 2 deletions src/test/ui/const-generics/issue-67945-1.rs
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@ struct Bug<S> {
//~^ ERROR parameter `S` is never used
A: [(); {
let x: S = MaybeUninit::uninit();
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
//[full]~^^ ERROR mismatched types
let b = &*(&x as *const _ as *const S);
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
0
}],
}
12 changes: 6 additions & 6 deletions src/test/ui/const-generics/issue-67945-2.min.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/issue-67945-2.rs:12:16
|
LL | let x: S = MaybeUninit::uninit();
| ^ non-trivial anonymous constants must not depend on the parameter `S`
| ^ cannot perform const operation using `S`
|
= note: type parameters are currently not permitted in anonymous constants
= note: type parameters may not be used in anonymous constants

error: generic parameters must not be used inside of non-trivial constant values
error: generic parameters must not be used inside const evaluations
--> $DIR/issue-67945-2.rs:15:45
|
LL | let b = &*(&x as *const _ as *const S);
| ^ non-trivial anonymous constants must not depend on the parameter `S`
| ^ cannot perform const operation using `S`
|
= note: type parameters are currently not permitted in anonymous constants
= note: type parameters may not be used in anonymous constants

error[E0392]: parameter `S` is never used
--> $DIR/issue-67945-2.rs:9:12
4 changes: 2 additions & 2 deletions src/test/ui/const-generics/issue-67945-2.rs
Original file line number Diff line number Diff line change
@@ -10,10 +10,10 @@ struct Bug<S> {
//~^ ERROR parameter `S` is never used
A: [(); {
let x: S = MaybeUninit::uninit();
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
//[full]~^^ ERROR mismatched types
let b = &*(&x as *const _ as *const S);
//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
//[min]~^ ERROR generic parameters must not be used inside const evaluations
0
}],
}
Loading