Skip to content

Commit c080b8f

Browse files
author
Nick Hamann
committed
---
yaml --- r: 209315 b: refs/heads/auto c: b593359 h: refs/heads/master i: 209313: ad67344 209311: 4763afd v: v3
1 parent 8a04825 commit c080b8f

File tree

14 files changed

+168
-135
lines changed

14 files changed

+168
-135
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: cccc137b888af7561687aae7e6af3ed32461c160
13+
refs/heads/auto: b593359f7f90d7cb9ec71a4b99f9b1396603a8a8
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: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,54 @@ enum Method { GET, POST }
396396
```
397397
"##,
398398

399+
E0261: r##"
400+
When using a lifetime like `'a` in a type, it must be declared before being
401+
used.
402+
403+
These two examples illustrate the problem:
404+
405+
```
406+
// error, use of undeclared lifetime name `'a`
407+
fn foo(x: &'a str) { }
408+
409+
struct Foo {
410+
// error, use of undeclared lifetime name `'a`
411+
x: &'a str,
412+
}
413+
```
414+
415+
These can be fixed by declaring lifetime parameters:
416+
417+
```
418+
fn foo<'a>(x: &'a str) { }
419+
420+
struct Foo<'a> {
421+
x: &'a str,
422+
}
423+
```
424+
"##,
425+
426+
E0262: r##"
427+
Declaring certain lifetime names in parameters is disallowed. For example,
428+
because the `'static` lifetime is a special built-in lifetime name denoting
429+
the lifetime of the entire program, this is an error:
430+
431+
```
432+
// error, illegal lifetime parameter name `'static`
433+
fn foo<'static>(x: &'static str) { }
434+
```
435+
"##,
436+
437+
E0263: r##"
438+
A lifetime name cannot be declared more than once in the same scope. For
439+
example:
440+
441+
```
442+
// error, lifetime name `'a` declared twice in the same scope
443+
fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { }
444+
```
445+
"##,
446+
399447
E0265: r##"
400448
This error indicates that a static or constant references itself.
401449
All statics and constants need to resolve to a value in an acyclic manner.
@@ -814,9 +862,6 @@ register_diagnostics! {
814862
E0136,
815863
E0138,
816864
E0139,
817-
E0261, // use of undeclared lifetime name
818-
E0262, // illegal lifetime parameter name
819-
E0263, // lifetime name declared twice in same scope
820865
E0264, // unknown external lang item
821866
E0266, // expected item
822867
E0269, // not all control paths return a value

branches/auto/src/librustc_typeck/diagnostics.rs

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,37 @@ let x_is_nonzero = x as bool;
261261
```
262262
"##,
263263

264+
E0055: r##"
265+
During a method call, a value is automatically dereferenced as many times as
266+
needed to make the value's type match the method's receiver. The catch is that
267+
the compiler will only attempt to dereference a number of times up to the
268+
recursion limit (which can be set via the `recursion_limit` attribute).
269+
270+
For a somewhat artificial example:
271+
272+
```
273+
#![recursion_limit="2"]
274+
275+
struct Foo;
276+
277+
impl Foo {
278+
fn foo(&self) {}
279+
}
280+
281+
fn main() {
282+
let foo = Foo;
283+
let ref_foo = &&Foo;
284+
285+
// error, reached the recursion limit while auto-dereferencing &&Foo
286+
ref_foo.foo();
287+
}
288+
```
289+
290+
One fix may be to increase the recursion limit. Note that it is possible to
291+
create an infinite recursion of dereferencing, in which case the only fix is to
292+
somehow break the recursion.
293+
"##,
294+
264295
E0062: r##"
265296
This error indicates that during an attempt to build a struct or struct-like
266297
enum variant, one of the fields was specified more than once. Each field should
@@ -511,6 +542,31 @@ enum Empty {}
511542
```
512543
"##,
513544

545+
E0089: r##"
546+
Not enough type parameters were supplied for a function. For example:
547+
548+
```
549+
fn foo<T, U>() {}
550+
551+
fn main() {
552+
foo::<f64>(); // error, expected 2 parameters, found 1 parameter
553+
}
554+
```
555+
556+
Note that if a function takes multiple type parameters but you want the compiler
557+
to infer some of them, you can use type placeholders:
558+
559+
```
560+
fn foo<T, U>(x: T) {}
561+
562+
fn main() {
563+
let x: bool = true;
564+
foo::<f64>(x); // error, expected 2 parameters, found 1 parameter
565+
foo::<_, f64>(x); // same as `foo::<bool, f64>(x)`
566+
}
567+
```
568+
"##,
569+
514570
E0106: r##"
515571
This error indicates that a lifetime is missing from a type. If it is an error
516572
inside a function signature, the problem may be with failing to adhere to the
@@ -707,6 +763,12 @@ impl Foo for Bar {
707763
}
708764
"##,
709765

766+
E0192: r##"
767+
Negative impls are only allowed for traits with default impls. For more
768+
information see the [opt-in builtin traits RFC](https://github.com/rust-lang/
769+
rfcs/blob/master/text/0019-opt-in-builtin-traits.md).
770+
"##,
771+
710772
E0197: r##"
711773
Inherent implementations (one that do not implement a trait but provide
712774
methods associated with a type) are always safe because they are not
@@ -936,6 +998,12 @@ const C: [u32; u8::MAX + f64::EPSILON] = [];
936998
```
937999
"##,
9381000

1001+
E0318: r##"
1002+
Default impls for a trait must be located in the same crate where the trait was
1003+
defined. For more information see the [opt-in builtin traits RFC](https://github
1004+
.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md).
1005+
"##,
1006+
9391007
E0322: r##"
9401008
The `Sized` trait is a special trait built-in to the compiler for types with a
9411009
constant size known at compile-time. This trait is automatically implemented
@@ -1045,7 +1113,6 @@ register_diagnostics! {
10451113
E0040, // explicit use of destructor method
10461114
E0044, // foreign items may not have type parameters
10471115
E0045, // variadic function must have C calling convention
1048-
E0055, // method has an incompatible type for trait
10491116
E0057, // method has an incompatible type for trait
10501117
E0059,
10511118
E0060,
@@ -1060,7 +1127,6 @@ register_diagnostics! {
10601127
E0086,
10611128
E0087,
10621129
E0088,
1063-
E0089,
10641130
E0090,
10651131
E0091,
10661132
E0092,
@@ -1098,7 +1164,6 @@ register_diagnostics! {
10981164
E0189, // deprecated: can only cast a boxed pointer to a boxed object
10991165
E0190, // deprecated: can only cast a &-pointer to an &-object
11001166
E0191, // value of the associated type must be specified
1101-
E0192, // negative impls are allowed just for `Send` and `Sync`
11021167
E0193, // cannot bound type where clause bounds may only be attached to types
11031168
// involving type parameters
11041169
E0194,
@@ -1146,7 +1211,6 @@ register_diagnostics! {
11461211
E0246, // illegal recursive type
11471212
E0247, // found module name used as a type
11481213
E0248, // found value name used as a type
1149-
E0318, // can't create default impls for traits outside their crates
11501214
E0319, // trait impls for defaulted traits allowed just for structs/enums
11511215
E0320, // recursive overflow during dropck
11521216
E0321, // extended coherence rules for defaulted traits violated

branches/auto/src/librustdoc/clean/inline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEn
217217
clean::TypedefItem(clean::Typedef {
218218
type_: t.ty.clean(cx),
219219
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
220-
}, false)
220+
})
221221
}
222222

223223
pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
@@ -370,7 +370,7 @@ pub fn build_impl(cx: &DocContext,
370370
subst::ParamSpace::TypeSpace).clean(cx);
371371
Some(clean::Item {
372372
name: Some(assoc_ty.name.clean(cx)),
373-
inner: clean::TypedefItem(typedef, true),
373+
inner: clean::TypedefItem(typedef),
374374
source: clean::Span::empty(),
375375
attrs: vec![],
376376
visibility: None,

branches/auto/src/librustdoc/clean/mod.rs

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ pub enum ItemEnum {
343343
EnumItem(Enum),
344344
FunctionItem(Function),
345345
ModuleItem(Module),
346-
TypedefItem(Typedef, bool /* is associated type */),
346+
TypedefItem(Typedef),
347347
StaticItem(Static),
348348
ConstantItem(Constant),
349349
TraitItem(Trait),
@@ -664,7 +664,6 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
664664
path: path,
665665
typarams: None,
666666
did: did,
667-
is_generic: false,
668667
},
669668
lifetimes: vec![]
670669
}, ast::TraitBoundModifier::None)
@@ -707,12 +706,7 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
707706
}
708707

709708
TraitBound(PolyTrait {
710-
trait_: ResolvedPath {
711-
path: path,
712-
typarams: None,
713-
did: self.def_id,
714-
is_generic: false,
715-
},
709+
trait_: ResolvedPath { path: path, typarams: None, did: self.def_id, },
716710
lifetimes: late_bounds
717711
}, ast::TraitBoundModifier::None)
718712
}
@@ -1292,7 +1286,7 @@ impl Clean<Item> for ast::ImplItem {
12921286
type_params: Vec::new(),
12931287
where_predicates: Vec::new()
12941288
},
1295-
}, true),
1289+
}),
12961290
ast::MacImplItem(_) => {
12971291
MacroItem(Macro {
12981292
source: self.span.to_src(cx),
@@ -1407,13 +1401,11 @@ pub struct PolyTrait {
14071401
/// it does not preserve mutability or boxes.
14081402
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)]
14091403
pub enum Type {
1410-
/// structs/enums/traits (most that'd be an ast::TyPath)
1404+
/// structs/enums/traits (anything that'd be an ast::TyPath)
14111405
ResolvedPath {
14121406
path: Path,
14131407
typarams: Option<Vec<TyParamBound>>,
14141408
did: ast::DefId,
1415-
/// true if is a `T::Name` path for associated types
1416-
is_generic: bool,
14171409
},
14181410
/// For parameterized types, so the consumer of the JSON don't go
14191411
/// looking for types which don't exist anywhere.
@@ -1602,13 +1594,8 @@ impl Clean<Type> for ast::Ty {
16021594
TyObjectSum(ref lhs, ref bounds) => {
16031595
let lhs_ty = lhs.clean(cx);
16041596
match lhs_ty {
1605-
ResolvedPath { path, typarams: None, did, is_generic } => {
1606-
ResolvedPath {
1607-
path: path,
1608-
typarams: Some(bounds.clean(cx)),
1609-
did: did,
1610-
is_generic: is_generic,
1611-
}
1597+
ResolvedPath { path, typarams: None, did } => {
1598+
ResolvedPath { path: path, typarams: Some(bounds.clean(cx)), did: did}
16121599
}
16131600
_ => {
16141601
lhs_ty // shouldn't happen
@@ -1688,7 +1675,6 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
16881675
path: path,
16891676
typarams: None,
16901677
did: did,
1691-
is_generic: false,
16921678
}
16931679
}
16941680
ty::ty_trait(box ty::TyTrait { ref principal, ref bounds }) => {
@@ -1703,7 +1689,6 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
17031689
path: path,
17041690
typarams: Some(typarams),
17051691
did: did,
1706-
is_generic: false,
17071692
}
17081693
}
17091694
ty::ty_tup(ref t) => Tuple(t.clean(cx)),
@@ -2100,7 +2085,7 @@ impl Clean<Item> for doctree::Typedef {
21002085
inner: TypedefItem(Typedef {
21012086
type_: self.ty.clean(cx),
21022087
generics: self.gen.clean(cx),
2103-
}, false),
2088+
}),
21042089
}
21052090
}
21062091
}
@@ -2270,7 +2255,7 @@ fn build_deref_target_impls(cx: &DocContext,
22702255

22712256
for item in items {
22722257
let target = match item.inner {
2273-
TypedefItem(ref t, true) => &t.type_,
2258+
TypedefItem(ref t) => &t.type_,
22742259
_ => continue,
22752260
};
22762261
let primitive = match *target {
@@ -2595,7 +2580,10 @@ fn resolve_type(cx: &DocContext,
25952580
None => panic!("unresolved id not in defmap")
25962581
};
25972582

2598-
let is_generic = match def {
2583+
match def {
2584+
def::DefSelfTy(..) if path.segments.len() == 1 => {
2585+
return Generic(token::get_name(special_idents::type_self.name).to_string());
2586+
}
25992587
def::DefPrimTy(p) => match p {
26002588
ast::TyStr => return Primitive(Str),
26012589
ast::TyBool => return Primitive(Bool),
@@ -2613,14 +2601,13 @@ fn resolve_type(cx: &DocContext,
26132601
ast::TyFloat(ast::TyF32) => return Primitive(F32),
26142602
ast::TyFloat(ast::TyF64) => return Primitive(F64),
26152603
},
2616-
def::DefSelfTy(..) if path.segments.len() == 1 => {
2617-
return Generic(token::get_name(special_idents::type_self.name).to_string());
2604+
def::DefTyParam(_, _, _, n) => {
2605+
return Generic(token::get_name(n).to_string())
26182606
}
2619-
def::DefSelfTy(..) | def::DefTyParam(..) => true,
2620-
_ => false,
2607+
_ => {}
26212608
};
26222609
let did = register_def(&*cx, def);
2623-
ResolvedPath { path: path, typarams: None, did: did, is_generic: is_generic }
2610+
ResolvedPath { path: path, typarams: None, did: did }
26242611
}
26252612

26262613
fn register_def(cx: &DocContext, def: def::Def) -> ast::DefId {
@@ -2834,7 +2821,6 @@ fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
28342821
}
28352822
}],
28362823
},
2837-
is_generic: false,
28382824
}
28392825
}
28402826

branches/auto/src/librustdoc/html/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@ impl fmt::Display for clean::Type {
437437
clean::Generic(ref name) => {
438438
f.write_str(name)
439439
}
440-
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
441-
// Paths like T::Output and Self::Output should be rendered with all segments
442-
try!(resolved_path(f, did, path, is_generic));
440+
clean::ResolvedPath{ did, ref typarams, ref path } => {
441+
// Paths like Self::Output should be rendered with all segments
442+
try!(resolved_path(f, did, path, path.segments[0].name == "Self"));
443443
tybounds(f, typarams)
444444
}
445445
clean::Infer => write!(f, "_"),

0 commit comments

Comments
 (0)