Skip to content

Commit ebad1d1

Browse files
committed
---
yaml --- r: 169711 b: refs/heads/master c: 3248bc5 h: refs/heads/master i: 169709: ea46e20 169707: 5dd9222 169703: f658e7b 169695: 6610045 v: v3
1 parent c28330d commit ebad1d1

File tree

6 files changed

+62
-67
lines changed

6 files changed

+62
-67
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2f99a41fe1a27a48e96bc2616ec9faa6de924386
2+
refs/heads/master: 3248bc5bd0384712e70f67eb90daa38ae5e5a21f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
55
refs/heads/try: 5204084bd2e46af7cc6e0147430e44dd0d657bbb

trunk/src/libcollections/string.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ pub trait ToString {
932932
fn to_string(&self) -> String;
933933
}
934934

935-
impl<T: fmt::String + ?Sized> ToString for T {
935+
impl<T: fmt::String> ToString for T {
936936
fn to_string(&self) -> String {
937937
use core::fmt::Writer;
938938
let mut buf = String::new();
@@ -994,12 +994,6 @@ mod tests {
994994
assert_eq!(owned.as_ref().map(|s| s.as_slice()), Some("string"));
995995
}
996996

997-
#[test]
998-
fn test_unsized_to_string() {
999-
let s: &str = "abc";
1000-
let _: String = (*s).to_string();
1001-
}
1002-
1003997
#[test]
1004998
fn test_from_utf8() {
1005999
let xs = b"hello".to_vec();

trunk/src/libcollections/vec.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
//! let two = xs.pop();
4545
//! ```
4646
47-
#![stable]
48-
4947
use core::prelude::*;
5048

5149
use alloc::boxed::Box;

trunk/src/libcore/fmt/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! Utilities for formatting and printing strings
1212
1313
#![allow(unused_variables)]
14-
#![stable]
1514

1615
use any;
1716
use cell::{Cell, RefCell, Ref, RefMut};

trunk/src/librustc/session/config.rs

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl Passes {
370370
}
371371
}
372372

373-
/// Declare a macro that will define all CodegenOptions fields and parsers all
373+
/// Declare a macro that will define all CodegenOptions/DebuggingOptions fields and parsers all
374374
/// at once. The goal of this macro is to define an interface that can be
375375
/// programmatically used by the option parser in order to initialize the struct
376376
/// without hardcoding field names all over the place.
@@ -380,23 +380,67 @@ impl Passes {
380380
/// cgsetters module which is a bunch of generated code to parse an option into
381381
/// its respective field in the struct. There are a few hand-written parsers for
382382
/// parsing specific types of values in this module.
383-
macro_rules! cgoptions {
384-
($($opt:ident : $t:ty = ($init:expr, $parse:ident, $desc:expr)),* ,) =>
383+
macro_rules! options {
384+
($struct_name:ident, $setter_name:ident, $defaultfn:ident,
385+
$buildfn:ident, $prefix:expr, $outputname:expr,
386+
$stat:ident, $mod_desc:ident, $mod_set:ident,
387+
$($opt:ident : $t:ty = ($init:expr, $parse:ident, $desc:expr)),* ,) =>
385388
(
386389
#[derive(Clone)]
387-
pub struct CodegenOptions { $(pub $opt: $t),* }
390+
pub struct $struct_name { $(pub $opt: $t),* }
388391

389-
pub fn basic_codegen_options() -> CodegenOptions {
390-
CodegenOptions { $($opt: $init),* }
392+
pub fn $defaultfn() -> $struct_name {
393+
$struct_name { $($opt: $init),* }
391394
}
392395

393-
pub type CodegenSetter = fn(&mut CodegenOptions, v: Option<&str>) -> bool;
394-
pub const CG_OPTIONS: &'static [(&'static str, CodegenSetter,
396+
pub fn $buildfn(matches: &getopts::Matches) -> $struct_name
397+
{
398+
let mut op = $defaultfn();
399+
for option in matches.opt_strs($prefix).into_iter() {
400+
let mut iter = option.splitn(1, '=');
401+
let key = iter.next().unwrap();
402+
let value = iter.next();
403+
let option_to_lookup = key.replace("-", "_");
404+
let mut found = false;
405+
for &(candidate, setter, opt_type_desc, _) in $stat.iter() {
406+
if option_to_lookup != candidate { continue }
407+
if !setter(&mut op, value) {
408+
match (value, opt_type_desc) {
409+
(Some(..), None) => {
410+
early_error(format!("{} option `{}` takes no \
411+
value", $outputname, key)[])
412+
}
413+
(None, Some(type_desc)) => {
414+
early_error(format!("{0} option `{1}` requires \
415+
{2} ({3} {1}=<value>)",
416+
$outputname, key, type_desc, $prefix)[])
417+
}
418+
(Some(value), Some(type_desc)) => {
419+
early_error(format!("incorrect value `{}` for {} \
420+
option `{}` - {} was expected",
421+
value, $outputname, key, type_desc)[])
422+
}
423+
(None, None) => unreachable!()
424+
}
425+
}
426+
found = true;
427+
break;
428+
}
429+
if !found {
430+
early_error(format!("unknown codegen option: `{}`",
431+
key)[]);
432+
}
433+
}
434+
return op;
435+
}
436+
437+
pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
438+
pub const $stat: &'static [(&'static str, $setter_name,
395439
Option<&'static str>, &'static str)] =
396-
&[ $( (stringify!($opt), cgsetters::$opt, cg_type_descs::$parse, $desc) ),* ];
440+
&[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
397441

398442
#[allow(non_upper_case_globals)]
399-
mod cg_type_descs {
443+
mod $mod_desc {
400444
pub const parse_bool: Option<&'static str> = None;
401445
pub const parse_opt_bool: Option<&'static str> = None;
402446
pub const parse_string: Option<&'static str> = Some("a string");
@@ -410,11 +454,11 @@ macro_rules! cgoptions {
410454
Some("a number");
411455
}
412456

413-
mod cgsetters {
414-
use super::{CodegenOptions, Passes, SomePasses, AllPasses};
457+
mod $mod_set {
458+
use super::{$struct_name, Passes, SomePasses, AllPasses};
415459

416460
$(
417-
pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
461+
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
418462
$parse(&mut cg.$opt, v)
419463
}
420464
)*
@@ -506,7 +550,9 @@ macro_rules! cgoptions {
506550
}
507551
) }
508552

509-
cgoptions! {
553+
options! {CodegenOptions, CodegenSetter, basic_codegen_options,
554+
build_codegen_options, "C", "codegen",
555+
CG_OPTIONS, cg_type_desc, cgsetters,
510556
ar: Option<String> = (None, parse_opt_string,
511557
"tool to assemble archives with"),
512558
linker: Option<String> = (None, parse_opt_string,
@@ -562,47 +608,6 @@ cgoptions! {
562608
"Optimize with possible levels 0-3"),
563609
}
564610

565-
pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
566-
{
567-
let mut cg = basic_codegen_options();
568-
for option in matches.opt_strs("C").into_iter() {
569-
let mut iter = option.splitn(1, '=');
570-
let key = iter.next().unwrap();
571-
let value = iter.next();
572-
let option_to_lookup = key.replace("-", "_");
573-
let mut found = false;
574-
for &(candidate, setter, opt_type_desc, _) in CG_OPTIONS.iter() {
575-
if option_to_lookup != candidate { continue }
576-
if !setter(&mut cg, value) {
577-
match (value, opt_type_desc) {
578-
(Some(..), None) => {
579-
early_error(&format!("codegen option `{}` takes no \
580-
value", key)[])
581-
}
582-
(None, Some(type_desc)) => {
583-
early_error(&format!("codegen option `{0}` requires \
584-
{1} (-C {0}=<value>)",
585-
key, type_desc)[])
586-
}
587-
(Some(value), Some(type_desc)) => {
588-
early_error(&format!("incorrect value `{}` for codegen \
589-
option `{}` - {} was expected",
590-
value, key, type_desc)[])
591-
}
592-
(None, None) => unreachable!()
593-
}
594-
}
595-
found = true;
596-
break;
597-
}
598-
if !found {
599-
early_error(&format!("unknown codegen option: `{}`",
600-
key)[]);
601-
}
602-
}
603-
return cg;
604-
}
605-
606611
pub fn default_lib_output() -> CrateType {
607612
CrateTypeRlib
608613
}

trunk/src/libunicode/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ mod u_str;
5757
/// (inclusive) are allowed. A `char` can always be safely cast to a `u32`;
5858
/// however the converse is not always true due to the above range limits
5959
/// and, as such, should be performed via the `from_u32` function..
60-
#[stable]
6160
pub mod char {
6261
pub use core::char::{MAX, from_u32, from_digit};
6362

0 commit comments

Comments
 (0)