Skip to content

Rollup of 7 pull requests #36300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3401f4e
Add E0466 error explanation
GuillaumeGomez Aug 29, 2016
b9eaeb1
Add E0467 error explanation
GuillaumeGomez Aug 29, 2016
e32dad3
Add E0468 error explanation
GuillaumeGomez Aug 29, 2016
980402c
Add E0469 error explanation
GuillaumeGomez Aug 29, 2016
5629f7e
Add E0470 error explanation
GuillaumeGomez Aug 29, 2016
7c53eb9
Add librustc metadata error codes to global check
GuillaumeGomez Aug 29, 2016
8d3fd03
Clean up thread-local storage docs
apasel422 Sep 4, 2016
1aa777b
Updated E0559 to new format
Cobrand Sep 4, 2016
e4784fc
Remove mention of `unsafe_no_drop_flag` from Reference and Nomicon
apasel422 Sep 5, 2016
d53ea97
E0516 Update error format #36108
gavinb Aug 30, 2016
8bcd6a3
E0517 Update error format #36109
gavinb Aug 30, 2016
cd56d47
E0518 Update error format #36111
gavinb Aug 30, 2016
e8c5dc4
Updated E0527 to new error format
Cobrand Aug 29, 2016
dc0e9c0
Add missing urls
GuillaumeGomez Sep 6, 2016
d3b305e
Rollup merge of #36102 - GuillaumeGomez:rustc_metadata_diagnostics, r…
Sep 6, 2016
a4a9f04
Rollup merge of #36121 - Cobrand:master, r=jonathandturner
Sep 6, 2016
f03886e
Rollup merge of #36128 - gavinb:error_msgs_p2, r=jonathandturner
Sep 6, 2016
0ffa53f
Rollup merge of #36263 - apasel422:scoped, r=steveklabnik
Sep 6, 2016
d21e489
Rollup merge of #36267 - Cobrand:E0559, r=jonathandturner
Sep 6, 2016
f654719
Rollup merge of #36273 - apasel422:unsafe_no_drop_flag, r=steveklabnik
Sep 6, 2016
c059459
Rollup merge of #36298 - GuillaumeGomez:hashmap_doc, r=steveklabnik
Sep 6, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/doc/nomicon/safe-unsafe-meaning.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ can therefore be trusted. You can use `unsafe` on a trait implementation
to declare that the implementation of that trait has adhered to whatever
contracts the trait's documentation requires.

There is also the `#[unsafe_no_drop_flag]` attribute, which exists for
historic reasons and is being phased out. See the section on [drop flags]
for details.

The standard library has a number of unsafe functions, including:

* `slice::get_unchecked`, which performs unchecked indexing, allowing
Expand Down
10 changes: 0 additions & 10 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2059,10 +2059,6 @@ macro scope.
outside of its dynamic extent), and thus this attribute has the word
"unsafe" in its name. To use this, the
`unsafe_destructor_blind_to_params` feature gate must be enabled.
- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
destructors from being run twice. Destructors might be run multiple times on
the same object with this attribute. To use this, the `unsafe_no_drop_flag` feature
gate must be enabled.
- `doc` - Doc comments such as `/// foo` are equivalent to `#[doc = "foo"]`.
- `rustc_on_unimplemented` - Write a custom note to be shown along with the error
when the trait is found to be unimplemented on a type.
Expand Down Expand Up @@ -2458,12 +2454,6 @@ The currently implemented features of the reference compiler are:
* `unboxed_closures` - Rust's new closure design, which is currently a work in
progress feature with many known bugs.

* `unsafe_no_drop_flag` - Allows use of the `#[unsafe_no_drop_flag]` attribute,
which removes hidden flag added to a type that
implements the `Drop` trait. The design for the
`Drop` flag is subject to change, and this feature
may be removed in the future.

* `unmarked_api` - Allows use of items within a `#![staged_api]` crate
which have not been marked with a stability marker.
Such items should not be allowed by the compiler to exist,
Expand Down
24 changes: 16 additions & 8 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ struct CheckAttrVisitor<'a> {
impl<'a> CheckAttrVisitor<'a> {
fn check_inline(&self, attr: &ast::Attribute, target: Target) {
if target != Target::Fn {
span_err!(self.sess, attr.span, E0518, "attribute should be applied to function");
struct_span_err!(self.sess, attr.span, E0518, "attribute should be applied to function")
.span_label(attr.span, &format!("requires a function"))
.emit();
}
}

Expand All @@ -56,18 +58,20 @@ impl<'a> CheckAttrVisitor<'a> {

let mut conflicting_reprs = 0;
for word in words {

let name = match word.name() {
Some(word) => word,
None => continue,
};

let message = match &*name {
let (message, label) = match &*name {
"C" => {
conflicting_reprs += 1;
if target != Target::Struct &&
target != Target::Union &&
target != Target::Enum {
"attribute should be applied to struct, enum or union"
("attribute should be applied to struct, enum or union",
"a struct, enum or union")
} else {
continue
}
Expand All @@ -77,15 +81,17 @@ impl<'a> CheckAttrVisitor<'a> {
// can be used to modify another repr hint
if target != Target::Struct &&
target != Target::Union {
"attribute should be applied to struct or union"
("attribute should be applied to struct or union",
"a struct or union")
} else {
continue
}
}
"simd" => {
conflicting_reprs += 1;
if target != Target::Struct {
"attribute should be applied to struct"
("attribute should be applied to struct",
"a struct")
} else {
continue
}
Expand All @@ -95,15 +101,17 @@ impl<'a> CheckAttrVisitor<'a> {
"isize" | "usize" => {
conflicting_reprs += 1;
if target != Target::Enum {
"attribute should be applied to enum"
("attribute should be applied to enum",
"an enum")
} else {
continue
}
}
_ => continue,
};

span_err!(self.sess, attr.span, E0517, "{}", message);
struct_span_err!(self.sess, attr.span, E0517, "{}", message)
.span_label(attr.span, &format!("requires {}", label))
.emit();
}
if conflicting_reprs > 1 {
span_warn!(self.sess, attr.span, E0566,
Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@ pub fn diagnostics_registry() -> errors::registry::Registry {
all_errors.extend_from_slice(&rustc_privacy::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc_trans::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc_const_eval::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc_metadata::DIAGNOSTICS);

Registry::new(&all_errors)
}
Expand Down
188 changes: 181 additions & 7 deletions src/librustc_metadata/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A link name was given with an empty name. Erroneous code example:
The rust compiler cannot link to an external library if you don't give it its
name. Example:

```
```ignore
#[link(name = "some_lib")] extern {} // ok!
```
"##,
Expand Down Expand Up @@ -72,7 +72,7 @@ A link was used without a name parameter. Erroneous code example:
Please add the name parameter to allow the rust compiler to find the library
you want. Example:

```
```ignore
#[link(kind = "dylib", name = "some_lib")] extern {} // ok!
```
"##,
Expand All @@ -91,6 +91,185 @@ You need to link your code to the relevant crate in order to be able to use it
well, and you link to them the same way.
"##,

E0466: r##"
Macro import declarations were malformed.

Erroneous code examples:

```compile_fail,E0466
#[macro_use(a_macro(another_macro))] // error: invalid import declaration
extern crate some_crate;

#[macro_use(i_want = "some_macros")] // error: invalid import declaration
extern crate another_crate;
```

This is a syntax error at the level of attribute declarations. The proper
syntax for macro imports is the following:

```ignore
// In some_crate:
#[macro_export]
macro_rules! get_tacos {
...
}

#[macro_export]
macro_rules! get_pimientos {
...
}

// In your crate:
#[macro_use(get_tacos, get_pimientos)] // It imports `get_tacos` and
extern crate some_crate; // `get_pimientos` macros from some_crate
```

If you would like to import all exported macros, write `macro_use` with no
arguments.
"##,

E0467: r##"
Macro reexport declarations were empty or malformed.

Erroneous code examples:

```compile_fail,E0467
#[macro_reexport] // error: no macros listed for export
extern crate macros_for_good;

#[macro_reexport(fun_macro = "foo")] // error: not a macro identifier
extern crate other_macros_for_good;
```

This is a syntax error at the level of attribute declarations.

Currently, `macro_reexport` requires at least one macro name to be listed.
Unlike `macro_use`, listing no names does not reexport all macros from the
given crate.

Decide which macros you would like to export and list them properly.

These are proper reexport declarations:

```ignore
#[macro_reexport(some_macro, another_macro)]
extern crate macros_for_good;
```
"##,

E0468: r##"
A non-root module attempts to import macros from another crate.

Example of erroneous code:

```compile_fail,E0468
mod foo {
#[macro_use(helpful_macro)] // error: must be at crate root to import
extern crate some_crate; // macros from another crate
helpful_macro!(...)
}
```

Only `extern crate` imports at the crate root level are allowed to import
macros.

Either move the macro import to crate root or do without the foreign macros.
This will work:

```ignore
#[macro_use(helpful_macro)]
extern crate some_crate;

mod foo {
helpful_macro!(...)
}
```
"##,

E0469: r##"
A macro listed for import was not found.

Erroneous code example:

```compile_fail,E0469
#[macro_use(drink, be_merry)] // error: imported macro not found
extern crate collections;

fn main() {
// ...
}
```

Either the listed macro is not contained in the imported crate, or it is not
exported from the given crate.

This could be caused by a typo. Did you misspell the macro's name?

Double-check the names of the macros listed for import, and that the crate
in question exports them.

A working version would be:

```ignore
// In some_crate crate:
#[macro_export]
macro_rules! eat {
...
}

#[macro_export]
macro_rules! drink {
...
}

// In your crate:
#[macro_use(eat, drink)]
extern crate some_crate; //ok!
```
"##,

E0470: r##"
A macro listed for reexport was not found.

Erroneous code example:

```compile_fail,E0470
#[macro_reexport(drink, be_merry)]
extern crate collections;

fn main() {
// ...
}
```

Either the listed macro is not contained in the imported crate, or it is not
exported from the given crate.

This could be caused by a typo. Did you misspell the macro's name?

Double-check the names of the macros listed for reexport, and that the crate
in question exports them.

A working version:

```ignore
// In some_crate crate:
#[macro_export]
macro_rules! eat {
...
}

#[macro_export]
macro_rules! drink {
...
}

// In your_crate:
#[macro_reexport(eat, drink)]
extern crate some_crate;
```
"##,

}

register_diagnostics! {
Expand All @@ -102,11 +281,6 @@ register_diagnostics! {
E0462, // found staticlib `..` instead of rlib or dylib
E0464, // multiple matching crates for `..`
E0465, // multiple .. candidates for `..` found
E0466, // bad macro import
E0467, // bad macro reexport
E0468, // an `extern crate` loading macros must be at the crate root
E0469, // imported macro not found
E0470, // reexported macro not found
E0519, // local crate and dependency have same (crate-name, disambiguator)
E0523, // two dependencies have same (crate-name, disambiguator) but different SVH
}
2 changes: 2 additions & 0 deletions src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ pub mod index;
pub mod loader;
pub mod macro_import;
pub mod tls_context;

__build_diagnostic_array! { librustc_metadata, DIAGNOSTICS }
7 changes: 5 additions & 2 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
}
}
hir::TyTypeof(ref _e) => {
span_err!(tcx.sess, ast_ty.span, E0516,
"`typeof` is a reserved keyword but unimplemented");
struct_span_err!(tcx.sess, ast_ty.span, E0516,
"`typeof` is a reserved keyword but unimplemented")
.span_label(ast_ty.span, &format!("reserved keyword"))
.emit();

tcx.types.err
}
hir::TyInfer => {
Expand Down
9 changes: 6 additions & 3 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let min_len = before.len() + after.len();
if slice.is_none() {
if min_len != size {
span_err!(tcx.sess, pat.span, E0527,
"pattern requires {} elements but array has {}",
min_len, size);
struct_span_err!(
tcx.sess, pat.span, E0527,
"pattern requires {} elements but array has {}",
min_len, size)
.span_label(pat.span, &format!("expected {} elements",size))
.emit();
}
(inner_ty, tcx.types.err)
} else if let Some(rest) = size.checked_sub(min_len) {
Expand Down
Loading