Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/72352.rs: fixed with errors #416

Merged
merged 1 commit into from
Jun 24, 2020
Merged

ices/72352.rs: fixed with errors #416

merged 1 commit into from
Jun 24, 2020

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#72352

#![allow(incomplete_features)]
#![feature(const_compare_raw_pointers)]
#![feature(const_generics)]

use std::ffi::{CStr, CString};

fn main() {
    let baguette = CString::new("baguette").unwrap();
    let ptr = baguette.as_ptr();
    println!("{}", unsafe {
        unsafely_do_the_thing::<safely_do_the_thing>(ptr)
    });
}

unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
    F(CStr::from_ptr(ptr))
}

fn safely_do_the_thing(s: &CStr) -> usize {
    s.to_bytes().len()
}
=== stdout ===
=== stderr ===
error[E0557]: feature has been removed
 --> /home/runner/work/glacier/glacier/ices/72352.rs:2:12
  |
2 | #![feature(const_compare_raw_pointers)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
  |
  = note: cannot be allowed in const eval in any meaningful way

error: using function pointers as const generic parameters is forbidden
  --> /home/runner/work/glacier/glacier/ices/72352.rs:15:42
   |
15 | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
   |                                          ^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

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

=== stdout ===
=== stderr ===
error[E0557]: feature has been removed
 --> /home/runner/work/glacier/glacier/ices/72352.rs:2:12
  |
2 | #![feature(const_compare_raw_pointers)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
  |
  = note: cannot be allowed in const eval in any meaningful way

error: using function pointers as const generic parameters is forbidden
  --> /home/runner/work/glacier/glacier/ices/72352.rs:15:42
   |
15 | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
   |                                          ^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0557`.
==============
@JohnTitor JohnTitor merged commit 5c0241a into master Jun 24, 2020
@JohnTitor JohnTitor deleted the autofix/ices/72352.rs branch June 24, 2020 12:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants