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

do not use const stability attribute when we don't even need to call the intrinsic in const #1497

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

RalfJung
Copy link
Member

Id' like to revert rust-lang/rust#97276 since we didn't actually mean to support writing to mutable references in const. But that won't work if stdarch uses the stability attribute. I hope we can just remove it here, otherwise this will be a pain to land...

@rustbot
Copy link
Collaborator

rustbot commented Nov 14, 2023

r? @Amanieu

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

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 14, 2023
revert stabilization of const_intrinsic_copy

`@rust-lang/wg-const-eval`  I don't know what we were thinking when we approved rust-lang#97276... const-eval isn't supposed to be able to mutate anything yet! It's also near impossible to actually call `copy` in const on stable since `&mut` expressions are generally unstable. However, there's one exception...

```rust
static mut INT: i32 = unsafe {
    let val = &mut [1]; // `&mut` on arrays is allowed in `static mut`
    (val as *mut [i32; 1]).copy_from(&[42], 1);
    val[0]
};

fn main() { unsafe {
    dbg!(INT);
} }
```

Inside `static mut`, we accept some `&mut` since ~forever, to make `static mut FOO: &mut [T] = &mut [...];` work. We reject any attempt to actually write to that mutable reference though... except for the `copy` functions.

I think we should revert stabilizing these functions that take `*mut`, and then re-stabilize them together with `ptr.write` once mutable references are stable.

(This will likely fail on PowerPC until rust-lang/stdarch#1497 lands. But we'll need a crater run first anyway.)
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 14, 2023
revert stabilization of const_intrinsic_copy

`@rust-lang/wg-const-eval`  I don't know what we were thinking when we approved rust-lang#97276... const-eval isn't supposed to be able to mutate anything yet! It's also near impossible to actually call `copy` in const on stable since `&mut` expressions are generally unstable. However, there's one exception...

```rust
static mut INT: i32 = unsafe {
    let val = &mut [1]; // `&mut` on arrays is allowed in `static mut`
    (val as *mut [i32; 1]).copy_from(&[42], 1);
    val[0]
};

fn main() { unsafe {
    dbg!(INT);
} }
```

Inside `static mut`, we accept some `&mut` since ~forever, to make `static mut FOO: &mut [T] = &mut [...];` work. We reject any attempt to actually write to that mutable reference though... except for the `copy` functions.

I think we should revert stabilizing these functions that take `*mut`, and then re-stabilize them together with `ptr.write` once mutable references are stable.

(This will likely fail on PowerPC until rust-lang/stdarch#1497 lands. But we'll need a crater run first anyway.)
@Amanieu Amanieu merged commit 205b3a1 into rust-lang:master Nov 16, 2023
26 checks passed
@RalfJung
Copy link
Member Author

Strangely it looks like my branch is not actually merged in this repo? Did this get rebased?

rust-lang projects usually use merging and I find that a lot nicer than rebase -- it preserves which state the repo was in when I actually worked on this branch. Also with rebasing there's no way to detect which of my feature branches have already been merged so I have to delete them all by hand.

@RalfJung RalfJung deleted the non-const-copy branch November 21, 2023 07:14
@Amanieu
Copy link
Member

Amanieu commented Nov 21, 2023

I think the repo was configured this way when I inherited it: it doesn't allow merging, only rebasing for PR. I don't have permissions to change the settings though.

@lu-zero
Copy link
Contributor

lu-zero commented Nov 21, 2023

Ideally there is a setting to autodelete the branch on merge no matter the merge strategy used

@RalfJung
Copy link
Member Author

Ideally there is a setting to autodelete the branch on merge no matter the merge strategy used

That would help, but doesn't take care of the local versions of these feature branches in my checkouts.

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2024
revert stabilization of const_intrinsic_copy

`@rust-lang/wg-const-eval`  I don't know what we were thinking when we approved rust-lang#97276... const-eval isn't supposed to be able to mutate anything yet! It's also near impossible to actually call `copy` in const on stable since `&mut` expressions are generally unstable. However, there's one exception...

```rust
static mut INT: i32 = unsafe {
    let val = &mut [1]; // `&mut` on arrays is allowed in `static mut`
    (val as *mut [i32; 1]).copy_from(&[42], 1);
    val[0]
};

fn main() { unsafe {
    dbg!(INT);
} }
```

Inside `static mut`, we accept some `&mut` since ~forever, to make `static mut FOO: &mut [T] = &mut [...];` work. We reject any attempt to actually write to that mutable reference though... except for the `copy` functions.

I think we should revert stabilizing these functions that take `*mut`, and then re-stabilize them together with `ptr.write` once mutable references are stable.

(This will likely fail on PowerPC until rust-lang/stdarch#1497 lands. But we'll need a crater run first anyway.)
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2024
revert stabilization of const_intrinsic_copy

`@rust-lang/wg-const-eval`  I don't know what we were thinking when we approved rust-lang#97276... const-eval isn't supposed to be able to mutate anything yet! It's also near impossible to actually call `copy` in const on stable since `&mut` expressions are generally unstable. However, there's one exception...

```rust
static mut INT: i32 = unsafe {
    let val = &mut [1]; // `&mut` on arrays is allowed in `static mut`
    (val as *mut [i32; 1]).copy_from(&[42], 1);
    val[0]
};

fn main() { unsafe {
    dbg!(INT);
} }
```

Inside `static mut`, we accept some `&mut` since ~forever, to make `static mut FOO: &mut [T] = &mut [...];` work. We reject any attempt to actually write to that mutable reference though... except for the `copy` functions.

I think we should revert stabilizing these functions that take `*mut`, and then re-stabilize them together with `ptr.write` once mutable references are stable.

(This will likely fail on PowerPC until rust-lang/stdarch#1497 lands. But we'll need a crater run first anyway.)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 8, 2024
revert stabilization of const_intrinsic_copy

`@rust-lang/wg-const-eval`  I don't know what we were thinking when we approved rust-lang/rust#97276... const-eval isn't supposed to be able to mutate anything yet! It's also near impossible to actually call `copy` in const on stable since `&mut` expressions are generally unstable. However, there's one exception...

```rust
static mut INT: i32 = unsafe {
    let val = &mut [1]; // `&mut` on arrays is allowed in `static mut`
    (val as *mut [i32; 1]).copy_from(&[42], 1);
    val[0]
};

fn main() { unsafe {
    dbg!(INT);
} }
```

Inside `static mut`, we accept some `&mut` since ~forever, to make `static mut FOO: &mut [T] = &mut [...];` work. We reject any attempt to actually write to that mutable reference though... except for the `copy` functions.

I think we should revert stabilizing these functions that take `*mut`, and then re-stabilize them together with `ptr.write` once mutable references are stable.

(This will likely fail on PowerPC until rust-lang/stdarch#1497 lands. But we'll need a crater run first anyway.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants