Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
librustc has been updated
  • Loading branch information
GuillaumeGomez committed Feb 6, 2015
1 parent 8b12d3d commit 664c41b
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 66 deletions.
28 changes: 14 additions & 14 deletions src/librustc/lint/builtin.rs
Expand Up @@ -699,7 +699,7 @@ impl LintPass for UnusedAttributes {

if !attr::is_used(attr) {
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute");
if CRATE_ATTRS.contains(&attr.name().get()) {
if CRATE_ATTRS.contains(&&attr.name()[]) {
let msg = match attr.node.style {
ast::AttrOuter => "crate-level attribute should be an inner \
attribute: add an exclamation mark: #![foo]",
Expand Down Expand Up @@ -801,7 +801,7 @@ impl LintPass for UnusedResults {
None => {}
Some(s) => {
msg.push_str(": ");
msg.push_str(s.get());
msg.push_str(&s[]);
}
}
cx.span_lint(UNUSED_MUST_USE, sp, &msg[]);
Expand All @@ -826,8 +826,8 @@ impl NonCamelCaseTypes {
fn check_case(&self, cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
fn is_camel_case(ident: ast::Ident) -> bool {
let ident = token::get_ident(ident);
if ident.get().is_empty() { return true; }
let ident = ident.get().trim_matches('_');
if ident.is_empty() { return true; }
let ident = ident.trim_matches('_');

// start with a non-lowercase letter rather than non-uppercase
// ones (some scripts don't have a concept of upper/lowercase)
Expand All @@ -844,7 +844,7 @@ impl NonCamelCaseTypes {
let s = token::get_ident(ident);

if !is_camel_case(ident) {
let c = to_camel_case(s.get());
let c = to_camel_case(&s[]);
let m = if c.is_empty() {
format!("{} `{}` should have a camel case name such as `CamelCase`", sort, s)
} else {
Expand Down Expand Up @@ -977,8 +977,8 @@ impl NonSnakeCase {
fn check_snake_case(&self, cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
fn is_snake_case(ident: ast::Ident) -> bool {
let ident = token::get_ident(ident);
if ident.get().is_empty() { return true; }
let ident = ident.get().trim_left_matches('\'');
if ident.is_empty() { return true; }
let ident = ident.trim_left_matches('\'');
let ident = ident.trim_matches('_');

let mut allow_underscore = true;
Expand All @@ -996,8 +996,8 @@ impl NonSnakeCase {
let s = token::get_ident(ident);

if !is_snake_case(ident) {
let sc = NonSnakeCase::to_snake_case(s.get());
if sc != s.get() {
let sc = NonSnakeCase::to_snake_case(&s[]);
if sc != &s[] {
cx.span_lint(NON_SNAKE_CASE, span,
&*format!("{} `{}` should have a snake case name such as `{}`",
sort, s, sc));
Expand Down Expand Up @@ -1077,10 +1077,10 @@ impl NonUpperCaseGlobals {
fn check_upper_case(cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
let s = token::get_ident(ident);

if s.get().chars().any(|c| c.is_lowercase()) {
let uc: String = NonSnakeCase::to_snake_case(s.get()).chars()
if s.chars().any(|c| c.is_lowercase()) {
let uc: String = NonSnakeCase::to_snake_case(&s[]).chars()
.map(|c| c.to_uppercase()).collect();
if uc != s.get() {
if uc != &s[] {
cx.span_lint(NON_UPPER_CASE_GLOBALS, span,
&format!("{} `{}` should have an upper case name such as `{}`",
sort, s, uc));
Expand Down Expand Up @@ -1241,7 +1241,7 @@ impl LintPass for UnusedImportBraces {
match items[0].node {
ast::PathListIdent {ref name, ..} => {
let m = format!("braces around {} is unnecessary",
token::get_ident(*name).get());
&token::get_ident(*name)[]);
cx.span_lint(UNUSED_IMPORT_BRACES, item.span,
&m[]);
},
Expand Down Expand Up @@ -1358,7 +1358,7 @@ impl UnusedMut {
pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| {
let ident = path1.node;
if let ast::BindByValue(ast::MutMutable) = mode {
if !token::get_ident(ident).get().starts_with("_") {
if !token::get_ident(ident).starts_with("_") {
match mutables.entry(ident.name.usize()) {
Vacant(entry) => { entry.insert(vec![id]); },
Occupied(mut entry) => { entry.get_mut().push(id); },
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/lint/context.rs
Expand Up @@ -341,7 +341,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
-> Vec<Result<(InternedString, Level, Span), Span>> {
let mut out = vec!();
for attr in attrs {
let level = match Level::from_str(attr.name().get()) {
let level = match Level::from_str(&attr.name()[]) {
None => continue,
Some(lvl) => lvl,
};
Expand Down Expand Up @@ -499,10 +499,10 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
continue;
}
Ok((lint_name, level, span)) => {
match self.lints.find_lint(lint_name.get(), &self.tcx.sess, Some(span)) {
match self.lints.find_lint(&lint_name[], &self.tcx.sess, Some(span)) {
Some(lint_id) => vec![(lint_id, level, span)],
None => {
match self.lints.lint_groups.get(lint_name.get()) {
match self.lints.lint_groups.get(&lint_name[]) {
Some(&(ref v, _)) => v.iter()
.map(|lint_id: &LintId|
(*lint_id, level, span))
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/metadata/creader.rs
Expand Up @@ -170,7 +170,7 @@ impl<'a> CrateReader<'a> {
fn process_crate(&self, c: &ast::Crate) {
for a in c.attrs.iter().filter(|m| m.name() == "link_args") {
match a.value_str() {
Some(ref linkarg) => self.sess.cstore.add_used_link_args(linkarg.get()),
Some(ref linkarg) => self.sess.cstore.add_used_link_args(&linkarg[]),
None => { /* fallthrough */ }
}
}
Expand All @@ -184,15 +184,15 @@ impl<'a> CrateReader<'a> {
ident, path_opt);
let name = match *path_opt {
Some((ref path_str, _)) => {
let name = path_str.get().to_string();
let name = path_str.to_string();
validate_crate_name(Some(self.sess), &name[],
Some(i.span));
name
}
None => ident.get().to_string(),
None => ident.to_string(),
};
Some(CrateInfo {
ident: ident.get().to_string(),
ident: ident.to_string(),
name: name,
id: i.id,
should_link: should_link(i),
Expand Down Expand Up @@ -237,7 +237,7 @@ impl<'a> CrateReader<'a> {
.collect::<Vec<&ast::Attribute>>();
for m in &link_args {
match m.value_str() {
Some(linkarg) => self.sess.cstore.add_used_link_args(linkarg.get()),
Some(linkarg) => self.sess.cstore.add_used_link_args(&linkarg[]),
None => { /* fallthrough */ }
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ impl<'a> CrateReader<'a> {
}
};
register_native_lib(self.sess, Some(m.span),
n.get().to_string(), kind);
n.to_string(), kind);
}
None => {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/csearch.rs
Expand Up @@ -383,7 +383,7 @@ pub fn is_staged_api(cstore: &cstore::CStore, def: ast::DefId) -> bool {
let cdata = cstore.get_crate_data(def.krate);
let attrs = decoder::get_crate_attributes(cdata.data());
for attr in &attrs {
if attr.name().get() == "staged_api" {
if &attr.name()[] == "staged_api" {
match attr.node.value.node { ast::MetaWord(_) => return true, _ => (/*pass*/) }
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -86,11 +86,11 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
}

fn encode_name(rbml_w: &mut Encoder, name: ast::Name) {
rbml_w.wr_tagged_str(tag_paths_data_name, token::get_name(name).get());
rbml_w.wr_tagged_str(tag_paths_data_name, &token::get_name(name)[]);
}

fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Ident) {
rbml_w.wr_tagged_str(tag_item_impl_type_basename, token::get_ident(name).get());
rbml_w.wr_tagged_str(tag_item_impl_type_basename, &token::get_ident(name));
}

pub fn encode_def_id(rbml_w: &mut Encoder, id: DefId) {
Expand Down Expand Up @@ -372,7 +372,7 @@ fn encode_path<PI: Iterator<Item=PathElem>>(rbml_w: &mut Encoder, path: PI) {
ast_map::PathMod(_) => tag_path_elem_mod,
ast_map::PathName(_) => tag_path_elem_name
};
rbml_w.wr_tagged_str(tag, token::get_name(pe.name()).get());
rbml_w.wr_tagged_str(tag, &token::get_name(pe.name())[]);
}
rbml_w.end_tag();
}
Expand Down Expand Up @@ -915,7 +915,7 @@ fn encode_method_argument_names(rbml_w: &mut Encoder,
rbml_w.start_tag(tag_method_argument_name);
if let ast::PatIdent(_, ref path1, _) = arg.pat.node {
let name = token::get_ident(path1.node);
rbml_w.writer.write_all(name.get().as_bytes());
rbml_w.writer.write_all(name.as_bytes());
}
rbml_w.end_tag();
}
Expand Down Expand Up @@ -1636,7 +1636,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
ast::MetaWord(ref name) => {
rbml_w.start_tag(tag_meta_item_word);
rbml_w.start_tag(tag_meta_item_name);
rbml_w.writer.write_all(name.get().as_bytes());
rbml_w.writer.write_all(name.as_bytes());
rbml_w.end_tag();
rbml_w.end_tag();
}
Expand All @@ -1645,10 +1645,10 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
ast::LitStr(ref value, _) => {
rbml_w.start_tag(tag_meta_item_name_value);
rbml_w.start_tag(tag_meta_item_name);
rbml_w.writer.write_all(name.get().as_bytes());
rbml_w.writer.write_all(name.as_bytes());
rbml_w.end_tag();
rbml_w.start_tag(tag_meta_item_value);
rbml_w.writer.write_all(value.get().as_bytes());
rbml_w.writer.write_all(value.as_bytes());
rbml_w.end_tag();
rbml_w.end_tag();
}
Expand All @@ -1658,7 +1658,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
ast::MetaList(ref name, ref items) => {
rbml_w.start_tag(tag_meta_item_list);
rbml_w.start_tag(tag_meta_item_name);
rbml_w.writer.write_all(name.get().as_bytes());
rbml_w.writer.write_all(name.as_bytes());
rbml_w.end_tag();
for inner_item in items {
encode_meta_item(rbml_w, &**inner_item);
Expand Down Expand Up @@ -1695,7 +1695,7 @@ fn encode_paren_sugar(rbml_w: &mut Encoder, paren_sugar: bool) {
fn encode_associated_type_names(rbml_w: &mut Encoder, names: &[ast::Name]) {
rbml_w.start_tag(tag_associated_type_names);
for &name in names {
rbml_w.wr_tagged_str(tag_associated_type_name, token::get_name(name).get());
rbml_w.wr_tagged_str(tag_associated_type_name, &token::get_name(name)[]);
}
rbml_w.end_tag();
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_match.rs
Expand Up @@ -249,7 +249,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
span_warn!(cx.tcx.sess, p.span, E0170,
"pattern binding `{}` is named the same as one \
of the variants of the type `{}`",
token::get_ident(&ident.node)[], ty_to_string(cx.tcx, pat_ty));
&token::get_ident(ident.node)[], ty_to_string(cx.tcx, pat_ty));
span_help!(cx.tcx.sess, p.span,
"if you meant to match on a variant, \
consider making the path in the pattern qualified: `{}::{}`",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/const_eval.rs
Expand Up @@ -610,7 +610,7 @@ pub fn lit_to_const(lit: &ast::Lit) -> const_val {
ast::LitInt(n, ast::UnsignedIntLit(_)) => const_uint(n),
ast::LitFloat(ref n, _) |
ast::LitFloatUnsuffixed(ref n) => {
const_float(n.get().parse::<f64>().unwrap() as f64)
const_float(n.parse::<f64>().unwrap() as f64)
}
ast::LitBool(b) => const_bool(b)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dead.rs
Expand Up @@ -321,7 +321,7 @@ fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
for attr in lint::gather_attrs(attrs) {
match attr {
Ok((ref name, lint::Allow, _))
if name.get() == dead_code => return true,
if &name[] == dead_code => return true,
_ => (),
}
}
Expand Down
18 changes: 7 additions & 11 deletions src/librustc/middle/infer/error_reporting.rs
Expand Up @@ -514,7 +514,6 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
lifetime of captured variable `{}`...",
ty::local_var_name_str(self.tcx,
upvar_id.var_id)
.get()
.to_string());
note_and_explain_region(
self.tcx,
Expand All @@ -526,7 +525,6 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
&format!("...but `{}` is only valid for ",
ty::local_var_name_str(self.tcx,
upvar_id.var_id)
.get()
.to_string())[],
sup,
"");
Expand Down Expand Up @@ -570,8 +568,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
&format!("captured variable `{}` does not \
outlive the enclosing closure",
ty::local_var_name_str(self.tcx,
id).get()
.to_string())[]);
id).to_string())[]);
note_and_explain_region(
self.tcx,
"captured variable is valid for ",
Expand Down Expand Up @@ -959,7 +956,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
// choice of lifetime name deterministic and thus easier to test.
let mut names = Vec::new();
for rn in region_names {
let lt_name = token::get_name(*rn).get().to_string();
let lt_name = token::get_name(*rn).to_string();
names.push(lt_name);
}
names.sort();
Expand Down Expand Up @@ -1438,15 +1435,15 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
}
infer::EarlyBoundRegion(_, name) => {
format!(" for lifetime parameter `{}`",
token::get_name(name).get())
&token::get_name(name))
}
infer::BoundRegionInCoherence(name) => {
format!(" for lifetime parameter `{}` in coherence check",
token::get_name(name).get())
&token::get_name(name)[])
}
infer::UpvarRegion(ref upvar_id, _) => {
format!(" for capture of `{}` by closure",
ty::local_var_name_str(self.tcx, upvar_id.var_id).get().to_string())
ty::local_var_name_str(self.tcx, upvar_id.var_id).to_string())
}
};

Expand Down Expand Up @@ -1527,7 +1524,6 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
&format!(
"...so that closure can access `{}`",
ty::local_var_name_str(self.tcx, upvar_id.var_id)
.get()
.to_string())[])
}
infer::InfStackClosure(span) => {
Expand All @@ -1553,7 +1549,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
does not outlive the enclosing closure",
ty::local_var_name_str(
self.tcx,
id).get().to_string())[]);
id).to_string())[]);
}
infer::IndexSlice(span) => {
self.tcx.sess.span_note(
Expand Down Expand Up @@ -1730,7 +1726,7 @@ impl LifeGiver {
fn with_taken(taken: &[ast::LifetimeDef]) -> LifeGiver {
let mut taken_ = HashSet::new();
for lt in taken {
let lt_name = token::get_name(lt.lifetime.name).get().to_string();
let lt_name = token::get_name(lt.lifetime.name).to_string();
taken_.insert(lt_name);
}
LifeGiver {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/lang_items.rs
Expand Up @@ -149,7 +149,7 @@ impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> {
fn visit_item(&mut self, item: &ast::Item) {
match extract(&item.attrs) {
Some(value) => {
let item_index = self.item_refs.get(value.get()).map(|x| *x);
let item_index = self.item_refs.get(&value[]).map(|x| *x);

match item_index {
Some(item_index) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/liveness.rs
Expand Up @@ -333,7 +333,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
fn variable_name(&self, var: Variable) -> String {
match self.var_kinds[var.get()] {
Local(LocalInfo { ident: nm, .. }) | Arg(_, nm) => {
token::get_ident(nm).get().to_string()
token::get_ident(nm).to_string()
},
ImplicitRet => "<implicit-ret>".to_string(),
CleanExit => "<clean-exit>".to_string()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Expand Up @@ -1543,7 +1543,7 @@ impl<'tcx> Repr<'tcx> for InteriorKind {
fn repr(&self, _tcx: &ty::ctxt) -> String {
match *self {
InteriorField(NamedField(fld)) => {
token::get_name(fld).get().to_string()
token::get_name(fld).to_string()
}
InteriorField(PositionalField(i)) => format!("#{}", i),
InteriorElement(_) => "[]".to_string(),
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/stability.rs
Expand Up @@ -180,7 +180,7 @@ impl Index {
pub fn new(krate: &Crate) -> Index {
let mut staged_api = false;
for attr in &krate.attrs {
if attr.name().get() == "staged_api" {
if &attr.name()[] == "staged_api" {
match attr.node.value.node {
ast::MetaWord(_) => {
attr::mark_used(attr);
Expand Down Expand Up @@ -239,12 +239,12 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
if !self.active_features.contains(feature) {
let msg = match *reason {
Some(ref r) => format!("use of unstable library feature '{}': {}",
feature.get(), r.get()),
None => format!("use of unstable library feature '{}'", feature.get())
&feature[], &r[]),
None => format!("use of unstable library feature '{}'", &feature[])
};

emit_feature_warn(&self.tcx.sess.parse_sess.span_diagnostic,
feature.get(), span, &msg[]);
&feature[], span, &msg[]);
}
}
Some(..) => {
Expand Down

0 comments on commit 664c41b

Please sign in to comment.