Skip to content

Commit 20c2cba

Browse files
committed
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
2 parents 46a43dc + 97833ee commit 20c2cba

21 files changed

+156
-84
lines changed

Diff for: src/doc/unstable-book/src/language-features/crate-visibility-modifier.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# `crate_visibility_modifier`
22

3-
The tracking issue for this feature is: [#45388]
3+
The tracking issue for this feature is: [#53120]
44

5-
[#45388]: https://github.com/rust-lang/rust/issues/45388
5+
[#53120]: https://github.com/rust-lang/rust/issues/53120
66

77
-----
88

Diff for: src/libcore/mem.rs

-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ pub const fn needs_drop<T>() -> bool {
489489
/// assert_eq!(0, x);
490490
/// ```
491491
#[inline]
492-
#[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::zeroed` instead")]
493492
#[stable(feature = "rust1", since = "1.0.0")]
494493
pub unsafe fn zeroed<T>() -> T {
495494
#[cfg(not(stage0))]

Diff for: src/libfmt_macros/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
test(attr(deny(warnings))))]
1212

1313
#![feature(nll)]
14+
#![feature(rustc_private)]
1415

1516
pub use self::Piece::*;
1617
pub use self::Position::*;

Diff for: src/librustc_resolve/build_reduced_graph.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use syntax::ext::base::{MacroKind, SyntaxExtension};
3232
use syntax::ext::base::Determinacy::Undetermined;
3333
use syntax::ext::hygiene::Mark;
3434
use syntax::ext::tt::macro_rules;
35-
use syntax::feature_gate::{is_builtin_attr, emit_feature_err, GateIssue};
35+
use syntax::feature_gate::is_builtin_attr;
3636
use syntax::parse::token::{self, Token};
3737
use syntax::std_inject::injected_crate_name;
3838
use syntax::symbol::keywords;
@@ -356,10 +356,6 @@ impl<'a> Resolver<'a> {
356356
.emit();
357357
return;
358358
} else if orig_name == Some(keywords::SelfLower.name()) {
359-
if !self.session.features_untracked().extern_crate_self {
360-
emit_feature_err(&self.session.parse_sess, "extern_crate_self", item.span,
361-
GateIssue::Language, "`extern crate self` is unstable");
362-
}
363359
self.graph_root
364360
} else {
365361
let crate_id = self.crate_loader.process_extern_crate(item, &self.definitions);

Diff for: src/librustc_resolve/lib.rs

+45-46
Original file line numberDiff line numberDiff line change
@@ -5134,60 +5134,59 @@ impl<'a> Resolver<'a> {
51345134
);
51355135

51365136
// See https://github.com/rust-lang/rust/issues/32354
5137-
if old_binding.is_import() || new_binding.is_import() {
5138-
let binding = if new_binding.is_import() && !new_binding.span.is_dummy() {
5139-
new_binding
5137+
let directive = match (&new_binding.kind, &old_binding.kind) {
5138+
(NameBindingKind::Import { directive, .. }, _) if !new_binding.span.is_dummy() =>
5139+
Some((directive, new_binding.span)),
5140+
(_, NameBindingKind::Import { directive, .. }) if !old_binding.span.is_dummy() =>
5141+
Some((directive, old_binding.span)),
5142+
_ => None,
5143+
};
5144+
if let Some((directive, binding_span)) = directive {
5145+
let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
5146+
format!("Other{}", name)
51405147
} else {
5141-
old_binding
5148+
format!("other_{}", name)
51425149
};
51435150

5144-
let cm = self.session.source_map();
5145-
let rename_msg = "you can use `as` to change the binding name of the import";
5146-
5147-
if let (
5148-
Ok(snippet),
5149-
NameBindingKind::Import { directive, ..},
5150-
_dummy @ false,
5151-
) = (
5152-
cm.span_to_snippet(binding.span),
5153-
binding.kind.clone(),
5154-
binding.span.is_dummy(),
5155-
) {
5156-
let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
5157-
format!("Other{}", name)
5158-
} else {
5159-
format!("other_{}", name)
5160-
};
5151+
let mut suggestion = None;
5152+
match directive.subclass {
5153+
ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } =>
5154+
suggestion = Some(format!("self as {}", suggested_name)),
5155+
ImportDirectiveSubclass::SingleImport { source, .. } => {
5156+
if let Some(pos) = source.span.hi().0.checked_sub(binding_span.lo().0)
5157+
.map(|pos| pos as usize) {
5158+
if let Ok(snippet) = self.session.source_map()
5159+
.span_to_snippet(binding_span) {
5160+
if pos <= snippet.len() {
5161+
suggestion = Some(format!(
5162+
"{} as {}{}",
5163+
&snippet[..pos],
5164+
suggested_name,
5165+
if snippet.ends_with(";") { ";" } else { "" }
5166+
))
5167+
}
5168+
}
5169+
}
5170+
}
5171+
ImportDirectiveSubclass::ExternCrate { source, target, .. } =>
5172+
suggestion = Some(format!(
5173+
"extern crate {} as {};",
5174+
source.unwrap_or(target.name),
5175+
suggested_name,
5176+
)),
5177+
_ => unreachable!(),
5178+
}
51615179

5180+
let rename_msg = "you can use `as` to change the binding name of the import";
5181+
if let Some(suggestion) = suggestion {
51625182
err.span_suggestion_with_applicability(
5163-
binding.span,
5164-
&rename_msg,
5165-
match directive.subclass {
5166-
ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } =>
5167-
format!("self as {}", suggested_name),
5168-
ImportDirectiveSubclass::SingleImport { source, .. } =>
5169-
format!(
5170-
"{} as {}{}",
5171-
&snippet[..((source.span.hi().0 - binding.span.lo().0) as usize)],
5172-
suggested_name,
5173-
if snippet.ends_with(";") {
5174-
";"
5175-
} else {
5176-
""
5177-
}
5178-
),
5179-
ImportDirectiveSubclass::ExternCrate { source, target, .. } =>
5180-
format!(
5181-
"extern crate {} as {};",
5182-
source.unwrap_or(target.name),
5183-
suggested_name,
5184-
),
5185-
_ => unreachable!(),
5186-
},
5183+
binding_span,
5184+
rename_msg,
5185+
suggestion,
51875186
Applicability::MaybeIncorrect,
51885187
);
51895188
} else {
5190-
err.span_label(binding.span, rename_msg);
5189+
err.span_label(binding_span, rename_msg);
51915190
}
51925191
}
51935192

Diff for: src/libstd/sync/mutex.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,7 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
450450
#[stable(feature = "std_debug", since = "1.16.0")]
451451
impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
452452
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
453-
f.debug_struct("MutexGuard")
454-
.field("lock", &self.__lock)
455-
.finish()
453+
fmt::Debug::fmt(&**self, f)
456454
}
457455
}
458456

Diff for: src/libsyntax/feature_gate.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,6 @@ declare_features! (
453453
// Adds `reason` and `expect` lint attributes.
454454
(active, lint_reasons, "1.31.0", Some(54503), None),
455455

456-
// `extern crate self as foo;` puts local crate root into extern prelude under name `foo`.
457-
(active, extern_crate_self, "1.31.0", Some(56409), None),
458-
459456
// Allows paths to enum variants on type aliases.
460457
(active, type_alias_enum_variants, "1.31.0", Some(49683), None),
461458

@@ -689,6 +686,8 @@ declare_features! (
689686
(accepted, uniform_paths, "1.32.0", Some(53130), None),
690687
// Allows `cfg(target_vendor = "...")`.
691688
(accepted, cfg_target_vendor, "1.33.0", Some(29718), None),
689+
// `extern crate self as foo;` puts local crate root into extern prelude under name `foo`.
690+
(accepted, extern_crate_self, "1.34.0", Some(56409), None),
692691
);
693692

694693
// If you change this, please modify `src/doc/unstable-book` as well. You must

Diff for: src/libtest/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#![feature(asm)]
2626
#![cfg_attr(stage0, feature(cfg_target_vendor))]
2727
#![feature(fnbox)]
28-
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
28+
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))]
2929
#![feature(nll)]
3030
#![feature(set_stdio)]
3131
#![feature(panic_unwind)]

Diff for: src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(non_camel_case_types)]
33

44
// ignore-emscripten
5+
// ignore-aarch64 FIXME: https://github.com/rust-lang/rust/issues/54510
56

67
// Test that the simd_reduce_{op} intrinsics produce the correct results.
78

Diff for: src/test/ui/feature-gates/feature-gate-extern_crate_self.rs

-3
This file was deleted.

Diff for: src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr

-11
This file was deleted.

Diff for: src/test/ui/imports/extern-crate-self-fail.rs renamed to src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(extern_crate_self)]
2-
31
extern crate self; //~ ERROR `extern crate self;` requires renaming
42

53
#[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self`

Diff for: src/test/ui/imports/extern-crate-self-fail.stderr renamed to src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: `extern crate self;` requires renaming
2-
--> $DIR/extern-crate-self-fail.rs:3:1
2+
--> $DIR/extern-crate-self-fail.rs:1:1
33
|
44
LL | extern crate self; //~ ERROR `extern crate self;` requires renaming
55
| ^^^^^^^^^^^^^^^^^^ help: try: `extern crate self as name;`
66

77
error: `macro_use` is not supported on `extern crate self`
8-
--> $DIR/extern-crate-self-fail.rs:5:1
8+
--> $DIR/extern-crate-self-fail.rs:3:1
99
|
1010
LL | #[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self`
1111
| ^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// run-pass
2+
3+
// Test that a macro can correctly expand the alias
4+
// in an `extern crate self as ALIAS` item.
5+
6+
fn the_answer() -> usize { 42 }
7+
8+
macro_rules! alias_self {
9+
($alias:ident) => { extern crate self as $alias; }
10+
}
11+
12+
alias_self!(the_alias);
13+
14+
fn main() {
15+
assert_eq!(the_alias::the_answer(), 42);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-pass
2+
3+
// Test that `extern crate self;` is accepted
4+
// syntactically as an item for use in a macro.
5+
6+
macro_rules! accept_item { ($x:item) => {} }
7+
8+
accept_item! {
9+
extern crate self;
10+
}
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// run-pass
2+
3+
// Test that a macro can correctly expand `self` in
4+
// an `extern crate self as ALIAS` item.
5+
6+
fn the_answer() -> usize { 42 }
7+
8+
macro_rules! extern_something {
9+
($alias:ident) => { extern crate $alias as the_alias; }
10+
}
11+
12+
extern_something!(self);
13+
14+
fn main() {
15+
assert_eq!(the_alias::the_answer(), 42);
16+
}

Diff for: src/test/ui/imports/extern-crate-self-pass.rs renamed to src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// compile-pass
22

3-
#![feature(extern_crate_self)]
4-
53
extern crate self as foo;
64

75
struct S;

Diff for: src/test/ui/issues/issue-56411.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
macro_rules! import {
2+
( $($name:ident),* ) => {
3+
$(
4+
mod $name;
5+
pub use self::$name;
6+
//~^ ERROR the name `issue_56411_aux` is defined multiple times
7+
//~| ERROR `issue_56411_aux` is private, and cannot be re-exported
8+
9+
)*
10+
}
11+
}
12+
13+
import!(issue_56411_aux);
14+
15+
fn main() {
16+
println!("Hello, world!");
17+
}

Diff for: src/test/ui/issues/issue-56411.stderr

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0255]: the name `issue_56411_aux` is defined multiple times
2+
--> $DIR/issue-56411.rs:5:21
3+
|
4+
LL | mod $name;
5+
| ---------- previous definition of the module `issue_56411_aux` here
6+
LL | pub use self::$name;
7+
| ^^^^^^^^^^^
8+
| |
9+
| `issue_56411_aux` reimported here
10+
| you can use `as` to change the binding name of the import
11+
...
12+
LL | import!(issue_56411_aux);
13+
| ------------------------- in this macro invocation
14+
|
15+
= note: `issue_56411_aux` must be defined only once in the type namespace of this module
16+
17+
error[E0365]: `issue_56411_aux` is private, and cannot be re-exported
18+
--> $DIR/issue-56411.rs:5:21
19+
|
20+
LL | pub use self::$name;
21+
| ^^^^^^^^^^^ re-export of private `issue_56411_aux`
22+
...
23+
LL | import!(issue_56411_aux);
24+
| ------------------------- in this macro invocation
25+
|
26+
= note: consider declaring type or module `issue_56411_aux` with `pub`
27+
28+
error: aborting due to 2 previous errors
29+
30+
Some errors occurred: E0255, E0365.
31+
For more information about an error, try `rustc --explain E0255`.

Diff for: src/test/ui/issues/issue_56411_aux.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// compile-pass
2+
3+
struct T {}
4+
5+
fn main() {}

Diff for: src/tools/linkchecker/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl FileEntry {
7878
fn parse_ids(&mut self, file: &Path, contents: &str, errors: &mut bool) {
7979
if self.ids.is_empty() {
8080
with_attrs_in_source(contents, " id", |fragment, i, _| {
81-
let frag = fragment.trim_left_matches("#").to_owned();
81+
let frag = fragment.trim_start_matches("#").to_owned();
8282
let encoded = small_url_encode(&frag);
8383
if !self.ids.insert(frag) {
8484
*errors = true;
@@ -343,7 +343,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(contents: &str, attr: &str,
343343
Some(i) => i,
344344
None => continue,
345345
};
346-
if rest[..pos_equals].trim_left_matches(" ") != "" {
346+
if rest[..pos_equals].trim_start_matches(" ") != "" {
347347
continue;
348348
}
349349

@@ -355,7 +355,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(contents: &str, attr: &str,
355355
};
356356
let quote_delim = rest.as_bytes()[pos_quote] as char;
357357

358-
if rest[..pos_quote].trim_left_matches(" ") != "" {
358+
if rest[..pos_quote].trim_start_matches(" ") != "" {
359359
continue;
360360
}
361361
let rest = &rest[pos_quote + 1..];

0 commit comments

Comments
 (0)