Skip to content

Commit a98e7ac

Browse files
committed
---
yaml --- r: 193783 b: refs/heads/beta c: 34ce376 h: refs/heads/master i: 193781: 1f73502 193779: 69cea44 193775: df0f8ef v: v3
1 parent b41c213 commit a98e7ac

File tree

18 files changed

+212
-208
lines changed

18 files changed

+212
-208
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: 9eed8ea644c18e81079be240684b41dd0cf00b02
34+
refs/heads/beta: 34ce3761404c417be756f8fcc030c210b8e34117
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: de8a23bbc3a7b9cbd7574b5b91a34af59bf030e6

branches/beta/configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,11 @@ then
823823
LLVM_VERSION=$($LLVM_CONFIG --version)
824824

825825
case $LLVM_VERSION in
826-
(3.[2-6]*)
826+
(3.[5-6]*)
827827
msg "found ok version of LLVM: $LLVM_VERSION"
828828
;;
829829
(*)
830-
err "bad LLVM version: $LLVM_VERSION, need >=3.0svn"
830+
err "bad LLVM version: $LLVM_VERSION, need >=3.5"
831831
;;
832832
esac
833833
fi

branches/beta/mk/main.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
290290
LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
291291
LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
292292
LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
293+
LLVM_LIBDIR_RUSTFLAGS_$(1)=-L "$$(LLVM_LIBDIR_$(1))"
293294
LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
294295
LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
295296
# On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),

branches/beta/mk/target.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
8484
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) \
8585
$$(RUST_LIB_FLAGS_ST$(1)) \
8686
-L "$$(RT_OUTPUT_DIR_$(2))" \
87-
-L "$$(LLVM_LIBDIR_$(2))" \
87+
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
8888
$$(LLVM_STDCPP_RUSTFLAGS_$(2)) \
8989
$$(RUSTFLAGS_$(4)) \
9090
--out-dir $$(@D) \

branches/beta/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
372372
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \
373373
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
374374
-L "$$(RT_OUTPUT_DIR_$(2))" \
375-
-L "$$(LLVM_LIBDIR_$(2))" \
375+
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
376376
$$(RUSTFLAGS_$(4))
377377

378378
endef

branches/beta/src/doc/trpl/concurrency.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn main() {
339339
});
340340
}
341341
342-
rx.recv().ok().expect("Could not recieve answer");
342+
rx.recv().ok().expect("Could not receive answer");
343343
}
344344
```
345345

branches/beta/src/librustc/middle/check_match.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ fn is_useful(cx: &MatchCheckCtxt,
646646
if rows[0].len() == 0 {
647647
return NotUseful;
648648
}
649+
assert!(rows.iter().all(|r| r.len() == v.len()));
649650
let real_pat = match rows.iter().find(|r| (*r)[0].id != DUMMY_NODE_ID) {
650651
Some(r) => raw_pat(r[0]),
651652
None if v.len() == 0 => return NotUseful,
@@ -654,7 +655,12 @@ fn is_useful(cx: &MatchCheckCtxt,
654655
let left_ty = if real_pat.id == DUMMY_NODE_ID {
655656
ty::mk_nil(cx.tcx)
656657
} else {
657-
ty::pat_ty(cx.tcx, &*real_pat)
658+
let left_ty = ty::pat_ty(cx.tcx, &*real_pat);
659+
660+
match real_pat.node {
661+
ast::PatIdent(ast::BindByRef(..), _, _) => ty::deref(left_ty, false).unwrap().ty,
662+
_ => left_ty,
663+
}
658664
};
659665

660666
let max_slice_length = rows.iter().filter_map(|row| match row[0].node {

branches/beta/src/librustc/middle/dead.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
4747
struct_has_extern_repr: bool,
4848
ignore_non_const_paths: bool,
4949
inherited_pub_visibility: bool,
50-
ignore_variant_stack: Vec<ast::NodeId>,
5150
}
5251

5352
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
@@ -60,7 +59,6 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
6059
struct_has_extern_repr: false,
6160
ignore_non_const_paths: false,
6261
inherited_pub_visibility: false,
63-
ignore_variant_stack: vec![],
6462
}
6563
}
6664

@@ -81,9 +79,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
8179
def::DefPrimTy(_) => (),
8280
def::DefVariant(enum_id, variant_id, _) => {
8381
self.check_def_id(enum_id);
84-
if !self.ignore_variant_stack.contains(&variant_id.node) {
85-
self.check_def_id(variant_id);
86-
}
82+
self.check_def_id(variant_id);
8783
}
8884
_ => {
8985
self.check_def_id(def.def_id());
@@ -282,23 +278,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
282278
visit::walk_expr(self, expr);
283279
}
284280

285-
fn visit_arm(&mut self, arm: &ast::Arm) {
286-
if arm.pats.len() == 1 {
287-
let pat = &*arm.pats[0];
288-
let variants = pat_util::necessary_variants(&self.tcx.def_map, pat);
289-
290-
// Inside the body, ignore constructions of variants
291-
// necessary for the pattern to match. Those construction sites
292-
// can't be reached unless the variant is constructed elsewhere.
293-
let len = self.ignore_variant_stack.len();
294-
self.ignore_variant_stack.push_all(&*variants);
295-
visit::walk_arm(self, arm);
296-
self.ignore_variant_stack.truncate(len);
297-
} else {
298-
visit::walk_arm(self, arm);
299-
}
300-
}
301-
302281
fn visit_pat(&mut self, pat: &ast::Pat) {
303282
let def_map = &self.tcx.def_map;
304283
match pat.node {
@@ -418,11 +397,6 @@ fn create_and_seed_worklist(tcx: &ty::ctxt,
418397
worklist.push(*id);
419398
}
420399
for id in reachable_symbols {
421-
// Reachable variants can be dead, because we warn about
422-
// variants never constructed, not variants never used.
423-
if let Some(ast_map::NodeVariant(..)) = tcx.map.find(*id) {
424-
continue;
425-
}
426400
worklist.push(*id);
427401
}
428402

branches/beta/src/librustc/middle/pat_util.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,3 @@ pub fn def_to_path(tcx: &ty::ctxt, id: ast::DefId) -> ast::Path {
155155
span: DUMMY_SP,
156156
})
157157
}
158-
159-
/// Return variants that are necessary to exist for the pattern to match.
160-
pub fn necessary_variants(dm: &DefMap, pat: &ast::Pat) -> Vec<ast::NodeId> {
161-
let mut variants = vec![];
162-
walk_pat(pat, |p| {
163-
match p.node {
164-
ast::PatEnum(_, _) |
165-
ast::PatIdent(_, _, None) |
166-
ast::PatStruct(..) => {
167-
match dm.borrow().get(&p.id) {
168-
Some(&PathResolution {base_def: DefVariant(_, id, _), ..}) => {
169-
variants.push(id.node);
170-
}
171-
_ => ()
172-
}
173-
}
174-
_ => ()
175-
}
176-
true
177-
});
178-
variants.sort();
179-
variants.dedup();
180-
variants
181-
}

branches/beta/src/librustc/session/search_paths.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use std::slice;
1212
use std::path::{Path, PathBuf};
13+
use session::early_error;
1314

1415
#[derive(Clone, Debug)]
1516
pub struct SearchPaths {
@@ -50,6 +51,9 @@ impl SearchPaths {
5051
} else {
5152
(PathKind::All, path)
5253
};
54+
if path.is_empty() {
55+
early_error("empty search path given via `-L`");
56+
}
5357
self.paths.push((kind, PathBuf::new(path)));
5458
}
5559

branches/beta/src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ impl NonCamelCaseTypes {
811811
if i == 0 {
812812
c.to_uppercase().collect::<String>()
813813
} else {
814-
c.to_string()
814+
c.to_lowercase().collect()
815815
}
816816
)).collect::<Vec<_>>().concat()
817817
}

branches/beta/src/librustdoc/html/render.rs

Lines changed: 117 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
//! both occur before the crate is rendered.
3535
pub use self::ExternalLocation::*;
3636

37+
use std::ascii::OwnedAsciiExt;
3738
use std::cell::RefCell;
3839
use std::cmp::Ordering;
3940
use std::collections::{HashMap, HashSet};
@@ -239,6 +240,51 @@ struct IndexItem {
239240
path: String,
240241
desc: String,
241242
parent: Option<ast::DefId>,
243+
search_type: Option<IndexItemFunctionType>,
244+
}
245+
246+
/// A type used for the search index.
247+
struct Type {
248+
name: Option<String>,
249+
}
250+
251+
impl fmt::Display for Type {
252+
/// Formats type as {name: $name}.
253+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
254+
// Wrapping struct fmt should never call us when self.name is None,
255+
// but just to be safe we write `null` in that case.
256+
match self.name {
257+
Some(ref n) => write!(f, "{{\"name\":\"{}\"}}", n),
258+
None => write!(f, "null")
259+
}
260+
}
261+
}
262+
263+
/// Full type of functions/methods in the search index.
264+
struct IndexItemFunctionType {
265+
inputs: Vec<Type>,
266+
output: Option<Type>
267+
}
268+
269+
impl fmt::Display for IndexItemFunctionType {
270+
/// Formats a full fn type as a JSON {inputs: [Type], outputs: Type/null}.
271+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
272+
// If we couldn't figure out a type, just write `null`.
273+
if self.inputs.iter().any(|ref i| i.name.is_none()) ||
274+
(self.output.is_some() && self.output.as_ref().unwrap().name.is_none()) {
275+
return write!(f, "null")
276+
}
277+
278+
let inputs: Vec<String> = self.inputs.iter().map(|ref t| format!("{}", t)).collect();
279+
try!(write!(f, "{{\"inputs\":[{}],\"output\":", inputs.connect(",")));
280+
281+
match self.output {
282+
Some(ref t) => try!(write!(f, "{}", t)),
283+
None => try!(write!(f, "null"))
284+
};
285+
286+
Ok(try!(write!(f, "}}")))
287+
}
242288
}
243289

244290
// TLS keys used to carry information around during rendering.
@@ -407,8 +453,9 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::Result<String> {
407453
ty: shortty(item),
408454
name: item.name.clone().unwrap(),
409455
path: fqp[..fqp.len() - 1].connect("::"),
410-
desc: shorter(item.doc_value()).to_string(),
456+
desc: shorter(item.doc_value()),
411457
parent: Some(did),
458+
search_type: None,
412459
});
413460
},
414461
None => {}
@@ -458,7 +505,11 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::Result<String> {
458505
let pathid = *nodeid_to_pathid.get(&nodeid).unwrap();
459506
try!(write!(&mut w, ",{}", pathid));
460507
}
461-
None => {}
508+
None => try!(write!(&mut w, ",null"))
509+
}
510+
match item.search_type {
511+
Some(ref t) => try!(write!(&mut w, ",{}", t)),
512+
None => try!(write!(&mut w, ",null"))
462513
}
463514
try!(write!(&mut w, "]"));
464515
}
@@ -872,12 +923,21 @@ impl DocFolder for Cache {
872923

873924
match parent {
874925
(parent, Some(path)) if is_method || (!self.privmod && !hidden_field) => {
926+
// Needed to determine `self` type.
927+
let parent_basename = self.parent_stack.first().and_then(|parent| {
928+
match self.paths.get(parent) {
929+
Some(&(ref fqp, _)) => Some(fqp[fqp.len() - 1].clone()),
930+
_ => None
931+
}
932+
});
933+
875934
self.search_index.push(IndexItem {
876935
ty: shortty(&item),
877936
name: s.to_string(),
878937
path: path.connect("::").to_string(),
879-
desc: shorter(item.doc_value()).to_string(),
938+
desc: shorter(item.doc_value()),
880939
parent: parent,
940+
search_type: get_index_search_type(&item, parent_basename),
881941
});
882942
}
883943
(Some(parent), None) if is_method || (!self.privmod && !hidden_field)=> {
@@ -1467,13 +1527,14 @@ fn full_path(cx: &Context, item: &clean::Item) -> String {
14671527
return s
14681528
}
14691529

1470-
fn shorter<'a>(s: Option<&'a str>) -> &'a str {
1530+
fn shorter<'a>(s: Option<&'a str>) -> String {
14711531
match s {
1472-
Some(s) => match s.find("\n\n") {
1473-
Some(pos) => &s[..pos],
1474-
None => s,
1475-
},
1476-
None => ""
1532+
Some(s) => s.lines().take_while(|line|{
1533+
(*line).chars().any(|chr|{
1534+
!chr.is_whitespace()
1535+
})
1536+
}).collect::<Vec<_>>().connect("\n"),
1537+
None => "".to_string()
14771538
}
14781539
}
14791540

@@ -1603,7 +1664,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
16031664
</tr>
16041665
",
16051666
*myitem.name.as_ref().unwrap(),
1606-
Markdown(shorter(myitem.doc_value())),
1667+
Markdown(&shorter(myitem.doc_value())[..]),
16071668
class = shortty(myitem),
16081669
href = item_path(myitem),
16091670
title = full_path(cx, myitem),
@@ -2307,6 +2368,52 @@ fn make_item_keywords(it: &clean::Item) -> String {
23072368
format!("{}, {}", get_basic_keywords(), it.name.as_ref().unwrap())
23082369
}
23092370

2371+
fn get_index_search_type(item: &clean::Item,
2372+
parent: Option<String>) -> Option<IndexItemFunctionType> {
2373+
let decl = match item.inner {
2374+
clean::FunctionItem(ref f) => &f.decl,
2375+
clean::MethodItem(ref m) => &m.decl,
2376+
clean::TyMethodItem(ref m) => &m.decl,
2377+
_ => return None
2378+
};
2379+
2380+
let mut inputs = Vec::new();
2381+
2382+
// Consider `self` an argument as well.
2383+
if let Some(name) = parent {
2384+
inputs.push(Type { name: Some(name.into_ascii_lowercase()) });
2385+
}
2386+
2387+
inputs.extend(&mut decl.inputs.values.iter().map(|arg| {
2388+
get_index_type(&arg.type_)
2389+
}));
2390+
2391+
let output = match decl.output {
2392+
clean::FunctionRetTy::Return(ref return_type) => Some(get_index_type(return_type)),
2393+
_ => None
2394+
};
2395+
2396+
Some(IndexItemFunctionType { inputs: inputs, output: output })
2397+
}
2398+
2399+
fn get_index_type(clean_type: &clean::Type) -> Type {
2400+
Type { name: get_index_type_name(clean_type).map(|s| s.into_ascii_lowercase()) }
2401+
}
2402+
2403+
fn get_index_type_name(clean_type: &clean::Type) -> Option<String> {
2404+
match *clean_type {
2405+
clean::ResolvedPath { ref path, .. } => {
2406+
let segments = &path.segments;
2407+
Some(segments[segments.len() - 1].name.clone())
2408+
},
2409+
clean::Generic(ref s) => Some(s.clone()),
2410+
clean::Primitive(ref p) => Some(format!("{:?}", p)),
2411+
clean::BorrowedRef { ref type_, .. } => get_index_type_name(type_),
2412+
// FIXME: add all from clean::Type.
2413+
_ => None
2414+
}
2415+
}
2416+
23102417
pub fn cache() -> Arc<Cache> {
23112418
CACHE_KEY.with(|c| c.borrow().clone())
23122419
}

0 commit comments

Comments
 (0)