Auto merge of #57918 - Centril:rollup, r=Centril
Rollup of 7 pull requests Successful merges: - #57407 (Stabilize extern_crate_self) - #57703 (Make MutexGuard's Debug implementation more useful.) - #57764 (Fix some minor warnings) - #57825 (un-deprecate mem::zeroed) - #57827 (Ignore aarch64 in simd-intrinsic-generic-reduction) - #57908 (resolve: Fix span arithmetics in the import conflict error) - #57913 (Change crate-visibility-modifier issue number in The Unstable Book) Failed merges: r? @ghost
This commit is contained in:
commit
20c2cba61d
21 changed files with 156 additions and 84 deletions
|
@ -1,8 +1,8 @@
|
|||
# `crate_visibility_modifier`
|
||||
|
||||
The tracking issue for this feature is: [#45388]
|
||||
The tracking issue for this feature is: [#53120]
|
||||
|
||||
[#45388]: https://github.com/rust-lang/rust/issues/45388
|
||||
[#53120]: https://github.com/rust-lang/rust/issues/53120
|
||||
|
||||
-----
|
||||
|
||||
|
|
|
@ -489,7 +489,6 @@ pub const fn needs_drop<T>() -> bool {
|
|||
/// assert_eq!(0, x);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::zeroed` instead")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub unsafe fn zeroed<T>() -> T {
|
||||
#[cfg(not(stage0))]
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
test(attr(deny(warnings))))]
|
||||
|
||||
#![feature(nll)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
pub use self::Piece::*;
|
||||
pub use self::Position::*;
|
||||
|
|
|
@ -32,7 +32,7 @@ use syntax::ext::base::{MacroKind, SyntaxExtension};
|
|||
use syntax::ext::base::Determinacy::Undetermined;
|
||||
use syntax::ext::hygiene::Mark;
|
||||
use syntax::ext::tt::macro_rules;
|
||||
use syntax::feature_gate::{is_builtin_attr, emit_feature_err, GateIssue};
|
||||
use syntax::feature_gate::is_builtin_attr;
|
||||
use syntax::parse::token::{self, Token};
|
||||
use syntax::std_inject::injected_crate_name;
|
||||
use syntax::symbol::keywords;
|
||||
|
@ -356,10 +356,6 @@ impl<'a> Resolver<'a> {
|
|||
.emit();
|
||||
return;
|
||||
} else if orig_name == Some(keywords::SelfLower.name()) {
|
||||
if !self.session.features_untracked().extern_crate_self {
|
||||
emit_feature_err(&self.session.parse_sess, "extern_crate_self", item.span,
|
||||
GateIssue::Language, "`extern crate self` is unstable");
|
||||
}
|
||||
self.graph_root
|
||||
} else {
|
||||
let crate_id = self.crate_loader.process_extern_crate(item, &self.definitions);
|
||||
|
|
|
@ -5134,60 +5134,59 @@ impl<'a> Resolver<'a> {
|
|||
);
|
||||
|
||||
// See https://github.com/rust-lang/rust/issues/32354
|
||||
if old_binding.is_import() || new_binding.is_import() {
|
||||
let binding = if new_binding.is_import() && !new_binding.span.is_dummy() {
|
||||
new_binding
|
||||
let directive = match (&new_binding.kind, &old_binding.kind) {
|
||||
(NameBindingKind::Import { directive, .. }, _) if !new_binding.span.is_dummy() =>
|
||||
Some((directive, new_binding.span)),
|
||||
(_, NameBindingKind::Import { directive, .. }) if !old_binding.span.is_dummy() =>
|
||||
Some((directive, old_binding.span)),
|
||||
_ => None,
|
||||
};
|
||||
if let Some((directive, binding_span)) = directive {
|
||||
let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
|
||||
format!("Other{}", name)
|
||||
} else {
|
||||
old_binding
|
||||
format!("other_{}", name)
|
||||
};
|
||||
|
||||
let cm = self.session.source_map();
|
||||
let mut suggestion = None;
|
||||
match directive.subclass {
|
||||
ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } =>
|
||||
suggestion = Some(format!("self as {}", suggested_name)),
|
||||
ImportDirectiveSubclass::SingleImport { source, .. } => {
|
||||
if let Some(pos) = source.span.hi().0.checked_sub(binding_span.lo().0)
|
||||
.map(|pos| pos as usize) {
|
||||
if let Ok(snippet) = self.session.source_map()
|
||||
.span_to_snippet(binding_span) {
|
||||
if pos <= snippet.len() {
|
||||
suggestion = Some(format!(
|
||||
"{} as {}{}",
|
||||
&snippet[..pos],
|
||||
suggested_name,
|
||||
if snippet.ends_with(";") { ";" } else { "" }
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImportDirectiveSubclass::ExternCrate { source, target, .. } =>
|
||||
suggestion = Some(format!(
|
||||
"extern crate {} as {};",
|
||||
source.unwrap_or(target.name),
|
||||
suggested_name,
|
||||
)),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let rename_msg = "you can use `as` to change the binding name of the import";
|
||||
|
||||
if let (
|
||||
Ok(snippet),
|
||||
NameBindingKind::Import { directive, ..},
|
||||
_dummy @ false,
|
||||
) = (
|
||||
cm.span_to_snippet(binding.span),
|
||||
binding.kind.clone(),
|
||||
binding.span.is_dummy(),
|
||||
) {
|
||||
let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
|
||||
format!("Other{}", name)
|
||||
} else {
|
||||
format!("other_{}", name)
|
||||
};
|
||||
|
||||
if let Some(suggestion) = suggestion {
|
||||
err.span_suggestion_with_applicability(
|
||||
binding.span,
|
||||
&rename_msg,
|
||||
match directive.subclass {
|
||||
ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } =>
|
||||
format!("self as {}", suggested_name),
|
||||
ImportDirectiveSubclass::SingleImport { source, .. } =>
|
||||
format!(
|
||||
"{} as {}{}",
|
||||
&snippet[..((source.span.hi().0 - binding.span.lo().0) as usize)],
|
||||
suggested_name,
|
||||
if snippet.ends_with(";") {
|
||||
";"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
),
|
||||
ImportDirectiveSubclass::ExternCrate { source, target, .. } =>
|
||||
format!(
|
||||
"extern crate {} as {};",
|
||||
source.unwrap_or(target.name),
|
||||
suggested_name,
|
||||
),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
binding_span,
|
||||
rename_msg,
|
||||
suggestion,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else {
|
||||
err.span_label(binding.span, rename_msg);
|
||||
err.span_label(binding_span, rename_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -450,9 +450,7 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
|
|||
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||
impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("MutexGuard")
|
||||
.field("lock", &self.__lock)
|
||||
.finish()
|
||||
fmt::Debug::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -453,9 +453,6 @@ declare_features! (
|
|||
// Adds `reason` and `expect` lint attributes.
|
||||
(active, lint_reasons, "1.31.0", Some(54503), None),
|
||||
|
||||
// `extern crate self as foo;` puts local crate root into extern prelude under name `foo`.
|
||||
(active, extern_crate_self, "1.31.0", Some(56409), None),
|
||||
|
||||
// Allows paths to enum variants on type aliases.
|
||||
(active, type_alias_enum_variants, "1.31.0", Some(49683), None),
|
||||
|
||||
|
@ -689,6 +686,8 @@ declare_features! (
|
|||
(accepted, uniform_paths, "1.32.0", Some(53130), None),
|
||||
// Allows `cfg(target_vendor = "...")`.
|
||||
(accepted, cfg_target_vendor, "1.33.0", Some(29718), None),
|
||||
// `extern crate self as foo;` puts local crate root into extern prelude under name `foo`.
|
||||
(accepted, extern_crate_self, "1.34.0", Some(56409), None),
|
||||
);
|
||||
|
||||
// If you change this, please modify `src/doc/unstable-book` as well. You must
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#![feature(asm)]
|
||||
#![cfg_attr(stage0, feature(cfg_target_vendor))]
|
||||
#![feature(fnbox)]
|
||||
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
|
||||
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))]
|
||||
#![feature(nll)]
|
||||
#![feature(set_stdio)]
|
||||
#![feature(panic_unwind)]
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#![allow(non_camel_case_types)]
|
||||
|
||||
// ignore-emscripten
|
||||
// ignore-aarch64 FIXME: https://github.com/rust-lang/rust/issues/54510
|
||||
|
||||
// Test that the simd_reduce_{op} intrinsics produce the correct results.
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
extern crate self as foo; //~ ERROR `extern crate self` is unstable
|
||||
|
||||
fn main() {}
|
|
@ -1,11 +0,0 @@
|
|||
error[E0658]: `extern crate self` is unstable (see issue #56409)
|
||||
--> $DIR/feature-gate-extern_crate_self.rs:1:1
|
||||
|
|
||||
LL | extern crate self as foo; //~ ERROR `extern crate self` is unstable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(extern_crate_self)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(extern_crate_self)]
|
||||
|
||||
extern crate self; //~ ERROR `extern crate self;` requires renaming
|
||||
|
||||
#[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self`
|
|
@ -1,11 +1,11 @@
|
|||
error: `extern crate self;` requires renaming
|
||||
--> $DIR/extern-crate-self-fail.rs:3:1
|
||||
--> $DIR/extern-crate-self-fail.rs:1:1
|
||||
|
|
||||
LL | extern crate self; //~ ERROR `extern crate self;` requires renaming
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `extern crate self as name;`
|
||||
|
||||
error: `macro_use` is not supported on `extern crate self`
|
||||
--> $DIR/extern-crate-self-fail.rs:5:1
|
||||
--> $DIR/extern-crate-self-fail.rs:3:1
|
||||
|
|
||||
LL | #[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self`
|
||||
| ^^^^^^^^^^^^
|
|
@ -0,0 +1,16 @@
|
|||
// run-pass
|
||||
|
||||
// Test that a macro can correctly expand the alias
|
||||
// in an `extern crate self as ALIAS` item.
|
||||
|
||||
fn the_answer() -> usize { 42 }
|
||||
|
||||
macro_rules! alias_self {
|
||||
($alias:ident) => { extern crate self as $alias; }
|
||||
}
|
||||
|
||||
alias_self!(the_alias);
|
||||
|
||||
fn main() {
|
||||
assert_eq!(the_alias::the_answer(), 42);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// compile-pass
|
||||
|
||||
// Test that `extern crate self;` is accepted
|
||||
// syntactically as an item for use in a macro.
|
||||
|
||||
macro_rules! accept_item { ($x:item) => {} }
|
||||
|
||||
accept_item! {
|
||||
extern crate self;
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,16 @@
|
|||
// run-pass
|
||||
|
||||
// Test that a macro can correctly expand `self` in
|
||||
// an `extern crate self as ALIAS` item.
|
||||
|
||||
fn the_answer() -> usize { 42 }
|
||||
|
||||
macro_rules! extern_something {
|
||||
($alias:ident) => { extern crate $alias as the_alias; }
|
||||
}
|
||||
|
||||
extern_something!(self);
|
||||
|
||||
fn main() {
|
||||
assert_eq!(the_alias::the_answer(), 42);
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
// compile-pass
|
||||
|
||||
#![feature(extern_crate_self)]
|
||||
|
||||
extern crate self as foo;
|
||||
|
||||
struct S;
|
17
src/test/ui/issues/issue-56411.rs
Normal file
17
src/test/ui/issues/issue-56411.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
macro_rules! import {
|
||||
( $($name:ident),* ) => {
|
||||
$(
|
||||
mod $name;
|
||||
pub use self::$name;
|
||||
//~^ ERROR the name `issue_56411_aux` is defined multiple times
|
||||
//~| ERROR `issue_56411_aux` is private, and cannot be re-exported
|
||||
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
import!(issue_56411_aux);
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
31
src/test/ui/issues/issue-56411.stderr
Normal file
31
src/test/ui/issues/issue-56411.stderr
Normal file
|
@ -0,0 +1,31 @@
|
|||
error[E0255]: the name `issue_56411_aux` is defined multiple times
|
||||
--> $DIR/issue-56411.rs:5:21
|
||||
|
|
||||
LL | mod $name;
|
||||
| ---------- previous definition of the module `issue_56411_aux` here
|
||||
LL | pub use self::$name;
|
||||
| ^^^^^^^^^^^
|
||||
| |
|
||||
| `issue_56411_aux` reimported here
|
||||
| you can use `as` to change the binding name of the import
|
||||
...
|
||||
LL | import!(issue_56411_aux);
|
||||
| ------------------------- in this macro invocation
|
||||
|
|
||||
= note: `issue_56411_aux` must be defined only once in the type namespace of this module
|
||||
|
||||
error[E0365]: `issue_56411_aux` is private, and cannot be re-exported
|
||||
--> $DIR/issue-56411.rs:5:21
|
||||
|
|
||||
LL | pub use self::$name;
|
||||
| ^^^^^^^^^^^ re-export of private `issue_56411_aux`
|
||||
...
|
||||
LL | import!(issue_56411_aux);
|
||||
| ------------------------- in this macro invocation
|
||||
|
|
||||
= note: consider declaring type or module `issue_56411_aux` with `pub`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0255, E0365.
|
||||
For more information about an error, try `rustc --explain E0255`.
|
5
src/test/ui/issues/issue_56411_aux.rs
Normal file
5
src/test/ui/issues/issue_56411_aux.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
// compile-pass
|
||||
|
||||
struct T {}
|
||||
|
||||
fn main() {}
|
|
@ -78,7 +78,7 @@ impl FileEntry {
|
|||
fn parse_ids(&mut self, file: &Path, contents: &str, errors: &mut bool) {
|
||||
if self.ids.is_empty() {
|
||||
with_attrs_in_source(contents, " id", |fragment, i, _| {
|
||||
let frag = fragment.trim_left_matches("#").to_owned();
|
||||
let frag = fragment.trim_start_matches("#").to_owned();
|
||||
let encoded = small_url_encode(&frag);
|
||||
if !self.ids.insert(frag) {
|
||||
*errors = true;
|
||||
|
@ -343,7 +343,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(contents: &str, attr: &str,
|
|||
Some(i) => i,
|
||||
None => continue,
|
||||
};
|
||||
if rest[..pos_equals].trim_left_matches(" ") != "" {
|
||||
if rest[..pos_equals].trim_start_matches(" ") != "" {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(contents: &str, attr: &str,
|
|||
};
|
||||
let quote_delim = rest.as_bytes()[pos_quote] as char;
|
||||
|
||||
if rest[..pos_quote].trim_left_matches(" ") != "" {
|
||||
if rest[..pos_quote].trim_start_matches(" ") != "" {
|
||||
continue;
|
||||
}
|
||||
let rest = &rest[pos_quote + 1..];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue