Skip to content

Commit be0dcd3

Browse files
committed
---
yaml --- r: 159754 b: refs/heads/auto c: 9c808ff h: refs/heads/master v: v3
1 parent 754b3a0 commit be0dcd3

File tree

4 files changed

+79
-56
lines changed

4 files changed

+79
-56
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 0b90cded149b74b4ceb51a7ea5d3394aeb4e06a8
13+
refs/heads/auto: 9c808ffee44afad69aeeeec835601d44bf0e9147
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,6 @@ register_diagnostics!(
144144
E0165,
145145
E0166,
146146
E0167,
147-
E0168
147+
E0168,
148+
E0169
148149
)

branches/auto/src/librustc/middle/typeck/astconv.rs

Lines changed: 75 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub fn opt_ast_region_to_region<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
202202
r
203203
}
204204

205-
fn ast_path_substs<'tcx,AC,RS>(
205+
fn ast_path_substs_for_ty<'tcx,AC,RS>(
206206
this: &AC,
207207
rscope: &RS,
208208
decl_def_id: ast::DefId,
@@ -233,12 +233,35 @@ fn ast_path_substs<'tcx,AC,RS>(
233233
assert!(decl_generics.types.all(|d| d.space != FnSpace));
234234

235235
let (regions, types) = match path.segments.last().unwrap().parameters {
236-
ast::AngleBracketedParameters(ref data) =>
237-
angle_bracketed_parameters(this, rscope, data),
238-
ast::ParenthesizedParameters(ref data) =>
239-
parenthesized_parameters(this, binder_id, data),
236+
ast::AngleBracketedParameters(ref data) => {
237+
convert_angle_bracketed_parameters(this, rscope, data)
238+
}
239+
ast::ParenthesizedParameters(ref data) => {
240+
span_err!(tcx.sess, path.span, E0169,
241+
"parenthesized parameters may only be used with a trait");
242+
(Vec::new(), convert_parenthesized_parameters(this, data))
243+
}
240244
};
241245

246+
create_substs_for_ast_path(this, rscope, path.span, decl_def_id,
247+
decl_generics, self_ty, types, regions, associated_ty)
248+
}
249+
250+
fn create_substs_for_ast_path<'tcx,AC,RS>(
251+
this: &AC,
252+
rscope: &RS,
253+
span: Span,
254+
decl_def_id: ast::DefId,
255+
decl_generics: &ty::Generics,
256+
self_ty: Option<ty::t>,
257+
types: Vec<ty::t>,
258+
regions: Vec<ty::Region>,
259+
associated_ty: Option<ty::t>)
260+
-> Substs
261+
where AC: AstConv<'tcx>, RS: RegionScope
262+
{
263+
let tcx = this.tcx();
264+
242265
// If the type is parameterized by the this region, then replace this
243266
// region with the current anon region binding (in other words,
244267
// whatever & would get replaced with).
@@ -248,10 +271,10 @@ fn ast_path_substs<'tcx,AC,RS>(
248271
regions
249272
} else {
250273
let anon_regions =
251-
rscope.anon_regions(path.span, expected_num_region_params);
274+
rscope.anon_regions(span, expected_num_region_params);
252275

253276
if supplied_num_region_params != 0 || anon_regions.is_err() {
254-
span_err!(tcx.sess, path.span, E0107,
277+
span_err!(tcx.sess, span, E0107,
255278
"wrong number of lifetime parameters: expected {}, found {}",
256279
expected_num_region_params, supplied_num_region_params);
257280
}
@@ -283,7 +306,7 @@ fn ast_path_substs<'tcx,AC,RS>(
283306
} else {
284307
"expected"
285308
};
286-
this.tcx().sess.span_fatal(path.span,
309+
this.tcx().sess.span_fatal(span,
287310
format!("wrong number of type arguments: {} {}, found {}",
288311
expected,
289312
required_ty_param_count,
@@ -294,7 +317,7 @@ fn ast_path_substs<'tcx,AC,RS>(
294317
} else {
295318
"expected"
296319
};
297-
this.tcx().sess.span_fatal(path.span,
320+
this.tcx().sess.span_fatal(span,
298321
format!("wrong number of type arguments: {} {}, found {}",
299322
expected,
300323
formal_ty_param_count,
@@ -303,9 +326,9 @@ fn ast_path_substs<'tcx,AC,RS>(
303326

304327
if supplied_ty_param_count > required_ty_param_count
305328
&& !this.tcx().sess.features.borrow().default_type_params {
306-
span_err!(this.tcx().sess, path.span, E0108,
329+
span_err!(this.tcx().sess, span, E0108,
307330
"default type parameters are experimental and possibly buggy");
308-
span_help!(this.tcx().sess, path.span,
331+
span_help!(this.tcx().sess, span,
309332
"add #![feature(default_type_params)] to the crate attributes to enable");
310333
}
311334

@@ -331,66 +354,66 @@ fn ast_path_substs<'tcx,AC,RS>(
331354
// This is a default type parameter.
332355
let default = default.subst_spanned(tcx,
333356
&substs,
334-
Some(path.span));
357+
Some(span));
335358
substs.types.push(TypeSpace, default);
336359
}
337360
None => {
338-
tcx.sess.span_bug(path.span,
339-
"extra parameter without default");
361+
tcx.sess.span_bug(span, "extra parameter without default");
340362
}
341363
}
342364
}
343365

344366
for param in decl_generics.types.get_slice(AssocSpace).iter() {
345367
substs.types.push(
346368
AssocSpace,
347-
this.associated_type_binding(path.span,
369+
this.associated_type_binding(span,
348370
associated_ty,
349371
decl_def_id,
350372
param.def_id))
351373
}
352374

353375
return substs;
376+
}
354377

355-
fn angle_bracketed_parameters<'tcx, AC, RS>(this: &AC,
356-
rscope: &RS,
357-
data: &ast::AngleBracketedParameterData)
358-
-> (Vec<ty::Region>, Vec<ty::t>)
359-
where AC: AstConv<'tcx>, RS: RegionScope
360-
{
361-
let regions: Vec<_> =
362-
data.lifetimes.iter()
363-
.map(|l| ast_region_to_region(this.tcx(), l))
364-
.collect();
365-
366-
let types: Vec<_> =
367-
data.types.iter()
368-
.map(|t| ast_ty_to_ty(this, rscope, &**t))
369-
.collect();
370-
371-
(regions, types)
372-
}
378+
fn convert_angle_bracketed_parameters<'tcx, AC, RS>(this: &AC,
379+
rscope: &RS,
380+
data: &ast::AngleBracketedParameterData)
381+
-> (Vec<ty::Region>, Vec<ty::t>)
382+
where AC: AstConv<'tcx>, RS: RegionScope
383+
{
384+
let regions: Vec<_> =
385+
data.lifetimes.iter()
386+
.map(|l| ast_region_to_region(this.tcx(), l))
387+
.collect();
373388

374-
fn parenthesized_parameters<'tcx,AC>(this: &AC,
375-
binder_id: ast::NodeId,
376-
data: &ast::ParenthesizedParameterData)
377-
-> (Vec<ty::Region>, Vec<ty::t>)
378-
where AC: AstConv<'tcx>
379-
{
380-
let binding_rscope = BindingRscope::new(binder_id);
381-
382-
let inputs = data.inputs.iter()
383-
.map(|a_t| ast_ty_to_ty(this, &binding_rscope, &**a_t))
384-
.collect();
385-
let input_ty = ty::mk_tup(this.tcx(), inputs);
386-
387-
let output = match data.output {
388-
Some(ref output_ty) => ast_ty_to_ty(this, &binding_rscope, &**output_ty),
389-
None => ty::mk_nil(this.tcx())
390-
};
389+
let types: Vec<_> =
390+
data.types.iter()
391+
.map(|t| ast_ty_to_ty(this, rscope, &**t))
392+
.collect();
393+
394+
(regions, types)
395+
}
396+
397+
fn convert_parenthesized_parameters<'tcx,AC>(this: &AC,
398+
data: &ast::ParenthesizedParameterData)
399+
-> Vec<ty::t>
400+
where AC: AstConv<'tcx>
401+
{
402+
let binding_rscope = BindingRscope::new();
403+
404+
let inputs = data.inputs.iter()
405+
.map(|a_t| ast_ty_to_ty(this, &binding_rscope, &**a_t))
406+
.collect();
407+
let input_ty = ty::mk_tup(this.tcx(), inputs);
408+
409+
let output = match data.output {
410+
Some(ref output_ty) => ast_ty_to_ty(this, &binding_rscope, &**output_ty),
411+
None => ty::mk_nil(this.tcx()),
412+
};
413+
414+
vec![input_ty, output]
415+
}
391416

392-
(Vec::new(), vec![input_ty, output])
393-
}
394417
}
395418

396419
pub fn instantiate_trait_ref<'tcx,AC,RS>(this: &AC,

branches/auto/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4452,8 +4452,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
44524452
let type_and_substs = astconv::ast_path_to_ty_relaxed(fcx,
44534453
fcx.infcx(),
44544454
struct_id,
4455-
path,
4456-
expr.id);
4455+
path);
44574456
match fcx.mk_subty(false,
44584457
infer::Misc(path.span),
44594458
actual_structure_type,

0 commit comments

Comments
 (0)