Skip to content

Commit d2367ac

Browse files
committed
---
yaml --- r: 174321 b: refs/heads/snap-stage3 c: 3f0cc80 h: refs/heads/master i: 174319: ae1467b v: v3
1 parent 8344ddd commit d2367ac

File tree

21 files changed

+149
-148
lines changed

21 files changed

+149
-148
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: a833337943300db1c310a4cf9c84b7b4ef4e9468
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: bd8a43c668ba93d29e9671c0c8dc6b67428bf492
4+
refs/heads/snap-stage3: 3f0cc8011aef3f530663302d525bd2d8cb493db5
55
refs/heads/try: 08f6380a9f0b866796080094f44fe25ea5636547
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/liblibc/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,10 +2207,10 @@ pub mod consts {
22072207
pub const IPPROTO_TCP: c_int = 6;
22082208
pub const IPPROTO_IP: c_int = 0;
22092209
pub const IPPROTO_IPV6: c_int = 41;
2210-
pub const IP_MULTICAST_TTL: c_int = 10;
2211-
pub const IP_MULTICAST_LOOP: c_int = 11;
2212-
pub const IP_ADD_MEMBERSHIP: c_int = 12;
2213-
pub const IP_DROP_MEMBERSHIP: c_int = 13;
2210+
pub const IP_MULTICAST_TTL: c_int = 3;
2211+
pub const IP_MULTICAST_LOOP: c_int = 4;
2212+
pub const IP_ADD_MEMBERSHIP: c_int = 5;
2213+
pub const IP_DROP_MEMBERSHIP: c_int = 6;
22142214
pub const IPV6_ADD_MEMBERSHIP: c_int = 5;
22152215
pub const IPV6_DROP_MEMBERSHIP: c_int = 6;
22162216
pub const IP_TTL: c_int = 4;

branches/snap-stage3/src/librustc/middle/infer/error_reporting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11771177
ast::Return(ref ret_ty) => ast::Return(
11781178
self.rebuild_arg_ty_or_output(&**ret_ty, lifetime, anon_nums, region_names)
11791179
),
1180+
ast::DefaultReturn(span) => ast::DefaultReturn(span),
11801181
ast::NoReturn(span) => ast::NoReturn(span)
11811182
}
11821183
}

branches/snap-stage3/src/librustc_trans/trans/debuginfo.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,18 +1450,15 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14501450
let mut signature = Vec::with_capacity(fn_decl.inputs.len() + 1);
14511451

14521452
// Return type -- llvm::DIBuilder wants this at index 0
1453-
match fn_decl.output {
1454-
ast::Return(ref ret_ty) if ret_ty.node == ast::TyTup(vec![]) =>
1455-
signature.push(ptr::null_mut()),
1456-
_ => {
1457-
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
1458-
1459-
let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
1460-
let return_type = monomorphize::apply_param_substs(cx.tcx(),
1461-
param_substs,
1462-
&return_type);
1463-
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
1464-
}
1453+
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
1454+
let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
1455+
let return_type = monomorphize::apply_param_substs(cx.tcx(),
1456+
param_substs,
1457+
&return_type);
1458+
if ty::type_is_nil(return_type) {
1459+
signature.push(ptr::null_mut())
1460+
} else {
1461+
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
14651462
}
14661463

14671464
// Arguments types

branches/snap-stage3/src/librustc_trans/trans/foreign.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,8 @@ fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
445445
for (input, ty) in decl.inputs.iter().zip(sig.inputs.iter()) {
446446
check(&*input.ty, *ty)
447447
}
448-
match decl.output {
449-
ast::NoReturn(_) => {}
450-
ast::Return(ref ty) => check(&**ty, sig.output.unwrap())
448+
if let ast::Return(ref ty) = decl.output {
449+
check(&**ty, sig.output.unwrap())
451450
}
452451
}
453452
}

branches/snap-stage3/src/librustc_typeck/astconv.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,8 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
13591359
implied_output_region,
13601360
lifetimes_for_params,
13611361
&**output)),
1362-
ast::NoReturn(_) => ty::FnDiverging
1362+
ast::DefaultReturn(..) => ty::FnConverging(ty::mk_nil(this.tcx())),
1363+
ast::NoReturn(..) => ty::FnDiverging
13631364
};
13641365

13651366
(ty::BareFnTy {
@@ -1486,14 +1487,21 @@ pub fn ty_of_closure<'tcx>(
14861487

14871488
let expected_ret_ty = expected_sig.map(|e| e.output);
14881489

1490+
let is_infer = match decl.output {
1491+
ast::Return(ref output) if output.node == ast::TyInfer => true,
1492+
ast::DefaultReturn(..) => true,
1493+
_ => false
1494+
};
1495+
14891496
let output_ty = match decl.output {
1490-
ast::Return(ref output) if output.node == ast::TyInfer && expected_ret_ty.is_some() =>
1497+
_ if is_infer && expected_ret_ty.is_some() =>
14911498
expected_ret_ty.unwrap(),
1492-
ast::Return(ref output) if output.node == ast::TyInfer =>
1493-
ty::FnConverging(this.ty_infer(output.span)),
1499+
_ if is_infer =>
1500+
ty::FnConverging(this.ty_infer(decl.output.span())),
14941501
ast::Return(ref output) =>
14951502
ty::FnConverging(ast_ty_to_ty(this, &rb, &**output)),
1496-
ast::NoReturn(_) => ty::FnDiverging
1503+
ast::DefaultReturn(..) => unreachable!(),
1504+
ast::NoReturn(..) => ty::FnDiverging
14971505
};
14981506

14991507
debug!("ty_of_closure: input_tys={}", input_tys.repr(this.tcx()));

branches/snap-stage3/src/librustc_typeck/check/method/probe.rs

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct ProbeContext<'a, 'tcx:'a> {
4444
extension_candidates: Vec<Candidate<'tcx>>,
4545
impl_dups: HashSet<ast::DefId>,
4646
static_candidates: Vec<CandidateSource>,
47+
all_traits_search: bool,
4748
}
4849

4950
struct CandidateStep<'tcx> {
@@ -210,6 +211,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
210211
steps: Rc::new(steps),
211212
opt_simplified_steps: opt_simplified_steps,
212213
static_candidates: Vec::new(),
214+
all_traits_search: false,
213215
}
214216
}
215217

@@ -722,53 +724,60 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
722724
// THE ACTUAL SEARCH
723725

724726
fn pick(mut self) -> PickResult<'tcx> {
725-
match self.pick_core() {
726-
Some(r) => return r,
727-
None => {}
727+
let steps = self.steps.clone();
728+
729+
for step in steps.iter() {
730+
match self.pick_step(step) {
731+
Some(r) => {
732+
return r;
733+
}
734+
None => { }
735+
}
728736
}
729737

730738
let static_candidates = mem::replace(&mut self.static_candidates, vec![]);
731739

732-
// things failed, so lets look at all traits, for diagnostic purposes now:
733-
self.reset();
734-
735-
let span = self.span;
736-
let tcx = self.tcx();
737-
738-
self.assemble_extension_candidates_for_all_traits();
739-
740-
let out_of_scope_traits = match self.pick_core() {
741-
Some(Ok(p)) => vec![p.method_ty.container.id()],
742-
Some(Err(Ambiguity(v))) => v.into_iter().map(|source| {
743-
match source {
744-
TraitSource(id) => id,
745-
ImplSource(impl_id) => {
746-
match ty::trait_id_of_impl(tcx, impl_id) {
747-
Some(id) => id,
748-
None =>
749-
tcx.sess.span_bug(span,
750-
"found inherent method when looking at traits")
740+
let out_of_scope_traits = if !self.all_traits_search {
741+
// things failed, and we haven't yet looked through all
742+
// traits, so lets do that now:
743+
self.reset();
744+
self.all_traits_search = true;
745+
746+
let span = self.span;
747+
let tcx = self.tcx();
748+
749+
self.assemble_extension_candidates_for_all_traits();
750+
751+
match self.pick() {
752+
Ok(p) => vec![p.method_ty.container.id()],
753+
Err(Ambiguity(v)) => v.into_iter().map(|source| {
754+
match source {
755+
TraitSource(id) => id,
756+
ImplSource(impl_id) => {
757+
match ty::trait_id_of_impl(tcx, impl_id) {
758+
Some(id) => id,
759+
None => tcx.sess.span_bug(span,
760+
"found inherent method when looking \
761+
at traits")
762+
}
751763
}
752764
}
765+
}).collect(),
766+
// it'd be really weird for this assertion to trigger,
767+
// given the `vec![]` in the else branch below
768+
Err(NoMatch(_, others)) => {
769+
assert!(others.is_empty());
770+
vec![]
753771
}
754-
}).collect(),
755-
Some(Err(NoMatch(_, others))) => {
756-
assert!(others.is_empty());
757-
vec![]
758772
}
759-
None => vec![],
773+
} else {
774+
// we've just looked through all traits and didn't find
775+
// anything at all.
776+
vec![]
760777
};
761-
;
762778
Err(NoMatch(static_candidates, out_of_scope_traits))
763779
}
764780

765-
fn pick_core(&mut self) -> Option<PickResult<'tcx>> {
766-
let steps = self.steps.clone();
767-
768-
// find the first step that works
769-
steps.iter().filter_map(|step| self.pick_step(step)).next()
770-
}
771-
772781
fn pick_step(&mut self, step: &CandidateStep<'tcx>) -> Option<PickResult<'tcx>> {
773782
debug!("pick_step: step={}", step.repr(self.tcx()));
774783

branches/snap-stage3/src/librustc_typeck/check/method/suggest.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,16 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
147147
candidates.sort();
148148
let msg = format!(
149149
"methods from traits can only be called if the trait is in scope; \
150-
the following {traits_are} implemented but not in scope, \
151-
perhaps add a `use` for {one_of_them}:",
150+
the following {traits_are} implemented and {define} a method `{name}`:",
152151
traits_are = if candidates.len() == 1 {"trait is"} else {"traits are"},
153-
one_of_them = if candidates.len() == 1 {"it"} else {"one of them"});
152+
define = if candidates.len() == 1 {"defines"} else {"define"},
153+
name = method_ustring);
154154

155155
fcx.sess().fileline_help(span, &msg[]);
156156

157157
for (i, trait_did) in candidates.iter().enumerate() {
158158
fcx.sess().fileline_help(span,
159-
&*format!("candidate #{}: use `{}`",
159+
&*format!("candidate #{}: `{}`",
160160
i + 1,
161161
ty::item_path_str(fcx.tcx(), *trait_did)))
162162

@@ -174,11 +174,9 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
174174
candidates.sort_by(|a, b| a.cmp(b).reverse());
175175

176176
let msg = format!(
177-
"methods from traits can only be called if the trait is implemented and in scope; \
178-
the following {traits_define} a method `{name}`, \
179-
perhaps you need to implement {one_of_them}:",
177+
"methods from traits can only be called if the trait is implemented and \
178+
in scope; no such traits are but the following {traits_define} a method `{name}`:",
180179
traits_define = if candidates.len() == 1 {"trait defines"} else {"traits define"},
181-
one_of_them = if candidates.len() == 1 {"it"} else {"one of them"},
182180
name = method_ustring);
183181

184182
fcx.sess().fileline_help(span, &msg[]);

branches/snap-stage3/src/librustc_typeck/collect.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,9 @@ fn ty_of_foreign_fn_decl<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
14881488
let output = match decl.output {
14891489
ast::Return(ref ty) =>
14901490
ty::FnConverging(ast_ty_to_ty(ccx, &rb, &**ty)),
1491-
ast::NoReturn(_) =>
1491+
ast::DefaultReturn(..) =>
1492+
ty::FnConverging(ty::mk_nil(ccx.tcx)),
1493+
ast::NoReturn(..) =>
14921494
ty::FnDiverging
14931495
};
14941496

branches/snap-stage3/src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,14 +1141,16 @@ impl Clean<Argument> for ast::Arg {
11411141
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
11421142
pub enum FunctionRetTy {
11431143
Return(Type),
1144+
DefaultReturn,
11441145
NoReturn
11451146
}
11461147

11471148
impl Clean<FunctionRetTy> for ast::FunctionRetTy {
11481149
fn clean(&self, cx: &DocContext) -> FunctionRetTy {
11491150
match *self {
11501151
ast::Return(ref typ) => Return(typ.clean(cx)),
1151-
ast::NoReturn(_) => NoReturn
1152+
ast::DefaultReturn(..) => DefaultReturn,
1153+
ast::NoReturn(..) => NoReturn
11521154
}
11531155
}
11541156
}

branches/snap-stage3/src/librustdoc/html/format.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ impl fmt::String for clean::FunctionRetTy {
557557
match *self {
558558
clean::Return(clean::Tuple(ref tys)) if tys.is_empty() => Ok(()),
559559
clean::Return(ref ty) => write!(f, " -&gt; {}", ty),
560+
clean::DefaultReturn => Ok(()),
560561
clean::NoReturn => write!(f, " -&gt; !")
561562
}
562563
}

branches/snap-stage3/src/libsyntax/ast.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,10 @@ pub enum FunctionRetTy {
13901390
/// Functions with return type ! that always
13911391
/// raise an error or exit (i.e. never return to the caller)
13921392
NoReturn(Span),
1393+
/// Return type is not specified. Functions default to () and
1394+
/// closures default to inference. Span points to where return
1395+
/// type would be inserted.
1396+
DefaultReturn(Span),
13931397
/// Everything else
13941398
Return(P<Ty>),
13951399
}
@@ -1398,6 +1402,7 @@ impl FunctionRetTy {
13981402
pub fn span(&self) -> Span {
13991403
match *self {
14001404
NoReturn(span) => span,
1405+
DefaultReturn(span) => span,
14011406
Return(ref ty) => ty.span
14021407
}
14031408
}

branches/snap-stage3/src/libsyntax/fold.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ pub fn noop_fold_fn_decl<T: Folder>(decl: P<FnDecl>, fld: &mut T) -> P<FnDecl> {
726726
inputs: inputs.move_map(|x| fld.fold_arg(x)),
727727
output: match output {
728728
Return(ty) => Return(fld.fold_ty(ty)),
729+
DefaultReturn(span) => DefaultReturn(span),
729730
NoReturn(span) => NoReturn(span)
730731
},
731732
variadic: variadic
@@ -1189,14 +1190,7 @@ pub fn noop_fold_foreign_item<T: Folder>(ni: P<ForeignItem>, folder: &mut T) ->
11891190
attrs: attrs.move_map(|x| folder.fold_attribute(x)),
11901191
node: match node {
11911192
ForeignItemFn(fdec, generics) => {
1192-
ForeignItemFn(fdec.map(|FnDecl {inputs, output, variadic}| FnDecl {
1193-
inputs: inputs.move_map(|a| folder.fold_arg(a)),
1194-
output: match output {
1195-
Return(ty) => Return(folder.fold_ty(ty)),
1196-
NoReturn(span) => NoReturn(span)
1197-
},
1198-
variadic: variadic
1199-
}), folder.fold_generics(generics))
1193+
ForeignItemFn(folder.fold_fn_decl(fdec), folder.fold_generics(generics))
12001194
}
12011195
ForeignItemStatic(t, m) => {
12021196
ForeignItemStatic(folder.fold_ty(t), m)

branches/snap-stage3/src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,7 @@ mod test {
10661066
}),
10671067
id: ast::DUMMY_NODE_ID
10681068
}),
1069-
output: ast::Return(P(ast::Ty{id: ast::DUMMY_NODE_ID,
1070-
node: ast::TyTup(vec![]),
1071-
span:sp(15,15)})), // not sure
1069+
output: ast::DefaultReturn(sp(15, 15)),
10721070
variadic: false
10731071
}),
10741072
ast::Unsafety::Normal,

0 commit comments

Comments
 (0)