File: issue_58867_inline_as_ref_as_mut.rs

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,245,360 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (35 lines) | stat: -rw-r--r-- 967 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir
pub fn a<T>(x: &mut [T]) -> &mut [T] {
    // CHECK-LABEL: fn a(
    // CHECK: (inlined <[T] as AsMut<[T]>>::as_mut)
    x.as_mut()
}

// EMIT_MIR issue_58867_inline_as_ref_as_mut.b.Inline.after.mir
pub fn b<T>(x: &mut Box<T>) -> &mut T {
    // CHECK-LABEL: fn b(
    // CHECK: (inlined <Box<T> as AsMut<T>>::as_mut)
    x.as_mut()
}

// EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir
pub fn c<T>(x: &[T]) -> &[T] {
    // CHECK-LABEL: fn c(
    // CHECK: (inlined <[T] as AsRef<[T]>>::as_ref)
    x.as_ref()
}

// EMIT_MIR issue_58867_inline_as_ref_as_mut.d.Inline.after.mir
pub fn d<T>(x: &Box<T>) -> &T {
    // CHECK-LABEL: fn d(
    // CHECK: (inlined <Box<T> as AsRef<T>>::as_ref)
    x.as_ref()
}

fn main() {
    let mut boxed = Box::new(1);
    println!("{:?}", a(&mut [1]));
    println!("{:?}", b(&mut boxed));
    println!("{:?}", c(&[1]));
    println!("{:?}", d(&boxed));
}