Skip to content

Commit 935da07

Browse files
committed
auto merge of #15405 : pcwalton/rust/delifetime, r=nick29581
This was parsed by the parser but completely ignored; not even stored in the AST! This breaks code that looks like: static X: &'static [u8] = &'static [1, 2, 3]; Change this code to the shorter: static X: &'static [u8] = &[1, 2, 3]; Closes #15312. [breaking-change] r? @nick29581
2 parents 25e8b6e + 29ec250 commit 935da07

File tree

13 files changed

+23
-27
lines changed

13 files changed

+23
-27
lines changed

src/libregex_macros/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
316316

317317
#[inline]
318318
fn groups<'r>(&'r mut self, i: uint) -> &'r mut Captures {
319-
&'r mut self.queue[i].groups
319+
&mut self.queue[i].groups
320320
}
321321
}
322322
}

src/librustc/driver/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ pub fn get_os(triple: &str) -> Option<abi::Os> {
427427
}
428428
None
429429
}
430-
static os_names : &'static [(&'static str, abi::Os)] = &'static [
430+
static os_names : &'static [(&'static str, abi::Os)] = &[
431431
("mingw32", abi::OsWin32),
432432
("win32", abi::OsWin32),
433433
("darwin", abi::OsMacos),
@@ -442,7 +442,7 @@ pub fn get_arch(triple: &str) -> Option<abi::Architecture> {
442442
}
443443
None
444444
}
445-
static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'static [
445+
static architecture_abis : &'static [(&'static str, abi::Architecture)] = &[
446446
("i386", abi::X86),
447447
("i486", abi::X86),
448448
("i586", abi::X86),

src/librustc/lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl LintPass for UnusedAttribute {
540540
}
541541

542542
fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) {
543-
static ATTRIBUTE_WHITELIST: &'static [&'static str] = &'static [
543+
static ATTRIBUTE_WHITELIST: &'static [&'static str] = &[
544544
// FIXME: #14408 whitelist docs since rustdoc looks at them
545545
"doc",
546546

@@ -574,7 +574,7 @@ impl LintPass for UnusedAttribute {
574574
"unstable",
575575
];
576576

577-
static CRATE_ATTRS: &'static [&'static str] = &'static [
577+
static CRATE_ATTRS: &'static [&'static str] = &[
578578
"crate_type",
579579
"feature",
580580
"no_start",

src/libserialize/json.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ impl<T: Iterator<char>> Parser<T> {
11181118
/// Provides access to the current position in the logical structure of the
11191119
/// JSON stream.
11201120
pub fn stack<'l>(&'l self) -> &'l Stack {
1121-
return &'l self.stack;
1121+
return &self.stack;
11221122
}
11231123

11241124
fn eof(&self) -> bool { self.ch.is_none() }

src/libstd/collections/hashmap.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ mod table {
294294

295295
unsafe {
296296
debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
297-
(&'a *self.keys.offset(idx),
298-
&'a *self.vals.offset(idx))
297+
(&*self.keys.offset(idx), &*self.vals.offset(idx))
299298
}
300299
}
301300

@@ -306,8 +305,7 @@ mod table {
306305

307306
unsafe {
308307
debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
309-
(&'a *self.keys.offset(idx),
310-
&'a mut *self.vals.offset(idx))
308+
(&*self.keys.offset(idx), &mut *self.vals.offset(idx))
311309
}
312310
}
313311

@@ -319,8 +317,7 @@ mod table {
319317
unsafe {
320318
debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
321319
(transmute(self.hashes.offset(idx)),
322-
&'a mut *self.keys.offset(idx),
323-
&'a mut *self.vals.offset(idx))
320+
&mut *self.keys.offset(idx), &mut *self.vals.offset(idx))
324321
}
325322
}
326323

src/libsyntax/parse/parser.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2400,7 +2400,6 @@ impl<'a> Parser<'a> {
24002400
}
24012401
token::BINOP(token::AND) | token::ANDAND => {
24022402
self.expect_and();
2403-
let _lt = self.parse_opt_lifetime();
24042403
let m = self.parse_mutability();
24052404
let e = self.parse_prefix_expr();
24062405
hi = e.span.hi;

src/libterm/terminfo/parser/compiled.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::super::TermInfo;
1919

2020
// These are the orders ncurses uses in its compiled format (as of 5.9). Not sure if portable.
2121

22-
pub static boolfnames: &'static[&'static str] = &'static["auto_left_margin", "auto_right_margin",
22+
pub static boolfnames: &'static[&'static str] = &["auto_left_margin", "auto_right_margin",
2323
"no_esc_ctlc", "ceol_standout_glitch", "eat_newline_glitch", "erase_overstrike", "generic_type",
2424
"hard_copy", "has_meta_key", "has_status_line", "insert_null_glitch", "memory_above",
2525
"memory_below", "move_insert_mode", "move_standout_mode", "over_strike", "status_line_esc_ok",
@@ -31,12 +31,12 @@ pub static boolfnames: &'static[&'static str] = &'static["auto_left_margin", "au
3131
"no_correctly_working_cr", "gnu_has_meta_key", "linefeed_is_newline", "has_hardware_tabs",
3232
"return_does_clr_eol"];
3333

34-
pub static boolnames: &'static[&'static str] = &'static["bw", "am", "xsb", "xhp", "xenl", "eo",
34+
pub static boolnames: &'static[&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo",
3535
"gn", "hc", "km", "hs", "in", "db", "da", "mir", "msgr", "os", "eslok", "xt", "hz", "ul", "xon",
3636
"nxon", "mc5i", "chts", "nrrmc", "npc", "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy",
3737
"xvpa", "sam", "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "OTpt", "OTxr"];
3838

39-
pub static numfnames: &'static[&'static str] = &'static[ "columns", "init_tabs", "lines",
39+
pub static numfnames: &'static[&'static str] = &[ "columns", "init_tabs", "lines",
4040
"lines_of_memory", "magic_cookie_glitch", "padding_baud_rate", "virtual_terminal",
4141
"width_status_line", "num_labels", "label_height", "label_width", "max_attributes",
4242
"maximum_windows", "max_colors", "max_pairs", "no_color_video", "buffer_capacity",
@@ -46,12 +46,12 @@ pub static numfnames: &'static[&'static str] = &'static[ "columns", "init_tabs",
4646
"bit_image_entwining", "bit_image_type", "magic_cookie_glitch_ul", "carriage_return_delay",
4747
"new_line_delay", "backspace_delay", "horizontal_tab_delay", "number_of_function_keys"];
4848

49-
pub static numnames: &'static[&'static str] = &'static[ "cols", "it", "lines", "lm", "xmc", "pb",
49+
pub static numnames: &'static[&'static str] = &[ "cols", "it", "lines", "lm", "xmc", "pb",
5050
"vt", "wsl", "nlab", "lh", "lw", "ma", "wnum", "colors", "pairs", "ncv", "bufsz", "spinv",
5151
"spinh", "maddr", "mjump", "mcs", "mls", "npins", "orc", "orl", "orhi", "orvi", "cps", "widcs",
5252
"btns", "bitwin", "bitype", "UTug", "OTdC", "OTdN", "OTdB", "OTdT", "OTkn"];
5353

54-
pub static stringfnames: &'static[&'static str] = &'static[ "back_tab", "bell", "carriage_return",
54+
pub static stringfnames: &'static[&'static str] = &[ "back_tab", "bell", "carriage_return",
5555
"change_scroll_region", "clear_all_tabs", "clear_screen", "clr_eol", "clr_eos",
5656
"column_address", "command_character", "cursor_address", "cursor_down", "cursor_home",
5757
"cursor_invisible", "cursor_left", "cursor_mem_address", "cursor_normal", "cursor_right",
@@ -124,7 +124,7 @@ pub static stringfnames: &'static[&'static str] = &'static[ "back_tab", "bell",
124124
"acs_lrcorner", "acs_ltee", "acs_rtee", "acs_btee", "acs_ttee", "acs_hline", "acs_vline",
125125
"acs_plus", "memory_lock", "memory_unlock", "box_chars_1"];
126126

127-
pub static stringnames: &'static[&'static str] = &'static[ "cbt", "_", "cr", "csr", "tbc", "clear",
127+
pub static stringnames: &'static[&'static str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear",
128128
"_", "_", "hpa", "cmdch", "cup", "cud1", "home", "civis", "cub1", "mrcup", "cnorm", "cuf1",
129129
"ll", "cuu1", "cvvis", "dch1", "dl1", "dsl", "hd", "smacs", "blink", "bold", "smcup", "smdc",
130130
"dim", "smir", "invis", "prot", "rev", "smso", "smul", "ech", "rmacs", "sgr0", "rmcup", "rmdc",

src/test/compile-fail/borrowck-forbid-static-unsafe-interior.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static STATIC1: UnsafeEnum<int> = VariantSafe;
3232
static STATIC2: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
3333
static STATIC3: MyUnsafe<int> = MyUnsafe{value: STATIC2};
3434

35-
static STATIC4: &'static Unsafe<int> = &'static STATIC2;
35+
static STATIC4: &'static Unsafe<int> = &STATIC2;
3636
//~^ ERROR borrow of immutable static items with unsafe interior is not allowed
3737

3838
struct Wrap<T> {

src/test/compile-fail/check-static-values-constraints.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ static mut STATIC14: SafeStruct = SafeStruct {
113113
field2: Variant4("str".to_string())
114114
};
115115

116-
static STATIC15: &'static [Box<MyOwned>] = &'static [box MyOwned, box MyOwned];
116+
static STATIC15: &'static [Box<MyOwned>] = &[box MyOwned, box MyOwned];
117117
//~^ ERROR static items are not allowed to have custom pointers
118118
//~^^ ERROR static items are not allowed to have custom pointers
119119

120120
static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) =
121-
(&'static box MyOwned, &'static box MyOwned);
121+
(&box MyOwned, &box MyOwned);
122122
//~^ ERROR static items are not allowed to have custom pointers
123123
//~^^ ERROR static items are not allowed to have custom pointers
124124

src/test/run-pass/issue-5917.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
struct T (&'static [int]);
12-
static t : T = T (&'static [5, 4, 3]);
12+
static t : T = T (&[5, 4, 3]);
1313
pub fn main () {
1414
let T(ref v) = t;
1515
assert_eq!(v[0], 5);

src/test/run-pass/issue-8578.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<'a> UninterpretedOption_NamePart {
1717
static instance: UninterpretedOption_NamePart = UninterpretedOption_NamePart {
1818
name_part: None,
1919
};
20-
&'static instance
20+
&instance
2121
}
2222
}
2323

src/test/run-pass/trans-tag-static-padding.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ fn default_instance() -> &'static Request {
4343
// size of struct may be not equal to size of struct, and
4444
// compiler crashes in internal assertion check.
4545
};
46-
&'static instance
46+
&instance
4747
}
4848

4949
fn non_default_instance() -> &'static Request {
5050
static instance: Request = Request {
5151
foo: TestSome(0x1020304050607080),
5252
bar: 19,
5353
};
54-
&'static instance
54+
&instance
5555
}
5656

5757
pub fn main() {

src/test/run-pass/typeck_type_placeholder_1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// This test checks that the `_` type placeholder works
1212
// correctly for enabling type inference.
1313

14-
static CONSTEXPR: *const int = &'static 413 as *const _;
14+
static CONSTEXPR: *const int = &413 as *const _;
1515

1616
pub fn main() {
1717
let x: Vec<_> = range(0u, 5).collect();

0 commit comments

Comments
 (0)