Skip to content

Commit 97dfbed

Browse files
committed
---
yaml --- r: 235897 b: refs/heads/stable c: 75e4a78 h: refs/heads/master i: 235895: d5ad904 v: v3
1 parent 75cebda commit 97dfbed

File tree

11 files changed

+199
-122
lines changed

11 files changed

+199
-122
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: f6e9240a99e86d2c799dc29f179dd2870e51f71d
32+
refs/heads/stable: 75e4a78d15a837675eb6795b5afe4e1e3d27166c
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/doc/trpl/choosing-your-guarantees.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The main guarantee provided here is that the data will not be destroyed until al
8181
are out of scope.
8282

8383
This should be used when we wish to dynamically allocate and share some data (read-only) between
84-
various portions of yur program, where it is not certain which portion will finish using the pointer
84+
various portions of your program, where it is not certain which portion will finish using the pointer
8585
last. It's a viable alternative to `&T` when `&T` is either impossible to statically check for
8686
correctness, or creates extremely unergonomic code where the programmer does not wish to spend the
8787
development cost of working with.

branches/stable/src/doc/trpl/traits.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -347,40 +347,50 @@ easiest just to show an example:
347347

348348
```rust
349349
trait Foo {
350-
fn bar(&self);
350+
fn is_valid(&self) -> bool;
351351

352-
fn baz(&self) { println!("We called baz."); }
352+
fn is_invalid(&self) -> bool { !self.is_valid() }
353353
}
354354
```
355355

356-
Implementors of the `Foo` trait need to implement `bar()`, but they don’t
357-
need to implement `baz()`. They’ll get this default behavior. They can
356+
Implementors of the `Foo` trait need to implement `is_valid()`, but they don’t
357+
need to implement `is_invalid()`. They’ll get this default behavior. They can
358358
override the default if they so choose:
359359

360360
```rust
361361
# trait Foo {
362-
# fn bar(&self);
363-
# fn baz(&self) { println!("We called baz."); }
362+
# fn is_valid(&self) -> bool;
363+
#
364+
# fn is_invalid(&self) -> bool { !self.is_valid() }
364365
# }
365366
struct UseDefault;
366367

367368
impl Foo for UseDefault {
368-
fn bar(&self) { println!("We called bar."); }
369+
fn is_valid(&self) -> bool {
370+
println!("Called UseDefault.is_valid.");
371+
true
372+
}
369373
}
370374

371375
struct OverrideDefault;
372376

373377
impl Foo for OverrideDefault {
374-
fn bar(&self) { println!("We called bar."); }
378+
fn is_valid(&self) -> bool {
379+
println!("Called OverrideDefault.is_valid.");
380+
true
381+
}
375382

376-
fn baz(&self) { println!("Override baz!"); }
383+
fn is_invalid(&self) -> bool {
384+
println!("Called OverrideDefault.is_invalid!");
385+
true // this implementation is a self-contradiction!
386+
}
377387
}
378388

379389
let default = UseDefault;
380-
default.baz(); // prints "We called baz."
390+
assert!(!default.is_invalid()); // prints "Called UseDefault.is_valid."
381391

382392
let over = OverrideDefault;
383-
over.baz(); // prints "Override baz!"
393+
assert!(over.is_invalid()); // prints "Called OverrideDefault.is_invalid!"
384394
```
385395

386396
# Inheritance

branches/stable/src/libcore/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ impl<T, E: fmt::Debug> Result<T, E> {
744744
/// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
745745
/// ```
746746
#[inline]
747-
#[unstable(feature = "result_expect", reason = "newly introduced")]
747+
#[unstable(feature = "result_expect", reason = "newly introduced", issue = "27277")]
748748
pub fn expect(self, msg: &str) -> T {
749749
match self {
750750
Ok(t) => t,

branches/stable/src/librustc_lint/builtin.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,16 @@ fn is_repr_nullable_ptr<'tcx>(variants: &Vec<Rc<ty::VariantInfo<'tcx>>>) -> bool
436436
false
437437
}
438438

439+
fn ast_ty_to_normalized<'tcx>(tcx: &ty::ctxt<'tcx>,
440+
id: ast::NodeId)
441+
-> Ty<'tcx> {
442+
let tty = match tcx.ast_ty_to_ty_cache.borrow().get(&id) {
443+
Some(&t) => t,
444+
None => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
445+
};
446+
infer::normalize_associated_type(tcx, &tty)
447+
}
448+
439449
impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
440450
/// Check if the given type is "ffi-safe" (has a stable, well-defined
441451
/// representation which can be exported to C code).
@@ -638,11 +648,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
638648
}
639649

640650
fn check_def(&mut self, sp: Span, id: ast::NodeId) {
641-
let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().get(&id) {
642-
Some(&t) => t,
643-
None => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
644-
};
645-
let tty = infer::normalize_associated_type(self.cx.tcx, &tty);
651+
let tty = ast_ty_to_normalized(self.cx.tcx, id);
646652

647653
match ImproperCTypesVisitor::check_type_for_ffi(self, &mut FnvHashSet(), tty) {
648654
FfiResult::FfiSafe => {}
@@ -707,7 +713,10 @@ impl LintPass for ImproperCTypes {
707713
check_ty(cx, &*input.ty);
708714
}
709715
if let ast::Return(ref ret_ty) = decl.output {
710-
check_ty(cx, &**ret_ty);
716+
let tty = ast_ty_to_normalized(cx.tcx, ret_ty.id);
717+
if !tty.is_nil() {
718+
check_ty(cx, &ret_ty);
719+
}
711720
}
712721
}
713722

branches/stable/src/librustc_resolve/diagnostics.rs

Lines changed: 156 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,115 @@ impl Bar {
397397
```
398398
"##,
399399

400+
E0417: r##"
401+
A static variable was referenced in a pattern. Example of erroneous code:
402+
403+
```
404+
static FOO : i32 = 0;
405+
406+
match 0 {
407+
FOO => {} // error: static variables cannot be referenced in a
408+
// pattern, use a `const` instead
409+
_ => {}
410+
}
411+
```
412+
413+
The compiler needs to know the value of the pattern at compile time;
414+
compile-time patterns can defined via const or enum items. Please verify
415+
that the identifier is spelled correctly, and if so, use a const instead
416+
of static to define it. Example:
417+
418+
```
419+
const FOO : i32 = 0;
420+
421+
match 0 {
422+
FOO => {} // ok!
423+
_ => {}
424+
}
425+
```
426+
"##,
427+
428+
E0424: r##"
429+
The `self` keyword was used in a static method. Example of erroneous code:
430+
431+
```
432+
struct Foo;
433+
434+
impl Foo {
435+
fn bar(self) {}
436+
437+
fn foo() {
438+
self.bar(); // error: `self` is not available in a static method.
439+
}
440+
}
441+
```
442+
443+
Please check if the method's argument list should have contained `self`,
444+
`&self`, or `&mut self` (in case you didn't want to create a static
445+
method), and add it if so. Example:
446+
447+
```
448+
struct Foo;
449+
450+
impl Foo {
451+
fn bar(self) {}
452+
453+
fn foo(self) {
454+
self.bar(); // ok!
455+
}
456+
}
457+
```
458+
"##,
459+
460+
E0425: r##"
461+
An unresolved name was used. Example of erroneous codes:
462+
463+
```
464+
something_that_doesnt_exist::foo;
465+
// error: unresolved name `something_that_doesnt_exist::foo`
466+
467+
// or:
468+
trait Foo {
469+
fn bar() {
470+
Self; // error: unresolved name `Self`
471+
}
472+
}
473+
```
474+
475+
Please verify you didn't misspell the name or that you're not using an
476+
invalid object. Example:
477+
478+
```
479+
enum something_that_does_exist {
480+
foo
481+
}
482+
// or:
483+
mod something_that_does_exist {
484+
pub static foo : i32 = 0i32;
485+
}
486+
487+
something_that_does_exist::foo; // ok!
488+
```
489+
"##,
490+
491+
E0426: r##"
492+
An undeclared label was used. Example of erroneous code:
493+
494+
```
495+
loop {
496+
break 'a; // error: use of undeclared label `'a`
497+
}
498+
```
499+
500+
Please verify you spelt or declare the label correctly. Example:
501+
502+
```
503+
'a: loop {
504+
break 'a; // ok!
505+
}
506+
```
507+
"##,
508+
400509
E0428: r##"
401510
A type or module has been defined more than once. Example of erroneous
402511
code:
@@ -415,6 +524,53 @@ struct Bar2; // ok!
415524
```
416525
"##,
417526

527+
E0430: r##"
528+
The `self` import appears more than once in the list. Erroneous code example:
529+
530+
```
531+
use something::{self, self}; // error: `self` import can only appear once in
532+
// the list
533+
```
534+
535+
Please verify you didn't misspell the import name or remove the duplicated
536+
`self` import. Example:
537+
538+
```
539+
use something::self; // ok!
540+
```
541+
"##,
542+
543+
E0431: r##"
544+
`self` import was made. Erroneous code example:
545+
546+
```
547+
use {self}; // error: `self` import can only appear in an import list with a
548+
// non-empty prefix
549+
```
550+
551+
You cannot import the current module into itself, please remove this import
552+
or verify you didn't misspell it.
553+
"##,
554+
555+
E0432: r##"
556+
An import was unresolved. Erroneous code example:
557+
558+
```
559+
use something::Foo; // error: unresolved import `something::Foo`.
560+
```
561+
562+
Please verify you didn't misspell the import name or the import does exist
563+
in the module from where you tried to import it. Example:
564+
565+
```
566+
use something::Foo; // ok!
567+
568+
mod something {
569+
pub struct Foo;
570+
}
571+
```
572+
"##,
573+
418574
E0433: r##"
419575
Invalid import. Example of erroneous code:
420576
@@ -499,24 +655,15 @@ register_diagnostics! {
499655
E0414, // only irrefutable patterns allowed here
500656
E0415, // identifier is bound more than once in this parameter list
501657
E0416, // identifier is bound more than once in the same pattern
502-
E0417, // static variables cannot be referenced in a pattern, use a
503-
// `const` instead
504658
E0418, // is not an enum variant, struct or const
505659
E0419, // unresolved enum variant, struct or const
506660
E0420, // is not an associated const
507661
E0421, // unresolved associated const
508662
E0422, // does not name a structure
509663
E0423, // is a struct variant name, but this expression uses it like a
510664
// function name
511-
E0424, // `self` is not available in a static method.
512-
E0425, // unresolved name
513-
E0426, // use of undeclared label
514665
E0427, // cannot use `ref` binding mode with ...
515666
E0429, // `self` imports are only allowed within a { } list
516-
E0430, // `self` import can only appear once in the list
517-
E0431, // `self` import can only appear in an import list with a non-empty
518-
// prefix
519-
E0432, // unresolved import
520667
E0434, // can't capture dynamic environment in a fn item
521668
E0435, // attempt to use a non-constant value in a constant
522669
}

branches/stable/src/librustc_trans/trans/base.rs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ pub fn get_extern_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, did: ast::DefId,
227227
// FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow?
228228
// FIXME(nagisa): investigate whether it can be changed into define_global
229229
let c = declare::declare_global(ccx, &name[..], ty);
230-
231230
// Thread-local statics in some other crate need to *always* be linked
232231
// against in a thread-local fashion, so we need to be sure to apply the
233232
// thread-local attribute locally if it was present remotely. If we
@@ -239,42 +238,7 @@ pub fn get_extern_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, did: ast::DefId,
239238
llvm::set_thread_local(c, true);
240239
}
241240
}
242-
243-
// MSVC is a little ornery about how items are imported across dlls, and for
244-
// lots more info on dllimport/dllexport see the large comment in
245-
// SharedCrateContext::new. Unfortunately, unlike functions, statics
246-
// imported from dlls *must* be tagged with dllimport (if you forget
247-
// dllimport on a function then the linker fixes it up with an injected
248-
// shim). This means that to link correctly to an upstream Rust dynamic
249-
// library we need to make sure its statics are tagged with dllimport.
250-
//
251-
// Hence, if this translation is using dll storage attributes and the crate
252-
// that this const originated from is being imported as a dylib at some
253-
// point we tag this with dllimport.
254-
//
255-
// Note that this is not 100% correct for a variety of reasons:
256-
//
257-
// 1. If we are producing an rlib and linking to an upstream rlib, we'll
258-
// omit the dllimport. It's a possibility, though, that some later
259-
// downstream compilation will link the same upstream dependency as a
260-
// dylib and use our rlib, causing linker errors because we didn't use
261-
// dllimport.
262-
// 2. We may have multiple crate output types. For example if we are
263-
// emitting a statically linked binary as well as a dynamic library we'll
264-
// want to omit dllimport for the binary but we need to have it for the
265-
// dylib.
266-
//
267-
// For most every day uses, however, this should suffice. During the
268-
// bootstrap we're almost always linking upstream to a dylib for some crate
269-
// type output, so most imports will be tagged with dllimport (somewhat
270-
// appropriately). Otherwise rust dylibs linking against rust dylibs is
271-
// pretty rare in Rust so this will likely always be `false` and we'll never
272-
// tag with dllimport.
273-
//
274-
// Note that we can't just blindly tag all constants with dllimport as can
275-
// cause linkage errors when we're not actually linking against a dll. For
276-
// more info on this see rust-lang/rust#26591.
277-
if ccx.use_dll_storage_attrs() && ccx.upstream_dylib_used(did.krate) {
241+
if ccx.use_dll_storage_attrs() {
278242
llvm::SetDLLStorageClass(c, llvm::DLLImportStorageClass);
279243
}
280244
ccx.externs().borrow_mut().insert(name.to_string(), c);

0 commit comments

Comments
 (0)