Rollup merge of #22385 - dotdash:slice_by_val_copy, r=nikomatsakis
When matching against strings/slices, we call the comparison function for strings, which takes two string slices by value. The slices are passed in memory, and currently we just pass in a pointer to the original slice. That can cause misoptimizations because we emit a call to llvm.lifetime.end for all by-value arguments at the end of a function, which in this case marks the original slice as dead. So we need to properly create copies of the slices to pass them to the comparison function. Fixes #22008
This commit is contained in:
commit
34ab88e30b
2 changed files with 31 additions and 1 deletions
18
src/test/run-pass/issue22008.rs
Normal file
18
src/test/run-pass/issue22008.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
let command = "a";
|
||||
|
||||
match command {
|
||||
"foo" => println!("foo"),
|
||||
_ => println!("{}", command),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue