Skip to content

Commit 0f1c1eb

Browse files
authored
Rollup merge of rust-lang#55828 - oli-obk:promotion_strikes_again, r=eddyb
Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value` cc @pnkfelix fixes rust-lang#55806
2 parents 4c50964 + f4c9dd5 commit 0f1c1eb

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

src/libcore/num/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,7 @@ Basic usage:
21522152
", $Feature, "assert_eq!(", stringify!($SelfT), "::min_value(), 0);", $EndFeature, "
21532153
```"),
21542154
#[stable(feature = "rust1", since = "1.0.0")]
2155+
#[rustc_promotable]
21552156
#[inline]
21562157
pub const fn min_value() -> Self { 0 }
21572158
}
@@ -2168,6 +2169,7 @@ Basic usage:
21682169
stringify!($MaxV), ");", $EndFeature, "
21692170
```"),
21702171
#[stable(feature = "rust1", since = "1.0.0")]
2172+
#[rustc_promotable]
21712173
#[inline]
21722174
pub const fn max_value() -> Self { !0 }
21732175
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Crate that exports a const fn. Used for testing cross-crate.
12+
13+
#![feature(staged_api, rustc_attrs)]
14+
#![stable(since="1.0.0", feature = "mep")]
15+
16+
#![crate_type="rlib"]
17+
18+
#[rustc_promotable]
19+
#[stable(since="1.0.0", feature = "mep")]
20+
#[inline]
21+
pub const fn foo() -> usize { 22 }
22+
23+
#[stable(since="1.0.0", feature = "mep")]
24+
pub struct Foo(usize);
25+
26+
impl Foo {
27+
#[stable(since="1.0.0", feature = "mep")]
28+
#[inline]
29+
#[rustc_promotable]
30+
pub const fn foo() -> usize { 22 }
31+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// compile-pass
2+
// aux-build:promotable_const_fn_lib.rs
3+
4+
#![feature(nll)]
5+
6+
extern crate promotable_const_fn_lib;
7+
8+
use promotable_const_fn_lib::{foo, Foo};
9+
10+
fn main() {
11+
let x: &'static usize = &foo();
12+
let x: &'static usize = &Foo::foo();
13+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// compile-pass
2+
3+
#![feature(nll)]
4+
5+
fn main() {
6+
let x: &'static u8 = &u8::max_value();
7+
let x: &'static u16 = &u16::max_value();
8+
let x: &'static u32 = &u32::max_value();
9+
let x: &'static u64 = &u64::max_value();
10+
let x: &'static u128 = &u128::max_value();
11+
let x: &'static usize = &usize::max_value();
12+
let x: &'static u8 = &u8::min_value();
13+
let x: &'static u16 = &u16::min_value();
14+
let x: &'static u32 = &u32::min_value();
15+
let x: &'static u64 = &u64::min_value();
16+
let x: &'static u128 = &u128::min_value();
17+
let x: &'static usize = &usize::min_value();
18+
let x: &'static i8 = &i8::max_value();
19+
let x: &'static i16 = &i16::max_value();
20+
let x: &'static i32 = &i32::max_value();
21+
let x: &'static i64 = &i64::max_value();
22+
let x: &'static i128 = &i128::max_value();
23+
let x: &'static isize = &isize::max_value();
24+
let x: &'static i8 = &i8::min_value();
25+
let x: &'static i16 = &i16::min_value();
26+
let x: &'static i32 = &i32::min_value();
27+
let x: &'static i64 = &i64::min_value();
28+
let x: &'static i128 = &i128::min_value();
29+
let x: &'static isize = &isize::min_value();
30+
}

0 commit comments

Comments
 (0)