Skip to content

Commit 255c033

Browse files
committed
Auto merge of #72716 - Dylan-DPC:rollup-wdj97ab, r=Dylan-DPC
Rollup of 12 pull requests Successful merges: - #72239 (Implement PartialOrd and Ord for SocketAddr*) - #72466 (Stabilize str_strip feature) - #72605 (Add working example for E0617 explanation) - #72636 (Cleanup `Resolver::<clone|into>_outputs` methods) - #72645 (Add myself to .mailmap) - #72667 (expand unaligned_references test) - #72670 (Fix incorrect comment in generator test) - #72674 (Clippy should always build) - #72682 (Add test for #66930) - #72695 (update data layout for illumos x86) - #72697 (Remove rustc-ux-guidelines) - #72702 (rustc_lint: Remove `unused_crate_dependencies` from the `unused` group) Failed merges: r? @ghost
2 parents 4512721 + 049b6dd commit 255c033

File tree

25 files changed

+248
-225
lines changed

25 files changed

+248
-225
lines changed

.mailmap

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ David Manescu <[email protected]> <[email protected]>
7070
David Ross <[email protected]>
7171
Derek Chiang <[email protected]> Derek Chiang (Enchi Jiang) <[email protected]>
7272
Diggory Hardy <[email protected]> Diggory Hardy <[email protected]>
73+
74+
Donough Liu <[email protected]> DingMing Liu <[email protected]>
7375
Dustin Bensing <[email protected]>
7476
7577
Dzmitry Malyshau <[email protected]>

src/bootstrap/test.rs

+26-34
Original file line numberDiff line numberDiff line change
@@ -516,45 +516,37 @@ impl Step for Clippy {
516516
let host = self.host;
517517
let compiler = builder.compiler(stage, host);
518518

519-
let clippy = builder.ensure(tool::Clippy {
519+
let clippy = builder
520+
.ensure(tool::Clippy { compiler, target: self.host, extra_features: Vec::new() })
521+
.expect("in-tree tool");
522+
let mut cargo = tool::prepare_tool_cargo(
523+
builder,
520524
compiler,
521-
target: self.host,
522-
extra_features: Vec::new(),
523-
});
524-
if let Some(clippy) = clippy {
525-
let mut cargo = tool::prepare_tool_cargo(
526-
builder,
527-
compiler,
528-
Mode::ToolRustc,
529-
host,
530-
"test",
531-
"src/tools/clippy",
532-
SourceType::InTree,
533-
&[],
534-
);
525+
Mode::ToolRustc,
526+
host,
527+
"test",
528+
"src/tools/clippy",
529+
SourceType::InTree,
530+
&[],
531+
);
535532

536-
// clippy tests need to know about the stage sysroot
537-
cargo.env("SYSROOT", builder.sysroot(compiler));
538-
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
539-
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
540-
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
541-
let target_libs = builder
542-
.stage_out(compiler, Mode::ToolRustc)
543-
.join(&self.host)
544-
.join(builder.cargo_dir());
545-
cargo.env("HOST_LIBS", host_libs);
546-
cargo.env("TARGET_LIBS", target_libs);
547-
// clippy tests need to find the driver
548-
cargo.env("CLIPPY_DRIVER_PATH", clippy);
533+
// clippy tests need to know about the stage sysroot
534+
cargo.env("SYSROOT", builder.sysroot(compiler));
535+
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
536+
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
537+
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
538+
let target_libs =
539+
builder.stage_out(compiler, Mode::ToolRustc).join(&self.host).join(builder.cargo_dir());
540+
cargo.env("HOST_LIBS", host_libs);
541+
cargo.env("TARGET_LIBS", target_libs);
542+
// clippy tests need to find the driver
543+
cargo.env("CLIPPY_DRIVER_PATH", clippy);
549544

550-
cargo.arg("--").args(builder.config.cmd.test_args());
545+
cargo.arg("--").args(builder.config.cmd.test_args());
551546

552-
builder.add_rustc_lib_path(compiler, &mut cargo);
547+
builder.add_rustc_lib_path(compiler, &mut cargo);
553548

554-
try_run(builder, &mut cargo.into());
555-
} else {
556-
eprintln!("failed to test clippy: could not build");
557-
}
549+
try_run(builder, &mut cargo.into());
558550
}
559551
}
560552

src/doc/rustc-ux-guidelines.md

-90
This file was deleted.

src/libcore/str/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -4052,15 +4052,13 @@ impl str {
40524052
/// # Examples
40534053
///
40544054
/// ```
4055-
/// #![feature(str_strip)]
4056-
///
40574055
/// assert_eq!("foo:bar".strip_prefix("foo:"), Some("bar"));
40584056
/// assert_eq!("foo:bar".strip_prefix("bar"), None);
40594057
/// assert_eq!("foofoo".strip_prefix("foo"), Some("foo"));
40604058
/// ```
40614059
#[must_use = "this returns the remaining substring as a new slice, \
40624060
without modifying the original"]
4063-
#[unstable(feature = "str_strip", reason = "newly added", issue = "67302")]
4061+
#[stable(feature = "str_strip", since = "1.45.0")]
40644062
pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str> {
40654063
prefix.strip_prefix_of(self)
40664064
}
@@ -4082,14 +4080,13 @@ impl str {
40824080
/// # Examples
40834081
///
40844082
/// ```
4085-
/// #![feature(str_strip)]
40864083
/// assert_eq!("bar:foo".strip_suffix(":foo"), Some("bar"));
40874084
/// assert_eq!("bar:foo".strip_suffix("bar"), None);
40884085
/// assert_eq!("foofoo".strip_suffix("foo"), Some("foo"));
40894086
/// ```
40904087
#[must_use = "this returns the remaining substring as a new slice, \
40914088
without modifying the original"]
4092-
#[unstable(feature = "str_strip", reason = "newly added", issue = "67302")]
4089+
#[stable(feature = "str_strip", since = "1.45.0")]
40934090
pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str>
40944091
where
40954092
P: Pattern<'a>,

src/librustc_error_codes/error_codes/E0617.md

+11
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ Certain Rust types must be cast before passing them to a variadic function,
1717
because of arcane ABI rules dictated by the C standard. To fix the error,
1818
cast the value to the type specified by the error message (which you may need
1919
to import from `std::os::raw`).
20+
21+
In this case, `c_double` has the same size as `f64` so we can use it directly:
22+
23+
```no_run
24+
# extern {
25+
# fn printf(c: *const i8, ...);
26+
# }
27+
unsafe {
28+
printf(::std::ptr::null(), 0f64); // ok!
29+
}
30+
```

src/librustc_hir/hir.rs

-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub use rustc_ast::ast::{CaptureBy, Movability, Mutability};
1010
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
1111
use rustc_ast::node_id::NodeMap;
1212
use rustc_ast::util::parser::ExprPrecedence;
13-
use rustc_data_structures::fx::FxHashSet;
1413
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
1514
use rustc_macros::HashStable_Generic;
1615
use rustc_span::source_map::{SourceMap, Spanned};
@@ -2664,10 +2663,6 @@ impl<ID> TraitCandidate<ID> {
26642663
// Trait method resolution
26652664
pub type TraitMap<ID = HirId> = NodeMap<Vec<TraitCandidate<ID>>>;
26662665

2667-
// Map from the NodeId of a glob import to a list of items which are actually
2668-
// imported.
2669-
pub type GlobMap = NodeMap<FxHashSet<Symbol>>;
2670-
26712666
#[derive(Copy, Clone, Debug, HashStable_Generic)]
26722667
pub enum Node<'hir> {
26732668
Param(&'hir Param<'hir>),

src/librustc_lint/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
276276
UNUSED_ALLOCATION,
277277
UNUSED_DOC_COMMENTS,
278278
UNUSED_EXTERN_CRATES,
279-
UNUSED_CRATE_DEPENDENCIES,
280279
UNUSED_FEATURES,
281280
UNUSED_LABELS,
282281
UNUSED_PARENS,

src/librustc_middle/hir/map/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ impl<'hir> Map<'hir> {
169169
})
170170
}
171171

172-
// FIXME(eddyb) this function can and should return `LocalDefId`.
173172
#[inline]
174173
pub fn local_def_id(&self, hir_id: HirId) -> LocalDefId {
175174
self.opt_local_def_id(hir_id).unwrap_or_else(|| {
@@ -192,11 +191,6 @@ impl<'hir> Map<'hir> {
192191
self.tcx.definitions.opt_local_def_id(node)
193192
}
194193

195-
#[inline]
196-
pub fn as_local_node_id(&self, def_id: DefId) -> Option<NodeId> {
197-
self.tcx.definitions.as_local_node_id(def_id)
198-
}
199-
200194
#[inline]
201195
pub fn as_local_hir_id(&self, def_id: LocalDefId) -> HirId {
202196
self.tcx.definitions.as_local_hir_id(def_id)

src/librustc_middle/query/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,9 @@ rustc_queries! {
973973
desc { "fetching what a crate is named" }
974974
}
975975
query item_children(_: DefId) -> &'tcx [Export<hir::HirId>] {}
976-
query extern_mod_stmt_cnum(_: DefId) -> Option<CrateNum> {}
976+
query extern_mod_stmt_cnum(_: LocalDefId) -> Option<CrateNum> {
977+
desc { "fetching extern module statement" }
978+
}
977979

978980
query get_lib_features(_: CrateNum) -> LibFeatures {
979981
storage(ArenaCacheSelector<'tcx>)
@@ -1040,7 +1042,7 @@ rustc_queries! {
10401042
desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
10411043
}
10421044
query maybe_unused_extern_crates(_: CrateNum)
1043-
-> &'tcx [(DefId, Span)] {
1045+
-> &'tcx [(LocalDefId, Span)] {
10441046
eval_always
10451047
desc { "looking up all possibly unused extern crates" }
10461048
}

src/librustc_middle/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ pub struct GlobalCtxt<'tcx> {
925925
pub consts: CommonConsts<'tcx>,
926926

927927
/// Resolutions of `extern crate` items produced by resolver.
928-
extern_crate_map: FxHashMap<DefId, CrateNum>,
928+
extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
929929

930930
/// Map indicating what traits are in scope for places where this
931931
/// is relevant; generated by resolve.
@@ -944,7 +944,7 @@ pub struct GlobalCtxt<'tcx> {
944944
pub queries: query::Queries<'tcx>,
945945

946946
maybe_unused_trait_imports: FxHashSet<LocalDefId>,
947-
maybe_unused_extern_crates: Vec<(DefId, Span)>,
947+
maybe_unused_extern_crates: Vec<(LocalDefId, Span)>,
948948
/// A map of glob use to a set of names it actually imports. Currently only
949949
/// used in save-analysis.
950950
glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,

src/librustc_middle/ty/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ mod sty;
120120
pub struct ResolverOutputs {
121121
pub definitions: rustc_hir::definitions::Definitions,
122122
pub cstore: Box<CrateStoreDyn>,
123-
pub extern_crate_map: FxHashMap<DefId, CrateNum>,
123+
pub extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
124124
pub trait_map: FxHashMap<hir::HirId, Vec<hir::TraitCandidate<hir::HirId>>>,
125125
pub maybe_unused_trait_imports: FxHashSet<LocalDefId>,
126-
pub maybe_unused_extern_crates: Vec<(DefId, Span)>,
126+
pub maybe_unused_extern_crates: Vec<(LocalDefId, Span)>,
127127
pub export_map: ExportMap<hir::HirId>,
128128
pub glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
129129
/// Extern prelude entries. The value is `true` if the entry was introduced

src/librustc_resolve/build_reduced_graph.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'a> Resolver<'a> {
130130
Some(def_id) => def_id,
131131
None => return self.ast_transform_scopes.get(&expn_id).unwrap_or(&self.graph_root),
132132
};
133-
if let Some(id) = self.definitions.as_local_node_id(def_id) {
133+
if let Some(id) = def_id.as_local() {
134134
self.local_macro_def_scopes[&id]
135135
} else {
136136
let module_def_id = ty::DefIdTree::parent(&*self, def_id).unwrap();
@@ -640,9 +640,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
640640
} else if orig_name == Some(kw::SelfLower) {
641641
self.r.graph_root
642642
} else {
643+
let def_id = self.r.definitions.local_def_id(item.id);
643644
let crate_id =
644645
self.r.crate_loader.process_extern_crate(item, &self.r.definitions);
645-
self.r.extern_crate_map.insert(item.id, crate_id);
646+
self.r.extern_crate_map.insert(def_id, crate_id);
646647
self.r.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX })
647648
};
648649

@@ -1173,10 +1174,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
11731174
_ => unreachable!(),
11741175
};
11751176

1176-
let def_id = self.r.definitions.local_def_id(item.id).to_def_id();
1177-
let res = Res::Def(DefKind::Macro(ext.macro_kind()), def_id);
1178-
self.r.macro_map.insert(def_id, ext);
1179-
self.r.local_macro_def_scopes.insert(item.id, parent_scope.module);
1177+
let def_id = self.r.definitions.local_def_id(item.id);
1178+
let res = Res::Def(DefKind::Macro(ext.macro_kind()), def_id.to_def_id());
1179+
self.r.macro_map.insert(def_id.to_def_id(), ext);
1180+
self.r.local_macro_def_scopes.insert(def_id, parent_scope.module);
11801181

11811182
if macro_rules {
11821183
let ident = ident.normalize_to_macros_2_0();

src/librustc_resolve/check_unused.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,17 @@ impl<'a, 'b> UnusedImportCheckVisitor<'a, 'b> {
6464
fn check_import(&mut self, id: ast::NodeId) {
6565
let mut used = false;
6666
self.r.per_ns(|this, ns| used |= this.used_imports.contains(&(id, ns)));
67+
let def_id = self.r.definitions.local_def_id(id);
6768
if !used {
68-
if self.r.maybe_unused_trait_imports.contains(&id) {
69+
if self.r.maybe_unused_trait_imports.contains(&def_id) {
6970
// Check later.
7071
return;
7172
}
7273
self.unused_import(self.base_id).add(id);
7374
} else {
7475
// This trait import is definitely used, in a way other than
7576
// method resolution.
76-
self.r.maybe_unused_trait_imports.remove(&id);
77+
self.r.maybe_unused_trait_imports.remove(&def_id);
7778
if let Some(i) = self.unused_imports.get_mut(&self.base_id) {
7879
i.unused.remove(&id);
7980
}
@@ -245,7 +246,8 @@ impl Resolver<'_> {
245246
}
246247
}
247248
ImportKind::ExternCrate { .. } => {
248-
self.maybe_unused_extern_crates.push((import.id, import.span));
249+
let def_id = self.definitions.local_def_id(import.id);
250+
self.maybe_unused_extern_crates.push((def_id, import.span));
249251
}
250252
ImportKind::MacroUse => {
251253
let msg = "unused `#[macro_use]` import";

src/librustc_resolve/late.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2209,7 +2209,8 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
22092209
) -> SmallVec<[NodeId; 1]> {
22102210
let mut import_ids = smallvec![];
22112211
while let NameBindingKind::Import { import, binding, .. } = kind {
2212-
self.r.maybe_unused_trait_imports.insert(import.id);
2212+
let id = self.r.definitions.local_def_id(import.id);
2213+
self.r.maybe_unused_trait_imports.insert(id);
22132214
self.r.add_to_glob_map(&import, trait_name);
22142215
import_ids.push(import.id);
22152216
kind = &binding.kind;

0 commit comments

Comments
 (0)