Skip to content

Rollup of 6 pull requests #36885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Oct 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1566,11 +1566,11 @@ floating! { f64 }
// Implementation of Display/Debug for various core types

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Debug for *const T {
impl<T: ?Sized> Debug for *const T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Debug for *mut T {
impl<T: ?Sized> Debug for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ supported_targets! {
("x86_64-unknown-netbsd", x86_64_unknown_netbsd),
("x86_64-rumprun-netbsd", x86_64_rumprun_netbsd),

("i686_unknown_haiku", i686_unknown_haiku),
("x86_64_unknown_haiku", x86_64_unknown_haiku),
("i686-unknown-haiku", i686_unknown_haiku),
("x86_64-unknown-haiku", x86_64_unknown_haiku),

("x86_64-apple-darwin", x86_64_apple_darwin),
("i686-apple-darwin", i686_apple_darwin),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let link_meta = self.link_meta;
let is_rustc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeRustcMacro);
let root = self.lazy(&CrateRoot {
rustc_version: RUSTC_VERSION.to_string(),
rustc_version: rustc_version(),
name: link_meta.crate_name.clone(),
triple: tcx.sess.opts.target_triple.clone(),
hash: link_meta.crate_hash,
Expand Down
9 changes: 5 additions & 4 deletions src/librustc_metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
//! metadata::loader or metadata::creader for all the juicy details!

use cstore::MetadataBlob;
use schema::{METADATA_HEADER, RUSTC_VERSION};
use schema::{METADATA_HEADER, rustc_version};

use rustc::hir::svh::Svh;
use rustc::session::Session;
Expand Down Expand Up @@ -382,7 +382,7 @@ impl<'a> Context<'a> {
}
if !self.rejected_via_version.is_empty() {
err.help(&format!("please recompile that crate using this compiler ({})",
RUSTC_VERSION));
rustc_version()));
let mismatches = self.rejected_via_version.iter();
for (i, &CrateMismatch { ref path, ref got }) in mismatches.enumerate() {
err.note(&format!("crate `{}` path #{}: {} compiled by {:?}",
Expand Down Expand Up @@ -597,9 +597,10 @@ impl<'a> Context<'a> {

fn crate_matches(&mut self, metadata: &MetadataBlob, libpath: &Path) -> Option<Svh> {
let root = metadata.get_root();
if root.rustc_version != RUSTC_VERSION {
let rustc_version = rustc_version();
if root.rustc_version != rustc_version {
info!("Rejecting via version: expected {} got {}",
RUSTC_VERSION, root.rustc_version);
rustc_version, root.rustc_version);
self.rejected_via_version.push(CrateMismatch {
path: libpath.to_path_buf(),
got: root.rustc_version
Expand Down
8 changes: 3 additions & 5 deletions src/librustc_metadata/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ use syntax_pos::{self, Span};

use std::marker::PhantomData;

#[cfg(not(test))]
pub const RUSTC_VERSION: &'static str = concat!("rustc ", env!("CFG_VERSION"));

#[cfg(test)]
pub const RUSTC_VERSION: &'static str = "rustc 0.0.0-unit-test";
pub fn rustc_version() -> String {
format!("rustc {}", option_env!("CFG_VERSION").unwrap_or("unknown version"))
}

/// Metadata encoding version.
/// NB: increment this if you change the format of metadata such that
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3534,7 +3534,7 @@ fn module_to_string(module: Module) -> String {
} else {
// danger, shouldn't be ident?
names.push(token::intern("<opaque>"));
collect_mod(names, module);
collect_mod(names, module.parent.unwrap());
}
}
collect_mod(&mut names, module);
Expand Down
20 changes: 16 additions & 4 deletions src/librustc_typeck/check/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,25 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {

if num_supplied_types > 0 && num_supplied_types != num_method_types {
if num_method_types == 0 {
span_err!(self.tcx.sess, self.span, E0035,
"does not take type parameters");
struct_span_err!(self.tcx.sess, self.span, E0035,
"does not take type parameters")
.span_label(self.span, &"called with unneeded type parameters")
.emit();
} else {
span_err!(self.tcx.sess, self.span, E0036,
struct_span_err!(self.tcx.sess, self.span, E0036,
"incorrect number of type parameters given for this method: \
expected {}, found {}",
num_method_types, num_supplied_types);
num_method_types, num_supplied_types)
.span_label(self.span,
&format!("Passed {} type argument{}, expected {}",
num_supplied_types,
if num_supplied_types != 1 {
"s"
} else {
""
},
num_method_types))
.emit();
}
supplied_method_types = vec![self.tcx.types.err; num_method_types];
}
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,10 +1164,12 @@ fn convert_enum_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
} else if let Some(disr) = repr_type.disr_incr(tcx, prev_disr) {
Some(disr)
} else {
span_err!(tcx.sess, v.span, E0370,
"enum discriminant overflowed on value after {}; \
set explicitly via {} = {} if that is desired outcome",
prev_disr.unwrap(), v.node.name, wrapped_disr);
struct_span_err!(tcx.sess, v.span, E0370,
"enum discriminant overflowed")
.span_label(v.span, &format!("overflowed on value after {}", prev_disr.unwrap()))
.note(&format!("explicitly set `{} = {}` if that is desired outcome",
v.node.name, wrapped_disr))
.emit();
None
}.unwrap_or(wrapped_disr);
prev_disr = Some(disr);
Expand Down
25 changes: 15 additions & 10 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,34 +283,34 @@ impl Item {
}
}
pub fn is_mod(&self) -> bool {
ItemType::from(self) == ItemType::Module
self.type_() == ItemType::Module
}
pub fn is_trait(&self) -> bool {
ItemType::from(self) == ItemType::Trait
self.type_() == ItemType::Trait
}
pub fn is_struct(&self) -> bool {
ItemType::from(self) == ItemType::Struct
self.type_() == ItemType::Struct
}
pub fn is_enum(&self) -> bool {
ItemType::from(self) == ItemType::Module
self.type_() == ItemType::Module
}
pub fn is_fn(&self) -> bool {
ItemType::from(self) == ItemType::Function
self.type_() == ItemType::Function
}
pub fn is_associated_type(&self) -> bool {
ItemType::from(self) == ItemType::AssociatedType
self.type_() == ItemType::AssociatedType
}
pub fn is_associated_const(&self) -> bool {
ItemType::from(self) == ItemType::AssociatedConst
self.type_() == ItemType::AssociatedConst
}
pub fn is_method(&self) -> bool {
ItemType::from(self) == ItemType::Method
self.type_() == ItemType::Method
}
pub fn is_ty_method(&self) -> bool {
ItemType::from(self) == ItemType::TyMethod
self.type_() == ItemType::TyMethod
}
pub fn is_primitive(&self) -> bool {
ItemType::from(self) == ItemType::Primitive
self.type_() == ItemType::Primitive
}
pub fn is_stripped(&self) -> bool {
match self.inner { StrippedItem(..) => true, _ => false }
Expand Down Expand Up @@ -342,6 +342,11 @@ impl Item {
pub fn stable_since(&self) -> Option<&str> {
self.stability.as_ref().map(|s| &s.since[..])
}

/// Returns a documentation-level item type from the item.
pub fn type_(&self) -> ItemType {
ItemType::from(self)
}
}

#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
Expand Down
Loading