From dc9ac884195fe59c096ec356ae7b74d7f889faad Mon Sep 17 00:00:00 2001
From: Alex von Gluck IV
Date: Fri, 30 Sep 2016 13:17:22 -0500
Subject: [PATCH 1/9] Haiku: Fix target triplet delimiter
---
src/librustc_back/target/mod.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs
index 087078021a188..4cabd47c2e674 100644
--- a/src/librustc_back/target/mod.rs
+++ b/src/librustc_back/target/mod.rs
@@ -166,8 +166,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),
From d8239e3e59e8b6c36514cfd1363264943b9c08d1 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez
Date: Fri, 30 Sep 2016 21:30:05 +0200
Subject: [PATCH 2/9] Update E0035 to new error format
---
src/librustc_typeck/check/method/confirm.rs | 6 ++++--
src/test/compile-fail/E0035.rs | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs
index ab59fafb65209..22e4018b24fb0 100644
--- a/src/librustc_typeck/check/method/confirm.rs
+++ b/src/librustc_typeck/check/method/confirm.rs
@@ -312,8 +312,10 @@ 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,
"incorrect number of type parameters given for this method: \
diff --git a/src/test/compile-fail/E0035.rs b/src/test/compile-fail/E0035.rs
index 43f46e3578c20..9322d21d2a88d 100644
--- a/src/test/compile-fail/E0035.rs
+++ b/src/test/compile-fail/E0035.rs
@@ -17,4 +17,5 @@ impl Test {
fn main() {
let x = Test;
x.method::(); //~ ERROR E0035
+ //~| NOTE called with unneeded type parameters
}
From c66c4533d115635dae58108f8e6fa03ef4ff511e Mon Sep 17 00:00:00 2001
From: Corey Farwell
Date: Wed, 28 Sep 2016 22:53:35 -0400
Subject: [PATCH 3/9] =?UTF-8?q?Migrate=20Item=20=E2=9E=A1=20ItemType=20fun?=
=?UTF-8?q?ction=20to=20method.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/librustdoc/clean/mod.rs | 25 +++++++++++--------
src/librustdoc/html/render.rs | 45 ++++++++++++++++-------------------
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 0ae059509bd10..da0f6bd995ae3 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -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 }
@@ -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)]
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 9c80f6e98c39c..9c0071816e7cf 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -591,7 +591,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
for &(did, ref item) in orphan_impl_items {
if let Some(&(ref fqp, _)) = paths.get(&did) {
search_index.push(IndexItem {
- ty: item_type(item),
+ ty: item.type_(),
name: item.name.clone().unwrap(),
path: fqp[..fqp.len() - 1].join("::"),
desc: Escape(&shorter(item.doc_value())).to_string(),
@@ -835,11 +835,6 @@ fn mkdir(path: &Path) -> io::Result<()> {
}
}
-/// Returns a documentation-level item type from the item.
-fn item_type(item: &clean::Item) -> ItemType {
- ItemType::from(item)
-}
-
/// Takes a path to a source file and cleans the path to it. This canonicalizes
/// things like ".." to components which preserve the "top down" hierarchy of a
/// static HTML tree. Each component in the cleaned path will be passed as an
@@ -1075,7 +1070,7 @@ impl DocFolder for Cache {
// inserted later on when serializing the search-index.
if item.def_id.index != CRATE_DEF_INDEX {
self.search_index.push(IndexItem {
- ty: item_type(&item),
+ ty: item.type_(),
name: s.to_string(),
path: path.join("::").to_string(),
desc: Escape(&shorter(item.doc_value())).to_string(),
@@ -1122,7 +1117,7 @@ impl DocFolder for Cache {
self.access_levels.is_public(item.def_id)
{
self.paths.insert(item.def_id,
- (self.stack.clone(), item_type(&item)));
+ (self.stack.clone(), item.type_()));
}
}
// link variants to their parent enum because pages aren't emitted
@@ -1135,7 +1130,7 @@ impl DocFolder for Cache {
clean::PrimitiveItem(..) if item.visibility.is_some() => {
self.paths.insert(item.def_id, (self.stack.clone(),
- item_type(&item)));
+ item.type_()));
}
_ => {}
@@ -1304,7 +1299,7 @@ impl Context {
title.push_str(it.name.as_ref().unwrap());
}
title.push_str(" - Rust");
- let tyname = item_type(it).css_class();
+ let tyname = it.type_().css_class();
let desc = if it.is_crate() {
format!("API documentation for the Rust `{}` crate.",
self.shared.layout.krate)
@@ -1407,7 +1402,7 @@ impl Context {
// buf will be empty if the item is stripped and there is no redirect for it
if !buf.is_empty() {
let name = item.name.as_ref().unwrap();
- let item_type = item_type(&item);
+ let item_type = item.type_();
let file_name = &item_path(item_type, name);
let joint_dst = self.dst.join(file_name);
try_err!(fs::create_dir_all(&self.dst), &self.dst);
@@ -1444,7 +1439,7 @@ impl Context {
for item in &m.items {
if maybe_ignore_item(item) { continue }
- let short = item_type(item).css_class();
+ let short = item.type_().css_class();
let myname = match item.name {
None => continue,
Some(ref s) => s.to_string(),
@@ -1541,7 +1536,7 @@ impl<'a> Item<'a> {
}
Some(format!("{path}{file}?gotosrc={goto}",
path = path,
- file = item_path(item_type(self.item), external_path.last().unwrap()),
+ file = item_path(self.item.type_(), external_path.last().unwrap()),
goto = self.item.def_id.index.as_usize()))
}
}
@@ -1586,7 +1581,7 @@ impl<'a> fmt::Display for Item<'a> {
}
}
write!(fmt, "{}",
- item_type(self.item), self.item.name.as_ref().unwrap())?;
+ self.item.type_(), self.item.name.as_ref().unwrap())?;
write!(fmt, "")?; // in-band
write!(fmt, "")?;
@@ -1739,8 +1734,8 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
}
fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: usize, idx2: usize) -> Ordering {
- let ty1 = item_type(i1);
- let ty2 = item_type(i2);
+ let ty1 = i1.type_();
+ let ty2 = i2.type_();
if ty1 != ty2 {
return (reorder(ty1), idx1).cmp(&(reorder(ty2), idx2))
}
@@ -1764,7 +1759,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
continue;
}
- let myty = Some(item_type(myitem));
+ let myty = Some(myitem.type_());
if curty == Some(ItemType::ExternCrate) && myty == Some(ItemType::Import) {
// Put `extern crate` and `use` re-exports in the same section.
curty = myty;
@@ -1851,9 +1846,9 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
name = *myitem.name.as_ref().unwrap(),
stab_docs = stab_docs,
docs = shorter(Some(&Markdown(doc_value).to_string())),
- class = item_type(myitem),
+ class = myitem.type_(),
stab = myitem.stability_class(),
- href = item_path(item_type(myitem), myitem.name.as_ref().unwrap()),
+ href = item_path(myitem.type_(), myitem.name.as_ref().unwrap()),
title = full_path(cx, myitem))?;
}
}
@@ -2059,7 +2054,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::Item)
-> fmt::Result {
let name = m.name.as_ref().unwrap();
- let item_type = item_type(m);
+ let item_type = m.type_();
let id = derive_id(format!("{}.{}", item_type, name));
let ns_id = derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "\
@@ -2145,7 +2140,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
let (ref path, _) = cache.external_paths[&it.def_id];
path[..path.len() - 1].join("/")
},
- ty = item_type(it).css_class(),
+ ty = it.type_().css_class(),
name = *it.name.as_ref().unwrap())?;
Ok(())
}
@@ -2154,7 +2149,7 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink) -> String {
use html::item_type::ItemType::*;
let name = it.name.as_ref().unwrap();
- let ty = match item_type(it) {
+ let ty = match it.type_() {
Typedef | AssociatedType => AssociatedType,
s@_ => s,
};
@@ -2232,7 +2227,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
link: AssocItemLink)
-> fmt::Result {
let name = meth.name.as_ref().unwrap();
- let anchor = format!("#{}.{}", item_type(meth), name);
+ let anchor = format!("#{}.{}", meth.type_(), name);
let href = match link {
AssocItemLink::Anchor(Some(ref id)) => format!("#{}", id),
AssocItemLink::Anchor(None) => anchor,
@@ -2740,7 +2735,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
link: AssocItemLink, render_mode: RenderMode,
is_default_item: bool, outer_version: Option<&str>,
trait_: Option<&clean::Trait>) -> fmt::Result {
- let item_type = item_type(item);
+ let item_type = item.type_();
let name = item.name.as_ref().unwrap();
let render_method_item: bool = match render_mode {
@@ -2932,7 +2927,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
relpath: '{path}'\
}};",
name = it.name.as_ref().map(|x| &x[..]).unwrap_or(""),
- ty = item_type(it).css_class(),
+ ty = it.type_().css_class(),
path = relpath)?;
if parentlen == 0 {
// there is no sidebar-items.js beyond the crate root path
From 7732e621f49a91cb9dd5d788d333da4f6618f39e Mon Sep 17 00:00:00 2001
From: Corey Farwell
Date: Thu, 29 Sep 2016 00:40:32 -0400
Subject: [PATCH 4/9] Simplify logic around Context's root_path.
Was previously cached and maintained in the `Context`, which to me seems
overkill.
---
src/librustdoc/html/render.rs | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 9c0071816e7cf..46461226381a3 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -89,9 +89,6 @@ pub struct Context {
/// Current hierarchy of components leading down to what's currently being
/// rendered
pub current: Vec,
- /// String representation of how to get back to the root path of the 'doc/'
- /// folder in terms of a relative URL.
- pub root_path: String,
/// The current destination folder of where HTML artifacts should be placed.
/// This changes as the context descends into the module hierarchy.
pub dst: PathBuf,
@@ -496,7 +493,6 @@ pub fn run(mut krate: clean::Crate,
krate = render_sources(&dst, &mut scx, krate)?;
let cx = Context {
current: Vec::new(),
- root_path: String::new(),
dst: dst,
render_redirect_pages: false,
shared: Arc::new(scx),
@@ -1225,6 +1221,12 @@ impl<'a> Cache {
}
impl Context {
+ /// String representation of how to get back to the root path of the 'doc/'
+ /// folder in terms of a relative URL.
+ fn root_path(&self) -> String {
+ repeat("../").take(self.current.len()).collect::()
+ }
+
/// Recurse in the directory structure and change the "root path" to make
/// sure it always points to the top (relatively)
fn recurse(&mut self, s: String, f: F) -> T where
@@ -1235,7 +1237,6 @@ impl Context {
}
let prev = self.dst.clone();
self.dst.push(&s);
- self.root_path.push_str("../");
self.current.push(s);
info!("Recursing into {}", self.dst.display());
@@ -1246,8 +1247,6 @@ impl Context {
// Go back to where we were at
self.dst = prev;
- let len = self.root_path.len();
- self.root_path.truncate(len - 3);
self.current.pop().unwrap();
return ret;
@@ -1310,7 +1309,7 @@ impl Context {
let keywords = make_item_keywords(it);
let page = layout::Page {
css_class: tyname,
- root_path: &self.root_path,
+ root_path: &self.root_path(),
title: &title,
description: &desc,
keywords: &keywords,
@@ -1324,8 +1323,7 @@ impl Context {
&Item{ cx: self, item: it },
self.shared.css_file_extension.is_some())?;
} else {
- let mut url = repeat("../").take(self.current.len())
- .collect::();
+ let mut url = self.root_path();
if let Some(&(ref names, ty)) = cache().paths.get(&it.def_id) {
for name in &names[..names.len() - 1] {
url.push_str(name);
@@ -1487,7 +1485,7 @@ impl<'a> Item<'a> {
}).map(|l| &l.1);
let root = match root {
Some(&Remote(ref s)) => s.to_string(),
- Some(&Local) => self.cx.root_path.clone(),
+ Some(&Local) => self.cx.root_path(),
None | Some(&Unknown) => return None,
};
Some(format!("{root}/{krate}/macro.{name}.html?gotomacrosrc=1",
@@ -1502,7 +1500,7 @@ impl<'a> Item<'a> {
let path = PathBuf::from(&self.item.source.filename);
self.cx.shared.local_sources.get(&path).map(|path| {
format!("{root}src/{krate}/{path}#{href}",
- root = self.cx.root_path,
+ root = self.cx.root_path(),
krate = self.cx.shared.layout.krate,
path = path,
href = href)
@@ -1526,7 +1524,7 @@ impl<'a> Item<'a> {
};
let mut path = match cache.extern_locations.get(&self.item.def_id.krate) {
Some(&(_, Remote(ref s))) => s.to_string(),
- Some(&(_, Local)) => self.cx.root_path.clone(),
+ Some(&(_, Local)) => self.cx.root_path(),
Some(&(_, Unknown)) => return None,
None => return None,
};
@@ -2913,7 +2911,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
write!(fmt, "::")?;
}
write!(fmt, "{}",
- &cx.root_path[..(cx.current.len() - i - 1) * 3],
+ &cx.root_path()[..(cx.current.len() - i - 1) * 3],
*name)?;
}
write!(fmt, "
")?;
From 4d5e81d80d1a52a2bc7233dc570e60cd9ae74b91 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez
Date: Fri, 30 Sep 2016 21:44:55 +0200
Subject: [PATCH 5/9] Update E0036 to new error format
---
src/librustc_typeck/check/method/confirm.rs | 16 +++++++++++++---
src/test/compile-fail/E0036.rs | 1 +
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs
index 22e4018b24fb0..e81bca3c17183 100644
--- a/src/librustc_typeck/check/method/confirm.rs
+++ b/src/librustc_typeck/check/method/confirm.rs
@@ -314,13 +314,23 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
if num_method_types == 0 {
struct_span_err!(self.tcx.sess, self.span, E0035,
"does not take type parameters")
- .span_label(self.span, "called with unneeded 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];
}
diff --git a/src/test/compile-fail/E0036.rs b/src/test/compile-fail/E0036.rs
index 35fd6e8942fe7..ecb6dac66f218 100644
--- a/src/test/compile-fail/E0036.rs
+++ b/src/test/compile-fail/E0036.rs
@@ -20,4 +20,5 @@ fn main() {
let x = Test;
let v = &[0];
x.method::(v); //~ ERROR E0036
+ //~| NOTE Passed 2 type arguments, expected 1
}
From 8ea426a6ceb0bee93799a4ffbec6e03c95d2c670 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez
Date: Fri, 30 Sep 2016 22:52:47 +0200
Subject: [PATCH 6/9] Update E0370 to new error format
---
src/librustc_typeck/collect.rs | 10 ++++---
src/test/compile-fail/discrim-overflow-2.rs | 32 +++++++++++++++------
src/test/compile-fail/discrim-overflow.rs | 32 +++++++++++++++------
3 files changed, 54 insertions(+), 20 deletions(-)
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index e5d4d4a9dae2c..cdd7bef2c7fb9 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -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);
diff --git a/src/test/compile-fail/discrim-overflow-2.rs b/src/test/compile-fail/discrim-overflow-2.rs
index 0ff740212e8fa..213683b580883 100644
--- a/src/test/compile-fail/discrim-overflow-2.rs
+++ b/src/test/compile-fail/discrim-overflow-2.rs
@@ -24,7 +24,9 @@ fn f_i8() {
enum A {
Ok = i8::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed on value after 127i8; set explicitly via OhNo = -128i8 if that is desired outcome
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 127i8
+ //~| NOTE explicitly set `OhNo = -128i8` if that is desired outcome
}
}
@@ -33,7 +35,9 @@ fn f_u8() {
enum A {
Ok = u8::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed on value after 255u8; set explicitly via OhNo = 0u8 if that is desired outcome
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 255u8
+ //~| NOTE explicitly set `OhNo = 0u8` if that is desired outcome
}
}
@@ -42,7 +46,9 @@ fn f_i16() {
enum A {
Ok = i16::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 32767i16
+ //~| NOTE explicitly set `OhNo = -32768i16` if that is desired outcome
}
}
@@ -51,7 +57,9 @@ fn f_u16() {
enum A {
Ok = u16::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 65535u16
+ //~| NOTE explicitly set `OhNo = 0u16` if that is desired outcome
}
}
@@ -60,7 +68,9 @@ fn f_i32() {
enum A {
Ok = i32::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 2147483647i32
+ //~| NOTE explicitly set `OhNo = -2147483648i32` if that is desired outcome
}
}
@@ -69,7 +79,9 @@ fn f_u32() {
enum A {
Ok = u32::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 4294967295u32
+ //~| NOTE explicitly set `OhNo = 0u32` if that is desired outcome
}
}
@@ -78,7 +90,9 @@ fn f_i64() {
enum A {
Ok = i64::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 9223372036854775807i64
+ //~| NOTE explicitly set `OhNo = -9223372036854775808i64` if that is desired outcome
}
}
@@ -87,7 +101,9 @@ fn f_u64() {
enum A {
Ok = u64::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 18446744073709551615u64
+ //~| NOTE explicitly set `OhNo = 0u64` if that is desired outcome
}
}
diff --git a/src/test/compile-fail/discrim-overflow.rs b/src/test/compile-fail/discrim-overflow.rs
index 7316e737b6da8..a3039b8d9573a 100644
--- a/src/test/compile-fail/discrim-overflow.rs
+++ b/src/test/compile-fail/discrim-overflow.rs
@@ -22,7 +22,9 @@ fn f_i8() {
enum A {
Ok = i8::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed on value after 127i8; set explicitly via OhNo = -128i8 if that is desired outcome
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 127i8
+ //~| NOTE explicitly set `OhNo = -128i8` if that is desired outcome
}
let x = A::Ok;
@@ -33,7 +35,9 @@ fn f_u8() {
enum A {
Ok = u8::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed on value after 255u8; set explicitly via OhNo = 0u8 if that is desired outcome
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 255u8
+ //~| NOTE explicitly set `OhNo = 0u8` if that is desired outcome
}
let x = A::Ok;
@@ -44,7 +48,9 @@ fn f_i16() {
enum A {
Ok = i16::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| NOTE overflowed on value after 32767i16
+ //~| NOTE explicitly set `OhNo = -32768i16` if that is desired outcome
}
let x = A::Ok;
@@ -55,7 +61,9 @@ fn f_u16() {
enum A {
Ok = u16::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| overflowed on value after 65535u16
+ //~| NOTE explicitly set `OhNo = 0u16` if that is desired outcome
}
let x = A::Ok;
@@ -66,7 +74,9 @@ fn f_i32() {
enum A {
Ok = i32::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| overflowed on value after 2147483647i32
+ //~| NOTE explicitly set `OhNo = -2147483648i32` if that is desired outcome
}
let x = A::Ok;
@@ -77,7 +87,9 @@ fn f_u32() {
enum A {
Ok = u32::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| overflowed on value after 4294967295u32
+ //~| NOTE explicitly set `OhNo = 0u32` if that is desired outcome
}
let x = A::Ok;
@@ -88,7 +100,9 @@ fn f_i64() {
enum A {
Ok = i64::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| overflowed on value after 9223372036854775807i64
+ //~| NOTE explicitly set `OhNo = -9223372036854775808i64` if that is desired outcome
}
let x = A::Ok;
@@ -99,7 +113,9 @@ fn f_u64() {
enum A {
Ok = u64::MAX - 1,
Ok2,
- OhNo, //~ ERROR enum discriminant overflowed
+ OhNo, //~ ERROR enum discriminant overflowed [E0370]
+ //~| overflowed on value after 18446744073709551615u64
+ //~| NOTE explicitly set `OhNo = 0u64` if that is desired outcome
}
let x = A::Ok;
From 41832f27ba5323be8e8935775d95f61bd18ac289 Mon Sep 17 00:00:00 2001
From: Scott Olson
Date: Fri, 30 Sep 2016 16:24:50 -0600
Subject: [PATCH 7/9] Fix RUSTC_VERSION for 'documenting' build stage.
Previously the `env!("RUSTC_VERSION")` requirement would break the
"Documenting rustc_metadata" stage of the rustc build, since that
environment variable is only defined during the main build.
---
src/librustc_metadata/encoder.rs | 2 +-
src/librustc_metadata/loader.rs | 9 +++++----
src/librustc_metadata/schema.rs | 8 +++-----
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs
index ca4fb77d95ad6..4d18462848e5d 100644
--- a/src/librustc_metadata/encoder.rs
+++ b/src/librustc_metadata/encoder.rs
@@ -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,
diff --git a/src/librustc_metadata/loader.rs b/src/librustc_metadata/loader.rs
index fc94cec916aad..75242fc36db76 100644
--- a/src/librustc_metadata/loader.rs
+++ b/src/librustc_metadata/loader.rs
@@ -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;
@@ -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 {:?}",
@@ -597,9 +597,10 @@ impl<'a> Context<'a> {
fn crate_matches(&mut self, metadata: &MetadataBlob, libpath: &Path) -> Option {
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
diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs
index 58e18bc709e3c..1a46315e9cd7a 100644
--- a/src/librustc_metadata/schema.rs
+++ b/src/librustc_metadata/schema.rs
@@ -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
From ba1a49337f8408279e6773818ba4b8215762cb31 Mon Sep 17 00:00:00 2001
From: Alex Burka
Date: Sat, 1 Oct 2016 01:50:56 +0000
Subject: [PATCH 8/9] impl Debug for raw pointers to unsized data
---
src/libcore/fmt/mod.rs | 4 ++--
src/test/run-pass/deriving-show.rs | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs
index a9f53d3abb8b9..9aba6703386a2 100644
--- a/src/libcore/fmt/mod.rs
+++ b/src/libcore/fmt/mod.rs
@@ -1566,11 +1566,11 @@ floating! { f64 }
// Implementation of Display/Debug for various core types
#[stable(feature = "rust1", since = "1.0.0")]
-impl Debug for *const T {
+impl Debug for *const T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl Debug for *mut T {
+impl Debug for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
diff --git a/src/test/run-pass/deriving-show.rs b/src/test/run-pass/deriving-show.rs
index 1f30f3ecedc96..e858ba8c823b8 100644
--- a/src/test/run-pass/deriving-show.rs
+++ b/src/test/run-pass/deriving-show.rs
@@ -24,6 +24,9 @@ enum Enum {
StructVariant { x: isize, y : usize }
}
+#[derive(Debug)]
+struct Pointers(*const Send, *mut Sync);
+
macro_rules! t {
($x:expr, $expected:expr) => {
assert_eq!(format!("{:?}", $x), $expected.to_string())
From 91e1f24f12462b3b573a82c2355e8b803024cbab Mon Sep 17 00:00:00 2001
From: Jeffrey Seyfried
Date: Sat, 1 Oct 2016 07:38:47 +0000
Subject: [PATCH 9/9] Fix `module_to_string`.
---
src/librustc_resolve/lib.rs | 2 +-
src/test/compile-fail/issue-36881.rs | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 src/test/compile-fail/issue-36881.rs
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 0694edd235777..d1bfb7d786eb3 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -3534,7 +3534,7 @@ fn module_to_string(module: Module) -> String {
} else {
// danger, shouldn't be ident?
names.push(token::intern(""));
- collect_mod(names, module);
+ collect_mod(names, module.parent.unwrap());
}
}
collect_mod(&mut names, module);
diff --git a/src/test/compile-fail/issue-36881.rs b/src/test/compile-fail/issue-36881.rs
new file mode 100644
index 0000000000000..cca20e968e0c4
--- /dev/null
+++ b/src/test/compile-fail/issue-36881.rs
@@ -0,0 +1,14 @@
+// Copyright 2016 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 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ extern crate rand;
+ use rand::Rng; //~ ERROR unresolved import
+}