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

rustc: Add `#[rustc_args_required_const]` #48018

Merged
merged 1 commit into from Feb 7, 2018

Conversation

Projects
None yet
7 participants
@alexcrichton
Copy link
Member

alexcrichton commented Feb 5, 2018

This commit adds a new unstable attribute to the compiler which requires that
arguments to a function are always provided as constants. The primary use case
for this is SIMD intrinsics where arguments are defined by vendors to be
constant and in LLVM they indeed must be constant as well.

For now this is mostly just a semantic guarantee in rustc that an argument is a
constant when invoked, phases like trans don't actually take advantage of it
yet. This means that we'll be able to use this in stdsimd but we won't be able
to remove the constify_* macros just yet. Hopefully soon though!

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 5, 2018

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton

This comment has been minimized.

Copy link
Member Author

alexcrichton commented Feb 5, 2018

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned pnkfelix Feb 5, 2018

@@ -73,7 +73,7 @@ pub enum Candidate {

/// Array of indices found in the third argument of
/// a call to one of the simd_shuffleN intrinsics.

This comment has been minimized.

@eddyb

eddyb Feb 5, 2018

Member

Should also update the comment.

let terminator = mir[bb].terminator();
let ty = match terminator.kind {
TerminatorKind::Call { ref args, .. } => {
args[2].ty(mir, tcx)
args[index].ty(mir, tcx)
}
_ => {
span_bug!(terminator.source_info.span,

This comment has been minimized.

@eddyb

eddyb Feb 5, 2018

Member

Also the ICE message here.

rustc: Add `#[rustc_args_required_const]`
This commit adds a new unstable attribute to the compiler which requires that
arguments to a function are always provided as constants. The primary use case
for this is SIMD intrinsics where arguments are defined by vendors to be
constant and in LLVM they indeed must be constant as well.

For now this is mostly just a semantic guarantee in rustc that an argument is a
constant when invoked, phases like trans don't actually take advantage of it
yet. This means that we'll be able to use this in stdsimd but we won't be able
to remove the `constify_*` macros just yet. Hopefully soon though!

@alexcrichton alexcrichton force-pushed the alexcrichton:require-const-arg branch from dfca1b7 to 27a4e73 Feb 5, 2018

@alexcrichton

This comment has been minimized.

Copy link
Member Author

alexcrichton commented Feb 5, 2018

@bors: r=eddyb

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 5, 2018

📌 Commit 27a4e73 has been approved by eddyb

@varkor

This comment has been minimized.

Copy link
Member

varkor commented Feb 6, 2018

Out of curiosity, is there a reason you decided to use argument indices rather than names, which would appear to me to be more readable and harder to get wrong?

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Feb 6, 2018

@varkor Names come from pattern-matching bindings, arguments don't (necessarily) have them.

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 7, 2018

Rollup merge of rust-lang#48018 - alexcrichton:require-const-arg, r=e…
…ddyb

rustc: Add `#[rustc_args_required_const]`

This commit adds a new unstable attribute to the compiler which requires that
arguments to a function are always provided as constants. The primary use case
for this is SIMD intrinsics where arguments are defined by vendors to be
constant and in LLVM they indeed must be constant as well.

For now this is mostly just a semantic guarantee in rustc that an argument is a
constant when invoked, phases like trans don't actually take advantage of it
yet. This means that we'll be able to use this in stdsimd but we won't be able
to remove the `constify_*` macros just yet. Hopefully soon though!

bors added a commit that referenced this pull request Feb 7, 2018

Auto merge of #48053 - Manishearth:rollup, r=Manishearth
Rollup of 10 pull requests

- Successful merges: #47613, #47631, #47810, #47883, #47922, #47944, #48014, #48018, #48020, #48028
- Failed merges:

@bors bors merged commit 27a4e73 into rust-lang:master Feb 7, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@alexcrichton alexcrichton deleted the alexcrichton:require-const-arg branch Feb 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.