about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--compiler/rustc_codegen_llvm/src/back/write.rs21
-rw-r--r--compiler/rustc_codegen_ssa/src/back/metadata.rs7
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs6
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs12
-rw-r--r--compiler/rustc_hir_typeck/src/gather_locals.rs23
-rw-r--r--compiler/rustc_hir_typeck/src/inherited.rs2
-rw-r--r--compiler/rustc_hir_typeck/src/lib.rs7
-rw-r--r--compiler/rustc_hir_typeck/src/pat.rs4
-rw-r--r--compiler/rustc_hir_typeck/src/writeback.rs2
-rw-r--r--compiler/rustc_target/Cargo.toml5
-rw-r--r--compiler/rustc_target/src/spec/avr_gnu_base.rs337
-rw-r--r--compiler/rustc_target/src/spec/mod.rs1
-rw-r--r--library/core/src/str/mod.rs40
-rw-r--r--library/std/src/collections/hash/map.rs8
-rw-r--r--src/bootstrap/defaults/config.dist.toml3
-rw-r--r--src/librustdoc/passes/collect_intra_doc_links.rs4
-rw-r--r--src/tools/compiletest/src/common.rs14
-rw-r--r--src/tools/compiletest/src/runtest.rs2
19 files changed, 416 insertions, 83 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 3aa3e4c4438..b78004c93df 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4069,6 +4069,7 @@ name = "rustc_target"
 version = "0.0.0"
 dependencies = [
  "bitflags",
+ "object 0.31.1",
  "rustc_abi",
  "rustc_data_structures",
  "rustc_feature",
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs
index 53b4296802e..b6de5ee40c7 100644
--- a/compiler/rustc_codegen_llvm/src/back/write.rs
+++ b/compiler/rustc_codegen_llvm/src/back/write.rs
@@ -875,14 +875,19 @@ unsafe fn embed_bitcode(
     //   passed though then these sections will show up in the final output.
     //   Additionally the flag that we need to set here is `SHF_EXCLUDE`.
     //
+    // * XCOFF - AIX linker ignores content in .ipa and .info if no auxiliary
+    //   symbol associated with these sections.
+    //
     // Unfortunately, LLVM provides no way to set custom section flags. For ELF
     // and COFF we emit the sections using module level inline assembly for that
     // reason (see issue #90326 for historical background).
+    let is_aix = cgcx.opts.target_triple.triple().contains("-aix");
     let is_apple = cgcx.opts.target_triple.triple().contains("-ios")
         || cgcx.opts.target_triple.triple().contains("-darwin")
         || cgcx.opts.target_triple.triple().contains("-tvos")
         || cgcx.opts.target_triple.triple().contains("-watchos");
     if is_apple
+        || is_aix
         || cgcx.opts.target_triple.triple().starts_with("wasm")
         || cgcx.opts.target_triple.triple().starts_with("asmjs")
     {
@@ -895,7 +900,13 @@ unsafe fn embed_bitcode(
         );
         llvm::LLVMSetInitializer(llglobal, llconst);
 
-        let section = if is_apple { c"__LLVM,__bitcode" } else { c".llvmbc" };
+        let section = if is_apple {
+            c"__LLVM,__bitcode"
+        } else if is_aix {
+            c".ipa"
+        } else {
+            c".llvmbc"
+        };
         llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
         llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
         llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
@@ -907,7 +918,13 @@ unsafe fn embed_bitcode(
             c"rustc.embedded.cmdline".as_ptr().cast(),
         );
         llvm::LLVMSetInitializer(llglobal, llconst);
-        let section = if is_apple { c"__LLVM,__cmdline" } else { c".llvmcmd" };
+        let section = if is_apple {
+            c"__LLVM,__cmdline"
+        } else if is_aix {
+            c".info"
+        } else {
+            c".llvmcmd"
+        };
         llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
         llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
     } else {
diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs
index b198e35e0c1..1b1e9138871 100644
--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs
+++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs
@@ -20,7 +20,7 @@ use rustc_metadata::EncodedMetadata;
 use rustc_session::cstore::MetadataLoader;
 use rustc_session::Session;
 use rustc_target::abi::Endian;
-use rustc_target::spec::{RelocModel, Target};
+use rustc_target::spec::{ef_avr_arch, RelocModel, Target};
 
 /// The default metadata loader. This is used by cg_llvm and cg_clif.
 ///
@@ -287,6 +287,11 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
             // Source: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_e_flags_identifies_abi_type_and_version
             elf::EF_LARCH_OBJABI_V1 | elf::EF_LARCH_ABI_DOUBLE_FLOAT
         }
+        Architecture::Avr => {
+            // Resolve the ISA revision and set
+            // the appropriate EF_AVR_ARCH flag.
+            ef_avr_arch(&sess.target.options.cpu)
+        }
         _ => 0,
     };
     // adapted from LLVM's `MCELFObjectTargetWriter::getOSABI`
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
index cf6d9eda321..6921a0bb283 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
@@ -2,7 +2,7 @@ use crate::callee::{self, DeferredCallResolution};
 use crate::errors::CtorIsPrivate;
 use crate::method::{self, MethodCallee, SelfSource};
 use crate::rvalue_scopes;
-use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy, RawTy};
+use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, RawTy};
 use rustc_data_structures::captures::Captures;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed, MultiSpan, StashKey};
@@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         format!("{:p}", self)
     }
 
-    pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> {
+    pub fn local_ty(&self, span: Span, nid: hir::HirId) -> Ty<'tcx> {
         self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| {
             span_bug!(span, "no type for local variable {}", self.tcx.hir().node_to_string(nid))
         })
@@ -1152,7 +1152,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         );
 
         if let Res::Local(hid) = res {
-            let ty = self.local_ty(span, hid).decl_ty;
+            let ty = self.local_ty(span, hid);
             let ty = self.normalize(span, ty);
             self.write_ty(hir_id, ty);
             return (ty, res);
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 3c67280e0d4..dacd5559c71 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -6,8 +6,7 @@ use crate::method::MethodCallee;
 use crate::TupleArgumentsFlag::*;
 use crate::{errors, Expectation::*};
 use crate::{
-    struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy, Needs, RawTy,
-    TupleArgumentsFlag,
+    struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, Needs, RawTy, TupleArgumentsFlag,
 };
 use rustc_ast as ast;
 use rustc_data_structures::fx::FxIndexSet;
@@ -1423,7 +1422,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         // See #44848.
         let ref_bindings = pat.contains_explicit_ref_binding();
 
-        let local_ty = self.local_ty(init.span, hir_id).revealed_ty;
+        let local_ty = self.local_ty(init.span, hir_id);
         if let Some(m) = ref_bindings {
             // Somewhat subtle: if we have a `ref` binding in the pattern,
             // we want to avoid introducing coercions for the RHS. This is
@@ -1453,7 +1452,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
     pub(in super::super) fn check_decl(&self, decl: Declaration<'tcx>) {
         // Determine and write the type which we'll check the pattern against.
-        let decl_ty = self.local_ty(decl.span, decl.hir_id).decl_ty;
+        let decl_ty = self.local_ty(decl.span, decl.hir_id);
         self.write_ty(decl.hir_id, decl_ty);
 
         // Type check the initializer.
@@ -1799,9 +1798,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             let err = self.tcx.ty_error(guar);
             self.write_ty(hir_id, err);
             self.write_ty(pat.hir_id, err);
-            let local_ty = LocalTy { decl_ty: err, revealed_ty: err };
-            self.locals.borrow_mut().insert(hir_id, local_ty);
-            self.locals.borrow_mut().insert(pat.hir_id, local_ty);
+            self.locals.borrow_mut().insert(hir_id, err);
+            self.locals.borrow_mut().insert(pat.hir_id, err);
         }
     }
 
diff --git a/compiler/rustc_hir_typeck/src/gather_locals.rs b/compiler/rustc_hir_typeck/src/gather_locals.rs
index d9b9b34ba58..4f45a24b216 100644
--- a/compiler/rustc_hir_typeck/src/gather_locals.rs
+++ b/compiler/rustc_hir_typeck/src/gather_locals.rs
@@ -1,4 +1,4 @@
-use crate::{FnCtxt, LocalTy};
+use crate::FnCtxt;
 use rustc_hir as hir;
 use rustc_hir::intravisit::{self, Visitor};
 use rustc_hir::PatKind;
@@ -48,7 +48,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
         Self { fcx, outermost_fn_param_pat: None }
     }
 
-    fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
+    fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
         match ty_opt {
             None => {
                 // Infer the variable's type.
@@ -56,23 +56,20 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
                     kind: TypeVariableOriginKind::TypeInference,
                     span,
                 });
-                self.fcx
-                    .locals
-                    .borrow_mut()
-                    .insert(nid, LocalTy { decl_ty: var_ty, revealed_ty: var_ty });
+                self.fcx.locals.borrow_mut().insert(nid, var_ty);
                 var_ty
             }
             Some(typ) => {
                 // Take type that the user specified.
                 self.fcx.locals.borrow_mut().insert(nid, typ);
-                typ.revealed_ty
+                typ
             }
         }
     }
 
-    /// Allocates a [LocalTy] for a declaration, which may have a type annotation. If it does have
-    /// a type annotation, then the LocalTy stored will be the resolved type. This may be found
-    /// again during type checking by querying [FnCtxt::local_ty] for the same hir_id.
+    /// Allocates a type for a declaration, which may have a type annotation. If it does have
+    /// a type annotation, then the [`Ty`] stored will be the resolved type. This may be found
+    /// again during type checking by querying [`FnCtxt::local_ty`] for the same hir_id.
     fn declare(&mut self, decl: Declaration<'tcx>) {
         let local_ty = match decl.ty {
             Some(ref ty) => {
@@ -87,7 +84,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
                     .user_provided_types_mut()
                     .insert(ty.hir_id, c_ty);
 
-                Some(LocalTy { decl_ty: o_ty.normalized, revealed_ty: o_ty.normalized })
+                Some(o_ty.normalized)
             }
             None => None,
         };
@@ -96,7 +93,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
         debug!(
             "local variable {:?} is assigned type {}",
             decl.pat,
-            self.fcx.ty_to_string(self.fcx.locals.borrow().get(&decl.hir_id).unwrap().decl_ty)
+            self.fcx.ty_to_string(*self.fcx.locals.borrow().get(&decl.hir_id).unwrap())
         );
     }
 }
@@ -151,7 +148,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
             debug!(
                 "pattern binding {} is assigned to {} with type {:?}",
                 ident,
-                self.fcx.ty_to_string(self.fcx.locals.borrow().get(&p.hir_id).unwrap().decl_ty),
+                self.fcx.ty_to_string(*self.fcx.locals.borrow().get(&p.hir_id).unwrap()),
                 var_ty
             );
         }
diff --git a/compiler/rustc_hir_typeck/src/inherited.rs b/compiler/rustc_hir_typeck/src/inherited.rs
index c193d761804..05e5db9f0f3 100644
--- a/compiler/rustc_hir_typeck/src/inherited.rs
+++ b/compiler/rustc_hir_typeck/src/inherited.rs
@@ -30,7 +30,7 @@ pub struct Inherited<'tcx> {
 
     pub(super) typeck_results: RefCell<ty::TypeckResults<'tcx>>,
 
-    pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
+    pub(super) locals: RefCell<HirIdMap<Ty<'tcx>>>,
 
     pub(super) fulfillment_cx: RefCell<Box<dyn TraitEngine<'tcx>>>,
 
diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs
index 7a897778ff7..6f7288ed7e5 100644
--- a/compiler/rustc_hir_typeck/src/lib.rs
+++ b/compiler/rustc_hir_typeck/src/lib.rs
@@ -89,13 +89,6 @@ macro_rules! type_error_struct {
     })
 }
 
-/// The type of a local binding, including the revealed type for anon types.
-#[derive(Copy, Clone, Debug)]
-pub struct LocalTy<'tcx> {
-    decl_ty: Ty<'tcx>,
-    revealed_ty: Ty<'tcx>,
-}
-
 /// If this `DefId` is a "primary tables entry", returns
 /// `Some((body_id, body_ty, fn_sig))`. Otherwise, returns `None`.
 ///
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index 5af955d3134..9c989d3b4b2 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -594,7 +594,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         debug!("check_pat_ident: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
 
-        let local_ty = self.local_ty(pat.span, pat.hir_id).decl_ty;
+        let local_ty = self.local_ty(pat.span, pat.hir_id);
         let eq_ty = match bm {
             ty::BindByReference(mutbl) => {
                 // If the binding is like `ref x | ref mut x`,
@@ -635,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         ty: Ty<'tcx>,
         ti: TopInfo<'tcx>,
     ) {
-        let var_ty = self.local_ty(span, var_id).decl_ty;
+        let var_ty = self.local_ty(span, var_id);
         if let Some(mut err) = self.demand_eqtype_pat_diag(span, var_ty, ty, ti) {
             let hir = self.tcx.hir();
             let var_ty = self.resolve_vars_with_obligations(var_ty);
diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs
index 29abe921bbd..0cf3a4e877a 100644
--- a/compiler/rustc_hir_typeck/src/writeback.rs
+++ b/compiler/rustc_hir_typeck/src/writeback.rs
@@ -348,7 +348,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
 
     fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
         intravisit::walk_local(self, l);
-        let var_ty = self.fcx.local_ty(l.span, l.hir_id).decl_ty;
+        let var_ty = self.fcx.local_ty(l.span, l.hir_id);
         let var_ty = self.resolve(var_ty, &l.span);
         self.write_ty_to_typeck_results(l.hir_id, var_ty);
     }
diff --git a/compiler/rustc_target/Cargo.toml b/compiler/rustc_target/Cargo.toml
index dff22fad4ec..a71e2e8cc57 100644
--- a/compiler/rustc_target/Cargo.toml
+++ b/compiler/rustc_target/Cargo.toml
@@ -14,3 +14,8 @@ rustc_feature = { path = "../rustc_feature" }
 rustc_macros = { path = "../rustc_macros" }
 rustc_serialize = { path = "../rustc_serialize" }
 rustc_span = { path = "../rustc_span" }
+
+[dependencies.object]
+version = "0.31.1"
+default-features = false
+features = ["elf"]
diff --git a/compiler/rustc_target/src/spec/avr_gnu_base.rs b/compiler/rustc_target/src/spec/avr_gnu_base.rs
index 9c3406b5313..fbec44b716a 100644
--- a/compiler/rustc_target/src/spec/avr_gnu_base.rs
+++ b/compiler/rustc_target/src/spec/avr_gnu_base.rs
@@ -1,4 +1,5 @@
 use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};
+use object::elf;
 
 /// A base target for AVR devices using the GNU toolchain.
 ///
@@ -29,3 +30,339 @@ pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
         },
     }
 }
+
+/// Resolve the value of the EF_AVR_ARCH field for AVR ELF files, given the
+/// name of the target CPU / MCU.
+///
+/// In ELF files using the AVR architecture, the lower 7 bits of the e_flags
+/// field is a code that identifies the "ISA revision" of the object code.
+///
+/// This flag is generally set by AVR compilers in their output ELF files,
+/// and linkers like avr-ld check this flag in all of their input files to
+/// make sure they are compiled with the same ISA revision.
+pub fn ef_avr_arch(target_cpu: &str) -> u32 {
+    // Adapted from llvm-project/llvm/lib/target/AVR/AVRDevices.td
+    match target_cpu {
+        // Generic MCUs
+        "avr1" => elf::EF_AVR_ARCH_AVR1,
+        "avr2" => elf::EF_AVR_ARCH_AVR2,
+        "avr25" => elf::EF_AVR_ARCH_AVR25,
+        "avr3" => elf::EF_AVR_ARCH_AVR3,
+        "avr31" => elf::EF_AVR_ARCH_AVR31,
+        "avr35" => elf::EF_AVR_ARCH_AVR35,
+        "avr4" => elf::EF_AVR_ARCH_AVR4,
+        "avr5" => elf::EF_AVR_ARCH_AVR5,
+        "avr51" => elf::EF_AVR_ARCH_AVR51,
+        "avr6" => elf::EF_AVR_ARCH_AVR6,
+        "avrxmega1" => elf::EF_AVR_ARCH_XMEGA1,
+        "avrxmega2" => elf::EF_AVR_ARCH_XMEGA2,
+        "avrxmega3" => elf::EF_AVR_ARCH_XMEGA3,
+        "avrxmega4" => elf::EF_AVR_ARCH_XMEGA4,
+        "avrxmega5" => elf::EF_AVR_ARCH_XMEGA5,
+        "avrxmega6" => elf::EF_AVR_ARCH_XMEGA6,
+        "avrxmega7" => elf::EF_AVR_ARCH_XMEGA7,
+        "avrtiny" => elf::EF_AVR_ARCH_AVRTINY,
+
+        // Specific MCUs
+        "at90s1200" => elf::EF_AVR_ARCH_AVR1,
+        "attiny11" => elf::EF_AVR_ARCH_AVR1,
+        "attiny12" => elf::EF_AVR_ARCH_AVR1,
+        "attiny15" => elf::EF_AVR_ARCH_AVR1,
+        "attiny28" => elf::EF_AVR_ARCH_AVR1,
+        "at90s2313" => elf::EF_AVR_ARCH_AVR2,
+        "at90s2323" => elf::EF_AVR_ARCH_AVR2,
+        "at90s2333" => elf::EF_AVR_ARCH_AVR2,
+        "at90s2343" => elf::EF_AVR_ARCH_AVR2,
+        "attiny22" => elf::EF_AVR_ARCH_AVR2,
+        "attiny26" => elf::EF_AVR_ARCH_AVR2,
+        "at86rf401" => elf::EF_AVR_ARCH_AVR25,
+        "at90s4414" => elf::EF_AVR_ARCH_AVR2,
+        "at90s4433" => elf::EF_AVR_ARCH_AVR2,
+        "at90s4434" => elf::EF_AVR_ARCH_AVR2,
+        "at90s8515" => elf::EF_AVR_ARCH_AVR2,
+        "at90c8534" => elf::EF_AVR_ARCH_AVR2,
+        "at90s8535" => elf::EF_AVR_ARCH_AVR2,
+        "ata5272" => elf::EF_AVR_ARCH_AVR25,
+        "ata6616c" => elf::EF_AVR_ARCH_AVR25,
+        "attiny13" => elf::EF_AVR_ARCH_AVR25,
+        "attiny13a" => elf::EF_AVR_ARCH_AVR25,
+        "attiny2313" => elf::EF_AVR_ARCH_AVR25,
+        "attiny2313a" => elf::EF_AVR_ARCH_AVR25,
+        "attiny24" => elf::EF_AVR_ARCH_AVR25,
+        "attiny24a" => elf::EF_AVR_ARCH_AVR25,
+        "attiny4313" => elf::EF_AVR_ARCH_AVR25,
+        "attiny44" => elf::EF_AVR_ARCH_AVR25,
+        "attiny44a" => elf::EF_AVR_ARCH_AVR25,
+        "attiny84" => elf::EF_AVR_ARCH_AVR25,
+        "attiny84a" => elf::EF_AVR_ARCH_AVR25,
+        "attiny25" => elf::EF_AVR_ARCH_AVR25,
+        "attiny45" => elf::EF_AVR_ARCH_AVR25,
+        "attiny85" => elf::EF_AVR_ARCH_AVR25,
+        "attiny261" => elf::EF_AVR_ARCH_AVR25,
+        "attiny261a" => elf::EF_AVR_ARCH_AVR25,
+        "attiny441" => elf::EF_AVR_ARCH_AVR25,
+        "attiny461" => elf::EF_AVR_ARCH_AVR25,
+        "attiny461a" => elf::EF_AVR_ARCH_AVR25,
+        "attiny841" => elf::EF_AVR_ARCH_AVR25,
+        "attiny861" => elf::EF_AVR_ARCH_AVR25,
+        "attiny861a" => elf::EF_AVR_ARCH_AVR25,
+        "attiny87" => elf::EF_AVR_ARCH_AVR25,
+        "attiny43u" => elf::EF_AVR_ARCH_AVR25,
+        "attiny48" => elf::EF_AVR_ARCH_AVR25,
+        "attiny88" => elf::EF_AVR_ARCH_AVR25,
+        "attiny828" => elf::EF_AVR_ARCH_AVR25,
+        "at43usb355" => elf::EF_AVR_ARCH_AVR3,
+        "at76c711" => elf::EF_AVR_ARCH_AVR3,
+        "atmega103" => elf::EF_AVR_ARCH_AVR31,
+        "at43usb320" => elf::EF_AVR_ARCH_AVR31,
+        "attiny167" => elf::EF_AVR_ARCH_AVR35,
+        "at90usb82" => elf::EF_AVR_ARCH_AVR35,
+        "at90usb162" => elf::EF_AVR_ARCH_AVR35,
+        "ata5505" => elf::EF_AVR_ARCH_AVR35,
+        "ata6617c" => elf::EF_AVR_ARCH_AVR35,
+        "ata664251" => elf::EF_AVR_ARCH_AVR35,
+        "atmega8u2" => elf::EF_AVR_ARCH_AVR35,
+        "atmega16u2" => elf::EF_AVR_ARCH_AVR35,
+        "atmega32u2" => elf::EF_AVR_ARCH_AVR35,
+        "attiny1634" => elf::EF_AVR_ARCH_AVR35,
+        "atmega8" => elf::EF_AVR_ARCH_AVR4,
+        "ata6289" => elf::EF_AVR_ARCH_AVR4,
+        "atmega8a" => elf::EF_AVR_ARCH_AVR4,
+        "ata6285" => elf::EF_AVR_ARCH_AVR4,
+        "ata6286" => elf::EF_AVR_ARCH_AVR4,
+        "ata6612c" => elf::EF_AVR_ARCH_AVR4,
+        "atmega48" => elf::EF_AVR_ARCH_AVR4,
+        "atmega48a" => elf::EF_AVR_ARCH_AVR4,
+        "atmega48pa" => elf::EF_AVR_ARCH_AVR4,
+        "atmega48pb" => elf::EF_AVR_ARCH_AVR4,
+        "atmega48p" => elf::EF_AVR_ARCH_AVR4,
+        "atmega88" => elf::EF_AVR_ARCH_AVR4,
+        "atmega88a" => elf::EF_AVR_ARCH_AVR4,
+        "atmega88p" => elf::EF_AVR_ARCH_AVR4,
+        "atmega88pa" => elf::EF_AVR_ARCH_AVR4,
+        "atmega88pb" => elf::EF_AVR_ARCH_AVR4,
+        "atmega8515" => elf::EF_AVR_ARCH_AVR4,
+        "atmega8535" => elf::EF_AVR_ARCH_AVR4,
+        "atmega8hva" => elf::EF_AVR_ARCH_AVR4,
+        "at90pwm1" => elf::EF_AVR_ARCH_AVR4,
+        "at90pwm2" => elf::EF_AVR_ARCH_AVR4,
+        "at90pwm2b" => elf::EF_AVR_ARCH_AVR4,
+        "at90pwm3" => elf::EF_AVR_ARCH_AVR4,
+        "at90pwm3b" => elf::EF_AVR_ARCH_AVR4,
+        "at90pwm81" => elf::EF_AVR_ARCH_AVR4,
+        "ata5702m322" => elf::EF_AVR_ARCH_AVR5,
+        "ata5782" => elf::EF_AVR_ARCH_AVR5,
+        "ata5790" => elf::EF_AVR_ARCH_AVR5,
+        "ata5790n" => elf::EF_AVR_ARCH_AVR5,
+        "ata5791" => elf::EF_AVR_ARCH_AVR5,
+        "ata5795" => elf::EF_AVR_ARCH_AVR5,
+        "ata5831" => elf::EF_AVR_ARCH_AVR5,
+        "ata6613c" => elf::EF_AVR_ARCH_AVR5,
+        "ata6614q" => elf::EF_AVR_ARCH_AVR5,
+        "ata8210" => elf::EF_AVR_ARCH_AVR5,
+        "ata8510" => elf::EF_AVR_ARCH_AVR5,
+        "atmega16" => elf::EF_AVR_ARCH_AVR5,
+        "atmega16a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega161" => elf::EF_AVR_ARCH_AVR5,
+        "atmega162" => elf::EF_AVR_ARCH_AVR5,
+        "atmega163" => elf::EF_AVR_ARCH_AVR5,
+        "atmega164a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega164p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega164pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega165" => elf::EF_AVR_ARCH_AVR5,
+        "atmega165a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega165p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega165pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega168" => elf::EF_AVR_ARCH_AVR5,
+        "atmega168a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega168p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega168pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega168pb" => elf::EF_AVR_ARCH_AVR5,
+        "atmega169" => elf::EF_AVR_ARCH_AVR5,
+        "atmega169a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega169p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega169pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega32" => elf::EF_AVR_ARCH_AVR5,
+        "atmega32a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega323" => elf::EF_AVR_ARCH_AVR5,
+        "atmega324a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega324p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega324pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega324pb" => elf::EF_AVR_ARCH_AVR5,
+        "atmega325" => elf::EF_AVR_ARCH_AVR5,
+        "atmega325a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega325p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega325pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega3250" => elf::EF_AVR_ARCH_AVR5,
+        "atmega3250a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega3250p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega3250pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega328" => elf::EF_AVR_ARCH_AVR5,
+        "atmega328p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega328pb" => elf::EF_AVR_ARCH_AVR5,
+        "atmega329" => elf::EF_AVR_ARCH_AVR5,
+        "atmega329a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega329p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega329pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega3290" => elf::EF_AVR_ARCH_AVR5,
+        "atmega3290a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega3290p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega3290pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega406" => elf::EF_AVR_ARCH_AVR5,
+        "atmega64" => elf::EF_AVR_ARCH_AVR5,
+        "atmega64a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega640" => elf::EF_AVR_ARCH_AVR5,
+        "atmega644" => elf::EF_AVR_ARCH_AVR5,
+        "atmega644a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega644p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega644pa" => elf::EF_AVR_ARCH_AVR5,
+        "atmega645" => elf::EF_AVR_ARCH_AVR5,
+        "atmega645a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega645p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega649" => elf::EF_AVR_ARCH_AVR5,
+        "atmega649a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega649p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega6450" => elf::EF_AVR_ARCH_AVR5,
+        "atmega6450a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega6450p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega6490" => elf::EF_AVR_ARCH_AVR5,
+        "atmega6490a" => elf::EF_AVR_ARCH_AVR5,
+        "atmega6490p" => elf::EF_AVR_ARCH_AVR5,
+        "atmega64rfr2" => elf::EF_AVR_ARCH_AVR5,
+        "atmega644rfr2" => elf::EF_AVR_ARCH_AVR5,
+        "atmega16hva" => elf::EF_AVR_ARCH_AVR5,
+        "atmega16hva2" => elf::EF_AVR_ARCH_AVR5,
+        "atmega16hvb" => elf::EF_AVR_ARCH_AVR5,
+        "atmega16hvbrevb" => elf::EF_AVR_ARCH_AVR5,
+        "atmega32hvb" => elf::EF_AVR_ARCH_AVR5,
+        "atmega32hvbrevb" => elf::EF_AVR_ARCH_AVR5,
+        "atmega64hve" => elf::EF_AVR_ARCH_AVR5,
+        "atmega64hve2" => elf::EF_AVR_ARCH_AVR5,
+        "at90can32" => elf::EF_AVR_ARCH_AVR5,
+        "at90can64" => elf::EF_AVR_ARCH_AVR5,
+        "at90pwm161" => elf::EF_AVR_ARCH_AVR5,
+        "at90pwm216" => elf::EF_AVR_ARCH_AVR5,
+        "at90pwm316" => elf::EF_AVR_ARCH_AVR5,
+        "atmega32c1" => elf::EF_AVR_ARCH_AVR5,
+        "atmega64c1" => elf::EF_AVR_ARCH_AVR5,
+        "atmega16m1" => elf::EF_AVR_ARCH_AVR5,
+        "atmega32m1" => elf::EF_AVR_ARCH_AVR5,
+        "atmega64m1" => elf::EF_AVR_ARCH_AVR5,
+        "atmega16u4" => elf::EF_AVR_ARCH_AVR5,
+        "atmega32u4" => elf::EF_AVR_ARCH_AVR5,
+        "atmega32u6" => elf::EF_AVR_ARCH_AVR5,
+        "at90usb646" => elf::EF_AVR_ARCH_AVR5,
+        "at90usb647" => elf::EF_AVR_ARCH_AVR5,
+        "at90scr100" => elf::EF_AVR_ARCH_AVR5,
+        "at94k" => elf::EF_AVR_ARCH_AVR5,
+        "m3000" => elf::EF_AVR_ARCH_AVR5,
+        "atmega128" => elf::EF_AVR_ARCH_AVR51,
+        "atmega128a" => elf::EF_AVR_ARCH_AVR51,
+        "atmega1280" => elf::EF_AVR_ARCH_AVR51,
+        "atmega1281" => elf::EF_AVR_ARCH_AVR51,
+        "atmega1284" => elf::EF_AVR_ARCH_AVR51,
+        "atmega1284p" => elf::EF_AVR_ARCH_AVR51,
+        "atmega128rfa1" => elf::EF_AVR_ARCH_AVR51,
+        "atmega128rfr2" => elf::EF_AVR_ARCH_AVR51,
+        "atmega1284rfr2" => elf::EF_AVR_ARCH_AVR51,
+        "at90can128" => elf::EF_AVR_ARCH_AVR51,
+        "at90usb1286" => elf::EF_AVR_ARCH_AVR51,
+        "at90usb1287" => elf::EF_AVR_ARCH_AVR51,
+        "atmega2560" => elf::EF_AVR_ARCH_AVR6,
+        "atmega2561" => elf::EF_AVR_ARCH_AVR6,
+        "atmega256rfr2" => elf::EF_AVR_ARCH_AVR6,
+        "atmega2564rfr2" => elf::EF_AVR_ARCH_AVR6,
+        "atxmega16a4" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega16a4u" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega16c4" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega16d4" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega32a4" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega32a4u" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega32c3" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega32c4" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega32d3" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega32d4" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega32e5" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega16e5" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega8e5" => elf::EF_AVR_ARCH_XMEGA2,
+        "atxmega64a3" => elf::EF_AVR_ARCH_XMEGA4,
+        "atxmega64a3u" => elf::EF_AVR_ARCH_XMEGA4,
+        "atxmega64a4u" => elf::EF_AVR_ARCH_XMEGA4,
+        "atxmega64b1" => elf::EF_AVR_ARCH_XMEGA4,
+        "atxmega64b3" => elf::EF_AVR_ARCH_XMEGA4,
+        "atxmega64c3" => elf::EF_AVR_ARCH_XMEGA4,
+        "atxmega64d3" => elf::EF_AVR_ARCH_XMEGA4,
+        "atxmega64d4" => elf::EF_AVR_ARCH_XMEGA4,
+        "atxmega64a1" => elf::EF_AVR_ARCH_XMEGA5,
+        "atxmega64a1u" => elf::EF_AVR_ARCH_XMEGA5,
+        "atxmega128a3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega128a3u" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega128b1" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega128b3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega128c3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega128d3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega128d4" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega192a3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega192a3u" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega192c3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega192d3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega256a3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega256a3u" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega256a3b" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega256a3bu" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega256c3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega256d3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega384c3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega384d3" => elf::EF_AVR_ARCH_XMEGA6,
+        "atxmega128a1" => elf::EF_AVR_ARCH_XMEGA7,
+        "atxmega128a1u" => elf::EF_AVR_ARCH_XMEGA7,
+        "atxmega128a4u" => elf::EF_AVR_ARCH_XMEGA7,
+        "attiny4" => elf::EF_AVR_ARCH_AVRTINY,
+        "attiny5" => elf::EF_AVR_ARCH_AVRTINY,
+        "attiny9" => elf::EF_AVR_ARCH_AVRTINY,
+        "attiny10" => elf::EF_AVR_ARCH_AVRTINY,
+        "attiny20" => elf::EF_AVR_ARCH_AVRTINY,
+        "attiny40" => elf::EF_AVR_ARCH_AVRTINY,
+        "attiny102" => elf::EF_AVR_ARCH_AVRTINY,
+        "attiny104" => elf::EF_AVR_ARCH_AVRTINY,
+        "attiny202" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny402" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny204" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny404" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny804" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1604" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny406" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny806" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1606" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny807" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1607" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny212" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny412" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny214" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny414" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny814" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1614" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny416" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny816" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1616" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny3216" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny417" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny817" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1617" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny3217" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1624" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1626" => elf::EF_AVR_ARCH_XMEGA3,
+        "attiny1627" => elf::EF_AVR_ARCH_XMEGA3,
+        "atmega808" => elf::EF_AVR_ARCH_XMEGA3,
+        "atmega809" => elf::EF_AVR_ARCH_XMEGA3,
+        "atmega1608" => elf::EF_AVR_ARCH_XMEGA3,
+        "atmega1609" => elf::EF_AVR_ARCH_XMEGA3,
+        "atmega3208" => elf::EF_AVR_ARCH_XMEGA3,
+        "atmega3209" => elf::EF_AVR_ARCH_XMEGA3,
+        "atmega4808" => elf::EF_AVR_ARCH_XMEGA3,
+        "atmega4809" => elf::EF_AVR_ARCH_XMEGA3,
+
+        // Unknown target CPU => Unspecified/generic code
+        _ => 0,
+    }
+}
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index 88fbe2a8be1..0a42c4c2544 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -62,6 +62,7 @@ mod android_base;
 mod apple_base;
 pub use apple_base::deployment_target as current_apple_deployment_target;
 mod avr_gnu_base;
+pub use avr_gnu_base::ef_avr_arch;
 mod bpf_base;
 mod dragonfly_base;
 mod freebsd_base;
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index ef05b25fdd0..9a93bb72903 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -144,8 +144,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let len = "foo".len();
     /// assert_eq!(3, len);
@@ -165,8 +163,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let s = "";
     /// assert!(s.is_empty());
@@ -311,8 +307,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let bytes = "bors".as_bytes();
     /// assert_eq!(b"bors", bytes);
@@ -387,8 +381,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let s = "Hello";
     /// let ptr = s.as_ptr();
@@ -570,8 +562,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let s = "Löwe 老虎 Léopard";
     ///
@@ -649,8 +639,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let s = "Per Martin-Löf";
     ///
@@ -691,8 +679,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let mut s = "Per Martin-Löf".to_string();
     /// {
@@ -840,8 +826,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let mut bytes = "bors".bytes();
     ///
@@ -1020,8 +1004,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let text = "Zażółć gęślą jaźń";
     ///
@@ -1050,8 +1032,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let bananas = "bananas";
     ///
@@ -1077,8 +1057,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let bananas = "bananas";
     ///
@@ -1103,8 +1081,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let bananas = "bananas";
     ///
@@ -1463,8 +1439,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let v: Vec<&str> = "A.B.".split_terminator('.').collect();
     /// assert_eq!(v, ["A", "B"]);
@@ -1696,8 +1670,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let v: Vec<&str> = "abcXXXabcYYYabc".matches("abc").collect();
     /// assert_eq!(v, ["abc", "abc", "abc"]);
@@ -1732,8 +1704,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let v: Vec<&str> = "abcXXXabcYYYabc".rmatches("abc").collect();
     /// assert_eq!(v, ["abc", "abc", "abc"]);
@@ -1775,8 +1745,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let v: Vec<_> = "abcXXXabcYYYabc".match_indices("abc").collect();
     /// assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]);
@@ -1817,8 +1785,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let v: Vec<_> = "abcXXXabcYYYabc".rmatch_indices("abc").collect();
     /// assert_eq!(v, [(12, "abc"), (6, "abc"), (0, "abc")]);
@@ -1845,8 +1811,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// let s = "\n Hello\tworld\t\n";
     ///
@@ -2085,8 +2049,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// assert_eq!("11foo1bar11".trim_start_matches('1'), "foo1bar11");
     /// assert_eq!("123foo1bar123".trim_start_matches(char::is_numeric), "foo1bar123");
@@ -2232,8 +2194,6 @@ impl str {
     ///
     /// # Examples
     ///
-    /// Basic usage:
-    ///
     /// ```
     /// assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
     /// assert_eq!("123foo1bar123".trim_left_matches(char::is_numeric), "foo1bar123");
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index f3316d97c5f..a083b65604d 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -2543,12 +2543,12 @@ impl<'a, K, V> Entry<'a, K, V> {
     /// ```
     /// use std::collections::HashMap;
     ///
-    /// let mut map: HashMap<&str, String> = HashMap::new();
-    /// let s = "hoho".to_string();
+    /// let mut map = HashMap::new();
+    /// let value = "hoho";
     ///
-    /// map.entry("poneyland").or_insert_with(|| s);
+    /// map.entry("poneyland").or_insert_with(|| value);
     ///
-    /// assert_eq!(map["poneyland"], "hoho".to_string());
+    /// assert_eq!(map["poneyland"], "hoho");
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/bootstrap/defaults/config.dist.toml b/src/bootstrap/defaults/config.dist.toml
index 25d9e649f23..44efdf50b96 100644
--- a/src/bootstrap/defaults/config.dist.toml
+++ b/src/bootstrap/defaults/config.dist.toml
@@ -12,6 +12,9 @@ extended = true
 [llvm]
 download-ci-llvm = false
 [rust]
+# We have several defaults in bootstrap that depend on whether the channel is `dev` (e.g. `omit-git-hash` and `download-ci-llvm`).
+# Make sure they don't get set when installing from source.
+channel = "nightly"
 download-rustc = false
 
 [dist]
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index c31ba3304b0..0dd9e590b9b 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -398,6 +398,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
             .doc_link_resolutions(module_id)
             .get(&(Symbol::intern(path_str), ns))
             .copied()
+            // NOTE: do not remove this panic! Missing links should be recorded as `Res::Err`; if
+            // `doc_link_resolutions` is missing a `path_str`, that means that there are valid links
+            // that are being missed. To fix the ICE, change
+            // `rustc_resolve::rustdoc::attrs_to_preprocessed_links` to cache the link.
             .unwrap_or_else(|| panic!("no resolution for {:?} {:?} {:?}", path_str, ns, module_id))
             .and_then(|res| res.try_into().ok())
             .or_else(|| resolve_primitive(path_str, ns));
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs
index 81684c6f9f9..c95a125c737 100644
--- a/src/tools/compiletest/src/common.rs
+++ b/src/tools/compiletest/src/common.rs
@@ -439,7 +439,7 @@ pub struct TargetCfgs {
 
 impl TargetCfgs {
     fn new(config: &Config) -> TargetCfgs {
-        let targets: HashMap<String, TargetCfg> = serde_json::from_str(&rustc_output(
+        let mut targets: HashMap<String, TargetCfg> = serde_json::from_str(&rustc_output(
             config,
             &["--print=all-target-specs-json", "-Zunstable-options"],
         ))
@@ -454,6 +454,18 @@ impl TargetCfgs {
         let mut all_families = HashSet::new();
         let mut all_pointer_widths = HashSet::new();
 
+        // Handle custom target specs, which are not included in `--print=all-target-specs-json`.
+        if config.target.ends_with(".json") {
+            targets.insert(
+                config.target.clone(),
+                serde_json::from_str(&rustc_output(
+                    config,
+                    &["--print=target-spec-json", "-Zunstable-options", "--target", &config.target],
+                ))
+                .unwrap(),
+            );
+        }
+
         for (target, cfg) in targets.iter() {
             all_archs.insert(cfg.arch.clone());
             all_oses.insert(cfg.os.clone());
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 8bdc2d65d27..fddfbac78d5 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -4374,7 +4374,7 @@ impl ProcRes {
     pub fn print_info(&self) {
         fn render(name: &str, contents: &str) -> String {
             let contents = json::extract_rendered(contents);
-            let contents = contents.trim();
+            let contents = contents.trim_end();
             if contents.is_empty() {
                 format!("{name}: none")
             } else {