Skip to content

Rollup of 5 pull requests #99278

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

Merged
merged 26 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1599c5a
remove a string matching about methods
TaKO8Ki Jul 10, 2022
e24d13d
Update RLS
Xanewok Jul 14, 2022
b98fb49
Correctly handle crate level page on docs.rs as well
GuillaumeGomez Jul 13, 2022
e6aedf6
Add Nintendo Switch tier 3 target
jam1garner Sep 15, 2021
60beb1a
Don't use host linker for switch
leo60228 Sep 15, 2021
f688a56
Remove unnecessary linker args
leo60228 Sep 15, 2021
4bc8549
Add linker script for switch
leo60228 Sep 15, 2021
bee373c
Don't build std for switch
leo60228 Sep 15, 2021
7f88049
Remove unneeded options from Nintendo Switch target
jam1garner Sep 15, 2021
c690db4
Remove obsolete crt0 references in linker script
leo60228 Sep 15, 2021
fd81b99
Add docs for Switch target
leo60228 Sep 17, 2021
d04753e
Add aarch64-nintendo-switch.md to SUMMARY.md
leo60228 Sep 17, 2021
62aafb0
Rename aarch64-nintendo-switch to aarch64-nintendo-switch-freestanding
leo60228 Sep 17, 2021
aad2334
Make item spans more consistent
compiler-errors Jul 8, 2022
57f7618
Remove some usages of guess_head_span from typeck
compiler-errors Jul 7, 2022
27b6ab9
Remove some more usages of guess_head_span
compiler-errors Jul 8, 2022
78efaf4
remove tcx from ObligationCauseCode::span
compiler-errors Jul 8, 2022
03bfbe1
Move item_span from check_item_type into each function
compiler-errors Jul 8, 2022
4b890f3
Remove some span_of_impl+unwrap
compiler-errors Jul 8, 2022
fcfb3e9
Remove some more usages of guess_head_span
compiler-errors Jul 15, 2022
45b88af
simplify `suggest_deref_ref_or_into`
TaKO8Ki Jul 15, 2022
a6d3ee3
Rollup merge of #88991 - libstd-switch:aarch64-nintendo-switch, r=wes…
Dylan-DPC Jul 15, 2022
e0e6f1d
Rollup merge of #98869 - compiler-errors:stop_guessing_head_span, r=c…
Dylan-DPC Jul 15, 2022
24f0e14
Rollup merge of #99119 - TaKO8Ki:remove-string-matching-about-methods…
Dylan-DPC Jul 15, 2022
5c8c4db
Rollup merge of #99209 - GuillaumeGomez:crate-level-sidebar, r=jsha
Dylan-DPC Jul 15, 2022
8e3dd62
Rollup merge of #99246 - Xanewok:update-rls, r=jyn514
Dylan-DPC Jul 15, 2022
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
8 changes: 8 additions & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,14 @@ impl Expr<'_> {
_ => false,
}
}

pub fn method_ident(&self) -> Option<Ident> {
match self.kind {
ExprKind::MethodCall(receiver_method, ..) => Some(receiver_method.ident),
ExprKind::Unary(_, expr) | ExprKind::AddrOf(.., expr) => expr.method_ident(),
_ => None,
}
}
}

/// Checks if the specified expression is a built-in range literal.
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_infer/src/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
}

fn const_equate(&mut self, _a: Const<'tcx>, _b: Const<'tcx>) {
span_bug!(
self.cause.span(self.infcx.tcx),
"generic_const_exprs: unreachable `const_equate`"
);
span_bug!(self.cause.span(), "generic_const_exprs: unreachable `const_equate`");
}

fn normalization() -> NormalizationStrategy {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
swap_secondary_and_primary: bool,
force_label: bool,
) {
let span = cause.span(self.tcx);
let span = cause.span();

// For some types of errors, expected-found does not make
// sense, so just ignore the values we were given.
Expand Down Expand Up @@ -2085,7 +2085,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {

debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);

let span = trace.cause.span(self.tcx);
let span = trace.cause.span();
let failure_code = trace.cause.as_failure_code(terr);
let mut diag = match failure_code {
FailureCode::Error0038(did) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
expected_substs: SubstsRef<'tcx>,
actual_substs: SubstsRef<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let span = cause.span(self.tcx());
let span = cause.span();
let msg = format!(
"implementation of `{}` is not general enough",
self.tcx().def_path_str(trait_def_id),
Expand Down
20 changes: 9 additions & 11 deletions compiler/rustc_infer/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
trait_item_def_id: DefId,
requirement: &dyn fmt::Display,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let msg = "impl has stricter requirements than trait";
let sp = self.tcx.sess.source_map().guess_head_span(error_span);
let mut err = struct_span_err!(
self.tcx.sess,
error_span,
E0276,
"impl has stricter requirements than trait"
);

let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg);

if trait_item_def_id.is_local() {
if let Some(span) = self.tcx.hir().span_if_local(trait_item_def_id) {
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
err.span_label(
self.tcx.def_span(trait_item_def_id),
format!("definition of `{}` from trait", item_name),
);
err.span_label(span, format!("definition of `{}` from trait", item_name));
}

err.span_label(sp, format!("impl has extra requirement {}", requirement));
err.span_label(error_span, format!("impl has extra requirement {}", requirement));

err
}
Expand All @@ -48,7 +47,6 @@ pub fn report_object_safety_error<'tcx>(
hir::Node::Item(item) => Some(item.ident.span),
_ => None,
});
let span = tcx.sess.source_map().guess_head_span(span);
let mut err = struct_span_err!(
tcx.sess,
span,
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,8 @@ pub trait LintContext: Sized {
}

if let Some(span) = in_test_module {
let def_span = self.sess().source_map().guess_head_span(span);
db.span_help(
span.shrink_to_lo().to(def_span),
self.sess().source_map().guess_head_span(span),
"consider adding a `#[cfg(test)]` to the containing module",
);
}
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_middle/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,8 @@ impl<'tcx> ObligationCause<'tcx> {
ObligationCause { span, body_id: hir::CRATE_HIR_ID, code: Default::default() }
}

pub fn span(&self, tcx: TyCtxt<'tcx>) -> Span {
pub fn span(&self) -> Span {
match *self.code() {
ObligationCauseCode::CompareImplMethodObligation { .. }
| ObligationCauseCode::MainFunctionType
| ObligationCauseCode::StartFunctionType => {
tcx.sess.source_map().guess_head_span(self.span)
}
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
arm_span,
..
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1759,8 +1759,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
|| self.tcx.resolutions(()).has_pub_restricted
{
let descr = descr.to_string();
let vis_span =
self.tcx.sess.source_map().guess_head_span(self.tcx.def_span(def_id));
let vis_span = self.tcx.def_span(def_id);
if kind == "trait" {
self.tcx.sess.emit_err(InPublicInterfaceTraits {
span,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,8 @@ symbols! {
thumb2,
thumb_mode: "thumb-mode",
tmm_reg,
to_string,
to_vec,
todo_macro,
tool_attributes,
tool_lints,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelroLevel, Target, TargetOptions};

const LINKER_SCRIPT: &str = include_str!("./aarch64_nintendo_switch_freestanding_linker_script.ld");

/// A base target for Nintendo Switch devices using a pure LLVM toolchain.
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-none".into(),
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
options: TargetOptions {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
link_script: Some(LINKER_SCRIPT.into()),
os: "horizon".into(),
max_atomic_width: Some(128),
panic_strategy: PanicStrategy::Abort,
position_independent_executables: true,
dynamic_linking: true,
executables: true,
relro_level: RelroLevel::Off,
..Default::default()
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
OUTPUT_FORMAT(elf64-littleaarch64)
OUTPUT_ARCH(aarch64)
ENTRY(_start)

PHDRS
{
text PT_LOAD FLAGS(5);
rodata PT_LOAD FLAGS(4);
data PT_LOAD FLAGS(6);
bss PT_LOAD FLAGS(6);
dynamic PT_DYNAMIC;
}

SECTIONS
{
. = 0;

.text : ALIGN(0x1000) {
HIDDEN(__text_start = .);
KEEP(*(.text.jmp))

. = 0x80;

*(.text .text.*)
*(.plt .plt.*)
}

/* Read-only sections */

. = ALIGN(0x1000);

.module_name : { *(.module_name) } :rodata

.rodata : { *(.rodata .rodata.*) } :rodata
.hash : { *(.hash) }
.dynsym : { *(.dynsym .dynsym.*) }
.dynstr : { *(.dynstr .dynstr.*) }
.rela.dyn : { *(.rela.dyn) }

.eh_frame : {
HIDDEN(__eh_frame_start = .);
*(.eh_frame .eh_frame.*)
HIDDEN(__eh_frame_end = .);
}

.eh_frame_hdr : {
HIDDEN(__eh_frame_hdr_start = .);
*(.eh_frame_hdr .eh_frame_hdr.*)
HIDDEN(__eh_frame_hdr_end = .);
}

/* Read-write sections */

. = ALIGN(0x1000);

.data : {
*(.data .data.*)
*(.got .got.*)
*(.got.plt .got.plt.*)
} :data

.dynamic : {
HIDDEN(__dynamic_start = .);
*(.dynamic)
}

/* BSS section */

. = ALIGN(0x1000);

.bss : {
HIDDEN(__bss_start = .);
*(.bss .bss.*)
*(COMMON)
. = ALIGN(8);
HIDDEN(__bss_end = .);
} :bss
}
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,8 @@ supported_targets! {

("armv6k-nintendo-3ds", armv6k_nintendo_3ds),

("aarch64-nintendo-switch-freestanding", aarch64_nintendo_switch_freestanding),

("armv7-unknown-linux-uclibceabi", armv7_unknown_linux_uclibceabi),
("armv7-unknown-linux-uclibceabihf", armv7_unknown_linux_uclibceabihf),

Expand Down
11 changes: 3 additions & 8 deletions compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,10 +823,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {

ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
let found_kind = self.closure_kind(closure_substs).unwrap();
let closure_span =
self.tcx.sess.source_map().guess_head_span(
self.tcx.hir().span_if_local(closure_def_id).unwrap(),
);
let closure_span = self.tcx.def_span(closure_def_id);
let mut err = struct_span_err!(
self.tcx.sess,
closure_span,
Expand Down Expand Up @@ -951,9 +948,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
_ => None,
};

let found_span = found_did
.and_then(|did| self.tcx.hir().span_if_local(did))
.map(|sp| self.tcx.sess.source_map().guess_head_span(sp)); // the sp could be an fn def
let found_span = found_did.and_then(|did| self.tcx.hir().span_if_local(did));

if self.reported_closure_mismatch.borrow().contains(&(span, found_span)) {
// We check closures twice, with obligations flowing in different directions,
Expand Down Expand Up @@ -1089,7 +1084,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
kind: hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, .. }),
..
}) => (
sm.guess_head_span(fn_decl_span),
fn_decl_span,
hir.body(body)
.params
.iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
ty::Generator(..) => "generator",
_ => "function",
};
let span = self.tcx.sess.source_map().guess_head_span(span);
let mut err = struct_span_err!(
self.tcx.sess,
span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
),
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
span_bug!(
obligation.cause.span(self.selcx.tcx()),
obligation.cause.span(),
"ConstEquate: const_eval_resolve returned an unexpected error"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
// Run canonical query. If overflow occurs, rerun from scratch but this time
// in standard trait query mode so that overflow is handled appropriately
// within `SelectionContext`.
self.tcx.at(obligation.cause.span(self.tcx)).evaluate_obligation(c_pred)
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
}

// Helper function that canonicalizes and runs the query. If an
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
| (_, Err(ErrorHandled::Reported(_))) => Ok(EvaluatedToErr),
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
span_bug!(
obligation.cause.span(self.tcx()),
obligation.cause.span(),
"ConstEquate: const_eval_resolve returned an unexpected error"
)
}
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,11 +1958,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
);
}

if adt_def.did().is_local() {
err.span_label(
tcx.def_span(adt_def.did()),
format!("variant `{assoc_ident}` not found for this enum"),
);
if let Some(sp) = tcx.hir().span_if_local(adt_def.did()) {
err.span_label(sp, format!("variant `{}` not found here", assoc_ident));
}

err.emit()
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/_match.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::check::coercion::{AsCoercionSite, CoerceMany};
use crate::check::{Diverges, Expectation, FnCtxt, Needs};
use rustc_errors::{Applicability, Diagnostic, MultiSpan};
use rustc_errors::{Applicability, MultiSpan};
use rustc_hir::{self as hir, ExprKind};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::traits::Obligation;
Expand Down Expand Up @@ -127,7 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&cause,
Some(&arm.body),
arm_ty,
Some(&mut |err: &mut Diagnostic| {
Some(&mut |err| {
let Some(ret) = self.ret_type_span else {
return;
};
Expand Down
Loading